Commit Graph

3072 Commits

Author SHA1 Message Date
Jonathan Gamble
4e48ba36bd LibWeb: Better handling of union types in IDL code generation
First check if a string is a member of the enum before attempting
numeric conversion. This generates correct code for fields like:

AudioContextOptions {
  latencyHint: AudioContextLatencyCategory | double;
}
2026-01-26 18:46:39 +01:00
Andreas Kling
73c9d1a606 LibWeb: Implement the body element fills the html element quirk
In quirks mode, the body element expands to fill its parent (the html
element) when height is auto, per the quirks spec section 3.7.

This quirk applies when:
- The document is in quirks mode
- The body element has height: auto
- The body is not absolutely/fixed positioned
- The body is not floated
- The body is not inline-level
2026-01-26 16:48:21 +01:00
Andreas Kling
35839af2d2 LibWeb: Optimize getComputedStyle() to avoid layout when possible
Previously, getComputedStyle() would always call update_layout() for
most properties. This was expensive since layout involves a full tree
traversal even when only style information is needed.

This change introduces a more granular approach:
- Properties needing layout computation (used values like width/height)
  still call update_layout()
- Properties needing a layout node for resolved value computation
  (colors, border widths, etc.) also call update_layout()
- All other properties now only call update_style()

The set of properties needing layout node for resolution is now defined
in Properties.json via the "needs-layout-node-for-resolved-value" flag,
rather than being hardcoded. This is generated into a new function
property_needs_layout_node_for_resolved_value().
2026-01-26 12:40:36 +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
Andreas Kling
5fc276872a LibWeb: Add style invalidation for :open pseudo-class
Add proper style invalidation when the `open` attribute changes on
HTMLDetailsElement and HTMLDialogElement. The :open pseudo-class can
affect sibling selectors (e.g., `dialog:open + sibling`), so we need
full subtree + sibling invalidation.
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
Andreas Kling
81942a84f3 LibWeb: Allow hit testing visible children of hidden stacking contexts
Apply the same fix from the previous commit to StackingContext hit test.
Hidden stacking context roots should still allow their visible children
to be hit.
2026-01-25 10:55:30 +01:00
Andreas Kling
c550301a04 LibWeb: Allow hit testing visible children of hidden elements
Previously, hit testing would return early for elements with
visibility: hidden, which prevented their visible children from being
hit. Now we traverse children even for hidden elements, allowing visible
descendants to be hit while still preventing the hidden elements
themselves from being hit.

The key changes:
- PaintableBox::hit_test() and PaintableWithLines::hit_test() no longer
  return early for hidden elements, but still skip chrome hit testing
  and the final hit result for them
- hit_test_fragments() now checks is_visible() on each fragment's
  paintable to skip hidden text

This matches the CSS specification where visibility is inherited but
children can override it with visibility: visible.
2026-01-25 10:55:30 +01:00
Andreas Kling
d91c646788 LibWeb: Fix hit testing for text inside stacking context roots
When an element creates a stacking context (e.g. via position: relative
with z-index), its text fragments were not being hit tested. This was
because PaintableBox::hit_test() returns early when it has a stacking
context, and StackingContext::hit_test() only iterated child paintables,
not the stacking context root's own fragments.

Fix this by extracting fragment hit testing into a new method
hit_test_fragments() on PaintableWithLines, and calling it from
StackingContext::hit_test() when the stacking context root is a
PaintableWithLines.
2026-01-25 10:55:30 +01:00
Callum Law
afdde488c3 LibWeb: Correctly parse logical border-*-*-radius shorthands
Builds on #7609 by parsing these properties correctly in the first place
2026-01-25 10:22:10 +01:00
Tim Ledbetter
191e0e8c18 LibWeb: Support @-webkit-keyframes as an alias for @keyframes
This is listed as mandatory in the compat spec.
2026-01-25 09:33:24 +01:00
Aliaksandr Kalenik
2075eddbf1 LibWeb: Fix logical border-radius properties not being applied
Logical border-radius properties are parsed as Percentage/Length values,
not BorderRadiusStyleValue. Handle these types when applying style.
2026-01-24 21:43:23 +01:00
Aliaksandr Kalenik
44d90af3d6 LibGfx+LibWeb: Cache SkTextBlob in GlyphRun
Previously, SkTextBlob was built on every paint in
DisplayListPlayerSkia::draw_glyph_run(), which meant:
- Repeated work when the same display list is painted multiple times
- Glyph arrays were allocated and populated on each paint

