Commit graph

7 commits

Author SHA1 Message Date
Tim Ledbetter
5b1120d0f4 LibWeb: Hit-test SVG paths against their fill geometry
Previously, hit testing for SVG paths used the path's bounding box.
2026-06-14 17:45:28 +02:00
Aliaksandr Kalenik
78cda6a97e LibWeb: Reserve visual viewport AVC root
The accumulated visual context tree used index 0 as a null sentinel, so
visual viewport transforms were only represented by adding a normal
transform node when the transform was non-identity. That made callers
treat index 0 as a special no-context value and kept the tree shape
dependent on the visual viewport state.

Reserve index 0 as the visual viewport transform node instead. AVC
traversal, display-list replay, hit testing, debug dumping, and root
paint state now treat that node as a real root. Rebaseline the affected
display-list and async-scrolling text expectations so the explicit root
node appears in AVC dumps.
2026-06-03 02:12:39 +01:00
Andreas Kling
fe188b7d57 LibWeb: Make message drag selection more eager
Use selection-specific caret hit testing while starting and extending
mouse selections. The public caret-position API keeps its normal line
ranking, but selection drags now snap below-line movement to line edges
and prefer the previous line when starting in a nearby inter-line gap.

Add coverage for dragging from message text, after-text space, gutters,
author names, avatar-adjacent areas, and row bottoms so these inert
message regions reliably start selection.
2026-05-30 21:36:47 +02:00
Andreas Kling
6b8bd2699a LibWeb: Record foreignObject descendant hit tests
Add coverage for hit testing an HTML child inside an SVG
foreignObject when the SVG root uses paint containment. This captures
the case from Discord guild icons, where the SVG root is positioned and
paint-contained around a masked foreignObject.

When an SVG root establishes a stacking context, we were painting its
children without entering the root SVG paint path. That skipped the root
visual context setup before reaching a foreignObject. The foreignObject
then painted HTML descendants as SVG boxes, so their background-phase
hit-test entries were not emitted and the SVG root could win hit testing
instead.

Use the normal SVG box paint path for stacking-context SVG roots, and
record descendant hit-test items when painting a foreignObject. Keep the
existing SVG rendering path for the descendants so masked foreignObject
content is not repainted through full CSS stacking-context phases.
2026-05-30 21:36:47 +02:00
Andreas Kling
5c26e86354 LibWeb: Expose document caretPositionFromPoint
Add the CSSOM View CaretPosition interface and expose the Document API.
Use retained hit-test data to populate offsetNode, offset, and
getClientRect().

Update IDL coverage and the window property baseline. Add a text test.
2026-05-30 13:50:48 +02:00
Andreas Kling
e621739189 LibWeb: Improve caret placement from retained hit-test data
Use retained caret line metadata to rank nearby lines and items when a
selection drag lands in gaps around text, tables, images, and overlays.
Prefer candidates close in both block and inline axes, while still
respecting paint order and direct caret targets.

Record container margin and glyph overflow information so selection does
not snap across adjacent rows, decorative boxes, or unrelated content.
Cover the fixed cases with text tests for page, table, logo, image, and
post-layout selection drags.
2026-05-30 13:50:48 +02:00
Andreas Kling
7445cff5e8 LibWeb: Use retained data for hit testing
Build a hit-test display list while recording paint output. Use it as
source of truth for point hit testing instead of recursively walking the
paintable tree in reverse paint order.

The retained list records target paintables, visual context indices,
border radii, caret rects, and line metadata needed by hit testing. It
also keeps a spatial index so point queries inspect nearby items before
checking containment in paint order.

Refresh scroll state before hit testing so visual context transforms use
current scroll offsets. Add text tests for rounded hit regions and
selection across non-text content.
2026-05-30 13:50:48 +02:00