Commit graph

70415 commits

Author SHA1 Message Date
Aliaksandr Kalenik
1bf4d3391e LibWeb: Use GC::Ptr for BrowsingContext pointer saved in Document
Likely we forgot to update `WeakPtr` to `GC::Ptr` after converting
`BrowsingContext` to GC-allocated object.
2025-07-17 15:55:30 +01:00
Jelle Raaijmakers
59a867d3e3 Tests: Enable all screenshot tests on all platforms
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
With the newly supported fuzzy matching in our test-web runner, we can
now define the expected maximum color channel and pixel count errors per
failing test and set a baseline they should not exceed.

The figures I added to these tests all come from my macOS M4 machine.
Most discrepancies seem to come from color calculations being slightly
off.
2025-07-17 12:59:11 +01:00
Jelle Raaijmakers
0d856a8fa7 Tests: Implement fuzzy screenshot comparisons in test-web
We now read WPT's `<meta name="fuzzy">` tags if present in tests and
apply them while comparing screenshots.
2025-07-17 12:59:11 +01:00
Jelle Raaijmakers
e4b2253b63 Tests: Replace load-reference-page debug action with internals method
WPT reference tests can add metadata to tests to instruct the test
runner how to interpret the results. Because of this, it is not enough
to have an action that starts loading the (mis)match reference: we need
the test runner to receive the metadata so it can act accordingly.

This sets our test runner up for potentially supporting multiple
(mis)match references, and fuzzy rendering matches - the latter will be
implemented in the following commit.
2025-07-17 12:59:11 +01:00
Jelle Raaijmakers
0f642ecb5c LibGfx: Replace Bitmap::visually_equals() with ::diff()
This produces more granural information on the actual pixel errors
present between two bitmaps. It now also asserts that both bitmaps are
the same size, since we should never compare two differently sized
bitmaps anyway.
2025-07-17 12:59:11 +01:00
Sam Atkins
b7b504cf2d LibWeb: Remove XML-derived attribute name validation from DOMStringMap
Corresponds to 841fcfdb2c
2025-07-17 13:54:01 +02:00
Tim Ledbetter
1e30fd5c6a Meta: Add WPT.sh bisect for finding WPT regressions automatically 2025-07-17 10:51:12 +02:00
Tim Ledbetter
117ff3778a Meta: Ensure the correct log file path is used with WPT.sh compare
Previously, using abolute paths with `WPT.sh compare` would fail, as
directories were always assumed to be relative to the working directory.
2025-07-17 10:51:12 +02:00
Jelle Raaijmakers
115e5f42af LibWeb: Improve graphical list item marker positioning
While 788d5368a7 took care of better text
marker positioning, this improves graphical marker positioning instead.

By looking at how Firefox and Chrome render markers, it's clear that
there are three parts to positioning a graphical marker:

  * The containing space that the marker resides in;
  * The marker dimensions;
  * The distance between the marker and the start of the list item.

The space that the marker can be contained in, is the area to the left
of the list item with a height of the marker's line-height. The marker
dimensions are relative to the marker's font's pixel size: most of them
are a square at 35% of the font size, but the disclosure markers are
sized at 50% instead. Finally, the marker distance is always gauged at
50% of the font size.

So for example, a list item with `list-style-type: disc` and `font-size:
20px`, has 10px between its start and the right side of the marker, and
the marker's dimensions are 7x7.

The percentages I've chosen closely resemble how Firefox lays out its
list item markers.
2025-07-17 09:35:09 +01:00
Andreas Kling
ada198bee0 LibJS: Add fast path for TypedArrayPrototype.copyWithin()
This can be a simple memmove() in the most common cases.

