Skip to content

blitz, taffy, core: clip-path hit testing, inline margins, 3D transforms, floated insets, <select> sizing, and block-in-inline - #209

Open
BernardoPe wants to merge 8 commits into
bpereira/compat-cssom-hover-fontsfrom
bpereira/compat-blitz-layout-transforms
Open

BernardoPe wants to merge 8 commits into
bpereira/compat-cssom-hover-fontsfrom
bpereira/compat-blitz-layout-transforms

Conversation

@BernardoPe

Copy link
Copy Markdown
Collaborator

Part 4 of 5 in a stacked compatibility series (stacked on #208).

Changes

  • clip-path hit testing (blitz-dom patch 0100): Exclude points outside basic clip-path shapes (inset, circle, ellipse, polygon) from hit testing so visually clipped overlays do not intercept clicks on underlying controls (p5js.org, ox.ac.uk, redis.io/docs).
  • Horizontal margins on non-replaced inline boxes (blitz-dom patch 0101, blitz-paint patch 0036, core/src/layout/geometry.rs): Record per-line, per-node inline-start offsets inside Built (preserving TextLayout <= 44 bytes) and apply them consistently in paint, fragment geometry, and atomic inline box placement (carbon.now.sh).
  • Non-perspective 3D transform projection (blitz-dom patch 0102): Project 3D transforms without perspective (m14 == m24 == 0, m44 == 1) onto the z = 0 plane via their 2D affine part per CSS Transforms 2, while keeping perspective transforms dropped with a TODO (fixes matrix3d menu hit-testing on squarespace.com).
  • Relative positioning insets on block-context floats (taffy patch 0013): Apply position: relative left/right/top/bottom insets after place_floated_box so push/pull float grids shift visually while surrounding floats still flow around the unshifted box per CSS2 §9.4.3 (jquery.com).
  • <select> UA inline-block box (blitz-dom patch 0103, core/src/dom/inner_text.rs): Give select display: inline-block; box-sizing: border-box; in default.css so author width and height apply even when options are hidden or empty (gov.uk, blogger.com, amazon.co.jp, mozilla.com), while keeping <select> out of innerText's atomic-inline isolation.
  • Auto-width block boxes inside inline formatting contexts (blitz-dom patch 0104): Stretch in-flow DisplayOutside::Block boxes with width: auto inside inline contexts to the available line width minus margins so a::before { display: block } occupies its own line per CSS2 §9.2.1.1 (ohsu.edu).
  • Clipped overflow scroll metrics regression test (core/src/layout/tests/clipped_scroll_width.rs).

Verification

  • packages/core/src/layout/tests/clipped_scroll_width.rs
  • packages/core/src/layout/tests/hit_test_clipped.rs
  • packages/core/src/layout/tests/inline_margins.rs
  • packages/core/src/layout/tests/transform_2d_subset.rs
  • packages/core/src/layout/tests/float_relative_insets.rs
  • packages/core/src/layout/tests/select_sizing.rs
  • packages/core/src/layout/tests/block_pseudo_in_inline.rs

@BernardoPe
BernardoPe added this pull request to stack #211 November 23, 2026 12:25
@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch from 7a3cc3a to c8264c8 Compare November 23, 2026 12:48
@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch 3 times, most recently from 42568cc to 21b59a7 Compare November 23, 2026 14:13
@github-actions github-actions Bot added the vouch:trusted Author is vouched, a collaborator, or a bot. label Nov 24, 2026
@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch from 21b59a7 to 5a8dc68 Compare November 24, 2026 20:59
@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch 2 times, most recently from a9340c2 to 4625491 Compare November 24, 2026 22:50
@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch from 4625491 to e877ec7 Compare November 25, 2026 22:16

@ruifigueira ruifigueira left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beep-boop-rui-agent-🤖

The blocking findings are fixed. Approving.

@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch from e877ec7 to cb28526 Compare November 26, 2026 12:18
A box that clips its overflow must not widen the document, while still
keeping its own hidden content reachable. The simple case already behaves
(taffy's scrollable-overflow contribution is clipped for a scroll
container), so this test pins it: a 2000px child inside a 375px
overflow:hidden panel leaves the document at zero scroll width and the
panel with its 1625px of scroll.

The panel's scroll width is read through read_scroll_info, so its field is
now crate-visible. Rust files are reformatted with the pinned toolchain's
edition 2021, which is what the fmt gate checks.

Signed-off-by: bpereira <bpereira@cloudflare.com>
Hit testing ignored `clip-path`, so visually clipped regions of an element
still intercepted pointer events instead of passing them through to underlying
controls.

Check basic shapes (`inset`, `circle`, `ellipse`, `polygon`) in local border-box
coordinates during hit testing, treating unsupported shapes as covering so an
unimplemented clip never makes an element unhittable.

https://drafts.fxtf.org/css-masking-1/#the-clip-path
Signed-off-by: bpereira <bpereira@cloudflare.com>
Parley lays inline text out without the margins of the boxes it runs through,
so `margin-left`/`margin-right` on a non-replaced inline box had no effect:
text stayed where it would sit with no margin, and following siblings did not
shift.

The inline layout now records, per line and node, the inline-start offset that
preceding non-replaced inline boxes' horizontal margins add, skipping the
inline root and any non-inline box. Paint, fragment geometry, and atomic inline
positions all apply that offset so painted text, client rects, and hit testing
agree.

https://drafts.csswg.org/css2/#inline-box-dimensions
Signed-off-by: bpereira <bpereira@cloudflare.com>
A transform list that mentioned any 3d function was dropped, so
`rotateX(45deg)`, `rotateY(50deg)` and `matrix3d(...)` left the box
untransformed: on Squarespace the navigation overlay's `matrix3d` did not move
its bounds, so the Resources button was hit-tested where the overlay's
untransformed top edge sat and the menu never switched panels.

Outside a 3d rendering context the transform still applies as a painting
effect, and without perspective the z = 0 plane projects to exactly the 2d
affine part of the matrix. A 20px box with `rotateX(45deg)` projects to 14.142px
tall at y = 2.929; a matrix with perspective is still dropped because its
projection is projective, not affine.

https://drafts.csswg.org/css-transforms-2/#3d-transform-rendering
https://drafts.csswg.org/css-transforms-2/#two-dimensional-subset
Signed-off-by: bpereira <bpereira@cloudflare.com>
A floated box with `position: relative` was placed in the float context and
committed without applying its `left`/`right`/`top`/`bottom` insets, so
push/pull float grid columns (e.g. `float: left; position: relative; left: 50%`
on jquery.com) stayed in their unshifted order.

Apply relative insets to block-context floats after `place_floated_box`, so
surrounding floats and content still flow around the unshifted float box per
CSS2 §9.4.3.

https://drafts.csswg.org/css2/#relative-positioning
Signed-off-by: bpereira <bpereira@cloudflare.com>
A block-level box nested inside an inline formatting context (such as
`a::before { content: ""; display: block; height: 20px }` on ohsu.edu) was
measured as a shrink-to-fit inline box of width 0, keeping it on the same line
as following inline text instead of occupying its own line.

Stretch in-flow `DisplayOutside::Block` inline boxes with `width: auto` to the
available line width minus margins so they occupy their own line and push
following inline content onto the next line per CSS2 §9.2.1.1 / §10.3.3.

https://drafts.csswg.org/css2/#anonymous-block-level
Signed-off-by: bpereira <bpereira@cloudflare.com>
…lip-path hit testing

Store inline horizontal margin offsets per positioned item index
(line_item_offsets: Vec<Vec<f32>>) instead of per NodeId so trailing text
after a margin-shifted span shifts cleanly without overlap, wrapped spans
apply start margin only on their first fragment and end margin only on
their last, percentage margins resolve against content_box_width(), and
compute_inline_margin_offsets runs in O(items + distinct nodes) only when
committing positions.

Populate line_item_offsets inside rebuild_evicted_layout so evicted
paragraphs match non-evicted geometry and paint, shift span background
and border fragment decorations in blitz-paint, and undo item shifts in
text_offset_at_point for caret/selection placement.

Evaluate clip-path hit-testing after the bounding-box prune in unscrolled
border-box space (applying inverse transform before scroll offset), and
use axis-specific radii for ellipse() closest-side/farthest-side.

Signed-off-by: bpereira <bpereira@cloudflare.com>
Stretch an auto-width block-level box inside an inline formatting context
only when the inline root's own width is definite. A shrink-to-fit
container (inline-block, float, abspos) measures its content under a
definite available width without a known width of its own, so stretching
there reported the available width as the pseudo's max-content
contribution and made the container fill the line.

Carry horizontal inline margins as zero-height Parley inline-box spacers
placed outside the element's style span. Parley now charges them to line
breaking, alignment and glyph positions, so wrapped and right-aligned
lines stay inside the box and span fragments cover the text they belong
to. Remove the post-layout per-item offset machinery from blitz-dom,
blitz-paint and the geometry walk.

Evict a root whose only inline boxes are margin spacers without a break
summary. Parley cannot summarize in-flow boxes, so the root rebuilds on
first access instead of keeping its shaped text resident.

Add layout and paint tests for the block pseudo shrink-to-fit cases, the
240px wrap and right-align repros, and the two span background cases.

Signed-off-by: Bernardo Pereira <bpereira@cloudflare.com>
@BernardoPe
BernardoPe force-pushed the bpereira/compat-blitz-layout-transforms branch from 1682d5b to 906b63d Compare November 27, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted Author is vouched, a collaborator, or a bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants