Skip to content

LibWeb: Key per-pass layout state by arena slot index - #10886

Merged
kalenikaliaksandr merged 2 commits into
LadybirdBrowser:masterfrom
kalenikaliaksandr:layout-state-arena-slots
Jul 27, 2026
Merged

LibWeb: Key per-pass layout state by arena slot index#10886
kalenikaliaksandr merged 2 commits into
LadybirdBrowser:masterfrom
kalenikaliaksandr:layout-state-arena-slots

Conversation

@kalenikaliaksandr

Copy link
Copy Markdown
Member

The separate per-document index used for per-pass layout state grows sparse between full passes. That forces periodic full relayouts through the dense-range veto even though each live arena slot is already unique and free-list allocation keeps active indices compact between passes.

Contained absolutely positioned children must be consumed in document
order. Their list was sorted by layout index, but a partial tree rebuild
only reindexes its rebuilt subtree. Rebuilt and reused positioned
siblings can therefore disagree with tree order in one containing block.

Compare actual tree positions when inserting children. This ensures that
rebuilt and reused positioned siblings stay in document order during
partial layout without depending on per-document indices.
The separate per-document index used for per-pass layout state grows
sparse between full passes. That forces periodic full relayouts through
the dense-range veto even though each live arena slot is already unique
and free-list allocation keeps active indices compact between passes.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a5bb2892-f330-465b-bc08-7c0be5eabe37

📥 Commits

Reviewing files that changed from the base of the PR and between e94da4a and b397098.

📒 Files selected for processing (11)
  • Libraries/LibWeb/DOM/Document.cpp
  • Libraries/LibWeb/DOM/Document.h
  • Libraries/LibWeb/Layout/LayoutState.cpp
  • Libraries/LibWeb/Layout/LayoutState.h
  • Libraries/LibWeb/Layout/Node.cpp
  • Libraries/LibWeb/Layout/Node.h
  • Libraries/LibWeb/Layout/Rust/src/layout_node_arena.rs
  • Libraries/LibWeb/Layout/Rust/src/node_data.rs
  • Tests/LibWeb/Text/expected/abspos-relayout-arena-slot-churn.txt
  • Tests/LibWeb/Text/expected/abspos-relayout-index-compaction.txt
  • Tests/LibWeb/Text/input/abspos-relayout-arena-slot-churn.html
💤 Files with no reviewable changes (6)
  • Libraries/LibWeb/Layout/Node.cpp
  • Tests/LibWeb/Text/expected/abspos-relayout-index-compaction.txt
  • Libraries/LibWeb/Layout/LayoutState.h
  • Libraries/LibWeb/DOM/Document.cpp
  • Libraries/LibWeb/Layout/Rust/src/node_data.rs
  • Libraries/LibWeb/DOM/Document.h

📝 Walkthrough

Walkthrough

Layout node indexing is removed in favor of arena slot indices. Layout-state storage and absolute-position ordering use arena slots and tree order, while partial relayout no longer bails out on dense-range growth. Related tests now require partial passes without full-layout passes.

Changes

Arena-slot layout state migration

Layer / File(s) Summary
Arena identity contract
Libraries/LibWeb/Layout/Rust/src/node_data.rs, Libraries/LibWeb/Layout/Node.*, Libraries/LibWeb/DOM/Document.h, Libraries/LibWeb/Layout/Rust/src/layout_node_arena.rs
Removes layout-index fields, accessors, allocation helpers, and bookkeeping, while exposing each layout node’s arena slot index and updating related assertions and tests.
Layout state and relayout migration
Libraries/LibWeb/Layout/LayoutState.*, Libraries/LibWeb/DOM/Document.cpp
Uses arena slots for UsedValues, orders contained absolute-position children by tree order, removes explicit store capacity setup, and simplifies full-layout bookkeeping and partial-relayout eligibility.
Relayout regression expectations
Tests/LibWeb/Text/input/abspos-relayout-arena-slot-churn.html, Tests/LibWeb/Text/expected/abspos-relayout-arena-slot-churn.txt
Updates the arena-slot churn test to require partial relayout on every iteration with no full passes and records the resulting metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the changeset by explaining the move from per-document layout indices to arena slot indexing and dense-range behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@kalenikaliaksandr
kalenikaliaksandr merged commit f731425 into LadybirdBrowser:master Jul 27, 2026
13 of 14 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.

1 participant