Commit graph

4025 commits

Author SHA1 Message Date
Sam Atkins
22cc36eeaa LibWeb/HTML: Replace "zero" with "0" in some places
Corresponds to 706b986010
2025-07-08 17:08:39 +01:00
Sam Atkins
e74afec9c5 LibWeb: Capitalize "No Popover state" consistently
Corresponds partly to 8035a256bf
2025-07-08 17:08:39 +01:00
Sam Atkins
b711b01f76 LibWeb/CSS: Remove comment that free space is distributed
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
Corresponds to 24c1b60e9a
2025-07-08 10:24:49 +01:00
Sam Atkins
d9aeffa302 LibWeb/CSS: Adjust grammar definitions
Corresponds to:
e2903b127e
1b4ea44fc8
2025-07-08 10:24:49 +01:00
Aliaksandr Kalenik
b87e01e304 LibWeb: Skip recording display list items with color.alpha() == 0
Cuts display list size, mostly because now we avoid lots of FillRect
previusly recorded for boxes with transparent background.

Website      | DisplayList Items Before | DisplayList Items After
-------------|--------------------------|-------------------------
ladybird.org | 1431                     | 1117
null.com     | 4714                     | 4484
discord.com  | 5360                     | 4992
2025-07-08 10:24:11 +02:00
Aliaksandr Kalenik
46097c6753 LibWeb: Avoid unnecessary save/restore in paint_background()
`paint_background()` is invoked for each PaintableBox, so by avoiding
save/restore pair emitted for each call, we substantially decrease
display list size.

Website      | DisplayList Items Before | DisplayList Items After
-------------|--------------------------|-------------------------
ladybird.org | 2753                     | 1431
null.com     | 5298                     | 4714
discord.com  | 6598                     | 5360
2025-07-08 10:24:11 +02:00
Aliaksandr Kalenik
9ac685b948 LibWeb: Remove unnecessary const_cast in ViewportPaintable 2025-07-07 22:04:25 +02:00
Aliaksandr Kalenik
5a874cc62a LibWeb: Remove ClippableAndScrollable mixin
Initially ClippableAndScrollable was introduced, because we had
PaintableBox and InlinePaintable and both wanted to share clipping and
scrolling logic. Now, when InlinePaintable is gone, we could inline
ClippableAndScrollable implementation into PaintableBox.
2025-07-07 22:04:25 +02:00
Shannon Booth
d5e41f1f72 LibWeb: Handle null namespace in prefix map serializing XML
A "namespace prefix map", see:

https://w3c.github.io/DOM-Parsing/#the-namespace-prefix-map

Is meant to also hold null namespaces:

> where namespaceURI values are the map's unique keys
> (which can include the null value representing no namespace)

Which we previously neglected. This resulted in a crash for
the updated WPT test.
2025-07-07 20:24:47 +01:00
edvwib
8ca956e6f1 LibWeb: Implement 'no-validate state' concept 2025-07-07 20:12:11 +01:00
Aliaksandr Kalenik
edfae02680 LibWeb: Make apply{clear}_clip_overflow_rect non-virtual
Some checks are pending
Push notes / build (push) Waiting to run
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
2025-07-07 18:55:30 +02:00
Aliaksandr Kalenik
c0526b085d LibWeb: Make apply_scroll_offset and reset_scroll_offset non-virtual 2025-07-07 18:55:30 +02:00
Aliaksandr Kalenik
773d19b406 LibWeb: Apply either enclosing or own clip rect depending on PaintPhase
Previously, we always applied the enclosing clip rectangle for all paint
phases except overlays, and the own clip rectangle for the background
and foreground phases. The problem is that applying a clip rectangle
means emitting an AddClipRect display list item for each clip rectangle
in the containing block. With this change, we choose whether to include
the own clip based on the paint phase and this way avoid emitting
AddClipRect for enclosing clip rectangles twice.
2025-07-07 18:55:30 +02:00
Andrew Kaster
9df7eb2e1b LibWeb: Support linking custom-built ANGLE libraries not from vcpkg
This is a similar approach to what we're using for skia.
2025-07-07 06:47:06 -04:00
Aliaksandr Kalenik
85001185a7 LibWeb: Remove unnecessary apply_own_clip_rect() in PaintableWithLines
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
Own clip rect is alredy applied in `PaintableBox::before_paint()` for
all paintables with lines, so there's no need to do it once again in
`PaintableWithLines::paint()`.
2025-07-06 21:56:02 +01:00
Aliaksandr Kalenik
af79781399 LibWeb: Remove unnecessary apply_own_clip_rect() in ImagePaintable
Own clip rect is alredy applied in `PaintableBox::before_paint()` for
all image paintables, so there's no need to do it once again in
`ImagePaintable::paint()`.
2025-07-06 21:56:02 +01:00
Aliaksandr Kalenik
8f39aa0d4a LibWeb: Verify that save and restore are balanced within StackingContext
Unbalanced save and restore means that effects only relevant to a
stacking context leak outside, which is never expected behavior. Having
a `VERIFY()` for that makes it much easier to catch such issues.
2025-07-06 22:18:27 +02:00
Shannon Booth
9e3a476890 LibWeb: Abort ongoing navigations when firing certain navigate events
Implements specification change:

