Commit graph

31289 commits

Author SHA1 Message Date
Nico Weber 1ed9e597a9 LibGfx/JPEGLoader: Use 1 / sqrt(8) instead of rsqrt(8)
At least on arm64, rsqrt(8) has noticeably worse precision:
https://github.com/SerenityOS/serenity/issues/22739#issuecomment-1912909835
2024-01-30 10:02:33 +01:00
Nico Weber 8a07aa9e9a LibGfx: Remove Gamma.h
It's been unused since c8c065b6b0.
2024-01-30 10:02:33 +01:00
Nico Weber 6971ba35d5 LibGfx+Tests: Support grayscale jpegs with 2x2 sampling and MCU reset
Non-interleaved files always have an MCU of one data unit.

(A "data unit" is an 8x8 tile of pixels, and an "MCU" is a
"minium coded unit", e.g. 2x2 data units for luminance and
1 data unit each for Cr and Cb for a YCrCb image with
4:2:0 subsampling.)

For the test case, I converted an existing image to a ppm:

    Build/lagom/bin/image -o out.ppm \
        Tests/LibGfx/test-inputs/jpg/12-bit.jpg

Then I converted it to grayscale and saved it as a pgm in Photoshop.
Then I turned it into a weird jpeg like so:

    path/to/cjpeg \
        -outfile Tests/LibGfx/test-inputs/jpg/grayscale_mcu.jpg \
        -sample 2x2 -restart 3 out.pgm

Makes 3 of the 5 jpegs failing to decode at #22780 go.
2024-01-30 05:35:22 +01:00
Kemal Zebari 22ea2f638a mktemp: Make sure to use target directory option argument
Previously, we ignored the -p argument if it was specified. This
would resort in a crash because final_target_directory wasn't given a
value.

This snapshot does away with giving this variable an Optional<> and
just has the -p argument be its default value.
2024-01-30 00:12:54 +00:00
Sam Atkins f4b345258d tar: Remove unnecessary conversions to String
We use these canonicalized_path variables as StringViews, so it doesn't
matter if they are a String or ByteString. And they're paths so
shouldn't be String anyway.
2024-01-29 23:14:39 +00:00
Sam Atkins 1750af83b0 3DFileViewer: Use ByteString for file paths 2024-01-29 23:14:39 +00:00
Sam Atkins 90240c0e02 Spreadsheet: Use ByteString for file paths 2024-01-29 23:14:39 +00:00
Sam Atkins 44ca55aaf8 LibFileSystemAccessClient+Userland: Return file paths as ByteStrings
Where it was straightforward to do so, I've updated the users to also
use ByteStrings for their file paths, but most of them have a temporary
String::from_byte_string() call instead.
2024-01-29 23:14:39 +00:00
Timothy Flynn 5a99a6afb4 LibWeb: Implement ReadableStreamBYOBRequest.respondWithNewView
The AO behind this prototype was added in commit ed1076d9ca,
so we can now trivially expose the prototype as well.
2024-01-29 17:10:56 -05:00
Timothy Flynn 3c11a1551d LibWeb: Add missing spec link to ReadableStreamBYOBRequest::respond 2024-01-29 17:10:56 -05:00
Nico Weber fd316728a0 Everywhere: Remove references to UserspaceEmulator 2024-01-29 20:20:55 +00:00
Nico Weber 3f9d0c7789 DevTools: Remove UserspaceEmulator
It hasn't been built since we dropped i386 support.

When we want to bring it back, we can get it back from source control.

No behavior change.
2024-01-29 20:20:55 +00:00
Tim Ledbetter 4e383bdac1 LibWeb: Set select element text when an option is initially selected
Previously, a select element's text would initially be empty if the
`selected` property was set on one of its options.
2024-01-29 20:05:14 +00:00
Nico Weber 002eb0ad03 LibGfx/JPEGLoader: Use ceil_div
No behavior change.
2024-01-29 13:33:10 -05:00
Nico Weber 393fb1f7b9 LibGfx/JPEGLoader: Pass SamplingFactors instead of Component to function
That's all this function reads from Component.

Also rename from validate_luma_and_modify_context() to
validate_sampling_factors_and_modify_context().

No behavior change.
2024-01-29 13:29:44 -05:00
Nico Weber b37f3c86fd LibGfx/WebPLoaderLossless: Fix grammar-o in comment 2024-01-29 09:12:06 -05:00
Ollrogge f784122703 LibCore: Refactor template definitions to header in ArgsParser
This allows for automatic template instatiation and remove the need to
explicitly instantiate the template functions for different types.
2024-01-29 13:58:37 +00:00
Bastiaan van der Plaat 350affe406 LibGUI+WindowServer: Add menu minimum width support 2024-01-29 05:29:41 -07:00
kleines Filmröllchen adc845e0cb Userland: Port to automatic GML initializer where possible 2024-01-29 05:21:48 -07:00
kleines Filmröllchen dec066fa5c GMLCompiler: Add common pattern for a user-defined fallible initializer
Many widget classes need to run substantial initialization code after
they have been setup from GML. With this change, an
initialize_fallibles() function is called if available, allowing the
initialization to be invoked from the GML setup automatically. This
means that the GML-generated creation function can now be used directly
for many more cases, and reduces code duplication.
2024-01-29 05:21:48 -07:00
MacDue b10f58a1fe LibWeb: Support x and y attributes on nested SVGs
This allows positioning a child SVG relative to its parent SVG.

