Commit Graph

20 Commits

Author SHA1 Message Date
Jelle Raaijmakers
3d2571b46e LibWeb: Implement text-decoration-skip-ink painting
Use Skia's SkTextBlob::getIntercepts() to find where glyph outlines
cross the underline/overline band, then split the decoration line into
segments with gaps around those intersections.
2026-03-26 12:15:36 +00:00
aguiarcode
49d66867bd LibWeb: Invalidate inline paint caches when text selection state changes 2026-03-24 13:06:15 +00:00
Jelle Raaijmakers
2e42421553 LibWeb: Invalidate paint cache for input/textarea on focus change
The invalidate_style() calls on text nodes in did_receive_focus() and
did_lose_focus() were no-ops since Node::invalidate_style() returns
early for character data nodes. Replace them with set_needs_repaint()
which properly invalidates the containing PaintableWithLines' paint
cache, ensuring selection highlights are cleared and the caret is
repainted when switching focus between text controls.

Fixes #8363
2026-03-11 16:44:19 +00:00
Jelle Raaijmakers
3ad969fce8 LibWeb: Clip <fieldset>'s background painting to exclude the legend
Although most dimensions include the `<legend>` of a `<fieldset>`, when
a background is defined for a `<fieldset>` we should clip it during
painting as to exclude the background of the `<legend>`.
2026-03-10 19:08:15 +00:00
Tim Ledbetter
fd4c5b53eb LibWeb: Invalidate paint cache for all layout node paintables on repaint 2026-03-10 15:54:44 +01:00
Luke Wilde
21713377e2 LibWeb: Paint SVG-in-img with a nested display list
This makes SVG-in-img appear sharp no matter the current
(pinch-to-)zoom level.
2026-02-24 19:13:23 +01:00
Aliaksandr Kalenik
beb7971762 Tests: Add display list test for zero-area clip commands 2026-02-24 16:41:20 +01:00
Aliaksandr Kalenik
5a073fdbf1 Tests: Add display list test for overflow on SVG inner elements
This test captures the current (incorrect) behavior where setting
`overflow: hidden` on an SVG `<g>` element produces a clip in the
display list. Per the CSS Overflow spec, overflow properties only apply
to block containers, flex containers, and grid containers — not SVG
graphics elements.
2026-02-24 12:28:55 +01:00
Aliaksandr Kalenik
19d3ca90b2 Tests: Add display list test for SVG foreignObject mask after relayout
This test verifies that SVG mask application on foreignObject is
preserved after partial SVG relayout. Currently the mask is not applied
to the foreignObject content after relayout because the stacking context
tree is not rebuilt.
2026-02-24 06:15:07 +01:00
Aliaksandr Kalenik
94d7c76226 LibWeb: Add test for z-index change causing double paint in display list
When z-index changes from 0 to a positive value on a positioned element,
the stacking context tree is not rebuilt, causing the element to be
painted twice. This test captures the current (incorrect) behavior.
2026-02-17 20:44:46 +01:00
Jelle Raaijmakers
d3a2e4bbbb LibWeb: Draw caret for empty contenteditable elements
We don't have a text node in these, so no fragments either. Maintaining
a special case for this situation seems much simpler than reworking
`contenteditable`s to always have a fragment.
2026-02-11 11:17:27 +01:00
Jelle Raaijmakers
3bc4374344 LibWeb: Draw caret for empty <input>s and <textarea>s
Our change to generate spans in PaintableWithLines from fragments also
broke drawing the caret for empty <input>s and <textarea>s, since spans
was empty in that case.

Fix this by moving caret drawing to PaintableWithLines, and only
invoking it if we have a cursor position set.
2026-02-11 11:17:27 +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
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
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
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
Aliaksandr Kalenik
a87b5c722d LibWeb: Add AccumulatedVisualContext debugging infrastructure 2026-01-15 19:50:53 +01:00
Jelle Raaijmakers
0cf6bd0324 LibWeb: Maintain rect positioning when rounding to device pixel rects
When rounding a CSSPixelRect to a DevicePixelRect, we simply pulled its
width and height through round() and called it a day. Unfortunately this
could negatively affect the rect's perceived positioning.

A rect at { 0.5, 0.0 } with size { 19.5 x 20.0 } should have its right
edge at position 20, but after rounding it would end up at { 1, 0 } with
size { 20 x 20 }, causing its right edge to be at position 21 instead.

Fix this by first rounding the right and bottom edges of the input rect,
and then determining the dimensions by subtracting its rounded position.

Fixes #245.
2025-08-19 21:53:46 +02:00
Jelle Raaijmakers
9e29d0c040 LibWeb: Make button layout wrappers inherit styles correctly
There are some nuances to creating these wrappers, such as manually
propagating certain text styles that are not inherited by default. We
already have the logic for this in
`NodeWithStyle::create_anonymous_wrapper()`, so reuse that method in our
implementation of the button layout.

Fixes applying certain text styles (such as `text-decoration`) to the
text of a `<button>`.
2025-08-19 11:12:23 +02:00
Aliaksandr Kalenik
8ae7417445 LibWeb: Add internals call to dump display list
It's useful to have tests that dump display list items, so we can more
easily see how changes to the display list recording process affect the
output. Even the small sample test added in this commit shows that we
currently record an unnecessary AddClipRect item for empty paint phases.

For now, the dump doesn't include every single property of an item, but
we can shape it to include more useful information as we iterate on it.
2025-07-13 19:15:05 +02:00