LibWeb: Skip node trees outside of range in insertParagraph

Instead of recursively iterating all descendants of the common ancestor
of the new line range that are not contained by that range, skip the
entire node tree as soon as we determine they're not.
This commit is contained in:
Jelle Raaijmakers 2024-12-04 10:33:23 +01:00 committed by Jelle Raaijmakers
commit d5143db081
Notes: github-actions[bot] 2024-12-10 13:55:47 +00:00

View file

@ -639,8 +639,9 @@ bool command_insert_paragraph_action(DOM::Document& document, String const&)
Vector<GC::Ref<DOM::Node>> contained_nodes;
auto common_ancestor = new_line_range->common_ancestor_container();
common_ancestor->for_each_in_subtree([&](GC::Ref<DOM::Node> child_node) {
if (new_line_range->contains_node(child_node))
contained_nodes.append(child_node);
if (!new_line_range->contains_node(child_node))
return TraversalDecision::SkipChildrenAndContinue;
contained_nodes.append(child_node);
return TraversalDecision::Continue;
});