Commit graph

70739 commits

Author SHA1 Message Date
Aliaksandr Kalenik
aea9136239 LibWeb: Remove unnecessary state saving in SVGPathPaintable::paint()
Nothing in this function needs to save painter state.
2025-08-01 05:25:56 -04:00
Aliaksandr Kalenik
0a97de85c9 LibWeb: Move item no-op check from display list player to recorder
If item doesn't produce any output then let's skip appending it to the
display list.
2025-08-01 05:25:56 -04:00
Aliaksandr Kalenik
7d90d9d0a3 LibWeb: Rename m_command_list to m_display_list in DisplayListRecorder 2025-08-01 05:25:56 -04:00
Aliaksandr Kalenik
b265618bfb LibWeb: Rename Command to DisplayListCommand
Gives name more consistent with other display list related classes.
2025-08-01 05:25:56 -04:00
Aliaksandr Kalenik
61114f6d16 LibWeb: Rename PaintContext to DisplayListRecordingContext
PaintContext dates back to a time when display lists didn't exist and it
truly represented "paint context". Renaming it to better align with its
current role.
2025-08-01 05:25:56 -04:00
Aliaksandr Kalenik
1001ff2599 LibGfx+LibWeb: Delete unused PaintStyle::paint() implementations
These are unused since we moved to Skia and it's misleading to keep
them around.
2025-08-01 04:39:50 -04:00
Jelle Raaijmakers
0ce1571e71 LibWeb: Selecting an editing host should focus it
Unspecced but common behavior in the major browsers: if the selection
moves to an editing host, the editing host itself should become focused.
2025-08-01 10:09:26 +02:00
Jelle Raaijmakers
c9d4913bb4 LibWeb: Do not modify selection if editing host is already selected
If an editing host receives focus, we would always set a new selection
range. However, we only need to do that if we're not already part of the
active range. This corresponds to behavior shown by Chrome and Firefox.
2025-08-01 10:09:26 +02:00
Jelle Raaijmakers
8537f0fa82 UI/AppKit: Focus webview if URL was changed
When we manually enter a new URL and hit enter, the web view gets
focused. But when the URL changes for other reasons, such as starting
Ladybird with a URL argument, the location field was still focused.
2025-08-01 10:09:26 +02:00
Jelle Raaijmakers
0cab272f7f LibWeb: Change Editing::editing_host_of_node() to Node::editing_host()
No functional changes.
2025-08-01 10:09:26 +02:00
Luke Wilde
3f5bc023e2 LibWeb+WebContent+UI: Remove unused same-origin policy toggle
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
Page::is_same_origin_policy_enabled is unused, and the original FIXME
has been implemented.
2025-07-31 18:38:03 -04:00
Kemal Zebari
4e4026c89a LibWeb/MimeSniff: Update Rar signature to match spec
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
2025-07-31 16:21:20 +02:00
zac
068974732f LibWeb: Improve cursor appearance
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
`draw_rect` renders the outline of a rectangle.
`fill_rect` seems like a better option for rendering the cursor.
2025-07-31 13:06:56 +02:00
Tim Ledbetter
ca9364983c LibWeb/CSS: Support interpolating filter and backdrop-filter values
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
2025-07-30 23:29:07 +02:00
Andreas Kling
3b63582068 LibWeb: More thoroughly detach layout/paint trees from each other
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
Before committing a new layout (and thus building a new paint tree)
we now go through both the old paint tree and the layout tree and detach
them from each other.

This is a little extra work, but it ensures that there are no lingering
references across the trees, which we were apparently accumulating in
some cases on Discord, causing GC leaks.
2025-07-30 16:58:29 -04:00
Tim Ledbetter
138eabcf0d Meta: Ensure WPT repository exists before attempting to import tests
Previously, importing tests would fail if the WPT repository wasn't
already cloned.
2025-07-30 22:47:04 +02:00
Jelle Raaijmakers
3e4a1cbd55 LibWeb: Use ConservativeVector for recorded node values in Editing API
The `RecordedNodeValue` struct contains a `GC::Ref` to a DOM node, which
might disappear as a result of a garbage collection. For example, during
the "outdent" command, we record nodes, split the parent of those nodes
potentially resulting in all kinds of DOM changes, and then try to
restore the nodes' values. This caused a crash in the
`editing/run/outdent.html` WPT subtests.

By returning a `ConservativeVector`, we make sure the `GC::Ref` gets
marked during sweeps and nodes do not suddenly disappear.
2025-07-30 16:36:17 -04:00
Jelle Raaijmakers
c4f5e7bee3 LibWeb: Implement anchor-size(..) function parsing
This parses `anchor-size(..)` functions in CSS, but does not yet result
in a useful `Size`: we need style & layout interleaving similar to
container queries for this, since the resulting value depends on layout
results.

Not supported yet: `anchor-size()` appearing inside a `calc()` node.