Shaves 500ms of load time off of https://terminal.shop/api
2025-07-17 08:50:04 +02:00
Callum Law
3d7c5115d8 LibWeb: Move Transformation::to_matrix to new CSV resolve methods
This gains us 2 WPT passes as we now correctly disallow relative lengths
in more places in the `DOMMatrix` constructor.
2025-07-17 08:31:52 +02:00
Aliaksandr Kalenik
aa31b69e7e LibWeb+WebContent: Delete unused page_did_layout() 2025-07-17 08:24:19 +02:00
Aliaksandr Kalenik
b0ef7f4427 LibWeb: Defer invalidation sets processing until update_style()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This change converts `Node::invalidate_style()` (invalidation sets
overload) from eagerly doing tree traversal that marks elements affected
by invalidation set to instead adding "pending invalidation sets" into
`StyleInvalidator`, processing of which is deferred until the next
`update_style()`. By doing that we sometimes substantially reduce amount
of work done performing tree traversal that marks elements for style
recalculation.

Improves performance on Discord, were according to my measurements we
were previously spending 20% of time in style invalidation, but now it's
down to <1%.
2025-07-17 00:43:26 +02:00
Aliaksandr Kalenik
8cbe27b2f9 LibWeb: Move perform_pending_style_invalidations() in StyleInvalidator
This change introduces StyleInvalidator as a preparation for upcoming
change that will make `perform_pending_style_invalidations()` take care
of pending invalidation sets.
2025-07-17 00:43:26 +02:00
Andreas Kling
03256a2543 LibWeb: Add "parallel queue" and allow it as fetch task destination
Note that it's not actually executing tasks in parallel, it's still
throwing them on the HTML event loop task queue, each with its own
unique task source.

This makes our fetch implementation a lot more robust when HTTP caching
is enabled, and you can now click links on https://terminal.shop/
without hitting TODO assertions in fetch.
2025-07-17 00:13:39 +02:00
Aliaksandr Kalenik
9a5ef95022 LibWeb: Delete unused m_animation_driver_timer in Document
Some checks failed
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled
2025-07-16 22:09:46 +02:00
Timothy Flynn
0e6ee925f0 Meta+LibJS: Update simdutf to version 7.3.3
This contains a fix for handling invalid trailing padding characters.
2025-07-16 17:03:15 +02:00
Timothy Flynn
66b21eee04 Meta: Update sqlite3 to version 3.50.2 2025-07-16 17:03:15 +02:00
Timothy Flynn
c6ebb7bf55 Meta+LibCrypto: Update openssl to version 3.5.1
This contains an API change that disallows setting the salt to a null
value. See:

4f5ffddfcb

This seems to be the opposite of the intended effect of that change,
but this patch includes a workaround nonetheless.

