LibWeb: Maintain tree order inside LayoutState

Before this change, we were at the mercy of hashed pointer addresses
when processing fragment relocation in LayoutState::commit().
This made inline fragment order non-deterministic, causing layouts to
shift around seemingly randomly on page reload.

By simply using OrderedHashMap, we automatically get tree order
processing here. This fixes a bunch of flaky tests on WPT.
This commit is contained in:
Andreas Kling 2025-05-19 13:18:10 +02:00 committed by Jelle Raaijmakers
commit ab051f2e12
Notes: github-actions[bot] 2025-05-19 13:22:58 +00:00
3 changed files with 27 additions and 1 deletions

View file

@ -205,7 +205,7 @@ struct LayoutState {
UsedValues& get_mutable(NodeWithStyle const&);
UsedValues const& get(NodeWithStyle const&) const;
HashMap<GC::Ref<Layout::Node const>, NonnullOwnPtr<UsedValues>> used_values_per_layout_node;
OrderedHashMap<GC::Ref<Layout::Node const>, NonnullOwnPtr<UsedValues>> used_values_per_layout_node;
private:
void resolve_relative_positions();