Commit Graph

29907 Commits

Author SHA1 Message Date
Shannon Booth
25f8b80eab LibWeb: Use move on ByteBuffer in TransferArrayBuffer 2023-11-19 18:53:17 +01:00
Shannon Booth
446a78f30e LibWeb: Implement Streams AO ReadableStreamAddReadIntoRequest
This is effectively identical to ReadableStreamAddReadRequest besides
from the fact that it takes a ReadIntoRequest instead of a ReadRequest,
and is instead intended to be used for BYOB readers.
2023-11-19 18:53:17 +01:00
Shannon Booth
f27e76b0b7 LibWeb: Make ReadableStreamAddReadRequest take a NonnullGCPtr
Make it more obvious in the function signature that this function will
be taking a GC ref to a ReadRequest by appending it to the
ReadableStreams pending read requests.
2023-11-19 18:53:17 +01:00
Shannon Booth
5ef41dca53 LibWeb: Implement Streams AO ReadableStreamFulfillReadIntoRequest 2023-11-19 18:53:17 +01:00
Shannon Booth
0880ea3e1c LibWeb: Add missing initialize override for ReadableStreamBYOBReader
This hasn't really come up as of yet because not enough of this class
has been implemented yet to actually do anything with it.
2023-11-19 18:53:17 +01:00
Shannon Booth
746526ca29 LibWeb: Add ReadIntoRequest to forwarding header 2023-11-19 18:53:17 +01:00
Andreas Kling
3c74dc9f4d LibJS: Segregate GC-allocated objects by type
This patch adds two macros to declare per-type allocators:

- JS_DECLARE_ALLOCATOR(TypeName)
- JS_DEFINE_ALLOCATOR(TypeName)

When used, they add a type-specific CellAllocator that the Heap will
delegate allocation requests to.

The result of this is that GC objects of the same type always end up
within the same HeapBlock, drastically reducing the ability to perform
type confusion attacks.

It also improves HeapBlock utilization, since each block now has cells
sized exactly to the type used within that block. (Previously we only
had a handful of block sizes available, and most GC allocations ended
up with a large amount of slack in their tails.)

There is a small performance hit from this, but I'm sure we can make
up for it elsewhere.

Note that the old size-based allocators still exist, and we fall back
to them for any type that doesn't have its own CellAllocator.
2023-11-19 12:10:31 +01:00
Andreas Kling
84a8ee01e1 LibJS: Lower HeapBlock size to 4 KiB
This is to prepare for making per-type allocators, since we'll have a
*lot* more HeapBlocks in that world.
2023-11-19 12:10:31 +01:00
Shannon Booth
eca9874e56 LibWeb: Port Element::attribute_changed from DeprecatedString to String
Which as you would expect has a bunch of fallout, but also results in a
whole lot of awkward conversions falling away.
2023-11-19 08:16:34 +00:00
Shannon Booth
6a2a7cad61 LibWeb/LibJS: Avoid GC visit of raw pointers where possible
This is mostly motivated for aesthetics, but also helps avoid some null
checks when we have a NonnullGCPtr<T> or in some cases a T&.
2023-11-19 08:05:45 +00:00
MacDue
4e04f81626 LibWeb: Don't encode painting limitations in RecordingPainter API
The current set of stacking context commands do not encode the
information needed to correctly paint the stacking context, instead,
they're based on the limitations of the current CPU renderer.

Stacking contexts should be able to be transformed by an arbitrary
3D transformation matrix, not just scaled from a source to a destination
rect. The `_with_mask()` stacking context also should not be separate
from the regular stacking context.

```c++
push_stacking_context(
	bool semitransparent_or_has_non_identity_transform,
	float opacity, Gfx::FloatRect const& source_rect,
	Gfx::FloatRect const& transformed_destination_rect,
	Gfx::IntPoint const& painter_location);

pop_stacking_context(
	bool semitransparent_or_has_non_identity_transform,
	Gfx::Painter::ScalingMode scaling_mode);

push_stacking_context_with_mask(
	Gfx::IntRect const& paint_rect);

pop_stacking_context_with_mask(
	Gfx::IntRect const& paint_rect,
	RefPtr<Gfx::Bitmap> const& mask_bitmap,
	Gfx::Bitmap::MaskKind mask_kind, float opacity);
```

This patch replaces this APIs with just:

```c++
push_stacking_context(
	float opacity,
        bool is_fixed_position,
        Gfx::IntRect const& source_paintable_rect,
	Gfx::IntPoint post_transform_translation,
	CSS::ImageRendering image_rendering,
	StackingContextTransform transform,
	Optional<StackingContextMask> mask);

pop_stacking_context()
```

And moves the implementation details into the executor, this should
allow future backends to implement stacking contexts without these
limitations.
2023-11-18 19:32:31 +01:00
MacDue
848b0d9c81 LibGfx: Add Gfx::extract_2d_affine_transform(Matrix4x4) helper 2023-11-18 19:32:31 +01:00
hanaa12G
1f0149e5a6 LibLine: Reset state after invalid character in DSR response
While parsing DSR response, we might encounter invalid characters, for
example, when we `cat` a binary file. Previously, we just pushed those
characters in `m_incomplete_data` buffer, which worked fine until we
didn't get a terminating character. We kept increasing coordinate value
and crashed in following assertion.
2023-11-18 18:33:00 +03:30
Aliaksandr Kalenik
7b3559f1c2 LibWeb: Remove navigate() in EventHandler::handle_mouseup()
Before this change `navigate()` was always invoked twice when a link
is clicked:
- From `activation_behavior` callback of `HTMLAnchorElement` during
  event dispatch.
