Skip to content

LibWeb: Move list marker layout into the list item's owning context - #11000

Merged
kalenikaliaksandr merged 1 commit into
LadybirdBrowser:masterfrom
kalenikaliaksandr:list-marker-fc-ownership
Aug 4, 2026
Merged

LibWeb: Move list marker layout into the list item's owning context#11000
kalenikaliaksandr merged 1 commit into
LadybirdBrowser:masterfrom
kalenikaliaksandr:list-marker-fc-ownership

Conversation

@kalenikaliaksandr

Copy link
Copy Markdown
Member

Outside markers of list items that establish an independent formatting context were laid out from outside the boundary: the outer block context measured and placed them, create_used_values allocated marker entries recursively together with the list item's, and the list item's content block size was overwritten with the marker line-height after its own run had finished.

Marker layout now runs in the epilogue of the list item's own block formatting context run; the outer context handles only markers of list items that participate in its flow directly. Outer float bands reach the run through a new input-only root sizing directive and the baseline comes from the run's derived baselines. The line-height floor is now part of automatic block size computation, so specified height and max-height win over it, matching other engines.

Marker used values are created at one fixed point per configuration: layout_list_item_marker for in-flow outside markers, the inline-level iterator for markers in inline flow, the float machinery for floating markers, and the abspos engine for absolutely positioned ones. The empty-slot assert in create_used_values catches any second creator.

Markers of absolutely positioned, floating, and flex-item list items were never laid out before and now work; the one rebaseline is such a marker changing from 0x0 to a placed box. New layout tests cover markers in flex-item, abspos, floating, flow-root, and overflow:hidden list items, marker baseline alignment in a flow-root list item, and specified heights winning over the floor; a ref test checks that overflow:hidden on a list item still clips its outside marker like other engines do.

Outside markers of list items that establish an independent formatting
context were laid out from outside the boundary: the outer block
context measured and placed them, create_used_values allocated marker
entries recursively together with the list item's, and the list item's
content block size was overwritten with the marker line-height after
its own run had finished.

Marker layout now runs in the epilogue of the list item's own block
formatting context run; the outer context handles only markers of list
items that participate in its flow directly. Outer float bands reach
the run through a new input-only root sizing directive and the baseline
comes from the run's derived baselines. The line-height floor is now
part of automatic block size computation, so specified height and
max-height win over it, matching other engines.

Marker used values are created at one fixed point per configuration:
layout_list_item_marker for in-flow outside markers, the inline-level
iterator for markers in inline flow, the float machinery for floating
markers, and the abspos engine for absolutely positioned ones. The
empty-slot assert in create_used_values catches any second creator.

Markers of absolutely positioned, floating, and flex-item list items
were never laid out before and now work; the one rebaseline is such a
marker changing from 0x0 to a placed box. New layout tests cover
markers in flex-item, abspos, floating, flow-root, and overflow:hidden
list items, marker baseline alignment in a flow-root list item, and
specified heights winning over the floor; a ref test checks that
overflow:hidden on a list item still clips its outside marker like
other engines do.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

List-item marker layout now creates used values from definite list-item dimensions, supports baseline placement, handles floats and absolute positioning, and passes float intrusion through child layout. Automatic block sizing excludes marker boxes from BFC contributions and floors automatic sizes by marker line height. New tests cover these cases.

List-item marker layout

