servo/components/layout
Martin Robinson 9bc16482a3
layout: Simplify PositioningContext by having it hold a single Vec (#36795)
`PositioningContext` held two vectors, one inside an `Option`, to
differentiate between the version used for a containing block for all
descendants (including `position: absolute` and `position: fixed`) or
only for `position: absolute` descendants. This distinction was really
hard to reason about and required a lot of bookkeeping about what kind
of `PositioningContext` a layout box's parent expected. In addition, it
led to a lot of mistakes.

This change simplifies things so that `PositioningContext` only holds a
single vector. When it comes time to lay out hoisted absolutely
positioned
fragments, the code then:
 - lays out all of them (in the case of a `PositioningContext` for all
   descendants), or
 - only lays out the `position: absolute` descendants and preserves the
   `position: fixed` descendants (in the case the `PositioningContext`
   is only for `position: absolute`.), or
- lays out none of them if the `PositioningContext` was created for
  box that did not establish a containing block for absolutes.

It's possible that this way of dealing with hoisted absolutes is a bit
less efficient, but, the number of these descendants is typically quite
small, so it should not be significant. In addition, this decreases the
size in memory of all `PositioningContexts` which are created in more
situations as time goes on.

Testing: There is a new WPT test with this change.
Fixes: #36696.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-02 12:20:11 +00:00
..
display_list layout: Account for transform in scrollable overflow (#36138) 2025-04-29 09:37:27 +00:00
flexbox layout: Simplify PositioningContext by having it hold a single Vec (#36795) 2025-05-02 12:20:11 +00:00
flow layout: Simplify PositioningContext by having it hold a single Vec (#36795) 2025-05-02 12:20:11 +00:00
fragment_tree layout: Account for transform in scrollable overflow (#36138) 2025-04-29 09:37:27 +00:00
table layout: Simplify PositioningContext by having it hold a single Vec (#36795) 2025-05-02 12:20:11 +00:00
taffy layout: Simplify PositioningContext by having it hold a single Vec (#36795) 2025-05-02 12:20:11 +00:00
tests layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
Cargo.toml layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
cell.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
construct_modern.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
context.rs Propagate image resolution errors in layout context (#36692) 2025-04-28 12:32:51 +00:00
dom.rs Remove HTMLCanvasDataSource and CanvasSource (#36794) 2025-05-01 17:49:59 +00:00
dom_traversal.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
formatting_contexts.rs layout: Simplify PositioningContext by having it hold a single Vec (#36795) 2025-05-02 12:20:11 +00:00
geom.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
layout_box_base.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
layout_impl.rs layout: Use box tree Fragments for offset parent queries (#36681) 2025-04-25 20:25:10 +00:00
lib.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
lists.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
positioned.rs layout: Simplify PositioningContext by having it hold a single Vec (#36795) 2025-05-02 12:20:11 +00:00
query.rs layout: Use box tree Fragments for offset parent queries (#36681) 2025-04-25 20:25:10 +00:00
quotes.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
replaced.rs Remove HTMLCanvasDataSource and CanvasSource (#36794) 2025-05-01 17:49:59 +00:00
sizing.rs layout: Combine layout_2020 and layout_thread_2020 into a crate called layout (#36613) 2025-04-19 10:17:03 +00:00
style_ext.rs layout: Let individual transform properties establish a stacking context (#36749) 2025-05-02 11:30:32 +00:00
traversal.rs layout: Structure reflow code to make it more modular (#36597) 2025-04-23 07:34:35 +00:00