mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-08 16:12:23 +02:00
Moving a node within the same parent changes sibling and positional relationships, but it does not make every descendant of the moved node need a fresh computed style. Handle this as a structural mutation at the old and new sibling edges and dirty only the moved root and the affected ancestors, instead of marking the entire moved subtree. Factor the existing previous- and next-sibling structural invalidation out of Node::invalidate_style() into invalidate_structurally_affected_- siblings(), and pull the ancestor child-needs-style-update walk into mark_ancestors_as_having_child_needing_style_update(). The new invalidate_style_after_same_parent_move() reuses both helpers. Whether the moved root itself needs its own style recomputed depends on whether any selector matched against it (or against a descendant) relied on its position in the sibling list. Track that via two new sticky bits on Element, set during selector matching: - m_affected_by_structural_pseudo_class_in_non_subject_position - m_affected_by_sibling_combinator_in_non_subject_position Both are write-once (sticky) because matching descendants can set them while we're not currently re-matching this element's own selectors; keeping them set is conservative and avoids stale descendant style. When neither bit is set and the element only carries subject-position positional/sibling/has() involvement, we just dirty the root and skip its descendants. Rebaseline same-parent-move-root-only and the structural-feature filter counters to reflect the new path. Matching behavior is unchanged.
90 KiB
90 KiB