mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Make shadow_including_first_ancestor_of_type() use the flat tree
Every user of this actually wants an ancestor in the flat tree - taking things like `<slot>` into account. So rename it and adjust its behavior to use that.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
bd753eafb6
commit
2994a7532d
Notes:
github-actions[bot]
2026-02-06 10:34:11 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/2994a7532d1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7745 Reviewed-by: https://github.com/gmta ✅
@@ -532,7 +532,7 @@ GC::Ptr<DOM::Element> HTMLElement::offset_parent() const
|
||||
return nullptr;
|
||||
|
||||
// 2. Let ancestor be the parent of the element in the flat tree and repeat these substeps:
|
||||
auto ancestor = shadow_including_first_ancestor_of_type<DOM::Element>();
|
||||
auto ancestor = first_flat_tree_ancestor_of_type<DOM::Element>();
|
||||
while (true) {
|
||||
// 1. If ancestor is closed-shadow-hidden from the element, its computed value of the position property is
|
||||
// fixed, and no ancestor establishes a fixed position containing block, terminate this algorithm and return
|
||||
@@ -570,7 +570,7 @@ GC::Ptr<DOM::Element> HTMLElement::offset_parent() const
|
||||
}
|
||||
|
||||
// 3. If there is no more parent of ancestor in the flat tree, terminate this algorithm and return null.
|
||||
auto parent_of_ancestor = ancestor->shadow_including_first_ancestor_of_type<DOM::Element>();
|
||||
auto parent_of_ancestor = ancestor->first_flat_tree_ancestor_of_type<DOM::Element>();
|
||||
if (!parent_of_ancestor)
|
||||
return nullptr;
|
||||
|
||||
@@ -1776,7 +1776,7 @@ GC::Ptr<HTMLElement> HTMLElement::topmost_popover_ancestor(GC::Ptr<DOM::Node> ne
|
||||
|
||||
// 5. If okNesting is false, then set candidate to candidateAncestor's parent in the flat tree.
|
||||
if (!ok_nesting)
|
||||
candidate = candidate_ancestor->shadow_including_first_ancestor_of_type<HTMLElement>();
|
||||
candidate = candidate_ancestor->first_flat_tree_ancestor_of_type<HTMLElement>();
|
||||
}
|
||||
|
||||
// 5. Let candidatePosition be popoverPositions[candidateAncestor].
|
||||
@@ -1788,7 +1788,7 @@ GC::Ptr<HTMLElement> HTMLElement::topmost_popover_ancestor(GC::Ptr<DOM::Node> ne
|
||||
};
|
||||
|
||||
// 10. Run checkAncestor given newPopoverOrTopLayerElement's parent node within the flat tree.
|
||||
check_ancestor(new_popover_or_top_layer_element->shadow_including_first_ancestor_of_type<HTMLElement>());
|
||||
check_ancestor(new_popover_or_top_layer_element->first_flat_tree_ancestor_of_type<HTMLElement>());
|
||||
|
||||
// 11. Run checkAncestor given source.
|
||||
check_ancestor(source.ptr());
|
||||
@@ -1812,7 +1812,7 @@ GC::Ptr<HTMLElement> HTMLElement::nearest_inclusive_open_popover()
|
||||
return current_node;
|
||||
|
||||
// 2. Set currentNode to currentNode's parent in the flat tree.
|
||||
current_node = current_node->shadow_including_first_ancestor_of_type<HTMLElement>();
|
||||
current_node = current_node->first_flat_tree_ancestor_of_type<HTMLElement>();
|
||||
}
|
||||
|
||||
// 3. Return null.
|
||||
@@ -1839,7 +1839,7 @@ GC::Ptr<HTMLElement> HTMLElement::nearest_inclusive_target_popover()
|
||||
}
|
||||
|
||||
// 3. Set currentNode to currentNode's ancestor in the flat tree.
|
||||
current_node = current_node->shadow_including_first_ancestor_of_type<HTMLElement>();
|
||||
current_node = current_node->first_flat_tree_ancestor_of_type<HTMLElement>();
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -1961,7 +1961,7 @@ GC::Ptr<HTMLElement> HTMLElement::topmost_clicked_popover(GC::Ptr<DOM::Node> nod
|
||||
|
||||
GC::Ptr<HTMLElement> nearest_element = as_if<HTMLElement>(*node);
|
||||
if (!nearest_element)
|
||||
nearest_element = node->shadow_including_first_ancestor_of_type<HTMLElement>();
|
||||
nearest_element = node->first_flat_tree_ancestor_of_type<HTMLElement>();
|
||||
|
||||
if (!nearest_element)
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user