Commit Graph

2213 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
5be98aaa07 LibWeb: Add internals.dumpLayoutTree(node) API
This new testing API dumps the layout subtree rooted at a given DOM
node. It will be useful for testing partial layout tree rebuilds, where
we need to verify the layout tree structure for specific subtrees rather
than the entire document.
2026-02-09 21:05:45 +01:00
Aliaksandr Kalenik
36a74feb61 Tests: Abspos size change in fO with ancestor containing block
This is a regression test for partial SVG relayout. When an absolutely
positioned element inside foreignObject has its containing block outside
the SVG subtree, changing its size should trigger a correct relayout.
2026-02-09 03:02:49 +01:00
Aliaksandr Kalenik
1e2a4cd7b6 Tests: Add test for SVG relayout with ancestor graphics element
Regression test for SVG partial layout that will be introduced in the
upcoming changes.
2026-02-09 03:02:49 +01:00
Aliaksandr Kalenik
b1921f60ce Tests: Add test for abspos in foreignObject with ancestor containing box
This test covers the case where an absolutely positioned element inside
<foreignObject> has a containing block that is an ancestor of the <svg>.
It serves as a regression test for partial SVG relayout that is going
to be introduced in the upcoming changes.
2026-02-09 03:02:49 +01:00
Timothy Flynn
4a8ef68b90 LibWeb: Protect against null navigables in lineage chain more thoroughly
This extends the null navigable check added in commit
b118c99c27 to include all ancestor and
descendant list lookups. Fixes a crash in the following WPT test:

/cookies/schemeful-same-site/schemeful-navigation.tentative.html
2026-02-08 14:51:25 -05:00
Shannon Booth
39976bb4b8 LibWeb/Bindings: Use DefineDataPropertyOrThrow in Replaceable setter 2026-02-07 11:49:36 +01:00
Shannon Booth
42c3199815 Tests/LibWeb: Import [PutForwards] WPT test 2026-02-06 19:23:30 +01:00
Shannon Booth
02e5e419d9 Tests/LibWeb: Import WPT test for IDL handling of attribute setters 2026-02-06 19:23:30 +01:00
Jelle Raaijmakers
2a2f8ef90b LibWeb+UI: Support triple clicking and dragging paragraphs
When triple clicking on text, we should select the entire paragraph, or
entire line in <input>s and <textarea>s. If the mouse button is held
down and the user starts dragging, the selection expands with additional
paragraphs or lines.