Layer / File(s) Summary
Marker used values and layout
Libraries/LibWeb/Rust/src/layout/block_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
Marker used values are created during marker layout. Used-value generation and floating-element handling no longer use marker-specific exceptions.
Marker flow and block sizing
Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs, Libraries/LibWeb/Rust/src/layout/geometry.rs
Marker placement receives baseline and float intrusion data. Floating markers remain in block layout. Automatic list-item sizing accounts for marker line height without counting marker boxes as BFC roots.
Marker layout and sizing tests
Tests/LibWeb/Layout/*, Tests/LibWeb/Ref/*
Fixtures and expected outputs cover marker sizing, baseline placement, floating and positioned items, flex items, flow roots, overflow clipping, and automatic block sizes.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the list-marker layout changes, used-value creation, sizing behavior, and added tests.
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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs`:
- Around line 2609-2621: Update the automatic block-size calculation around
automatic_block_size_for_block_level_element_disregarding_marker and
floor_list_item_automatic_block_size_by_marker_line_height so floating or
absolutely positioned markers return automatic_content_block_size unchanged.
Apply the same exclusion in the corresponding path near the other occurrence
(around the list-item sizing logic), while preserving the existing line-height
floor for in-flow markers.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0799ac88-0575-420a-8ef9-f80f4dede28a

📥 Commits

Reviewing files that changed from the base of the PR and between fb8acef and 7910893.

📒 Files selected for processing (20)
  • Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
  • Libraries/LibWeb/Rust/src/layout/geometry.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
  • Tests/LibWeb/Layout/expected/block-in-inline-in-floated-fieldset.txt
  • Tests/LibWeb/Layout/expected/list-item-specified-height-not-floored-by-marker.txt
  • Tests/LibWeb/Layout/expected/list-marker-in-abspos-list-item.txt
  • Tests/LibWeb/Layout/expected/list-marker-in-flex-item-list-item.txt
  • Tests/LibWeb/Layout/expected/list-marker-in-floating-list-item.txt
  • Tests/LibWeb/Layout/expected/list-marker-in-flow-root-and-overflow-hidden-list-item.txt
  • Tests/LibWeb/Layout/expected/list-marker-text-baseline-in-flow-root-list-item.txt
  • Tests/LibWeb/Layout/input/list-item-specified-height-not-floored-by-marker.html
  • Tests/LibWeb/Layout/input/list-marker-in-abspos-list-item.html
  • Tests/LibWeb/Layout/input/list-marker-in-flex-item-list-item.html
  • Tests/LibWeb/Layout/input/list-marker-in-floating-list-item.html
  • Tests/LibWeb/Layout/input/list-marker-in-flow-root-and-overflow-hidden-list-item.html
  • Tests/LibWeb/Layout/input/list-marker-text-baseline-in-flow-root-list-item.html
  • Tests/LibWeb/Ref/expected/overflow-hidden-list-item-clips-outside-marker-ref.html
  • Tests/LibWeb/Ref/input/overflow-hidden-list-item-clips-outside-marker.html

Comment on lines +2609 to +2621
) -> CssPixels {
let automatic_content_block_size = self.automatic_block_size_for_block_level_element_disregarding_marker(
node,
available_space,
constraints,
automatic_content_block_size_of_completed_run,
);
floor_list_item_automatic_block_size_by_marker_line_height(
self.state,
self.callbacks,
node,
automatic_content_block_size,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exclude out-of-flow markers from the automatic-size floor.

Lines 1411-1414 leave floating and absolutely positioned markers to their out-of-flow layout paths. This helper still raises the list item’s automatic block size from their line-height.

An auto-height list item can therefore grow for a large absolutely positioned marker. Return the original size when the marker is floating or absolutely positioned.

Proposed fix
     let marker = facts.list_item_marker();
     if marker.is_invalid() {
         return automatic_content_block_size;
     }
+    let marker_facts = state.node_facts(&callbacks, marker);
+    if marker_facts.is_floating() || marker_facts.is_absolutely_positioned() {
+        return automatic_content_block_size;
+    }
     automatic_content_block_size.max(state.style_facts(&callbacks, marker).line_height())

Also applies to: 2957-2979

🤖 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/block_formatting_context.rs` around lines
2609 - 2621, Update the automatic block-size calculation around
automatic_block_size_for_block_level_element_disregarding_marker and
floor_list_item_automatic_block_size_by_marker_line_height so floating or
absolutely positioned markers return automatic_content_block_size unchanged.
Apply the same exclusion in the corresponding path near the other occurrence
(around the list-item sizing logic), while preserving the existing line-height
floor for in-flow markers.

@kalenikaliaksandr
kalenikaliaksandr merged commit 10f4855 into LadybirdBrowser:master Aug 4, 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