LibWeb: Delete parent state pointer in LayoutState

It's safe to remove this pointer because intrinsic layout should never
look up a box's state beyond its containing block.

This change affects the expectations of two layout tests, but both
already differ slightly from other browsers, and the difference between
expectations is less than 5px.
This commit is contained in:
Aliaksandr Kalenik 2025-03-14 01:44:02 +01:00 committed by Andreas Kling
commit d8ff71fbb5
Notes: github-actions[bot] 2025-03-26 12:09:02 +00:00
5 changed files with 29 additions and 58 deletions

View file

@ -55,11 +55,6 @@ struct StaticPositionRect {
};
struct LayoutState {
LayoutState() = default;
explicit LayoutState(LayoutState const* parent);
~LayoutState();
struct UsedValues {
NodeWithStyle const& node() const { return *m_node; }
NodeWithStyle& node() { return const_cast<NodeWithStyle&>(*m_node); }
@ -200,19 +195,16 @@ struct LayoutState {
Optional<StaticPositionRect> m_static_position_rect;
};
~LayoutState();
// Commits the used values produced by layout and builds a paintable tree.
void commit(Box& root);
// NOTE: get_mutable() will CoW the UsedValues if it's inherited from an ancestor state;
UsedValues& get_mutable(NodeWithStyle const&);
// NOTE: get() will not CoW the UsedValues.
UsedValues const& get(NodeWithStyle const&) const;
HashMap<GC::Ref<Layout::Node const>, NonnullOwnPtr<UsedValues>> used_values_per_layout_node;
LayoutState const* m_parent { nullptr };
private:
void resolve_relative_positions();
};