Skip to content

LibWeb: Guarantee used values exist wherever layout reads them - #11042

Merged
kalenikaliaksandr merged 1 commit into
LadybirdBrowser:masterfrom
kalenikaliaksandr:used-values-no-probing
Aug 7, 2026
Merged

LibWeb: Guarantee used values exist wherever layout reads them#11042
kalenikaliaksandr merged 1 commit into
LadybirdBrowser:masterfrom
kalenikaliaksandr:used-values-no-probing

Conversation

@kalenikaliaksandr

Copy link
Copy Markdown
Member

LayoutState::try_used_values let callers probe whether a box has per-pass used values, conflating "give me the used values" with "did this box participate in layout this pass". The Option-ness was C++ heritage from the retired engine's nullable LayoutState::get(); against pass-local state, every layout-time read site can know the answer statically. Restructure so used values are guaranteed to exist at every read, then drop try_used_values and the per-context try_used_pointer wrappers.

LayoutState::try_used_values let callers probe whether a box has
per-pass used values, conflating "give me the used values" with "did
this box participate in layout this pass". The Option-ness was C++
heritage from the retired engine's nullable LayoutState::get(); against
pass-local state, every layout-time read site can know the answer
statically. Restructure so used values are guaranteed to exist at every
read, then drop try_used_values and the per-context try_used_pointer
wrappers.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The layout engine replaces optional used-value lookups with direct access, adds shared node participation predicates, updates inline geometry state, passes content inline size into line-data emission, and centralizes table row-group classification and participation logic.

Changes

Layout used-values and participation

Layer / File(s) Summary
Layout facts and access contracts
Libraries/LibWeb/Rust/src/css/display.rs, Libraries/LibWeb/Rust/src/layout/layout_state.rs
The code adds shared predicates for table row groups, flow participants, and out-of-flow nodes. Optional used-value access is removed from LayoutState.
Used-value initialization and block sizing
Libraries/LibWeb/Rust/src/layout/abspos_engine.rs, Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs, Libraries/LibWeb/Rust/src/layout/formatting_context.rs, Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
Absolute-positioned, block, grid, and generic formatting contexts directly retrieve or create used values. Block sizing and baseline selection use flow-participant filtering.
Inline geometry and line-data flow
Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs, Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs, Libraries/LibWeb/Rust/src/layout/layout_state.rs
Inline layout consolidates interrupting-block geometry, requires used values for geometry calculations, excludes out-of-flow fragmented ancestors, and passes content inline size to push_line_data.
Table run participation and row groups
Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
Table layout adds child participation logic and uses the unified row-group predicate for participant seeding, positioning, and baseline calculation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the removal of optional used-value access and the restructuring of guaranteed pass-local used values.
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Libraries/LibWeb/Rust/src/layout/layout_state.rs (1)

505-512: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document that is_flow_layout_participant still includes floating boxes.

is_flow_layout_participant excludes absolutely positioned boxes, list-item markers, and SVG mask/clip boxes, but not floating boxes. Callers in derive_baselines and automatic_block_size_for_bfc_root add a separate is_floating() check next to this predicate. Add a short doc comment on is_flow_layout_participant that states floats still pass this check, so future callers do not assume it covers floats.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Libraries/LibWeb/Rust/src/layout/layout_state.rs` around lines 505 - 512, Add
a short documentation comment above is_flow_layout_participant stating that
floating boxes still satisfy this predicate and must be checked separately with
is_floating(). Leave the predicate logic and callers such as derive_baselines
and automatic_block_size_for_bfc_root unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Libraries/LibWeb/Rust/src/layout/layout_state.rs`:
- Around line 505-512: Add a short documentation comment above
is_flow_layout_participant stating that floating boxes still satisfy this
predicate and must be checked separately with is_floating(). Leave the predicate
logic and callers such as derive_baselines and automatic_block_size_for_bfc_root
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e7b7b22f-bba5-4e28-a9a1-c3ccd728834c

📥 Commits

Reviewing files that changed from the base of the PR and between 692d8b4 and dc0b5c5.

📒 Files selected for processing (9)
  • Libraries/LibWeb/Rust/src/css/display.rs
  • Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
  • Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
  • Libraries/LibWeb/Rust/src/layout/formatting_context.rs
  • Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
  • Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
  • Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
  • Libraries/LibWeb/Rust/src/layout/layout_state.rs
  • Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs

@kalenikaliaksandr
kalenikaliaksandr merged commit f1ac946 into LadybirdBrowser:master Aug 7, 2026
14 of 15 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