- Directly from `handle_mouseup`.
2023-11-18 15:27:10 +01:00
Aliaksandr Kalenik
4f2a0a3d56 LibWeb: Remove ongoing navigation id check in navigate_to_a_fragment()
It is a mistake to add this early return in fragment navigation because
"ongoing navigation id" is not used during this kind of navigation.

With this change we no longer crash in Acid2 test after reload button
is pressed.
2023-11-18 15:27:10 +01:00
Ali Mohammad Pur
aa73a7c961 Shell: Accept null heredocs in POSIX mode
Fixes #21837.
2023-11-18 16:50:01 +03:30
Ali Mohammad Pur
2eb0a8f3d2 Shell: Expand for loop's iterated expr before iterating over it
This only applies to the POSIX mode.
Fixes #21715.
2023-11-18 16:50:01 +03:30
Sam Atkins
edaa5061c4 headless-browser: Add flag to dump screenshots of failing ref-tests
When the `--dump-failed-ref-tests` flag is provided, screenshots of the
actual and reference pages will be placed in
`Build/lagom/ladbybird/test-dumps`. This makes it a lot easier to spot
what's wrong with a failing test. :^)
2023-11-18 07:49:59 -05:00
Lachlan Jowett
4f5824cbd0 DisplaySettings: Desktop crash when non-image file type is used
If the user selects an non-image file
as their background, then at next
startup the desktop crashes.
2023-11-18 11:21:32 +00:00
Lucas CHOLLET
1afdf7f3c7 LibGfx/TIFF: Take the TIFF value by rvalue reference in handle_tag() 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
4ab2903e25 LibGfx/TIFF: Make TIFFLoadingContext::handle_tag be a free function
And move it to another file. This code is going to be generated soon, so
let's put it in another file.
2023-11-18 11:14:37 +00:00
Lucas CHOLLET
34d91dec5b LibGfx/TIFF: Extract metadata-related definition to their own file 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
1d1e7abba7 LibGfx/TIFF: Put the TIFFLoadingContext class in a TIFF namespace 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
b78f93d0b5 LibGfx/TIFF: Put metadata fields in their own struct 2023-11-18 11:14:37 +00:00
Martin Janiczek
b56e022ce8 AK: Add roundtrip fuzzer for Base64 2023-11-18 10:01:29 +01:00
Martin Janiczek
0465ba242b LibCompress: Upgrade compression fuzzer into a roundtrip fuzzer 2023-11-18 10:01:29 +01:00
Martin Janiczek
70ac6918d1 LibTest: Fix integer overflow in Gen::unsigned_int(u32)
NumericLimits<u32>::max + 1 overflowing to 0 caused us to call
AK::get_random_uniform(0) which doesn't make sense (the argument is an
_exclusive_ bound).
2023-11-18 10:01:29 +01:00
Idan Horowitz
f19349e1b6 LibJS: Instantiate primitive array expressions using a single operation
This will not meaningfully affect short array literals, but it does
give us a bit of extra perf when evaluating huge array expressions like
in Kraken/imaging-darkroom.js
2023-11-18 08:37:34 +01:00
Idan Horowitz
5e3a799e97 LibJS: Remove unused Literal AST node sub-type 2023-11-18 08:37:34 +01:00
Nico Weber
4440452f92 LibPDF: Support images with 1, 2, 4 bits per pixel
They just get upsampled to 8 bits per pixel images.
2023-11-18 07:33:15 +00:00
Nico Weber
bfe27228a3 LibPDF+LibGfx: Don't invert CMYK channels in JPEG data in PDFs
This is a hack: Ideally we'd have a CMYK Bitmap pixel format,
and we'd convert to rgb at blit time. Then we could also apply color
profiles (which for CMYK images are CMYK-based).

Also, the colors for our CMYK->RGB conversion are off for PDFs,
and we have distinct codepaths for this in Gfx::Color (for paths)
and JPEGs. So when we fix that, we'll have to fix it in two places.

But this doesn't require a lot of code and it's a huge visual
progression, so let's go with it for now.
2023-11-17 22:32:40 +00:00
Nico Weber
bd7ae7f91e LibPDF: Consistently asciibetize CommonNames.h
The file wasn't quite decided if it wanted to sort by ascii value
or by case folding. Now it uses ascii value, thanks to vim's
`:'<,'>sort`.

No behavior change.
2023-11-17 20:27:42 +00:00
Nico Weber
29396415d5 LibPDF: Add an initial implementation of type 3 glyph rendering
This is a very inefficient implementation: Every time a type 3 font
glyph is drawn, we parse its operator stream and execute all the
operators therein.

We'll want to instead cache the glyphs in bitmaps (at least in most
cases), like we do for other fonts. But it's a good first step, and
all the coordinate math seems to work in the files I've tested.