Co-Authored-By: devgianlu <altomanigianluca@gmail.com>
2025-07-16 17:03:15 +02:00
Timothy Flynn
2d121097c9 Meta: Update libpng to version 1.6.48 2025-07-16 17:03:15 +02:00
Timothy Flynn
d8657e53f0 Meta: Update libjpeg-turbo to version 3.1.0#2 2025-07-16 17:03:15 +02:00
Timothy Flynn
fd499ddb62 Meta: Update dirent to version 1.25 2025-07-16 17:03:15 +02:00
Timothy Flynn
776da5dd6b Meta: Update vcpkg baseline 2025-07-16 17:03:15 +02:00
Sam Atkins
27a666f3b2 LibWeb/CSS: Implement type(<syntax>) in attr()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Build Dev Container Image / build (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This lets the `attr()` interpret the attribute's contents as an
arbitrary type instead of just as a string or number.
2025-07-16 14:47:45 +01:00
Sam Atkins
0a5e8c2865 LibWeb/CSS: Implement "parse with a <syntax>"
Uses the SyntaxNode tree to parse a list of ComponentValues into some
kind of StyleValue.
2025-07-16 14:47:45 +01:00
Sam Atkins
ded2207762 LibWeb/CSS: Parse the CSS <syntax> type into a tree
`<syntax>` is a limited subset of the "value definition syntax" used in
CSS specs. It's used for `@property`'s `syntax` descriptor, and for the
`type()` function in `attr()`.
2025-07-16 14:47:45 +01:00
Sam Atkins
5d1ba658c9 Tests: Import attr()-related WPT tests 2025-07-16 14:47:45 +01:00
Sam Atkins
72a7a18502 LibWeb/CSS: Use parse_value() to shrink parse_css_value_for_properties() 2025-07-16 14:47:45 +01:00
Sam Atkins
c7d4c4fbff LibWeb/CSS: Add a method to parse a value based on a ValueType 2025-07-16 14:47:45 +01:00
Sam Atkins
08bf9d39de LibWeb/CSS: Add String->ValueType conversion function
And also move this out of PropertyID.h because it's a separate thing.

I considered generating this but there's really not much to it.
2025-07-16 14:47:45 +01:00
Sam Atkins
0c66adfa1a LibWeb/CSS: Check Enums.json for what type names are enums
The hard-coded list here is fragile. We can just look at the Enums file
to see what our actual enum names are, instead.
2025-07-16 14:47:45 +01:00
Sam Atkins
7e2fa2650d LibWeb/CSS: Sort the entries in Enums.json
I semi-unintentionally add a checker for this in the next commit.
2025-07-16 14:47:45 +01:00
Sam Atkins
d18b0c07ca LibWeb/CSS: Make UnresolvedStyleValue figure out if it contains ASFs
UnresolvedStyleValue::create() has one user where we know if there are
any arbitrary substitution functions in the list of CVs, and two users
where we don't know and just hope there aren't any. I'm about to add
another user that also doesn't know, and so it seems worth just making
UnresolvedStyleValue::create() do that work instead.

We keep the parameter, now Optional<>, so that we save some redundant
work in that one place where we do already know.
2025-07-16 14:47:45 +01:00
Sam Atkins
5aba457009 LibWeb/CSS: Add tokenize() method to style values, to get a list of CVs
A couple of arbitrary substitution functions require us to get or
produce some style value, and then substitute its ComponentValues into
the original ComponentValue list. So this commit gives CSSStyleValue a
tokenize() method that does so.

Apart from a couple of unusual cases like the guaranteed-invalid value,
style values can all be converted into ComponentValues by serializing
them as a string, and then parsing that as a list of component values.
That feels unnecessarily inefficient in most cases though, so I've
implemented faster overrides for a lot of the basic style value
classes, but left that serialize-and-reparse method as the fallback.
2025-07-16 14:47:45 +01:00
Sam Atkins
9bc5c6fb35 LibWeb/DOM: Add document getter to AbstractElement 2025-07-16 14:47:45 +01:00
Callum Law
33cf3d7782 LibWeb: Serialize RGB, HWB and HSL colors with unresolved components
Gains us 44 WPT passes.
2025-07-16 13:05:33 +01:00
Callum Law
6a9c8d7767 LibWeb: Don't resolve colors with unresolved components
`CSSColorValue`s which have unresolved `calc` components should be able
to be resolved. Previously we would always resolve them but with
incorrect values.

This is useful as we will now be able to now whether we should serialize
colors in their normalized form or not.

Slight regression in that we now serialize (RGB, HSL and HWB) colors
with components that rely on compute-time information as an empty
string, but that will be fixed in the next commit.
2025-07-16 13:05:33 +01:00
Callum Law
e66332c07a LibWeb: Add new CalculatedStyleValue::resolve_* methods
These new methods are built on top of the spec's
`simplify_a_calculation_tree` algorithm where the old methods were
ad-hoc.

These methods are not used anywhere yet as callers will need to be
migrated over from the deprecated methods one-by-one to account for
differences in behaviour.

No functionality changes.
2025-07-16 13:05:33 +01:00
Callum Law
afa95c2815 LibWeb: Mark CalculatedStyleValue::resolve_* methods as deprecated
The existing resolve methods are not to spec and we are working to
replace them with new ones based on the `simplify_a_calculation_tree`
method.

These are marked as deprecated rather than replaced outright as work
will need to be done on the caller side to be made compatible with the
new methods, for instance the new methods can fail to resolve (e.g.
if we are missing required context), where the existing methods will
always resolve (albeit sometimes with an incorrect value).

No functionality changes.
2025-07-16 13:05:33 +01:00
Callum Law
a13f6cdf86 LibWeb: Use correct command in reorder_modifiable_descendants
Gains us 7 WPT passes in the imported test
2025-07-16 12:40:38 +02:00
Callum Law
1d3e539c09 LibWeb: Account for logical property groups in set_a_declaration
When setting a declaration for a property in a logical property group,
it should appear after all other declarations which belong to the same
property group but have different mapping logic (are/aren't a logical
alias).

Gains us 1 WPT pass.
2025-07-16 11:16:49 +01:00
Callum Law
47ddc2ea87 LibWeb: Respect logical property groups when serializing shorthands
We should not serialize a group of properties `longhands` as a single
shorthand if there is any property declared between the first and
last property in `longhands` which is not part of `longhands` but
belongs to the same logical property group, and has different mapping
logic to any of property in `longhands`
2025-07-16 11:16:49 +01:00
Callum Law
05e2e398bd LibWeb: Add method to get logical property group for PropertyID 2025-07-16 11:16:49 +01:00
Sam Atkins
511e282002 LibWeb/HTML: Return CSSStyleProperties from getComputedStyle()
Corresponds to 94fdd8ab1e
2025-07-16 09:50:30 +02:00
Andrew Kaster
870915b594 Devcontainer: Set dynamic triplets for vcpkg cache feature
This ensures that when we set an overlay port directory for building
the vcpkg cache, we set the default (and host) triplet to match the
triplet files we have in each directory.
2025-07-16 08:36:50 +02:00
Andrew Kaster
0b854ed8eb Devcontainer: Enable vcpkg asset cache for vcpkg cache feature
This enables our vcpkg asset cache in the devcontainer setup, protecting
CI jobs against flaky upstream tarball downloads.
2025-07-16 08:36:50 +02:00
Jelle Raaijmakers
616a2af23d Tests: Enable screenshot tests on arm64
Of the available 71 screenshot tests that we have, 42 fail on macOS
arm64. Let's make it possible to skip those and run the remaining
succeeding screenshot tests on arm64 anyway.
2025-07-16 08:36:14 +02:00
Callum Law
a1c9b86ad3 LibWeb: Account for non-shorthand sub-properties when serializing border
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
When parsing values in `process_a_keyframes_argument` we don't expand
properties using `StyleComputer::for_each_property_expanding_shorthands`
unlike most other places - this means that if we parse a `border` we end
up with the `border`'s sub-properties (`border-width`, `border-style`,
`border-color`) still in their unexpanded forms (`CSSKeywordValue`,
`LengthStyleValue`, `StyleValueList`, etc) rather than
`ShorthandStyleValue`s which causes a crash when serializing the
`border` value in `KeyframeEffect::get_keyframes`.

The proper fix here is to parse `border`'s sub-properties directly to
`ShorthandStyleValue`s instead of relying on
`StyleComputer::for_each_property_expanding_shorthand` to do this
conversion for us but this may be a while off.

This commit also imports the previously crashing tests.
2025-07-16 06:49:38 +01:00
Aliaksandr Kalenik
52e9dcd911 LibWeb: Assign new m_viewport_size before resizing backing store
Fixes bug when `resize_backing_stores_if_needed()` picks up previous
viewport size for allocation of new backing stores.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/5336
2025-07-15 18:39:01 -04:00
Aliaksandr Kalenik
6ddc582551 LibWeb: Delete unreachable code in Node::invalidate_style()
`if (invalidation_set.needs_invalidate_whole_subtree())` branch in the
end of the function was always false.
2025-07-15 18:31:43 -04:00