Skip to content

fix: pass run_mode through layout#932

Draft
jkelleyrtp wants to merge 3 commits into
mainfrom
jk/positioning
Draft

fix: pass run_mode through layout#932
jkelleyrtp wants to merge 3 commits into
mainfrom
jk/positioning

Conversation

@jkelleyrtp

Copy link
Copy Markdown
Member

Root cause: Taffy's block layout had two places where it called PerformLayout on children when it only needed sizing information, causing descendant layouts to be overwritten with values computed at the wrong width.

Fix 1 — determine_content_based_container_width (line 632): Changed tree.perform_child_layout to tree.measure_child_size. This function only needs the child's width to determine the container's intrinsic width — it was needlessly doing full PerformLayout, which cascaded down and overwrote correct layouts.

Fix 2 — perform_final_layout_on_in_flow_children (line 846): Propagated the parent's run_mode to children instead of hardcoding PerformLayout. When a parent block is in ComputeSize mode, children now also get ComputeSize, preventing them from storing intermediate layout results. Also guarded set_unrounded_layout to only run in PerformLayout mode.

Result: node=31 (version selector) now correctly gets h=41 (matching Chrome), and the nav starts at y=49 instead of y=82, eliminating the 33px gap. All 4,380 Taffy tests pass.

Root cause: Taffy's block layout had two places where it called PerformLayout on children when it only needed sizing information, causing descendant layouts to be overwritten with values computed at the wrong width.

Fix 1 — determine_content_based_container_width (line 632): Changed tree.perform_child_layout to tree.measure_child_size. This function only needs the child's width to determine the container's intrinsic width — it was needlessly doing full PerformLayout, which cascaded down and overwrote correct layouts.

Fix 2 — perform_final_layout_on_in_flow_children (line 846): Propagated the parent's run_mode to children instead of hardcoding PerformLayout. When a parent block is in ComputeSize mode, children now also get ComputeSize, preventing them from storing intermediate layout results. Also guarded set_unrounded_layout to only run in PerformLayout mode.

Result: node=31 (version selector) now correctly gets h=41 (matching Chrome), and the nav starts at y=49 instead of y=82, eliminating the 33px gap. All 4,380 Taffy tests pass.
@nicoburns nicoburns changed the title fix: pass run_moade through layout fix: pass run_mode through layout Mar 23, 2026
@nicoburns

Copy link
Copy Markdown
Member

@jkelleyrtp Counter proposal: #935. Does that PR also fix the issue you were seeing?

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.

2 participants