Skip to content

LibWeb: Carry table cell intrinsic padding as a cell run input - #11029

Merged
kalenikaliaksandr merged 2 commits into
LadybirdBrowser:masterfrom
kalenikaliaksandr:task-b3-table-cell-stretch
Aug 7, 2026
Merged

LibWeb: Carry table cell intrinsic padding as a cell run input #11029
kalenikaliaksandr merged 2 commits into
LadybirdBrowser:masterfrom
kalenikaliaksandr:task-b3-table-cell-stretch

Conversation

@kalenikaliaksandr

Copy link
Copy Markdown
Member

Table cells whose vertical alignment can stretch them (any keyword
vertical-align, anonymous flex/grid wrappers, and percentage heights)
used to receive their committing inside layout during the row sizing
passes, before final row block sizes exist; position_cell_boxes() then
patched the stretch into the already-laid-out record.

Defer those cells' single committing inside layout to a new driver that
runs after row block sizes are final, and feed the row sizing passes
from throwaway measurements instead, exactly as percentage-height cells
already did in the first pass. The measured automatic block size is
adopted into the record so row sizing reads the same values as before,
and the pre-layout content block size is restored right before the
deferred committing run so the cell's children resolve percentages
against the same basis the undeferred layout used (children of a
definite-height cell see the specified height, not the adopted
automatic one).

No layout behavior change. This is preparation for carrying the cell's
intrinsic block padding as an input to its own committing run instead
of patching it into the record after the fact.

Table cells whose vertical alignment can stretch them (any keyword
vertical-align, anonymous flex/grid wrappers, and percentage heights)
used to receive their committing inside layout during the row sizing
passes, before final row block sizes exist; position_cell_boxes() then
patched the stretch into the already-laid-out record.

Defer those cells' single committing inside layout to a new driver that
runs after row block sizes are final, and feed the row sizing passes
from throwaway measurements instead, exactly as percentage-height cells
already did in the first pass. The measured automatic block size is
adopted into the record so row sizing reads the same values as before,
and the pre-layout content block size is restored right before the
deferred committing run so the cell's children resolve percentages
against the same basis the undeferred layout used (children of a
definite-height cell see the specified height, not the adopted
automatic one).

No layout behavior change. This is preparation for carrying the cell's
intrinsic block padding as an input to its own committing run instead
of patching it into the record after the fact.
The vertical-alignment stretch used to be patched into the cell's
already-laid-out record by position_cell_boxes(): after the cell's
committing inside layout finished, the stretch difference was added to
the record's block paddings. That leaves cell records mutating after
the cell's own run completes, which the future fragment world forbids.

Now that stretched cells' committing layout runs after row block sizes
are final, the table formatting context can compute the intrinsic block
padding up front and hand it to the cell's run as a RootSizingDirectives
input, applied to the cell's record before its contents are laid out.
position_cell_boxes() no longer writes anything into cell records; it
only places them. The padding values and their fixed-point rounding are
identical to the old patch (including the order-dependent baseline arm,
where the bottom fill absorbs the just-added top padding), so committed
output is unchanged: the content-box origin shift the old model created
by growing padding after layout is exactly reproduced by growing the
padding before a layout whose inputs do not depend on it.
@coderabbitai

coderabbitai Bot commented Aug 7, 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: 1180ff89-35d1-4e18-9e36-0e259e39e4e7

📥 Commits

Reviewing files that changed from the base of the PR and between bf6c4c7 and 18d6f61.

📒 Files selected for processing (3)
  • Libraries/LibWeb/Rust/src/layout/formatting_context.rs
  • Libraries/LibWeb/Rust/src/layout/geometry.rs
  • Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs

📝 Walkthrough

Walkthrough

Changes

Table-cell sizing

Layer / File(s) Summary
Cell sizing inputs and state
Libraries/LibWeb/Rust/src/layout/geometry.rs, Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
RootSizingDirectives and table state now carry intrinsic padding, layout inputs, and pre-layout cell sizes.
Deferred cell measurement
Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
Cells with percentage heights, keyword vertical-align, or anonymous flex/grid wrappers are measured before final row sizes are known.
Final cell layout and intrinsic padding
Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs, Libraries/LibWeb/Rust/src/layout/formatting_context.rs
Deferred cells are laid out after row sizing. Intrinsic padding is calculated and applied during final cell layout. The positioning path uses the committed layout results.

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

Sequence Diagram(s)

sequenceDiagram
  participant TableFormattingContext
  participant CellMeasurement
  participant RowSizing
  participant FormattingContext
  TableFormattingContext->>CellMeasurement: measure deferred cells
  CellMeasurement->>RowSizing: provide sizes and baselines
  RowSizing->>TableFormattingContext: resolve final row sizes
  TableFormattingContext->>FormattingContext: commit cell layout with intrinsic padding
  FormattingContext->>TableFormattingContext: return final cell geometry
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the deferred table-cell layout changes and the intrinsic block-padding preparation.
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.

@kalenikaliaksandr
kalenikaliaksandr merged commit 99659b2 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