Good test files from pdfa dataset 0000.zip:

- 0000559.pdf page 1 (and 2): Has a non-default font matrix;
  text appears mirrored if the font matrix isn't handled correctly

- 0000425.pdf, page 1: Draws several glyphs in a single run;
  glyphs overlap if Renderer::render_type3_glyph() ignores the
  passed-in point

- 0000211.pdf, any page: Uses type 3 glyphs for all text.
  Good perf test (already "reasonably fast")

- 0000521.pdf, page 5 (or 7 or or 16): The little red flag in the
  purple box is a type 3 font glyph, and it's colored (which in part
  means the first operator is `d0`, while all the other documents above
  use `d1`)
2023-11-17 19:47:53 +00:00
Nico Weber
14ddab5519 LibPDF: Stub out type3_font_set_glyph_width*
Type 3 font glyphs begin with either `d0` or `d1`. If we bail out
with an "unsupported" error on the very first operator in a glyph,
we'll never paint the glyph.

Just stub these out for now. We probably want to do more in here in
the future (see "TABLE 5.10 Type 3 font operators" in the 1.7 spec).
2023-11-17 19:47:53 +00:00
Nico Weber
54c98a46d8 LibPDF: Correctly parse the d0 and d1 operators
They are the first operator in a type 3 charproc.
Operator.h already knew about them, but we didn't manage to parse
them, since they're the only two operators that contain a digit.
2023-11-17 19:47:53 +00:00
Nico Weber
5513f8bbe3 LibPDF: Move ScopedState from a function on Renderer into Renderer
No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
126a0be595 LibPDF: Pass Renderer to SimpleFont::draw_glyph()
This makes it available in Type3Font::draw_glyph().

No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
bcc6439b5f LibPDF: Pass Renderer to PDFFont::draw_string()
It's a bit unfortunate that fonts need to know about the renderer,
but type 3 fonts contain PDF drawing operators, so it's necessary.

On the bright side, it makes it possible to pass fewer parameters
around and compute things locally as needed.

(As we implement more fonts, we'll probably want to create some
functions to do these computations in a central place, eventually.)

No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
e0c0864ddf LibPDF: Load a few values off a type 3 font dictionary 2023-11-17 19:47:53 +00:00
Nico Weber
9632d8ee49 LibPDF: Make SimpleFont font matrix configurable
Type 3 fonts can set it to a custom value.
2023-11-17 19:47:53 +00:00
Nico Weber
4cd1a2d319 LibPDF: Add some scaffolding for type 3 fonts 2023-11-17 19:47:53 +00:00
Nico Weber
7f999b1ff5 LibPDF: Sink m_base_font_name from PDFFont into subclasses
/BaseFont is a required key for type 0, type 1, and truetype
font dictionaries, but not for type 3 font dictionaries.

This is mechanical; type 0 fonts don't even use this yet
(but probably should).

PDFFont::initialize() is now empty and could be removed,
but maybe we'll put stuff there again later, so I'm leaving
it around for a bit longer.
2023-11-17 19:47:53 +00:00
Nico Weber
6c1da5db54 LibPDF: Make SimpleFont::draw_glyph() fallible 2023-11-17 19:47:53 +00:00
Nico Weber
843e9daa8c LibPDF: Remove unused PDFFont::type()
This got added in #15270, but its one use then got removed again
in #16150.

No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
26fd29baf8 LibPDF: Give Type3 fonts a dedicated error message
They're described in "5.5.4 Type 3 Fonts" in the PDF 1.7 spec, so we
shouldn't `internal_error()` on them. They're just not implemented yet.
2023-11-17 19:47:53 +00:00
Aliaksandr Kalenik
6bed27cca9 LibWeb: Use border box rect in getBoundingClientRect()
With this change we scroll to correct position on Acid2 :)
2023-11-17 20:46:56 +01:00
Aliaksandr Kalenik
ef71f46da6 LibWeb: Flesh out "scroll a target into view" spec implementation
This change fixes regressed Acid2 test and now we at least can see
the face after clicking "Take The Acid2 Test" link.
2023-11-17 20:46:56 +01:00
Nico Weber
5eaa403ddf LibPDF: Use font dictionary object as cache key, not resource name
In the main page contents, /T0 might refer to a different font than
it might refer to in an XObject. So don't use the `Tf` argument as
font cache key. Instead, use the address of the font dictionary object.

Fixes false cache sharing, and also allows us to share cache entries
if the same font dict is referred to by two different names.

Fixes a regression from 2340e834cd (but keeps the speed-up intact).
2023-11-17 19:14:39 +01:00
Nico Weber
443b3eac77 LibPDF: Let decode_png_prediction() call LibGfx's unfilter_scanline()
It's less code, but it also fixes a bug: The implementation in
Filter.cpp used to use the previous byte as reference value, while
we're supposed to use the value of the previous channel as reference
(at least when a pixel is larger than one byte).
2023-11-17 19:09:50 +01:00
Nico Weber
145ade3a86 LibPDF: Remove a needless AK:: qualification
No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
000d9da73c LibGfx: Allow passing FilterType::None to unfilter_scanline()
Makes calling this in LibPDF less awkward, and there's no reason
not to allow this.
2023-11-17 19:09:50 +01:00
Nico Weber
574357ef00 LibGfx: Use ceil_div() in png decoder
No behavior change, arguably easier to read.
2023-11-17 19:09:50 +01:00
Nico Weber
5a70813d11 LibGfx: Make unfilter_scanline() a static PNGImageDecoderPlugin method
That way, LibPDF will be able to call it.

