Skip to content

fix(layout): return border-box content quads - #2809

Merged
ldm0 merged 2 commits into
mainfrom
fix/content-quads-border-box
Nov 12, 2026
Merged

ldm0 merged 2 commits into
mainfrom
fix/content-quads-border-box

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR #2809 at a glance

**Track:** Trajectory Replay (Browser Eval). Replaces part of #640.

Closes #2797.
Replaces part of #640.

Problem

DOM.getContentQuads returned the content box instead of the border box. Padded but empty controls therefore got zero-area quads, which Puppeteer and Playwright discard, so click() on icon-only links/buttons failed; for other padded or bordered elements the click point shifted inward. Chromium returns border-box quads (LayoutObject::AbsoluteQuads). Repro (issue fixture, moli serve --layout): DOM.getContentQuads and DOM.getBoxModel on #b1 (100x50, padding 7, border 5) and #pad (empty inline-block, padding 12, border 1).

Change

moli-layout/src/layout_tree/source_query.rs (content_quads_for_output): use the fragment's box_model.border instead of box_model.content, matching client_rects_for_output, which already uses the border rect. Text fragments (no box model) are unchanged. pass_result_owns_complete_box_models_and_answers_a_batch_from_one_pass now also checks the content quad equals the border box.

Verification

Before: debug build of origin/main f935014; after: debug build of this branch.

# before
#b1  quads [[25,35,125,35,125,85,25,85]]   border [13,23,137,23,137,97,13,97]
#pad quads [[23,23,23,23,23,23,23,23]]     border [10,10,36,10,36,36,10,36]
# after (matches Chromium)
#b1  quads [[13,23,137,23,137,97,13,97]]   border [13,23,137,23,137,97,13,97]
#pad quads [[10,10,36,10,36,36,10,36]]     border [10,10,36,10,36,36,10,36]
  • cargo fmt --all: clean.
  • cargo clippy -p moli-layout --all-targets --all-features -- -D warnings: passed.
  • cargo nextest run -p moli-layout: 330 passed.
  • cargo nextest run -p moli-renderer-v8 -p moli-protocol -p moli-protocol-server -E 'test(quad) | test(scroll_into_view) | test(box_model) | test(geometry)': 223 passed.
  • Not run locally: workspace-wide clippy and the full workspace nextest; left to CI.

Cost

Debug builds, /usr/bin/time -l, median of 5 runs (repro: three interleaved rounds; shared host):

main this PR
issue repro over CDP (moli serve --layout) 1.315 / 1.348 / 1.317 s, 119.6–119.7 MB max RSS 1.306 / 1.597 / 1.307 s, 113.4–119.6 MB
ordinary page, moli fetch --layout of a local 46 KB article 0.110 s, 88.8 MB 0.100 s, 89.0 MB

The change reads a different field of the same fragment box model; no extra layout or allocation. The single 1.597 s round was host noise (the other two rounds match main).

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review of a67f462

No blocking findings

  • Correctness: moli-layout/src/layout_tree/source_query.rs:418-422 now maps box_model.border for Box and InlineBox fragments. This matches Chromium's LayoutObject::AbsoluteQuads (border box). Text fragments have no box model and still use fragment.rect. In moli-layout/src/projection.rs:654-662,720-722, box_model.border is the same rect as fragment.rect for both fragment kinds, so content quads now agree with client_rects_for_output. Each split inline still gets one quad per line fragment, with its own sliced border edges. Transforms take the same local_to_viewport.map_rect path as before, which maps all four corners (model.rs:260), so quads still follow the transform and are not reduced to an AABB. SVG has no padding or border, so its content box equals its border box and nothing changes there.
  • Other callers: scroll_query.rs:28,36 reaches content quads only when client rects are empty, which in practice means text nodes (unchanged). Otherwise it now scrolls the border box, as Chromium does. page_inspection.rs:174 node_quads uses the content-quad fallback only for text. provider.rs:114 (observable_sources_with_fragments) checks only whether the list is empty. The mock geometry path (mock/queries.rs:96) already returned the client (border) rect. The only change a client can see is DOM.getContentQuads. Puppeteer's and Playwright's click points move from the content-box centre to the border-box centre, which is what Chromium gives (equal for symmetric padding and border), and padded empty controls become clickable.
  • Test: the added assertion in phase5_output_contract.rs (border 3,3,114,74 vs content 10,10,100,60) fails without the fix.
  • Cost: the change reads a different field of the same struct, so no new work. The numbers in the body are plausible.
  • CI: Format, Node harness and revision checks pass. Nextest, Clippy, CDP smoke, Python harness, Windows and release builds were still pending when I looked.
  • Body: the picture is still pending.

@github-actions

Copy link
Copy Markdown

Sequential Navigation Soak A/B

