From c04f83f5f494c73c4954c7e1fa04df728fd32d0b Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Mon, 8 Sep 2025 14:40:34 +0200 Subject: [PATCH] LibWeb: Add view transition related user relevancy --- Libraries/LibWeb/DOM/Element.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 923a78fcf12..32b656d38e2 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -3282,21 +3282,25 @@ bool Element::is_relevant_to_the_user() if (document().get_selection()->contains_node(*this, true)) return true; - // Either the element or its contents are placed in the top layer. - bool is_in_top_layer = false; + bool has_relevant_contents = false; for_each_in_inclusive_subtree_of_type([&](auto& element) { + // Either the element or its contents are placed in the top layer. if (element.in_top_layer()) { - is_in_top_layer = true; + has_relevant_contents = true; + return TraversalDecision::Break; + } + + // The element has a flat tree descendant that is captured in a view transition. + if (&element != this && element.captured_in_a_view_transition()) { + has_relevant_contents = true; return TraversalDecision::Break; } return TraversalDecision::Continue; }); - if (is_in_top_layer) + if (has_relevant_contents) return true; - // FIXME: The element has a flat tree descendant that is captured in a view transition. - // NOTE: none of the above conditions are true, so the element is not relevant to the user. return false; }