No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
0416a07d56 LibPDF: Make filter byte not part of row in decode_png_prediction()
No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
b763960fc2 LibPDF: Convert decode_png_prediction to use spans
No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
588d6fab22 LibGfx+LibPDF: Create filter_type() for converting u8 to FilterType
...and use it in LibPDF.

No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
7e4fe8e610 LibPDF: Use PNG::paeth_predictor() in png decoding path
No behavior change.

Ideally, the PDF code would just call a function PNGLoader to do the
PNG unfiltering, but let's first try to make the implementations look
more similar.
2023-11-17 19:09:50 +01:00
Nico Weber
6b2c60404d LibGfx: Use PNG::paeth_predictor() in png decoding path
Increases code reuse between encoder and decoder a tiny bit.
No behavior change.

(We should use the vectorized version in the future! But first,
we should learn to do the prediction in-place.)
2023-11-17 19:09:50 +01:00
Timothy Flynn
2763fb45f7 LibTimeZone: Handle systems with varying zoneinfo file locations
On my mac, the zoneinfo location is /usr/share/zoneinfo.default. This
breaks our implementation for finding the system time zone, which was
assuming the zoneinfo location contains "/zoneinfo/". This patch makes
the implementation a bit more lenient.

This didn't break tests on CI because we fallback to UTC, which is the
time zone CI machines are in anyways.
2023-11-17 19:07:53 +01:00
Simon Wanner
6c8ab1ca0d LibJS/JIT: Add a builtin for Math.abs 2023-11-17 19:06:25 +01:00
Simon Wanner
86b85aa68b LibJS: Introduce Builtins
Builtins are functions that can be detected during bytecode generation
and enable fast-paths in the JIT.
2023-11-17 19:06:25 +01:00
Liav A
b9141d85d8 WindowServer: Introduce the window roll-up feature
The roll-up feature allows the user to set the window content to be
hidden, while retaining the window title bar visibility.
While in roll-up mode, the window height size is not changeable.
However, tiling the window or maximizing (as well as unmaximize) it will
instruct exiting the roll-up mode.
2023-11-17 17:31:51 +00:00
sSt3lla
6b72fc0924 Calculator: Convert DeprecatedString to String 2023-11-17 17:17:00 +00:00
Idan Horowitz
9677d8eeac LibWeb: Reject improperly encoded XML documents as not well-formed 2023-11-17 16:02:36 +01:00
Idan Horowitz
278e8afb42 LibWeb: Consider content-type charset when determining XML encoding 2023-11-17 16:02:36 +01:00
Idan Horowitz
07ea3ab306 LibWeb: Display error page when document parsing fails 2023-11-17 16:02:36 +01:00
Idan Horowitz
079c96376c LibTextCodec: Support validating encoded inputs 2023-11-17 16:02:36 +01:00
Ali Mohammad Pur
ad4470bc39 Shell: Escape program-provided completions unless they're marked as code
This makes it so program-provided completions don't have to worry about
escaping, making the Shell the only authority on escaping.
2023-11-17 11:02:02 +03:30
Aliaksandr Kalenik
f6a9f613c7 LibAccelGfx+LibWeb: Add basic support for linear gradients painting
Linear gradient painting is implemented in the following way:
1. The rectangle is divided into segments where each segment represents
   a simple linear gradient between an adjacent pair of stops.
2. Each quad is filled separately using a fragment shader that
   interpolates between two colors.

For now `angle` and `repeat_length` parameters are ignored.
2023-11-16 18:02:51 +01:00
Aliaksandr Kalenik
61a2e59d87 LibAccelGfx+WebContent: Add GPU painter support on macOS
With these changes it is now possible to create OpenGL context on macOS
and run GPU-painter. For now only QT client has a CLI param that turns
it on though.
2023-11-16 15:13:16 +01:00
Andreas Kling
ffe304e88b LibJS: Don't create arguments object due to o.arguments access
When deciding whether we need to create a full-blown `arguments` object,
we look at various things, starting as early as in the parser.

Until now, if the parser saw the identifier `arguments`, we'd decide
that it's enough of a clue that we should create the `arguments` object
since somebody is obviously accessing it.

However, that missed the case where someone is just accessing a property
named `arguments` on some object. In such cases (`o.arguments`), we now
hold off on creating an `arguments` object.

