LibWeb: Add command state & value overrides to DOM::Document

This commit is contained in:
Jelle Raaijmakers 2024-12-22 09:58:40 +01:00 committed by Andreas Kling
parent 67800091c5
commit e21ee10b3c
Notes: github-actions[bot] 2025-01-10 22:38:29 +00:00
6 changed files with 173 additions and 7 deletions

View file

@ -2745,6 +2745,23 @@ GC::Ptr<DOM::Node> wrap(
return new_parent;
}
void for_each_node_effectively_contained_in_range(GC::Ptr<DOM::Range> range, Function<TraversalDecision(GC::Ref<DOM::Node>)> callback)
{
if (!range)
return;
// A node can still be "effectively contained" in range even if it's not actually contained within the range; so we
// need to do an inclusive subtree traversal since the common ancestor could be matched as well.
range->common_ancestor_container()->for_each_in_inclusive_subtree([&](GC::Ref<DOM::Node> descendant) {
if (!is_effectively_contained_in_range(descendant, *range)) {
// NOTE: We cannot skip children here since if a descendant is not effectively contained within a range, its
// children might still be.
return TraversalDecision::Continue;
}
return callback(descendant);
});
}
bool has_visible_children(GC::Ref<DOM::Node> node)
{
bool has_visible_child = false;