Avoid calling is_or_contains_block in push_hoisted_child
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 203
- Avg merge
- 8h 58m
- Merged PRs (30d)
- 112
Description
Follow-up to #657.
`push_hoisted_child` (packages/blitz-dom/src/layout/construct.rs) calls `child.is_or_contains_block()` to decide whether a hoisted child needs an anonymous block wrapper:
```rust
let display_outside = if child.is_or_contains_block() {
DisplayOutside::Block
} else {
child_display.outside()
};
```
`is_or_contains_block()` (packages/blitz-dom/src/node/node.rs) recursively walks all descendants of inline flow nodes, so calling it per hoisted child during `display: contents` hoisting can become O(n²) in pathological trees (deeply nested inline content under contents nodes).
The classification is still needed semantically — an inline element containing a block descendant must be treated as block-level when deciding whether to wrap — so the fix should compute/cache the block-containing classification once (e.g. during flow-child classification or box construction) and pass the result into `push_hoisted_child`, rather than replacing the call with plain `display.outside()` (which would change layout behavior).
Related call sites with the same pattern: `classify_flow_children` and `collect_complex_layout_children` also call `is_or_contains_block` per child; a shared cached classification could cover those too.
[Written by Devin](https://dioxus.staging.devinenterprise.com/sessions/62b3de4395af4598a23a5918918f3239)
Contributor guide
Research direction
Start with push_hoisted_child in packages/blitz-dom/src/layout/construct.rs and is_or_contains_block in packages/blitz-dom/src/node/node.rs, then trace classify_flow_children and collect_complex_layout_children. Identify where flow-child classification or box construction can cache the result, pass it into the relevant callers, and verify that recursive per-child checks are avoided without changing anonymous block wrapping behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100