Adds 4280 WPT subtest passes in `css/css-anchor-position`.
2025-07-30 18:13:59 +01:00
Jelle Raaijmakers
02598040ad LibWeb: Add CSS::Parser::parse_dashed_ident() 2025-07-30 18:13:59 +01:00
Tete17
ae3bda993a LibWeb: Add initial TrustedType WPT tests 2025-07-30 15:51:35 +01:00
Tete17
5a40115b86 LibWeb: Implement getAttributeType for TrustedTypePolicyFactory
This allows authors to check if Trusted Type is required for a given
Element's content attribute. This allows to pass the correct type
when they call to Element.setAttribute.
2025-07-30 15:51:35 +01:00
Tete17
8fdd9b68dc LibWeb: First implementation of the TrustedTypePolicyFactory
Most of the functions are either not implemented of filled with dummy
values.
2025-07-30 15:51:35 +01:00
Tete17
223b1cc704 LibWeb: Add barebones SVGAnimationElement class
Many wpt test on trusted-types relay on this class being defined to even
begin the test as it declares some event handlers.

This is not really an implementation but the most basic setup needed to
run the tests.
2025-07-30 15:51:35 +01:00
Andreas Kling
c4b13589e9 LibWeb: Make StyleComputer and FontLoader GC-allocated
This allows them to keep style sheets alive while loading fonts for
them. Fixes some GC crashes seen on the WPT WOFF2 tests after
66a19b8550 stopped FetchRecord leaks from
keeping various other things alive.
2025-07-30 16:35:08 +02:00
Jelle Raaijmakers
aa563706ca LibWeb: Rework AnimationTimeline's monotonically increasing property
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
Our previous implementation kept track of an AnimationTimeline being
monotonically increasing, by looking at new time values coming in and
setting `m_monotonically_increasing` to `false` whenever a new value
is before the previous known time value.

As far as I can tell, the spec doesn't really ask us to do so: it just
defines 'monotonically increasing' as a property of a timeline, i.e. it
guarantees that returned time values from `::current_time()` are always
greater than or equal to the last returned value.

This fixes a common crash seen when the last render opportunity lies
before the document's origin time, and `::set_current_time()` was
invoked with a negative value. This was especially visible in the
`Text/input/wpt-import/css/cssom/CSSStyleSheet-constructable.html` test.
2025-07-30 14:37:54 +02:00
Aliaksandr Kalenik
a3af7ca1a0 LibJS: Skip PrivateEnvironment allocation if possible
If class doesn't have any private fields, we could avoid allocating
PrivateEnvironment for it.

This allows us to skip thousands of unnecessary PrivateEnvironment
allocations on Discord.
2025-07-30 13:01:53 +02:00
Aliaksandr Kalenik
d1fbb7b51e LibWeb: Invalidate less elements affected by CSS custom properties
Before this change, whenever element's attributes changed, we would add
a flag to "pending invalidation", indicating that all descendants whose
style uses CSS custom properties needed to be recomputed. This resulted
in severe overinvalidation, because we would run invalidation regardless
of whether any custom property on affected element actually changed.

This change takes another approach, and now we decide whether
descendant's style needs to be recomputed based on whether ancestor's
style recomputation results in a change of custom properties, though
this approach adds a little overhead to style computation as now we have
to compare old vs new hashmap of custom properties.

This brings substantial improvement on discord and x.com where, before
this change, advantage of using invalidation sets was lost and we had
to recompute all descendants, because almost all of them use custom
properties.
2025-07-30 11:06:05 +02:00
Aliaksandr Kalenik
cbe4ba60c3 LibWeb: Implement faster equals() for UnresolvedStyleValue
Compare `Vector<Parser::ComponentValue>` directly instead of
serializing them into strings first.

This is required for the upcoming changes where we would compare
previous and new sets of custom properties to figure out whether we need
to invalidate descendant elements. Without this change `equals()` would
show up being hot in profiles.
2025-07-30 11:06:05 +02:00
Aliaksandr Kalenik
b1efd62ce6 LibWeb: Save more details about ASF presence in UnresolvedStyleValue
In the upcoming changes we would have to know specifically whether
`var()`, `attr()` or both are included in UnresolvedStyleValue.
2025-07-30 11:06:05 +02:00
Aliaksandr Kalenik
d47a22150d AK: Define operator== for HashMap 2025-07-30 11:06:05 +02:00
Tim Ledbetter
62e52163d6 LibWeb: Interpolate text-shadow values as a shadow list
This is the same behavior as is currently used for `box-shadow`.
2025-07-30 10:51:50 +02:00
Tim Ledbetter
3ae48776fd LibWeb: Round integral values to the nearest integer when interpolating
Previously, color components were being incorrectly rounded when
interpolating.
2025-07-30 10:51:50 +02:00
Aliaksandr Kalenik
3c3f1f9fad LibWeb: Don't capture proxy as root in ProxyConstructor::revocable
`revoker_closure` is used to construct `NativeFunction` that visits
`raw_capture_range()`, so there is no need to use GC root for `proxy`.
2025-07-30 08:43:53 +02:00
Andreas Kling
66a19b8550 LibWeb: Make ESO "fetch group" weakly reference the fetch records
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
Otherwise we end up holding on to every fetch record indefinitely.