This expands on the work of Kai Wildberger (PR #7681) but was adjusted
for the work that happened previously to support double click + drag
moves and includes triple click support for our Qt UI.

Co-authored-by: Kai Wildberger <kiawildberger@gmail.com>
2026-02-06 14:18:10 +00:00
Jelle Raaijmakers
7f8d052b7e LibWeb: Support double click word selection dragging
In EventHandler, we now keep track of a mouse selection mode which is
either None, Character or Word. By double clicking a word and
immediately dragging, you can now extend the selection word by word
instead of by character.
2026-02-06 14:18:10 +00:00
Jelle Raaijmakers
f55fe69d4d LibWeb: Rework Internals' mouse control
Instead of defining somewhat high level mouse actions, allow granular
control of mouse clicks and mouse down/up/move events. We will want to
simulate things like holding down a mouse button after double clicking
and then dragging the mouse to another position in the future, and this
enables that.
2026-02-06 14:18:10 +00:00
Tim Ledbetter
0b346d1952 LibWeb: Distribute colspan cell width equally when baseline is zero
This matches the behavior of other engines.
2026-02-06 11:37:14 +00:00
Tim Ledbetter
1e8ae879c5 Tests: Reimport updated WPT test helper file 2026-02-06 11:37:14 +00:00
Jelle Raaijmakers
c56c933014 LibWeb+WebContent: Instantly update DPI for painting and media queries
If our UI informed the page of a DPI change, we would store the new
device pixel ratio and leave it at that. It would take a layout/style
update (e.g. by clicking the page) to actually render the page using the
new DPI. This is very visible on macOS when moving the Ladybird window
from a 1x resolution monitor to a HiDPI 2x monitor.

We now instantly update the backing stores and mark media queries for
reevaluation. Moving the Ladybird window on macOS now immediately
updates the page when dragging it to a HiDPI monitor.
2026-02-06 09:01:26 +01:00
Aliaksandr Kalenik
12ba454a5b LibWeb: Stop intrinsic size cache invalidation at SVG root boundaries
SVG root elements (SVGSVGBox) have intrinsic sizes determined solely
by their own attributes (width, height, viewBox), not by their
children. SVGFormattingContext::automatic_content_width/height() both
return 0 unconditionally, confirming children never contribute to the
SVG root's intrinsic size from the CSS layout perspective.

This means changes inside an SVG subtree cannot affect ancestor
intrinsic sizes, so we can stop the cache invalidation traversal at
SVG root boundaries, just like we already do for absolutely positioned
elements.
2026-02-05 20:26:30 +01:00
Callum Law
7f8ca1e9ce Tests: Import a bunch of ScrollTimeline tests 2026-02-05 16:45:34 +01:00
Sam Atkins
615e0c36a4 Tests: Import computed color-mix() test
All of this fails right now, but will gain some passes over subsequent
commits, and importing now lets us track that.
2026-02-05 13:48:10 +00:00
Sam Atkins
ce13ab733d LibWeb/DOM: Walk the flat tree to propagate layout tree updates
This fixes an issue where we wouldn't propagate the layout update from a
slotted node to its slot.
2026-02-05 11:21:08 +01:00
mikiubo
4a1a15ce66 LibWeb: Allow importing ChaCha20-Poly1305 JWK without alg
The WebCrypto specification does not require the "alg" member
to be present when importing a symmetric JWK, as long as the
key material itself is valid.

Add tests covering JWK import without an "alg" field.

This fixes the following WPT:
WebCryptoAPI/import_export/ChaCha20-Poly1305_importKey
2026-02-05 09:05:11 +01:00
Aliaksandr Kalenik
da2c07c66d LibWeb: Apply intermediate stacking context effects to abspos elements
Previously, absolutely positioned elements jumped directly to their
containing block's accumulated visual context, skipping effects
(opacity, mix-blend-mode, isolation) from intermediate ancestors. Per
CSS spec, these properties create stacking contexts that abspos elements
cannot escape — they only escape scroll containers and overflow clips.
2026-02-04 20:54:47 +01:00
Psychpsyo
617b8cb247 LibWeb: Implement the very basics of XRSession 2026-02-04 15:08:37 +01:00
Callum Law
6df4fe199e Tests: Import some @counter-style parsing tests 2026-02-03 09:58:47 +00:00
Tim Ledbetter
c44b30f0f1 LibWeb: Exclude UA internal shadow root elements in elementFromPoint()
When `elementFromPoint()` or `elementsFromPoint()` returns an element
that is inside a UA internal shadow root, we now return the shadow host
for that element.
2026-02-02 20:17:03 +00:00
Andreas Kling
5f434a442a LibWeb: Use targeted style invalidation when adding a new stylesheet
Instead of doing a full document style invalidation when a stylesheet is
dynamically added, we now analyze the new sheet's selectors to determine
which elements could potentially be affected, and only invalidate those.

This works by building an InvalidationSet from the rightmost compound
selector (the "subject") of each rule in the new stylesheet, extracting
class, ID, tag name, attribute, and pseudo-class features. We then walk
the DOM tree and only mark elements matching those features as needing a
style update.

If any selector has a rightmost compound that is purely universal (no
identifying features), or uses a pseudo-class not supported by the
invalidation set matching logic, we fall back to full invalidation.
2026-02-02 21:08:30 +01:00
Vahan Arakelyan
d04b74555b LibWeb/CSS: Make accentColor and accentColorText take accent-color value 2026-02-02 14:19:08 +00:00
Shannon Booth
57339a21a1 Tests/LibWeb: Import a WPT test for storage enumeration
Unfortunately the localStorage portion of this test is manually
disabled here as it is inherently racey with other localStorage
tests in the suite.
2026-02-01 08:35:36 -05:00
CountBleck
197c851802 LibWeb: Add a test for referrer policy delivery via <meta name=referrer> 2026-01-31 22:45:08 +01:00
CountBleck
f44c75a8de LibWeb: Import WPT tests concerning workers spawning other workers
Note that the importScripts() calls to /resources/testharness.js had to
be manually adjusted to use relative paths.
2026-01-31 22:45:08 +01:00
CountBleck
7722af9772 LibWeb: Allow the WPT test harness to be used inside workers
This commit changes any references of `window` (which may not exist) to
use `globalThis` instead.
2026-01-31 22:45:08 +01:00
CountBleck
c64d27aca4 LibWeb: Add a test checking the referrer of fetch()s from Workers
The referrer should actually exist and be equal to the worker URL (after
redirects). This didn't work before the previous commit.
2026-01-31 22:45:08 +01:00
CountBleck
bc0cceae1f LibWeb: Add a test checking the referrer of worker script fetches
Also, allow the echo server to reflect headers by substituting it into a
provided template body, enabling them to be read programmatically as
part of a script.
2026-01-31 22:45:08 +01:00
Shannon Booth
71a9106744 Tests/LibWeb: Import a javascript URL navigation testcase
It turns out that the failing tests actually regressed in:
3e0ea4f62e, which requires more
investigation.

I don't think we would be better off with a revert (and all browsers
already have different behaviour here), so let's just add an in
tree test for now.
2026-01-31 20:41:37 +01:00
Aliaksandr Kalenik
5f0540f800 LibWeb: Add test for hit testing after visual viewport horizontal scroll 2026-01-31 19:20:09 +01:00
Aliaksandr Kalenik
176e3b93b3 LibWeb: Add test for mouse event offset with nested CSS transforms
The test currently produces incorrect offsetX/offsetY values because
compute_mouse_event_offset() only inverts the target element's own
transform, not ancestor transforms.
2026-01-31 16:56:05 +01:00
Tim Ledbetter
b8bad97e76 LibWeb: Populate the data property for input events 2026-01-31 13:30:33 +01:00
Tim Ledbetter
ea855d2baf LibWeb: Clear assigned slot for slottables that become unassigned 2026-01-31 11:44:20 +01:00
Jelle Raaijmakers
e05503dbcb LibWeb: Send InputEvent with right .inputType on insert and delete
Applies to `<input>` and `<textarea>`. Editing commands in
`contenteditable` already sent the right events and input types.

