Commit Graph

6880 Commits

Author SHA1 Message Date
Ben Wiederhake
aeaa68c6fa AK: Remove unused include from NumberFormat 2026-02-17 12:38:51 +00:00
Callum Law
6d73a3e85f LibWeb: Parse @font-feature-values at-rule
We don't yet support the `font-display` descriptor as part of this
2026-02-17 12:25:27 +00:00
Callum Law
d998a0aeeb LibWeb: Add generic string_from_style_value method
Reduces duplication in line with `Time::from_style_value()`,
`Angle::from_style_value()` etc
2026-02-17 12:25:27 +00:00
Callum Law
784911fb6d LibWeb: Implement CSSFontFeatureValuesRule 2026-02-17 12:25:27 +00:00
Callum Law
fcdc05a4ee LibWeb: Implement CSSFontFeatureValuesMap
This will be used within `CSSFontFeatureValuesRule`
2026-02-17 12:25:27 +00:00
Jelle Raaijmakers
d5173fe6ca LibWeb: Inflate range rect by font ascenders/descenders
Chrome and Firefox inflate this rect to accommodate for the font's
ascenders and descenders, while the absolute rect for the fragment
remains unaffected. This fixes ascenders/descenders in text being
clipped when selecting text.
2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
819bfa11ec LibWeb: Simplify primary offset translation in ::range_rect()
No functional changes.
2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
8b32456473 LibWeb: Use explicit CSSPixels(float) constructor in ::range_rect()
No functional changes.
2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
f831534589 LibWeb: Add explanatory comment to ::range_rect() on trailing whitespace 2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
d2ad917fbc LibWeb: Simplify PaintableFragment::absolute_rect()
We can pass in offset() immediately. No functional changes.
2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
8654e2caf4 LibWeb: Apply letter-spacing for selection rects and grapheme bounds
Fixes the selection rect on the title text of https://modern-css.com/
being misaligned with the actual characters.
2026-02-17 10:51:48 +01:00
Jelle Raaijmakers
ded42e649b LibWeb: Do not scroll cursor into view on programmatic selection changes
We were mimicking Firefox' behavior that whenever a programmatic change
to an <input>'s or <textarea>'s selection happened, the new selection
focus is brought into view by scrolling. Currently we run a layout
update synchronously for that to make sure we have the fragment's
correct dimensions, which caused a significant performance regression in
Speedometer.

Since this is non-standard behavior, let's mimic Chromium instead which
does not scroll at all - only for direct user initiated input such as
typing.

Relevant issues:

* https://github.com/whatwg/html/issues/6217
* https://bugzilla.mozilla.org/show_bug.cgi?id=232405
* https://issues.chromium.org/issues/41081857
2026-02-17 10:24:00 +01:00
Jelle Raaijmakers
fa04c8db83 LibWeb: Move needs_layout_tree_rebuild to just before we use it
No functional changes.
2026-02-17 10:24:00 +01:00
Aliaksandr Kalenik
3c73457b26 LibWeb: Implement CSS Grid dense packing and fix span placement
Implement the `dense` keyword for `grid-auto-flow` so auto-placed items
backfill earlier gaps in the grid. The sparse/dense cursor logic is now
centralized in `place_grid_items()` step 4: dense resets the cursor to
the grid start before each search, while sparse keeps advancing forward.

Also fix a pre-existing bug where `find_unoccupied_place()` and several
placement helpers only checked if a single cell was unoccupied, ignoring
multi-cell spans. Add `OccupationGrid::is_area_occupied()` and use it
throughout to correctly verify the entire rectangular area is available.
2026-02-16 20:00:17 +01:00
Jelle Raaijmakers
aa2a95c775 LibWeb: Pass through background image painting even if area is empty
We should decide at a later stage, when we've calculated the final
background painting area, whether that area is empty and we can skip
painting the background.

Fixes #7973
2026-02-16 19:33:01 +01:00
Shannon Booth
b835e5cbda LibWeb/HTML: Remove uneeded indexed property functionality on Storage
With the bug in the previous commit fixed, we no longer need these
helpers to support JS like:

localStorage[1] = "my value";
2026-02-16 18:49:15 +01:00
Shannon Booth
1a3a775943 LibWeb: Treat numeric PropertyKeys as Strings per spec in PlatformObject
PropertyKey values can only be String or Symbol per spec; numeric keys
are an internal optimization and should be treated as Strings.

