Skip to content

LibWeb: Move anonymous text run filtering to Rust - #10926

Merged
kalenikaliaksandr merged 1 commit into
LadybirdBrowser:masterfrom
kalenikaliaksandr:libweb-rust-anonymous-text-run
Jul 29, 2026
Merged

LibWeb: Move anonymous text run filtering to Rust#10926
kalenikaliaksandr merged 1 commit into
LadybirdBrowser:masterfrom
kalenikaliaksandr:libweb-rust-anonymous-text-run

Conversation

@kalenikaliaksandr

Copy link
Copy Markdown
Member

The flex and grid item collection paths crossed into C++ to identify anonymous boxes containing only untransformed ASCII whitespace after node topology and text content had moved into the Rust arena.

Record the pre-transform whitespace classification during existing text synchronization, evaluate the predicate directly from arena node data in Rust, and remove the formatting-context callback. The separate fact keeps TextNode::text() behavior when rendered text differs after transformation or first-letter slicing.

The flex and grid item collection paths crossed into C++ to identify
anonymous boxes containing only untransformed ASCII whitespace after
node topology and text content had moved into the Rust arena.

Record the pre-transform whitespace classification during existing
text synchronization, evaluate the predicate directly from arena node
data in Rust, and remove the formatting-context callback. The separate
fact keeps TextNode::text() behavior when rendered text differs after
transformation or first-letter slicing.
@coderabbitai

coderabbitai Bot commented Jul 29, 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: 4f9aee86-af1b-4fab-8538-03bec5a31667

📥 Commits

Reviewing files that changed from the base of the PR and between 1505e5e and e8f298d.

📒 Files selected for processing (6)
  • Libraries/LibWeb/Layout/LayoutRustBridge.cpp
  • Libraries/LibWeb/Layout/TextNode.cpp
  • Libraries/LibWeb/Rust/src/layout/flex_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/layout_node_arena.rs
💤 Files with no reviewable changes (1)
  • Libraries/LibWeb/Layout/LayoutRustBridge.cpp

📝 Walkthrough

Walkthrough

The change moves anonymous whitespace text-run detection into Rust. Text nodes now synchronize an ASCII-whitespace flag into the layout arena, and flex/grid formatting contexts use a Rust predicate instead of a C++ callback.

Changes

Anonymous text-run handling

Layer / File(s) Summary
Text metadata synchronization
Libraries/LibWeb/Layout/TextNode.cpp, Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
Text synchronization and arena storage now retain whether untransformed text is ASCII whitespace.
Rust-side skip predicate
Libraries/LibWeb/Rust/src/layout/formatting_context.rs
Anonymous, non-generated nodes are eligible only when all child nodes are text containing ASCII whitespace.
Flex/grid integration and callback removal
Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs, Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs, Libraries/LibWeb/Layout/LayoutRustBridge.cpp
Flex and grid call the Rust predicate directly, while the bridge callback and helper are removed.

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

Sequence Diagram(s)

sequenceDiagram
  participant TextNode
  participant LayoutNodeArena
  participant FlexOrGridFormattingContext
  participant FfiLayoutFcCallbacks

  TextNode->>LayoutNodeArena: synchronize text and ASCII-whitespace flag
  FlexOrGridFormattingContext->>FfiLayoutFcCallbacks: check anonymous text run
  FfiLayoutFcCallbacks->>LayoutNodeArena: inspect node and child text metadata
  LayoutNodeArena-->>FfiLayoutFcCallbacks: return stored whitespace data
  FfiLayoutFcCallbacks-->>FlexOrGridFormattingContext: return skip decision
Loading

Possibly related PRs

Suggested reviewers: awesomekling, tcl3

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately matches the changes: moving anonymous text-run filtering to Rust, recording ASCII-whitespace state, and removing the callback.
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 1a85ae8 into LadybirdBrowser:master Jul 29, 2026
15 of 16 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