~11% speed-up on Octane/typescript.js :^)
2023-11-16 13:26:21 +01:00
Stephan Vedder
32352aa729 LibJS/JIT: Add a fast path for floating point comparisons 2023-11-16 11:43:44 +01:00
Aliaksandr Kalenik
4164af2ca4 LibWeb: Do not compensate padding for abspos boxes with static position
When a box does not have a top, left, bottom, or right, there is no
need to adjust the offset for positioning relative to the padding edge,
because the box remains in the normal flow.
2023-11-15 23:44:05 +01:00
Timothy Flynn
2c1bbf5a99 AK+LibIDL: Put IDL dbgln statement behind a debug flag
This is a bit spammy now that we are performing some overload resolution
at build time. The fallback to an interface has generally worked fine on
the types it warns about (BufferSource, Module, etc.) so let's not warn
about it for every build.
2023-11-15 23:42:53 +01:00
Timothy Flynn
e1092aed3c LibWeb: Don't reject worker scripts with a JavaScript MIME type
The condition for checking if a script has a JS MIME type is currently
flipped. Extract the check to a local to make it a bit easier to reason
about at quick glance.
2023-11-15 11:28:39 -05:00
Andrew Kaster
ea95256f83 LibWeb: Remove unused ResourceLoader::load(URL) overload
With the refactoring of Workers, nobody is calling this LoadRequest-less
overload. All new code should eventually be moved to fetch anyway.
2023-11-15 12:56:33 +01:00
Andrew Kaster
124c378472 LibWeb+WebWorker: Move worker execution into a new WebWorker process
We now create a WorkerAgent for the parent context, which is currently
only a Window. Note that Workers can have Workers per the spec.

The WorkerAgent spawns a WebWorker process to hold the actual
script execution of the Worker. This is modeled with the
DedicatedWorkerHost object in the WebWorker process.
A start_dedicated_worker IPC method in the WebWorker IPC creates the
WorkerHost object. Future different worker types may use different IPC
messages to create their WorkerHost instance.

This implementation cannot yet postMessage between the parent and the
child processes.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-11-15 12:56:33 +01:00
Andrew Kaster
3dbbb5b263 LibWeb: Implement fetch a classic worker script 2023-11-15 12:56:33 +01:00
Andrew Kaster
d7d84ee931 LibWeb: Ensure a Web::Page is associated with local Worker LoadRequests
This is a hack on top of a hack because Workers don't *really* need to
have a Web::Page at all, but the ResourceLoader infra that should be
going away soon ™️ is not quite ready to axe that requirement for
cookies.
2023-11-15 12:56:33 +01:00
Andrew Kaster
5586340cf3 LibWeb: Don't set EventTarget prototype on any WindowOrWorkerGlobalScope
The same limitations regarding construction of Window apply to all
WorkerGlobalScope classes as well.
2023-11-15 12:56:33 +01:00
Andrew Kaster
4fcff01ef3 LibWeb: Clean up assumptions in Bindings::HostDefined
We don't have a 'root execution environment' anymore (thankfully), so
we can make sure that the ESO the HostDefined object holds onto is a
NonnullGCPtr.
2023-11-15 12:56:33 +01:00
Aliaksandr Kalenik
eac7916d2c LibWeb: Use inner available space to calculate auto height of abspos
By using available_inner_space_or_constraints_from(available_space), we
ensure that the available space used to calculate the min/max content
height is constrained by the width specified for the box itself
(I know that at least GFC always expects available width to be
constrained by specified width if there is any).

This change improves layout in "Recent news" block on
https://telegram.org/
2023-11-15 11:26:14 +01:00
Kemal Zebari
6b5a0100d9 Browser: Move BookmarksBarWidget::PerformEditOn to anon namespace
Since none of `BookmarksBarWidget`'s methods use this enum class any
longer, let's just move it to the anonymous namespace so that
`BookmarkEditor` can still make use of it.
2023-11-14 15:38:09 -07:00
Adam Harald Jørgensen
e2f9011a8d Shell: Improve error propagation
This commit replaces 31 release_value_but_fixme_should_propagate_errors
calls with TRYs. :^)
2023-11-14 20:08:27 +03:30
Adam Harald Jørgensen
e89ba794d0 Shell: Include parent and base directories in expanded globs 2023-11-14 20:08:27 +03:30
Adam Harald Jørgensen
cc157629b4 Shell: Expand glob to only directories if it ends with a slash
The glob "*/" should only expand to directories, and the directories
should also have a trailing slash. This commit also replaces
Shell::split_path with StringView::split_view since it accomplishes the
same task.
2023-11-14 20:08:27 +03:30
Lucas CHOLLET
1e8004734f LibPDF: Don't consider the End of Data code as normal ASCII85 input
Data encoded with ASCII85 is terminated with the EOD code 0x7E3E. This
should not be considered as normal input but rather discarded.
2023-11-14 10:15:15 +01:00
Lucas CHOLLET
59a6d4b7bc LibPDF: Factorize duplicated code in Filter::decode_ascii85() 2023-11-14 10:15:15 +01:00
Lucas CHOLLET
2fe0647c68 LibPDF: Handle pdf-specific white spaces correctly in ASCII85
We were previously only looking the space character but PDF white
spaces is a superset of ascii spaces.
2023-11-14 10:15:15 +01:00
Lucas CHOLLET
db08fe12ec LibPDF: Implement Reader::is_[eol, whitespace](char)
These two static members are now used to implement respective `matches_`
methods but will also be useful to provide a global implementation of
the specified concept of whitespace.
2023-11-14 10:15:15 +01:00
Lucas CHOLLET
dac703a0b8 LibPDF: Avoid an unnecessary copy in Filter::decode_ascii85() 2023-11-14 10:15:15 +01:00
Kemal Zebari
e80d3ff518 LibWeb: Have MimeType::create() match its foward declaration 2023-11-14 10:14:09 +01:00
Kemal Zebari
6b37095ffd LibWeb: Validate MimeType(String, String) arguments correctly
This commit correctly validates the `type` and `subtype` arguments,
instead of checking for http quoted code points, by following how
the spec's MIME type parsing algorithm would validate a MIME type's
type and subtype.