Now the blob is built once during display list recording and cached in
GlyphRun.
2026-01-24 15:22:03 +01:00
Gingeh
7b3afbc11c LibWeb: Paint element overlay during Foreground paint phase
Also removed the FocusAndOverlay phase because it is now useless
2026-01-24 11:54:39 +01:00
Aliaksandr Kalenik
3e54291813 LibWeb: Move VisualViewport transform to AccumulatedVisualContext tree
Move the visual viewport (pinch-to-zoom) transform from a reserved slot
in DisplayList to the AccumulatedVisualContext tree as a root transform
node. Fixed position elements now correctly inherit from this context.

This requires rebuilding the context tree and display list on each zoom
change, but this overhead will be eliminated by future partial context
tree rebuilds.
2026-01-23 18:56:24 +01:00
Aliaksandr Kalenik
f63674e92d LibWeb: Fix scroll regression when pinch-to-zoom is applied
When scrolling with a visual viewport offset (from pinch-to-zoom),
scroll_viewport_by_delta() was passing m_viewport_scroll_offset + delta
to perform_a_scroll_of_the_viewport(). However, that function calculates
the scroll delta as `position - page_top()`, where page_top() includes
the visual viewport offset. This caused the effective scroll delta to be
reduced by the visual offset amount.

Fix by using the current page position (which includes the visual
offset) as the base for the delta calculation.

Regression from 0a57e1e8ac.
2026-01-23 17:52:50 +01:00
Jelle Raaijmakers
acd38ad795 Tests/LibWeb: Implement action_sequence in testdriver-vendor.js
This implements WebDriver Actions API support for key sequences with
modifier tracking in our testdriver-vendor.js. The action_sequence
function processes key sources, tracks Shift/Ctrl/Alt/Meta state across
events, and dispatches keys with the appropriate modifiers via
Internals.sendText().

This allows us to pass WPT tests that make use of that API in our own
test-web runner.
2026-01-23 14:21:35 +01:00
Jelle Raaijmakers
746362e5de LibWeb: Handle WebDriver special keys and Mod_Keypad in keyboard events
Add webdriver_key_to_key_code() in Internals.cpp to properly translate
WebDriver special key codes (0xE000-0xE05D) to KeyCode values with
appropriate modifiers. This ensures keys like Enter, Backspace, and
arrow keys are handled correctly when sent via Internals::send_text().

In EventHandler::handle_keydown(), strip Mod_Keypad when determining
Enter key behavior since it only indicates key location (numpad vs
standard keyboard), not a behavior change. The modifier is still passed
through to KeyboardEvent for the location property.