This fixes incorrect behavior for numeric property names on legacy
platform objects (e.g. Web Storage).
2026-02-16 18:49:15 +01:00
Shannon Booth
7015a5fae2 LibWeb/Bindings: Fix link for legacy platform object [[GetOwnProperty]]
The previous link was dead, probably from a spec rename.
2026-02-16 18:49:15 +01:00
Psychpsyo
68f27e9bbc LibWeb: Don't select text when multi-clicking user-select:none node 2026-02-16 15:57:55 +01:00
Callum Law
9f7f623455 LibWeb: Store FilterOperation::DropShadow sub-values as StyleValues
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
98e62cf86a LibWeb: Store FilterOperation::Blur::radius as StyleValue
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
caa5705edf LibWeb: Clamp blur() calculated values 2026-02-16 12:09:23 +00:00
Callum Law
c529614e67 LibWeb: Store FilterOperation::HueRotate::angle as StyleValue
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
68c596942c LibWeb: Store FilterOperation::Color::amount as StyleValue
This simplifies handling and means we now support tree counting
functions.
2026-02-16 12:09:23 +00:00
Callum Law
2c4db0da7e LibWeb: Clamp calculated filter color() amounts by context
This brings us in line with other properties/values and simplifies
handling of non-calculated values
2026-02-16 12:09:23 +00:00
Callum Law
e410efcfb7 LibWeb: Absolutize parsed canvas filter value 2026-02-16 12:09:23 +00:00
Callum Law
79dbca29ee LibWeb: Correctly serialize filter url() value
Previously we would have two closing parentheses when serializing a
`url()` within a `FilterValueListStyleValue`
2026-02-16 12:09:23 +00:00
Callum Law
cd799aa7e7 LibWeb: Forward declare CSS::FilterOperation structs
This means we don't need to include `FilterValueListStyleValue.h` in as
many places - reducing the rebuild from editing that file from 717 files
to 19.
2026-02-16 12:09:23 +00:00
Callum Law
3d3d0a50b6 LibWeb: Add generic Length::from_style_value method 2026-02-16 12:09:23 +00:00
Callum Law
846493831d LibWeb: Add generic number_from_style_value method 2026-02-16 12:09:23 +00:00
Psychpsyo
30c1f2f938 LibWeb: Do not re-target hits to fragments with user-select:none
This makes text selection more usable around them, as demonstrated in
the added test case.
2026-02-16 08:39:28 +01:00
Callum Law
33e590dddb LibWeb: Ensure that computation context cache is always cleared
Previously we didn't clear the computation context caches after:
 - Recomputing inherited style
 - Computing keyframe values

We now clear the caches in those two cases and verify it has been
cleared before using it.

Fixes #7959
2026-02-15 17:52:11 +01:00
Aliaksandr Kalenik
d61fe8622c LibWeb: Skip outside-subtree paintable creation during partial relayout
During partial subtree relayout, `LayoutState` pre-populates
`used_values_per_layout_node` with nodes outside the relayout subtree
(e.g. ancestor SVG graphics boxes) so dependent data can be resolved.
`LayoutState::commit()` was still creating paintables for all entries,
including those pre-populated outside-subtree nodes.

That produced extra disconnected paintables on ancestors across repeated
SVG partial relayouts.

Guard the main paintable-creation loop with
`m_subtree_root->is_inclusive_ancestor_of(node)` so only subtree nodes
get new paintables, while outside-subtree nodes keep their existing
state.
2026-02-15 17:47:30 +01:00
Aliaksandr Kalenik
397fe9c58e LibWeb: Dump all paintables attached to a layout node in dump_tree
Instead of dumping only the single paintable passed into the function,
iterate over all paintables attached to its layout node. This makes
detached/disconnected paintables visible in the dump output, which is
useful for debugging incremental layout issues.