It also uses the move-assigned member variables instead of the
arguments within the constructor body (as using the arguments at
this point will lead to undesired behavior).
2023-11-14 10:14:09 +01:00
MacDue
2248d85894 LibWeb: Remove should_ensure_creation_of_paintable() SVG hack
The elements this hack was being used for were grouping elements, and
can be properly sized: https://svgwg.org/svg2-draft/struct.html#Groups.

Note: Other than one test change the elements here are already covered
by layout tests.
2023-11-14 10:13:10 +01:00
MacDue
9b2b28b612 LibWeb: Use BoundingBox helper in SVGFormattingContext 2023-11-14 10:13:10 +01:00
MacDue
f3c8e88e5e LibGfx: Use BoundingBox helper in Gfx::Path 2023-11-14 10:13:10 +01:00
MacDue
93243283f0 LibGfx: Add BoundingBox helper class
This is a small helper class to compute the bounding box of a set of
points.
2023-11-14 10:13:10 +01:00
Tim Ledbetter
9a8cc5a98d LibDNS: Ensure DNS name and label sizes are within expected limits
Previously, the DNS packet parser would happily parse a DNS packet
containing an arbitrarily large domain name. We now limit each segment
of a domain name to 63 characters and the total domain name length to
253 characters. This is consistent with RFC1035, which specifies that
the maximum name length is 255 octets. This includes the initial length
byte and final null byte, which accounts for the 2 byte difference.
2023-11-14 10:12:44 +01:00
Tim Ledbetter
1793f51bc6 LibDNS: Make DNS packet parsing fallible
Previously, a DNS packet containing an invalid name would be returned
with an empty name. With this change, an error is returned if any error
is encountered during parsing.
2023-11-14 10:12:44 +01:00
Matthew Olsson
95d62822bf LibWeb: Implement KeyframeEffect::set_pseudo_element 2023-11-14 10:12:02 +01:00
Matthew Olsson
5824916f8c LibWeb: Add KeyframeEffect IDL objects 2023-11-14 10:12:02 +01:00
Nico Weber
9b022239c3 LibPDF: Apply all offsets of TJ operator
TJ acts on a list of either strings or numbers.
The strings are drawn, and the numbers are treated as offsets.

Previously, we'd only apply the last-seen number as offset when
we saw a string. That had the effect of us ignoring all but the
last number in front of a string, and ignoring numbers at the
end of the list.

Now, we apply all numbers as offsets.
Our rendering of Tests/LibPDF/text.pdf now matches other PDF viewers.
2023-11-14 10:11:09 +01:00
Nico Weber
1c2b0feb7b LibPDF: Change how CFF optional width prefix is stored
Per 5177.Type2.pdf 3.1 "Type 2 Charstring Organization",
a glyph's charstring looks like:

    w? {hs* vs* cm* hm* mt subpath}? {mt subpath}* endchar

The `w?` is the width of the glyph, but it's optional. So all
possible commands after it (hstem* vstem* cntrmask hintmask
moveto endchar) check if there's an extra number at the start
and interpret it as a width, for the very first command we read.

This was done by having an `is_first_command` local bool that
got set to false after the first command. That didn't work with
subrs: If the first command was a call to a subr that just pushed
a bunch of numbers, then the second command after it is the actual
first command.

Instead, move that bool into the state. Set it to false the
first time we try to read a width, since that means we just read
a command that could've been prefixed by a width.
2023-11-14 10:10:34 +01:00
Bastiaan van der Plaat
d3b3e49e19 LibJS/JIT: Use the x86_64 setcc instruction to remove a branch 2023-11-14 09:54:48 +01:00
Timothy Flynn
1d76738dde LibJS: Change Intl.Locale info APIs from property getters to methods
This is a normative change in the Intl Locale Info spec. See:
https://github.com/tc39/proposal-intl-locale-info/commit/e550152
2023-11-13 20:10:58 +01:00
Timothy Flynn
a357874c77 LibJS: Implement Intl.Locale.prototype.firstDayOfWeek
This is a normative change in the Intl Locale Info spec. See:
https://github.com/tc39/proposal-intl-locale-info/commit/f03a814
2023-11-13 20:10:58 +01:00
Tim Ledbetter
b5875700e2 LibJS: Don't hang when parsing invalid destructuring assignment target
Previously, certain crafted input could cause the JS parser to hang, as
it repeatedly tried to parse an EOF token after hitting an "invalid
destructuring assignment target" error. This change ensures that we
stop parsing after hitting this error condition.
2023-11-13 20:10:36 +01:00
Aliaksandr Kalenik
01d938c77b LibAccelGfx+LibWeb: Implement SetClipRect and ClearClipRect commands 2023-11-13 19:22:27 +01:00
Lucas CHOLLET
9e4d697d23 LibPDF: Detect DCT images correctly
Images can have multiple filters, each one of them is processed
sequentially. Only the last one will be relevant for the image format
(DCT or JPXDecode), so use the last filter instead of the first one to
detect that property.
2023-11-13 10:30:34 -05:00
Nico Weber
f882a3ae37 LibPDF: In ColorSpace creation code, use resolve_to() more
For valid PDFs, this makes no difference.