⚠️ Benchmark infrastructure failed before a comparison could be produced.

Workflow: timed_out. Inspect the workflow run for the failing build, harness, or artifact step.

No navigation resilience or memory conclusion is available for this run.

@github-actions

Copy link
Copy Markdown

Spider Bench A/B

⚠️ Spider Bench infrastructure failed before a comparison could be produced.

Workflow: timed_out. Inspect the workflow run for the failing build, harness, or artifact step.

No benchmark result or performance conclusion is available for this run.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

CI Regression Report

Source CI run · source state at render: in_progress · artifacts: 6/6

Check Status Signal
Release regression ✅ HEAD/base failures 0/0; raw binary 0.00%
Frontend differential ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes ✅ 8/8 Moli episodes passed; 0 failures
Runtime/CDP contracts ✅ 26 contract cases; 0 failures
CDP smoke ✅ 116/116 groups passed; 1,680 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary 0.00%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 154.16 MiB 154.16 MiB 0 B 0.00%
Stripped binary 106.61 MiB 106.61 MiB 0 B 0.00%
gzip binary 53.21 MiB 53.21 MiB +13 B +0.000023%
Rootfs 161.06 MiB 161.06 MiB 0 B 0.00%
gzip rootfs 62.30 MiB 62.30 MiB +26 B +0.000040%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.85 ms 27.41 ms +0.57 ms 4.03 MiB 4.12 MiB +98.00 KiB
CDP first page 49.29 ms 50.76 ms +1.47 ms 4.37 MiB 4.74 MiB +373.00 KiB
CDP warm page 11.01 ms 12.34 ms +1.33 ms 52.74 MiB 52.42 MiB −334.00 KiB
CLI about:blank 13.07 ms 14.04 ms +0.97 ms 4.19 MiB 2.98 MiB −1.21 MiB
CLI local JS 25.96 ms 25.98 ms +0.02 ms 3.78 MiB 4.40 MiB +630.00 KiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 24.53 ms 24.88 ms +0.36 ms 887.00 KiB 862.00 KiB −25.00 KiB 0 0/0
5 28.59 ms 28.62 ms +0.03 ms 13.13 MiB 29.79 MiB +16.66 MiB 0 0/0
10 29.43 ms 28.41 ms −1.02 ms 13.79 MiB 10.95 MiB −2.83 MiB 0 0/0
25 28.43 ms 29.10 ms +0.67 ms 12.94 MiB 11.39 MiB −1.55 MiB 0 0/0
100 27.53 ms 26.58 ms −0.94 ms 29.30 MiB 13.87 MiB −15.43 MiB 0 0/0
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Match DOM mismatch Diagnostic mismatch Moli error Reference error Infrastructure error Mismatched frames Duration
1,020 0 0 0 0 0 0 7m 3.01s
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Fast contract Episodes Passed Assertions Ready p50 Episode p50
Moli 8 8 47/47 29.26 ms 33.98 ms
Chromium 8 8 47/47 272.38 ms 89.11 ms
Operation p50 Chromium Moli Delta Delta %
navigate 45.54 ms 9.18 ms −36.36 ms −79.84%
observe 1.02 ms 1.11 ms +0.09 ms +9.15%
fill 2.95 ms 4.16 ms +1.22 ms +41.39%
click 6.28 ms 5.45 ms −0.83 ms −13.25%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 69.58 MiB 67.12 MiB 0.87% 12.02% 1 ✅
Chromium 1318.83 MiB 361.84 MiB 1.04% 40.10% 13 ⚠️ PSS partial
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
Suite Cases Failures Median case p50 Median case p95 Median peak PSS p50
Synthetic fetch 13 0 24.24 ms 25.12 ms 715.00 KiB
Long-lived CDP session 13 0 17.66 ms 18.45 ms —
CDP smoke — ✅ 116/116 groups passed; 1,680 scenarios

Workers: 4 · cumulative group time: 476.82 s · failed groups: 0

Slowest group Scenarios Duration Status
dom-input 62 25.92 s ✅
dom-input 62 25.85 s ✅
fetch-resource-dispatch 72 23.38 s ✅
fetch-resource-dispatch 72 23.09 s ✅
scrollbar-visibility 22 21.56 s ✅
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Completed Successful Expected DNS failure Unexpected failures Panics Crashes Timeouts Empty output
545/545 544 1 0 0 0 0 0

Frozen HTML · Linux · --wait done · 45 seconds per page · no retries. Content quality is evaluated separately.

Diagnostics: webmainbench-results — every page's Markdown, stderr, and exit status. Source run and artifacts

All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable.

@ldm0
ldm0 merged commit 8c64bf1 into main Nov 12, 2026
12 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOM.getContentQuads returns the content box instead of the border box; padded empty controls get zero-area quads

2 participants