This gains us 656 WPT subtest passes in `editing`.
2026-01-23 14:21:35 +01:00
Jelle Raaijmakers
da01b0c389 LibWeb: Insert newlines for line breaks in preformatted white-space
When inserting a line break in a contenteditable with preformatted
white-space (pre, pre-line, pre-wrap), insert a newline character (\n)
instead of a <br> element. Use <br> only for padding at end of line to
ensure the cursor can be placed on the new line.
2026-01-23 14:21:35 +01:00
Jelle Raaijmakers
b3d834eea5 Tests/LibWeb: Import WPT `editing/plaintext-only/insertLineBreak.html' 2026-01-23 14:21:35 +01:00
mikiubo
cd8465a6b5 LibCrypto: Add SHAKE digest support
Introduce a new SHAKE hash wrapper in LibCrypto backed by OpenSSL.

Wire cSHAKE128 and cSHAKE256 into WebCrypto.

Note that cSHAKE with non-empty functionName or customization is
currently rejected due to OpenSSL EVP limitations.

This fixes WPT:
WebCryptoAPI/digest/cshake.tentative.https.any.html
2026-01-22 19:47:09 -05:00
Reimar
26181f2958 LibWeb: Implement External interface 2026-01-22 14:56:46 +01:00
Timothy Flynn
d3041dc054 LibHTTP+LibWeb: Support the HTTP Vary response header
We now partition the HTTP disk cache based on the Vary response header.
If a cached response contains a Vary header, we look for each of the
header names in the outgoing HTTP request. The outgoing request must
match every header value in the original request for the cache entry
to be used; otherwise, a new request will be issued, and a separate
cache entry will be created.

Note that we must now defer creating the disk cache file itself until we
have received the response headers. The Vary key is computed from these
headers, and affects the partitioned disk cache file name.

There are further optimizations we can make here. If we have a Vary
mismatch, we could find the best candidate cached response and issue a
conditional HTTP request. The content server may then respond with an
HTTP 304 if the mismatched request headers are actually okay. But for
now, if we have a Vary mismatch, we issue an unconditional request as
a purely correctness-oriented patch.
2026-01-22 08:54:49 -05:00
Timothy Flynn
aa1517b727 LibHTTP+LibWeb+RequestServer: Handle the Fetch API's cache mode
If the cache mode is no-store, we must not interact with the cache at
all.

If the cache mode is reload, we must not use any cached response.

If the cache-mode is only-if-cached or force-cache, we are permitted
to respond with stale cache responses.

Note that we currently cannot test only-if-cached in test-web. Setting
this mode also requires setting the cors mode to same-origin, but our
http-test-server infra requires setting the cors mode to cors.
2026-01-22 07:05:06 -05:00
Luke Wilde
4d882cc682 LibWeb: Don't disentangle remote port when closing MessagePort
Otherwise, the remote port will lose its transport and not receive
queued messages. The remote port will automatically close anyway when
EOF is received on the socket.

This allows https://www.tripadvisor.com/ to load, where it instantiates
a module by creating a MessageChannel, setting port1's onmessage to the
module's instantiation function, posting an undefined message on port2
and then immediately closing port2.
2026-01-22 12:44:51 +01:00
Callum Law
55ce89d513 LibWeb: Support composition of BasicShapeStyleValue
This also required supporting composition for it's constituent types
(`RadialSizeStyleValue` and `BorderRadiusRect`).

The remaining failing subtests in the two affected tests are because we
dont yet support compositing of mixed values
2026-01-22 11:29:41 +00:00
Callum Law
1029bac5fc LibWeb: Support composition of EdgeStyleValue
The remaining failing tests in `background-position-composition.html`
are because we dont yet support compositing of mixed values
2026-01-22 11:29:41 +00:00
Callum Law
51bea3b308 LibWeb: Clamp interpolation of RadialSizeStyleValue 2026-01-22 11:29:41 +00:00
Callum Law
04885a2d41 Tests: Import some more composition and interpolation tests 2026-01-22 11:29:41 +00:00
Aliaksandr Kalenik
8b411ff8c6 LibWeb: Account for border-radius in hit testing
This change adds border-radius awareness to hit testing in two places:
1. ClipData::contains() now uses BorderRadiiData::contains() to properly
   check if a point is inside a rounded clip rect. This handles overflow
   clips from ancestor elements that have border-radius.
2. PaintableBox::hit_test() now directly checks the element's own
   border-radius before reporting a hit.
2026-01-22 11:30:17 +01:00
Aliaksandr Kalenik
0db9ce6131 Tests/LibWeb: Add hit test for border-radius clip
This test demonstrates that hit testing incorrectly hits elements
in areas clipped by border-radius. The corner point (5,5) should
not hit the target element because it falls outside the rounded
corner, but currently it does.
2026-01-22 11:30:17 +01:00
Shannon Booth
c6fab541b7 LibWeb: Fix storage set broadcast event never broadcasting old value
We had skipped some steps in the spec and were:
 * Always broadcasting an old value of null, instead of what it
   actually was previously.
 * Still broadcasting a storage event even if the value had
   not changed in storage compared to the last value.

Fix both issues by returning what the old value is in the setter and
implementing the missing logic.
2026-01-21 22:27:59 +01:00
Aliaksandr Kalenik
660e1a62b2 LibWeb: Remove clip-path handling from PaintableBox::get_masking_area()
This is now handled by AccumulatedVisualContext.
2026-01-21 19:10:26 +01:00
Timothy Flynn
938f21dadc Tests/LibWeb: Move the "html" folder to "HTML"
This test was added a couple of days ago. The new folder is messing with
case-insensitive operating systems like macOS.
2026-01-21 11:01:42 -05:00
Aliaksandr Kalenik
96a39aeaa6 LibWeb: Move effects application into AccumulatedVisualContext
Effects (opacity, blend mode, filters) must be applied in the parent's
coordinate space, before the element's transform. Previously this was
handled by manually switching to the parent's visual context when
applying effects at paint time.

By adding EffectsData to AccumulatedVisualContext and positioning it
before TransformData in the chain, effects are now naturally applied in
the correct order during display list replay, eliminating the special
case in StackingContext::paint().

For SVG filters that can generate content from empty elements (feFlood,
feImage, feTurbulence), a transparent FillRect command is emitted to
trigger the filter through the same AVC pipeline.
2026-01-21 16:19:18 +01:00
Jelle Raaijmakers
f966750d2c LibWeb: Use local coordinates for overflow clip hit testing 2026-01-21 12:57:22 +01:00
Jelle Raaijmakers
99923eac8d LibWeb: Add stubbed Speech API 2026-01-20 06:51:04 -05:00
Jelle Raaijmakers
f17ea50618 Tests/LibWeb: Import WPT Speech API IDL harness test 2026-01-20 06:51:04 -05:00
Timothy Flynn
17d7c2b6bd LibHTTP: Allow revalidating heuristically cacheable responses
This is expected by WPT (the /fetch/http-cache/304-update.any.html test
in particular).
2026-01-19 08:02:14 -05:00
Tim Ledbetter
0035690977 LibWeb: Return body from activeElement() when nothing is focused
This matches the behavior of other browsers.
2026-01-19 13:08:30 +01:00
Aliaksandr Kalenik
69ffe99054 LibWeb: Avoid duplicate transform/perspective context allocations
For position:relative/static elements, use visual parent's state
directly instead of containing block's state + intermediate walk.
This reuses existing context nodes, avoids duplicate allocations,
and eliminates the intermediate ancestor vector construction.
2026-01-19 11:39:47 +01:00
Aliaksandr Kalenik
365e8abd55 Tests/LibWeb: Add test for duplicate transform context allocation
This test demonstrates an issue where TransformData/PerspectiveData can
be allocated twice for the same paintable box when a position:relative
element has an inline transformed ancestor.
2026-01-19 11:39:47 +01:00
Aliaksandr Kalenik
23a74ddc2a LibWeb: Use AccumulatedVisualContext in Element::get_client_rects()
The previous implementation had a bug: it composed all ancestor
transforms but applied them around only the innermost element's
transform origin. The correct behavior is to apply each transform
around its own origin.

AccumulatedVisualContext already tracks all visual transformations
(transforms, scroll offsets, perspective) correctly for hit testing.
This change adds a new transform_rect_to_viewport() method that performs
the forward transformation (element coordinates to viewport
coordinates), which is the inverse direction of
transform_point_for_hit_test().

This fixes getBoundingClientRect() returning incorrect coordinates for
elements inside transformed ancestors with non-default
transform-origins.
2026-01-19 08:53:30 +01:00
Aliaksandr Kalenik
56ba5589a7 Tests: Add failing test for getBoundingClientRect with nested transforms
This test demonstrates incorrect behavior when getBoundingClientRect()
is called on an element inside a transformed ancestor with a non-default
transform-origin.
2026-01-19 08:53:30 +01:00
Tim Ledbetter
f8d6314db6 LibWeb: Account for scroll offset in iframe mouse event coordinates
When delegating mouse events to iframes, coordinate transformations
were not accounting for scroll offsets. This caused clicks inside
iframes to be incorrectly positioned when the parent page was scrolled.
2026-01-19 06:22:18 +01:00
Aliaksandr Kalenik
c9a8ca3b8c LibWeb: Rebuild AccumulatedVisualContext on clip property changes
AccumulatedVisualContext nodes capture a snapshot of the current clip
rect when the tree is built, so we must invalidate whenever the clip
property changes.
2026-01-19 04:01:37 +01:00
Aliaksandr Kalenik
f68b6cd0f0 Tests/LibWeb: Add failing test for clip property invalidation
This test verifies that modifying the CSS clip property via JavaScript
properly invalidates the accumulated visual context. Currently fails
because the clip rect in the display list remains unchanged after the
style update.
2026-01-19 04:01:37 +01:00
Aliaksandr Kalenik
eb860e2f10 LibWeb: Rebuild AccumulatedVisualContext on clip-path changes
AccumulatedVisualContext nodes capture a snapshot of the current
clip-path when the tree is built, so we must invalidate whenever the
clip-path changes.

Fixes regression introduced in 98afd82
2026-01-19 04:01:37 +01:00
Aliaksandr Kalenik
d208fa4316 Tests/LibWeb: Add failing test for clip-path invalidation
This test verifies that modifying clip-path via JavaScript properly
invalidates the accumulated visual context. Currently fails because the
clip-path in the display list remains unchanged after the style update.

Regression from 98afd82491.
2026-01-19 04:01:37 +01:00