For invalid PDFs, we now assert during the cast in resolve_to() instead
of returning a PDFError. However, most PDFs are valid, and even for
invalid PDFs, we'd previously keep the old color space around when
getting the PDF error and then usually assert later when the old
color space got passed a color with an unexpected number of components
(since the components were for the new color space).

Doesn't affect any of the > 2000 PDFs I use for testing locally,
is less code, and should make for less surprising asserts when it
does happen.
2023-11-13 10:29:26 -05:00
Stephan Vedder
9c63f9854b LibJS/JIT: Remove incorrect check for empty tag
This check is not required and prevented put_by_value
to take the actual fastpath.
2023-11-13 14:28:27 +01:00
Lucas CHOLLET
9bc25db9a3 LibPDF: Add support for the LZW filter
This allows us to decode the first page of ThinkingInPostScript.pdf :^)
2023-11-13 14:23:23 +01:00
Lucas CHOLLET
048ef11136 LibPDF: Factorize flate parameters handling to its own function
This part will be shared with the LZW filter, so let's factorize it.
2023-11-13 14:23:23 +01:00
Andreas Kling
e8c0cea5f9 LibJS/JIT: Use right shift to extract type tags in equality codegen
7% speed-up on Kraken/ai-astar.js, covers up most of the regression
from adding more fast paths. :^)
2023-11-13 13:49:21 +01:00
iliadsh
ad98834b50 LibJS/JIT: Add more equality fast paths 2023-11-13 13:33:43 +01:00
iliadsh
671cbf6a5b LibJS/JIT: Add GetGlobal fast path 2023-11-13 13:33:43 +01:00
iliadsh
ddea710933 LibJS: Expose various offsets for GetGlobal JIT fast path 2023-11-13 13:33:43 +01:00
iliadsh
c739c931c1 LibJS/JIT: Add PutByValue fast path for simple array access 2023-11-13 13:33:43 +01:00
Nico Weber
bbde3cbc90 LibPDF: Tolerate an indirect object as dict for CIE-based color spaces
Namely, for CalGrayColorSpace, CalRGBColorSpace, LabColorSpace.

Fixes a crash rendering any page of Adobe's 5014.CIDFont_Spec.pdf
(which uses CalRGBColorSpace with an indirect dict: The dict is
object `92 0`, and many color spaces are inline objects referring
to it).
2023-11-13 07:12:05 -05:00
Aliaksandr Kalenik
f7874d03fc LibWeb: Remove redundant flush() call in PaintingCommandExecutorGPU
Since we already call `Painter::flush()` in `PageHost::paint()` we do
not need to do that again in `PaintingCommandExecutorGPU` destructor.

This makes GPU painting run noticeably faster because `flush()` does
expensive `glReadPixels()` call.
2023-11-12 20:21:07 +01:00
Andreas Kling
b532dedc91 LibJS/JIT: Add fast path for GetById of Array.length
Array.length is magical (since it has to reflect the number of elements
in the object's property storage).

We now handle it specially in jitted code, giving us a massive speed-up
on Kraken/ai-astar.js (and probably many other things as well) :^)
2023-11-12 19:57:27 +01:00
Andreas Kling
e41f0d9dec LibJS/JIT: Add fast path for loose equality check between 2 objects
There are more fast paths to be added here, just starting with this
one since it's heavy on Kraken/ai-astar.js :^)
2023-11-12 19:57:27 +01:00
MacDue
4e9e183a34 LibWeb: Support mask-type style attribute for SVGs
This fixes the painting of an SVG on https://discord.com/.
2023-11-12 16:01:46 +01:00
MacDue
61fc5349fc LibWeb: Use list of PropertyIDs in SVG apply_presentational_hints()
The big o' if/else chain here was getting a bit unwieldy.

No behavior change.
2023-11-12 16:01:46 +01:00
Andreas Kling
cb7169d73f LibJS/JIT: Support the EnterObjectEnvironment bytecode instruction
We can now use `with` statements in jitted code. :^)
2023-11-12 14:21:41 +01:00
Andreas Kling
cfdb8a2756 LibJS/JIT: Update "unwind context" stack in JIT code
Until now, the unwind context stack has not been maintained by jitted
code, which meant we were unable to support the `with` statement.
This is a first step towards supporting that by making jitted code
call out to C++ to update the unwind context stack when entering/leaving
unwind contexts.

