mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Use TraversalDecision
for multi level Node traversal methods
This adds the `SkipChildrenAndContinue` option, where traversal continues but child nodes are not included.
This commit is contained in:
parent
c57d395a48
commit
398bf10b92
Notes:
sideshowbarker
2024-07-17 08:59:18 +09:00
Author: https://github.com/tcl3
Commit: 398bf10b92
Pull-request: https://github.com/SerenityOS/serenity/pull/24207
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/shannonbooth ✅
33 changed files with 229 additions and 215 deletions
|
@ -292,14 +292,14 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
|
||||
document.for_each_shadow_including_descendant([&](DOM::Node& inclusive_descendant) {
|
||||
if (!is<DOM::Element>(inclusive_descendant))
|
||||
return IterationDecision::Continue;
|
||||
return TraversalDecision::Continue;
|
||||
|
||||
auto& inclusive_descendant_element = static_cast<DOM::Element&>(inclusive_descendant);
|
||||
|
||||
if (inclusive_descendant_element.namespace_uri() == Namespace::HTML && inclusive_descendant_element.local_name() == local_name && (!extends.has_value() || inclusive_descendant_element.is_value() == name))
|
||||
upgrade_candidates.append(JS::make_handle(inclusive_descendant_element));
|
||||
|
||||
return IterationDecision::Continue;
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
|
||||
// 19. For each element element in upgrade candidates, enqueue a custom element upgrade reaction given element and definition.
|
||||
|
@ -388,12 +388,12 @@ void CustomElementRegistry::upgrade(JS::NonnullGCPtr<DOM::Node> root) const
|
|||
|
||||
root->for_each_shadow_including_inclusive_descendant([&](DOM::Node& inclusive_descendant) {
|
||||
if (!is<DOM::Element>(inclusive_descendant))
|
||||
return IterationDecision::Continue;
|
||||
return TraversalDecision::Continue;
|
||||
|
||||
auto& inclusive_descendant_element = static_cast<DOM::Element&>(inclusive_descendant);
|
||||
candidates.append(JS::make_handle(inclusive_descendant_element));
|
||||
|
||||
return IterationDecision::Continue;
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
|
||||
// 2. For each candidate of candidates, try to upgrade candidate.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue