Phase 9: Advanced Layout#
Wire up visibility: hidden in layout and rendering. Verify display: none works correctly end-to-end.
Current State#
display: noneis handled inbuild_box()— elements are excluded from the layout tree. This appears to work.Visibilityenum (Visible, Hidden, Collapse) is parsed in computed stylesvisibility: hiddenis NOT applied during rendering — hidden elements are still painted
Requirements#
visibility: hidden: The element still participates in layout (occupies space) but is NOT painted. Its children can override withvisibility: visible.- Propagate visibility to renderer: Pass the
visibilityvalue through the layout tree so the renderer can skip painting hidden boxes visibility: collapse: For non-table elements, treat ashidden. (Table-specific collapse behavior can be deferred.)- Inheritance:
visibilityis inherited — a hidden parent's children are hidden unless they explicitly setvisibility: visible
Files to Modify#
crates/layout/src/lib.rs— StorevisibilityonLayoutBoxcrates/render/src/lib.rs— Skip painting boxes withvisibility: hiddencrates/style/src/computed.rs— Ensurevisibilityis properly inherited
Tests#
visibility: hiddenelement occupies space but is not painted- Child of hidden element with
visibility: visibleIS painted display: noneelement occupies no space and is not paintedvisibility: collapseon non-table element behaves likehidden
Acceptance Criteria#
visibility: hiddenhides element visually while preserving layout space- Inheritance works correctly (children can override)
display: nonecontinues to work correctly- All tests pass, clippy clean, fmt clean