We also introduce a new "Catch" bytecode instruction that moves the
current exception into the accumulator. It's always emitted at the start
of a "catch" block.
2023-11-12 14:21:41 +01:00
Andreas Kling
298dfa96a4 LibJS: Remove unused members from EnterUnwindContext instruction 2023-11-12 14:21:41 +01:00
Andreas Kling
b6435ca280 LibJS: Unify bytecode instruction names with their helper names 2023-11-12 14:21:41 +01:00
Lucas CHOLLET
272be6b20a LibGfx/TIFF: Add support for LZW compression 2023-11-12 13:56:27 +01:00
Lucas CHOLLET
4f5a0227e2 LibGfx/TIFF: Add support for the differencing predictor
The differencing predictor is a different way to encode pixels in TIFF
images. Every pixel is encoded as a difference with the previous column
of the image, except the first column, obviously.

This parameter is materialized by a new tag for which reading was also
implemented.
2023-11-12 13:56:27 +01:00
Lucas CHOLLET
86ee7d219e LibCompress/LZW: Use its own debug flag
The file still used the `GIF_DEBUG` flag from when it was a part of the
GIF decoder. Let's give `LZWDecoder` its own flag.
2023-11-12 13:56:27 +01:00
Lucas CHOLLET
fcaebe56d7 LibCompress/LZW: Use a parameter to choose when to change the code size
Some users of the LZW algorithm use a different value to determine when
the size of the code changes. GIF increments the size when the number of
elements in the table is equal to 2^code_size while TIFF does it for a
count of 2^code_size - 1.

This patch adds the parameter m_offset_for_size_change with a default
value of 0 and our decoder will increment the code size when we reach
a table length of 2^code_size + m_offset_for_size_change. This allows us
to support both situations.
2023-11-12 13:56:27 +01:00
Lucas CHOLLET
0c0d7e8fd3 LibCompress/LZW: Support BigEndianInputBitStream
Let's templatize the LZWDecoder, so it can take both BigEndian and
LittleEndian variant.
2023-11-12 13:56:27 +01:00
Ali Mohammad Pur
869c7c9bab LibLine: Capture the current origin immediately after ^C
Otherwise a subsequent event (^C or resize) will make LibLine use the
previous origin instead of the real current one.
2023-11-12 13:55:20 +01:00
Tim Ledbetter
f87d93b4ee LibGfx/ICC: Ensure Macintosh ScriptCode length is within expected range
Previously, it was possible for a `TextDescriptionTagData` object with
an incorrect Macintosh ScriptCode description length to cause a buffer
overflow.
2023-11-12 07:58:39 +01:00
Tim Ledbetter
10624a2beb LibGfx/ICC: Avoid overflow when creating MultiLocalizedUnicodeTagData
Previously, it was possible for a `MultiLocalizedUnicodeTagData` object
with a incorrect length  or offset fields to cause a buffer overflow.
2023-11-12 07:58:39 +01:00
Zaggy1024
f9068c7f2e LibAudio: Ensure that Serenity playback streams are always stereo
The Serenity AudioServer assumes that all audio is stereo, so we
cannot output audio with a channel count other than 2.
2023-11-12 07:57:03 +01:00
Zaggy1024
d64ffb1b9b LibWeb: Output audio in stereo regardless of the encoded channel count
Audio loaders currently always output two channels, even if they were
encoded as mono. Therefore, we have to hardcode the channel count in
our audio plugin to avoid crashing until we can handle mono or multi-
channel audio better.

Fixes #21898
2023-11-12 07:57:03 +01:00
Nico Weber
f4a847894f LibPDF: Make SampledFunction::evaluate() work for n-dimensional input
I didn't find example code for this and the AI assistant did very
poorly on this as well. So I had to write it all by myself!

It can be much more efficient I think, but I think the overall
shape is maybe roughly fine.
2023-11-12 07:55:04 +01:00
Matthew Olsson
43dc9dfb69 LibWeb: Add the AnimationPlaybackEvent IDL object 2023-11-11 22:45:16 +01:00
Matthew Olsson
fe40bdfc01 LibWeb: Implement Animation::play_state 2023-11-11 22:45:16 +01:00
Matthew Olsson
8039fe78cd LibWeb: Implement Animation::set_playback_rate 2023-11-11 22:45:16 +01:00
Matthew Olsson
749462f3df LibWeb: Implement Animation::set_current_time 2023-11-11 22:45:16 +01:00
Matthew Olsson
f898b49c8e LibWeb: Implement Animation::current_time 2023-11-11 22:45:16 +01:00
Matthew Olsson
9802995de8 LibWeb: Track an Animation's play/pause task state
This only tracks whether the relevant steps should be executed at some
future (but very soon) time. This time will eventually be whenever the
"update animations and send events" procedure is invoked.
2023-11-11 22:45:16 +01:00
Matthew Olsson
422f43f4fc LibWeb: Implement Animation::set_start_time 2023-11-11 22:45:16 +01:00
Matthew Olsson
4889f53880 LibWeb: Implement Animation::set_timeline 2023-11-11 22:45:16 +01:00
MacDue
67fcee6fca LibWeb: Remove two fixed FIXMEs
Both fixed in #21785 :^)
2023-11-11 22:41:57 +01:00
MacDue
f57b3423eb LibWeb: Check for invalid SVG viewBox sizes
Fixes #21825
2023-11-11 22:41:57 +01:00
Tim Ledbetter
cdfe893717 LibGfx/OpenType: Ensure Cmap subtable offset is within expected range 2023-11-11 22:20:17 +01:00