335d7f4

Which fixes a crash in the imported test.
2025-07-06 21:43:56 +02:00
Aliaksandr Kalenik
809e465e05 LibWeb: Delete before_children_paint and after_children_paint hooks
These were only used in SVGSVGPaintable to apply scroll frame id, which
is already handled by `before_paint()` and `after_paint()` hooks in
PaintableBox.
2025-07-06 19:21:46 +02:00
Aliaksandr Kalenik
4ddbba64cc LibWeb: Delete unused includes in DisplayListRecorder.h 2025-07-06 19:21:13 +02:00
Aliaksandr Kalenik
3dffd71695 LibWeb: Verify that save/restore are balanced within paintable
Unbalanced save/restore within display list items recorded for a
paintable means that some state only relevant for the paintable leaks to
subsequent paintables, which is never expected behavior.
2025-07-06 19:21:13 +02:00
Aliaksandr Kalenik
ac4151a00b LibWeb: Fix ScopedCornerRadiusClip emitting unbalanced restore()
...when `m_do_apply` is false.
2025-07-06 19:21:13 +02:00
Aliaksandr Kalenik
9e232a70c3 LibWeb: Allow descendant boxes to contribute in overflow rect of parent
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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 inline children. This fixes an issue when we ignore abspos boxes
contained by PaintableWithLines while calculating overflow rect size.

Lots of layout tests are affected, because now PaintableWithLines has
overflow rect.

`Text/input/DOM/Element-set-scroll-left.html` is also affected and now
matches other browsers.
2025-07-06 17:10:18 +02:00
Timothy Flynn
5baa85cbee LibWeb: Add missing ValueInlines include to CanvasSettings.cpp
This missing include is causing an error in distribution builds.
2025-07-06 08:16:01 -04:00
Luke Wilde
985a481b5a LibWeb/CSP: Implement the object-src directive
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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-06 13:40:04 +12:00
Luke Wilde
1b12aa4d8e LibWeb/CSP: Implement the media-src directive 2025-07-06 13:40:04 +12:00
Luke Wilde
5addbcd61b LibWeb/CSP: Implement the manifest-src directive 2025-07-06 13:40:04 +12:00
Luke Wilde
002e993f68 LibWeb/CSP: Add [[nodiscard]] to result enums
This makes it so we don't have to remember to specify [[nodiscard]] on
functions that return them.
2025-07-06 13:40:04 +12:00
Tim Ledbetter
d7deb6d58f LibWeb: Make document origin opaque by default
This aligns our behavior with the specification, which says the default
value for a Document's origin is opaque unless otherwise specified
2025-07-06 13:39:45 +12:00
Tim Ledbetter
b3fa54a791 LibWeb: Set origin of new document in Document.parseHTMLUnsafe()
Previously, a crash would occur when accessing the origin of a document
created with this method.
2025-07-06 13:39:45 +12:00
Tim Ledbetter
66ca4496c3 LibWeb: Set Document origin for DOMParser created documents
Previously, a crash would occur when accessing the origin of a document
created with DOMParser.
2025-07-06 13:39:45 +12:00
Tim Ledbetter
05ef650a59 LibWeb: Respect presentation attributes that apply to not all elements
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
Some SVG presentation attributes are only supported on certain
elements. We now support these special cases for attributes and
elements that we currently have implemented.
2025-07-05 19:07:06 -04:00
Jelle Raaijmakers
2cc8f0821c LibWeb: Don't hit test anonymous containers if there are no fragments
We were always delegating hit tests to PaintableBox if a
PaintableWithLines has no fragments, which means that anonymous
containers could overlap with previous siblings and prioritize their
border box rect. Instead, the nearest non-anonymous ancestor should take
care of hit testing the children so the correct order is maintained.