Note: These have been implemented as CSS properties as in SVG 2, these
are geometry properties that can be used in CSS (see
https://www.w3.org/TR/SVG/geometry.html), but there is not much browser
support for this. It is nicer to implement than the ad-hoc SVG
attribute parsing though, so I feel it may make sense to port the rest
of the attributes specified here (which should fix some issues with
viewport relative sizes).
2024-01-29 10:01:10 +00:00
Aliaksandr Kalenik 556679fedd LibWeb: Account for scroll offset in hit-testing
The hit-testing position is now shifted by the scroll offsets before
performing any checks for containment. This is implemented by assigning
each PaintableBox/InlinePaintable an offset corresponding to the scroll
frame in which it is contained. The non-scroll-adjusted position is
still passed down when recursing to children because the assigned
offset accumulated for nested scroll frames.

With this change, hit testing works in the Inspector.
Fixes https://github.com/SerenityOS/serenity/issues/22068
2024-01-29 09:57:40 +01:00
Aliaksandr Kalenik beb1c85b6b LibWeb: Force scroll offsets update in Internals::hit_test()
Since we might enter Internals::hit_test() before the enclosing scroll
offsets are updated in the paintables tree during pre-paint, this
update need to be enforced.
2024-01-29 09:57:40 +01:00
Timothy Flynn 66959bcc09 LibWeb: Use the stream teeing methods for cloning Fetch response bodies 2024-01-29 07:21:59 +01:00
Timothy Flynn 6981ddfe13 LibWeb: Implement the ReadableByteStreamTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn d7612969e0 LibWeb: Invoke the correct Streams BYOB AOs when in a closed state 2024-01-29 07:21:59 +01:00
Timothy Flynn ed1076d9ca LibWeb: Implement the ReadableByteStreamControllerRespondWithNewView AO 2024-01-29 07:21:59 +01:00
Timothy Flynn 5e5b42730c LibWeb: Implement the CloneAsUint8Array AO 2024-01-29 07:21:59 +01:00
Timothy Flynn debfe996d7 LibWeb: Implement the ReadableStreamDefaultTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn d8413774df LibWeb: Expose the ReadableStream tee IDL interface
This just sets up the plumbing to the underlying ReadableStreamTee AO,
which as of this commit, will just throw a NotImplemented exception.
2024-01-29 07:21:59 +01:00
Timothy Flynn 5ccd1ff1bf LibWeb: Implement the StructuredClone AO 2024-01-29 07:21:59 +01:00
Aliaksandr Kalenik 20de69693b LibWeb: Fix hidden overflow clipping with nested CSS transforms
This is a fix for regression introduced in
0bf82f748f

All CSS transforms need to be removed from the clip rectangle before
applying it. However, it is still necessary to calculate it with
applied transforms to find the correct intersection of all clip
rectangles in the containing block chain.
2024-01-29 07:21:38 +01:00
Linus Groh e1d1aac7bc LibJS/Bytecode: Apply BigInt/Symbol ToObject avoidance in another place
Same as d667721b2 but in a different place.
2024-01-28 19:49:51 -05:00
Tim Ledbetter d1226f0b15 LibWeb: Don't crash when querying offsets of empty inline elements
Previously, querying `offsetTop` or `offsetLeft` of an inline element
with no text would cause a crash.
2024-01-28 23:32:40 +01:00
Tim Ledbetter 99fbd33d7d LibWeb: Make button flex wrapper inherit min-height property
This ensures that the vertical positioning of button text is correct
if a `min-height` property is present.
2024-01-28 14:48:33 +01:00
Aliaksandr Kalenik 0bf82f748f LibWeb: Move clip rect calculation to happen before painting
With this change, clip rectangles for boxes with hidden overflow or the
clip property are no longer calculated during the recording of painting
commands. Instead, it has moved to the "pre-paint" phase, along with
the assignment of scrolling offsets, and works in the following way:

1. The paintable tree is traversed to collect all paintable boxes that
   have hidden overflow or use the CSS clip property. For each of these
   boxes, the "final" clip rectangle is calculated by intersecting clip
   rectangles in the containing block chain for a box.
2. The paintable tree is traversed another time, and a clip rectangle
   is assigned for each paintable box contained by a node with hidden
   overflow or the clip property.

This way, clipping becomes much easier during the painting commands
recording phase, as it only concerns the use of already assigned clip
rectangles. The same approach is applied to handle scrolling offsets.

Also, clip rectangle calculation is now implemented more correctly, as
we no longer stop at the stacking context boundary while intersecting
clip rectangles in the containing block chain.

Fixes:
https://github.com/SerenityOS/serenity/issues/22932
https://github.com/SerenityOS/serenity/issues/22883
https://github.com/SerenityOS/serenity/issues/22679
https://github.com/SerenityOS/serenity/issues/22534
2024-01-28 08:25:28 +01:00
Shannon Booth eaf9a56c10 LibWeb: Actually clear stream controller algorithms when needed
Now that these algorithms are a HeapFunction as opposed to SafeFunction,
the problem mentioned in the FIXME is no longer applicable as these
functions are GC-allocated like everything else.
2024-01-27 21:40:25 -05:00
Shannon Booth 5f484d200a LibWeb: Port Stream algorithms from JS::SafeFunction to JS::HeapFunction 2024-01-27 21:40:25 -05:00
Shannon Booth e118430648 LibJS: Allow JS::create_heap_function to accept a lambda
This helps us avoid from needing to construct a Function<T> when
invoking `create_heap_function` with a lambda.

Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
2024-01-27 21:40:25 -05:00
Andreas Kling 9326ded5a4 LibJS: Fast path for Increment of Int32 value in bytecode interpreter
5% speed-up on Kraken/ai-astar.js in interpreter mode. :^)
2024-01-27 22:29:49 +01:00
Andreas Kling 9fcd6776cf LibJS: Add fast path for Array.length in the bytecode interpreter
13.8% speed-up on Kraken/ai-astar.js in interpreter mode. :^)
2024-01-27 22:29:49 +01:00
Andreas Kling 514af065a5 LibJS: Move shared bytecode/JIT helpers to a header file
This allows them to be inlined into the bytecode interpreter.