Found by analyzing GC heap graphs on Discord.
2025-07-29 20:00:17 -04:00
Aliaksandr Kalenik
4cbf47dcd2 LibWeb: Unregister ResizeObserver from Document when it has no targets
According to the spec, `ResizeObserver` needs to live for as long as
it's referenced from script or has observation targets. With this change
we make sure that `ResizeObserver` is unregistered from the `Document`
when it has no target.

Fixes GC leak that caused us to keep all resize observers alive until
document they belong to is destroyed.
2025-07-30 00:54:57 +02:00
Aliaksandr Kalenik
40fd2643cc LibWeb: Don't visit DocumentShadowRootList from Document
`ShadowRoot` register itself in Document` from constructor and
unregister itself from `finalize()`. The problem is that `finalize()`
won't be invoked for as long as `ShadowRoot` is visited by
`Document`, leading to GC leaks.
2025-07-30 00:54:57 +02:00
Aliaksandr Kalenik
52b4f2a40a LibWeb: Don't visit registered document observers from Document
`DocumentObserver` register itself in Document` from constructor and
unregister itself from `finalize()`. The problem is that `finalize()`
won't be invoked for as long as `DocumentObserver` is visited by
`Document`. By not visiting registered observers from `Document` we
move this responsibility to object that allocated observer, which is
always exactly what we want, e.g. once `SVGUseElement` that uses
observer is gone, observer won't be visited anymore which will lead to
`finalize()` being called.
2025-07-30 00:54:57 +02:00
Grant Knowlton
9e1e4f3b15 AK: Validate compressed tags in IPv4-mapped IPv6 address
This disallows parsing IPv4 mapped IPv6 address strings with multiple
compression prefixes.  Tests are provided for the updated
functionality.
2025-07-30 00:53:10 +02:00
Andrew Kaster
cf355d48b1 CMake: Install AppStream metainfo file with absolute path
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
Fixes CMake install with a separate build directory breakage introduced
by 1b1eae4409
2025-07-29 11:31:12 +02:00
Jan Koudijs
1b1eae4409 Meta: Add a freedesktop appstream/metainfo manifest
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
2025-07-28 19:37:48 -06:00
Andreas Kling
81d4079c12 LibWeb: Support CSS content property images (and lists, too!)
This patch expands our generated content support beyond single strings
to lists of strings and/or images.

Pseudo-elements like ::before and ::after can now use content:url(...)
to insert anonymous image boxes into the layout tree.

This is heavily used in Google Docs for UI elements.
2025-07-28 22:46:27 +02:00
Andreas Kling
77abe2a84d LibWeb: Allow ImageProvider subclasses to visit additional GC edges
More prep work for CSS content:image.
2025-07-28 22:46:27 +02:00
Andreas Kling
0e94c4e270 LibWeb: Allow ImageProvider to not have a corresponding DOM node
This is prep work for CSS content:image.
2025-07-28 22:46:27 +02:00
Andreas Kling
9603aa0745 LibWeb: Allow Layout::ImageBox to be anonymous
This is prep work for CSS content:image, which means pseudo-elements can
be used to generate images without a corresponding DOM node.
2025-07-28 22:46:27 +02:00
Timothy Flynn
67cc02ab59 LibWeb+UI: Add an explicit IPC to handle mouse leave events
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
The faux position we created here is adjusted by the device pixel ratio
later on, which would invoke integer overflow on screens with a DPR
greater than 1.

Instead of creating special data for a mouse move event, let's just add
an explicit leave event handler.
2025-07-28 21:26:33 +02:00
Timothy Flynn
8600925713 LibWeb: Port HTMLElement innerText/outerText to UTF-16 2025-07-28 18:30:50 +02:00
Timothy Flynn
5c561c1a53 LibWeb: Port node text content to UTF-16 2025-07-28 18:30:50 +02:00
Timothy Flynn
27a4c1eaf6 LibWeb: Remove errant comment from HTMLElement::rendered_text_fragment
This became untrue in  a1a740bb3e.
2025-07-28 18:30:50 +02:00
Timothy Flynn
63bce2b78c LibWeb: Remove the ad-hoc strip_newlines method from HTMLSelectElement
This doesn't appear to be doing anything that the Infra method it calls
isn't already doing.
2025-07-28 18:30:50 +02:00
Timothy Flynn
d9502505c2 AK: Fix bounds assertions in Utf16View::iterator_offset 2025-07-28 18:30:50 +02:00