Fixes #7668
2026-01-29 15:08:06 +01:00
Aliaksandr Kalenik
730b28f4dc LibWeb: Add tests for stacking context invalidation
This test verifies that stacking contexts are correctly created and
removed when CSS properties that affect stacking context are changed:
- opacity: transitioning to/from 1
- transform: transitioning to/from none
- filter: transitioning to/from none
- isolation: transitioning to/from isolate

It also verifies that changes within the "creating" range (e.g., opacity
0.5 -> 0.3, or transform translateX(10px) -> translateX(20px)) correctly
preserve the stacking context.
2026-01-28 18:05:41 +01:00
Timothy Flynn
4585734696 LibHTTP: Honor the min-fresh Cache-Control request directive 2026-01-28 11:31:04 -05:00
Timothy Flynn
896ecb28ab LibHTTP: Honor the max-stale Cache-Control request directive 2026-01-28 11:31:04 -05:00
Timothy Flynn
4a728b1f29 LibHTTP: Honor the max-age Cache-Control request directive 2026-01-28 11:31:04 -05:00
Timothy Flynn
26ddd0a904 LibHTTP: Honor the no-cache Cache-Control request directive 2026-01-28 11:31:04 -05:00
Timothy Flynn
cb1ad8a904 LibHTTP: Honor the no-store Cache-Control request directive 2026-01-28 11:31:04 -05:00
Andreas Kling
6b9797f480 LibWeb: Scope pseudo-class invalidation to common ancestor
When a pseudo-class state changed, we always walked the entire
document (or shadow root) tree to find affected elements, even
though only the subtree rooted at the old/new common ancestor
can be affected.

Narrow the tree walk to start from old_new_common_ancestor
instead of the root. To ensure ancestor-dependent selectors are
still correctly evaluated, we seed the style computer's ancestor
filter by walking up from the common ancestor to the root before
the invalidation walk.

This reduces the work from O(total elements) to
O(subtree elements) + O(tree depth), which is a large improvement
on pages where pseudo-class changes (hover, focus, active, target)
occur deep in the DOM.

This was extremely hot (10%+) when hovering mailboxes on GMail.
2026-01-27 10:58:47 +01:00
Shannon Booth
dcb56f6a53 Tests/LibWeb: Add regression test for acid3 numbered test 43
Where we previously had an invalidation bug, fixed by:
35839af2d2 as we are now
calling update_layout to get an updated z-index for
that layout node.
2026-01-27 09:45:40 +01:00
Shannon Booth
b6969fb82d LibURL: Remove default port handling for the IRC schemes
LibURL previously assigned a default port to the IRC schemes,
a carryover from SerenityOS where IRC is supported.

This behavior deviates from the URL Standard and affects URL parsing by
eliding an explicitly specified port when it matches the default (this
is considered a legacy behaviour of the web URL schemes). Remove the IRC
default port to restore spec-compliant behavior.
2026-01-26 18:46:59 +01:00
Shannon Booth
3e0ea4f62e LibWeb/HTML: Check ongoing navigation before javascript: URL navigation
See: https://github.com/whatwg/html/commit/976d272

This fixes a timeout in the included test. In order for the
test to run properly in our test harness it is modified slightly
(as we are loading the HTML from a file:// URL).
2026-01-26 18:46:54 +01:00
Andreas Kling
3b90eb1d49 LibWeb: Recompute child style when parent's display changes
When a parent element's display property changes (e.g., to flex or
grid), children may need to be blockified or un-blockified.
Previously, children only received a recompute_inherited_style() call
which doesn't run the blockification logic.

This patch adds a parent_display_changed flag to the recursive style
update that forces children to get a full style recompute when their
parent's display change triggers a layout tree rebuild.
2026-01-26 12:40:36 +01:00
mikiubo
ba75d4c014 LibCrypto: Add ChaCha20-Poly1305 support
Implement ChaCha20-Poly1305 AEAD using OpenSSL and expose it through
the WebCrypto API, including key management and AEAD parameters.

Add WPT:
/encrypt_decrypt/chacha20_poly1305.tentative.https.any.worker.html
2026-01-26 10:03:09 +01:00
Tim Ledbetter
66246a0f3a LibWeb: Implement composition for grid track size lists 2026-01-26 03:20:08 +01:00