7.6% speedup on Kraken/ai-astar.js in interpreter mode. :^)
2024-01-27 22:29:49 +01:00
Tim Ledbetter 6f5dd9e11c LibWeb: Return correct RoleType for composite ARIA role 2024-01-27 14:52:41 -05:00
Tim Ledbetter f0d2a21d77 LibWeb: Add missing ARIA roles to RoleType::build_role_object()
This change allows `contentinfo`, `none`, `subscript` and `superscript`
RoleTypes to be built. These were the only non-abstract role types
missing from this function.

This fixes an issue where clicking on an element with one of these role
types in Inspector would cause a crash.
2024-01-27 14:52:41 -05:00
Linus Groh d667721b24 LibJS: Skip object creation for BigInt and Symbol values in GetValue
I'm not sure why these were omitted initially - works fine for other
engines, e.g.:

- d5aed64eff/src/types/language/value.zig (L1279-L1292)
- 5792a94c10/Source/JavaScriptCore/runtime/JSCJSValue.cpp (L180-L206)
2024-01-27 13:11:18 -05:00
MacDue 5cf1570f40 LibWeb: Add initial support for nesting SVG viewports
Previously, we were handling viewBoxes/viewports in a slightly hacky
way, asking graphics elements to figure out what viewBox to use during
layout. This does not work in all cases, and can't allow for more
complex SVGs where it is possible to have nested viewports.

This commit makes the SVGFormattingContext keep track of the
viewport/boxes, and it now lays out each viewport recursively, where
each nested `<svg>` or `<symbol>` can establish a new viewport.

This fixes some previous edge cases, and starts to allow nested
viewports (there's still some issues to resolve there).

Fixes #22931
2024-01-27 18:12:13 +01:00
Andreas Kling 546143e9a6 LibWeb: Fix vector OOB access when comparing some calc() values
Before comparing the elements of two vectors, we have to check that
they have the same length. :^)

Fixes a crash seen on https://chat.openai.com/
2024-01-27 17:06:43 +01:00
Timothy Flynn 9272d185ad LibWeb: Implement a slightly better ad-hoc Body::clone method
Just creating a stream on the JS heap isn't enough, as we will later
crash when trying to read from that stream as it hasn't been properly
initialized. Instead, until we have teeing implemented (which is a
rather huge part of the Streams spec), create streams using proper AOs
that do initialize the stream.
2024-01-27 16:01:56 +01:00
Timothy Flynn c8c3866101 LibWeb: Implement the CreateReadableByteStream AO 2024-01-27 16:01:56 +01:00
Andreas Kling 8e20a44380 LibWeb: Avoid expensive containing_block lookups in PaintableFragment
The paintable has the containing block cached, so it's better (and less
code in general) to ask for it there.
2024-01-27 14:31:47 +01:00