Rebaseline content-image-simple layout test: the anonymous InlineNode
for ::before content spanning multiple lines legitimately has a
separate PaintableWithLines per line, which now all appear in the dump.
2026-02-15 17:47:30 +01:00
Aliaksandr Kalenik
0bec9a1e5d LibWeb: Add dumpPaintableTree() to Internals API
Expose the paintable tree dump through the internals object, analogous
to the existing dumpLayoutTree(). This is useful for testing and
debugging painting behavior.
2026-02-15 17:47:30 +01:00
Psychpsyo
6e1f2c10d6 LibWeb: Implement basics of the WebXR testing framework 2026-02-15 10:50:25 +01:00
Tim Ledbetter
8d0afda9f7 LibWeb: Dispatch pointer boundary events when hovered node changes 2026-02-15 02:36:01 +00:00
Tim Ledbetter
e4f37293fc LibWeb: Dispatch mouseenter events from ancestors to descendents
This is the opposite order to mouseleave and pointerleave events.
2026-02-15 02:36:01 +00:00
Tim Ledbetter
aafaec36ee LibWeb: Fire mouse boundary events before mouse move events 2026-02-15 02:36:01 +00:00
Tim Ledbetter
210cfc34f0 LibWeb: Ensure JS execution context exists in view transition callbacks
This change moves `TemporaryExecutionContext` creation to ensure that
all promise operations are covered.
2026-02-15 02:49:56 +01:00
Shannon Booth
00911a8b01 LibWeb/HTML: Assume WorkerGlobalScope runs in a SecureContext
As a stopgap until we have things wired up fully, consider
WorkerGlobalScope as a SecureContext so that IDL marked with
[SecureContext] is still exposed.
2026-02-14 23:23:17 +01:00
Psychpsyo
05c785b081 LibWeb: Only use overflow clip edge when overflow is set to clip 2026-02-14 22:58:21 +01:00
Psychpsyo
a7267f711b LibWeb: Add overflow-clip-margin-* properties
The corner radius isn't quite right yet, but this gives us
another couple WPT passes for these.
2026-02-14 22:58:21 +01:00
Psychpsyo
3253ddfcb2 LibWeb: Move clip data calculation into a helper 2026-02-14 22:58:21 +01:00
Aliaksandr Kalenik
36ca93908a LibWeb: Unify abspos containing block resolution across FCs
Introduce AbsposContainingBlockInfo and a virtual
resolve_abspos_containing_block_info() method on FormattingContext that
computes the containing block rect, per-axis positioning mode (static
position vs inset-from-rect), and optional grid alignment — all in one
place.

The base implementation handles the common case: padding-box rect of
the containing block, with inline containing block support. GFC
overrides it to return the grid area rect with alignment info.

This replaces the per-context abspos loops that BFC, FFC, TFC, and GFC
each had, with a shared layout_absolutely_positioned_children() +
layout_absolutely_positioned_element() pair. The offset computation is
simplified from ~40 lines of branching to a data-driven dispatch on the
axis mode, and GFC's ~130-line custom layout method is replaced by a
~30-line resolve override.
2026-02-14 22:50:24 +01:00
Tim Ledbetter
d49a2dcfa1 LibWeb: Implement word-break functionality using UAX#14 line breaking
We now use ICU's line break iterator to determine soft wrap
opportunities, enabling correct line breaking for CJK text.
2026-02-14 16:23:18 -05:00
Tim Ledbetter
ae0f5ef9ce LibUnicode+LibWeb: Add infrastructure for line segmentation using ICU
No behavior change This is needed for correct UAX#14 line breaking.
2026-02-14 16:23:18 -05:00
Luke Wilde
5e1493d4c0 LibWeb/CSS: Don't assume that we consumed a color space token
Fixes https://cockpit-project.org/ crashing on load.
2026-02-14 19:54:51 +00:00
Andreas Kling
2b6e6e4ea2 LibWeb: Fix crash in style inheritance for pseudo-element slots
Elements in internal shadow trees that represent CSS pseudo-elements
(e.g. the DetailsContent slot in <details>) store their cascaded
properties on the host element's pseudo-element data, not on the
element itself. This meant that when slotted elements walked the
inheritance chain and encountered such a slot, they would dereference
null cascaded properties and crash.

Fix this by copying the cascaded properties onto the slot element
itself after computing its style, keeping both cascaded and computed
properties accessible in the same place.
2026-02-14 14:36:21 -05:00
Praise-Garfield
7b635fc734 LibWeb: Check WWW-Authenticate on response, not request
The AD-HOC guard for HTTP 401 retry checks whether the request
contains a WWW-Authenticate header, but WWW-Authenticate is a
response header sent by the server to indicate which
authentication schemes it accepts. The check uses
request->header_list() where response->header_list() is
intended. Since requests never carry this header, the guard
never matches and the entire 401 retry path is dead code.
2026-02-14 14:35:41 -05:00