To achieve this, we no longer do an early hit test in
PaintableWithLines::hit_test() if there are no fragments and default
to the later PaintableBox::hit_test() call that does take anonymous
containers into account.

Fixes the issue seen in #4864.
2025-07-05 23:56:42 +01:00
Jelle Raaijmakers
c24be6a39d LibWeb: Extract hit testing on children into a separate method
This way we can reuse the logic between PaintableWithLines and
PaintableBox. It also introduces the .is_positioned() check for the
children of a PaintableWithLines, which makes sure to skip positioned
child nodes since those are handled by the StackingContext.
2025-07-05 23:56:42 +01:00
Jelle Raaijmakers
e3864f9a9e LibWeb: Do not hit test anonymous containers' box for inline content
A PaintableWithLines will first try to see if there are any fragments
that have a hit. If not, it falls back to hit testing against its border
box rect.

However, inline content is often hoisted out of its parent into an
anonymous container to maintain the invariant that all layout nodes
either have inline or block level children. If that's the case, we
should not check the border box rect of the anonymous container, because
we might trigger a hit too early if the node has previous siblings in
its original parent node that overlap with their bounds.

By ignoring anonymous nodes, we leave the border box hit testing to the
nearest non-anonymous ancestor, which correctly applies the hit testing
order to its children.

Note that the border box rect checks whether the _untransformed_ point
is inside of it, which mirrors the behavior of PaintableBox::hit_test().
2025-07-05 23:56:42 +01:00
Jelle Raaijmakers
1ec3b1c6df LibWeb: Simplify Document::elements_from_point()
We should not need to check if the result of a hit test is actually
visible for hit testing, because if it wasn't, it should not have been
returned from PaintableBox::hit_test() in the first place.
2025-07-05 23:56:42 +01:00
Jelle Raaijmakers
22dacde2c5 LibWeb: Simplify break loop condition in LineBuilder
No functional changes.
2025-07-05 23:56:42 +01:00
Shannon Booth
1b8a77f98c LibWeb/HTML: Avoid potential overflow of index for DOMStringList
The included WPT test passes through -1 which ends up modolo'ing
to u32 max at the IDL conversion layer, resulting in an unsigned
overflow when checking bounds.
2025-07-05 12:28:37 +01:00
Luke Wilde
715061fb79 LibWeb/CSP: Implement the img-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
1689353beb LibWeb/CSP: Implement the frame-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
e899438907 LibWeb/CSP: Implement the font-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
959bb5cc18 LibWeb/CSP: Implement the connect-src directive 2025-07-05 21:21:44 +12:00
Luke Wilde
203c2a6b30 LibWeb/CSP: Use GC::Heap instead of JS::Realm for directive checks 2025-07-05 21:21:44 +12:00
Psychpsyo
baf2063e31 LibWeb: Fix selection when start node is inside end node
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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 a regression introduced in
bc8870d019 (in a performant way this
time)
2025-07-04 20:19:50 +02:00
Sam Atkins
202c55bf28 LibWeb/CSS: Implement the :state(foo) pseudo-class
This matches custom elements that have `foo` in their custom states set.

The 2 test failures here are because we don't support `::part()` yet.
2025-07-04 18:10:28 +01:00
Sam Atkins
5387c923ca LibWeb/CSS: Use first_is_one_of() in can_selector_use_fast_matches()
Makes things a bit easier to read. I've also sorted the pseudo-classes.
2025-07-04 18:10:28 +01:00
Sam Atkins
b6ffea8990 LibWeb: Give Element a CustomStateSet, exposed by ElementInternals 2025-07-04 18:10:28 +01:00
Sam Atkins
e63d81b36e LibWeb: Add CustomStateSet IDL type 2025-07-04 18:10:28 +01:00
Sam Atkins
bc94431b99 IDLGenerators: Add a callback for when a setlike's set is modified
For simplicity, this requires that the setlike Foo class has a
`void on_set_modified_from_js(Badge<Bindings::FooPrototype>)` method.

This will be called after the set is modified from a generated `add()`,
`delete()`, or `clear()` method.
2025-07-04 18:10:28 +01:00
Psychpsyo
93ae57114d LibWeb: Stop clipping the root element's background 2025-07-04 16:18:57 +01:00