diff --git a/Userland/Libraries/LibWeb/CSS/StyleInvalidator.cpp b/Userland/Libraries/LibWeb/CSS/StyleInvalidator.cpp index 41c5159d66..7e1f817e2c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleInvalidator.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleInvalidator.cpp @@ -37,7 +37,7 @@ StyleInvalidator::StyleInvalidator(DOM::Document& document) if (!m_document.should_invalidate_styles_on_attribute_changes()) return; auto& style_resolver = m_document.style_resolver(); - m_document.for_each_in_subtree_of_type([&](auto& element) { + m_document.for_each_in_inclusive_subtree_of_type([&](auto& element) { m_elements_and_matching_rules_before.set(&element, style_resolver.collect_matching_rules(element)); return IterationDecision::Continue; }); @@ -48,7 +48,7 @@ StyleInvalidator::~StyleInvalidator() if (!m_document.should_invalidate_styles_on_attribute_changes()) return; auto& style_resolver = m_document.style_resolver(); - m_document.for_each_in_subtree_of_type([&](auto& element) { + m_document.for_each_in_inclusive_subtree_of_type([&](auto& element) { auto maybe_matching_rules_before = m_elements_and_matching_rules_before.get(&element); if (!maybe_matching_rules_before.has_value()) { element.set_needs_style_update(true); diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 540f1adfd4..3aa3100305 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -114,7 +114,7 @@ void Document::removed_last_ref() // Gather up all the descendants of this document and prune them from the tree. // FIXME: This could definitely be more elegant. NonnullRefPtrVector descendants; - for_each_in_subtree([&](auto& node) { + for_each_in_inclusive_subtree([&](auto& node) { if (&node != this) descendants.append(node); return IterationDecision::Continue; @@ -316,7 +316,7 @@ void Document::tear_down_layout_tree() NonnullRefPtrVector layout_nodes; - m_layout_root->for_each_in_subtree([&](auto& layout_node) { + m_layout_root->for_each_in_inclusive_subtree([&](auto& layout_node) { layout_nodes.append(layout_node); return IterationDecision::Continue; }); @@ -505,7 +505,7 @@ void Document::set_hovered_node(Node* node) NonnullRefPtrVector Document::get_elements_by_name(const String& name) const { NonnullRefPtrVector elements; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.attribute(HTML::AttributeNames::name) == name) elements.append(element); return IterationDecision::Continue; @@ -518,7 +518,7 @@ NonnullRefPtrVector Document::get_elements_by_tag_name(const FlyString& // FIXME: Support "*" for tag_name // https://dom.spec.whatwg.org/#concept-getelementsbytagname NonnullRefPtrVector elements; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.namespace_() == Namespace::HTML ? element.local_name().to_lowercase() == tag_name.to_lowercase() : element.local_name() == tag_name) { @@ -532,7 +532,7 @@ NonnullRefPtrVector Document::get_elements_by_tag_name(const FlyString& NonnullRefPtrVector Document::get_elements_by_class_name(const FlyString& class_name) const { NonnullRefPtrVector elements; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.has_class(class_name, in_quirks_mode() ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive)) elements.append(element); return IterationDecision::Continue; @@ -661,7 +661,7 @@ NonnullRefPtrVector Document::take_scripts_to_execute_a void Document::adopt_node(Node& subtree_root) { - subtree_root.for_each_in_subtree([&](auto& node) { + subtree_root.for_each_in_inclusive_subtree([&](auto& node) { node.set_document({}, *this); return IterationDecision::Continue; }); diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 0f2304a085..5b99ec487b 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -350,7 +350,7 @@ NonnullRefPtrVector Element::get_elements_by_tag_name(const FlyString& // FIXME: Support "*" for tag_name // https://dom.spec.whatwg.org/#concept-getelementsbytagname NonnullRefPtrVector elements; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.namespace_() == Namespace::HTML ? element.local_name().to_lowercase() == tag_name.to_lowercase() : element.local_name() == tag_name) { @@ -364,7 +364,7 @@ NonnullRefPtrVector Element::get_elements_by_tag_name(const FlyString& NonnullRefPtrVector Element::get_elements_by_class_name(const FlyString& class_name) const { NonnullRefPtrVector elements; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.has_class(class_name, m_document->in_quirks_mode() ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive)) elements.append(element); return IterationDecision::Continue; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 5bb5cffd7b..61ebb37232 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -114,7 +114,7 @@ RefPtr Node::create_layout_node() void Node::invalidate_style() { - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { element.set_needs_style_update(true); return IterationDecision::Continue; }); diff --git a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h index e362fbc5c0..c2eda07f3b 100644 --- a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h @@ -39,7 +39,7 @@ public: RefPtr get_element_by_id(const FlyString& id) const { RefPtr found_element; - static_cast(this)->template for_each_in_subtree_of_type([&](auto& element) { + static_cast(this)->template for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.attribute(HTML::AttributeNames::id) == id) { found_element = &element; return IterationDecision::Break; diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp index 8053f110ac..1f31c2938f 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp @@ -40,7 +40,7 @@ RefPtr ParentNode::query_selector(const StringView& selector_text) dump_selector(selector.value()); RefPtr result; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (SelectorEngine::matches(selector.value(), element)) { result = element; return IterationDecision::Break; @@ -60,7 +60,7 @@ NonnullRefPtrVector ParentNode::query_selector_all(const StringView& se dump_selector(selector.value()); NonnullRefPtrVector elements; - for_each_in_subtree_of_type([&](auto& element) { + for_each_in_inclusive_subtree_of_type([&](auto& element) { if (SelectorEngine::matches(selector.value(), element)) { elements.append(element); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 5d36bf51ee..81e4beb453 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -117,7 +117,7 @@ void HTMLFormElement::submit_form(RefPtr submitter, bool from_submi Vector parameters; - for_each_in_subtree_of_type([&](auto& node) { + for_each_in_inclusive_subtree_of_type([&](auto& node) { auto& input = downcast(node); if (!input.name().is_null() && (input.type() != "submit" || &input == submitter)) parameters.append({ input.name(), input.value() }); diff --git a/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp b/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp index df7663cc75..3301cd51ae 100644 --- a/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp @@ -48,7 +48,7 @@ void InitialContainingBlockBox::build_stacking_context_tree() set_stacking_context(make(*this, nullptr)); - for_each_in_subtree_of_type([&](Box& box) { + for_each_in_inclusive_subtree_of_type([&](Box& box) { if (&box == this) return IterationDecision::Continue; if (!box.establishes_stacking_context()) { @@ -101,7 +101,7 @@ void InitialContainingBlockBox::recompute_selection_states() auto selection = this->selection().normalized(); - for_each_in_subtree([&](auto& layout_node) { + for_each_in_inclusive_subtree([&](auto& layout_node) { if (!selection.is_valid()) { // Everything gets SelectionState::None. } else if (&layout_node == selection.start().layout_node && &layout_node == selection.end().layout_node) { diff --git a/Userland/Libraries/LibWeb/Layout/Label.cpp b/Userland/Libraries/LibWeb/Layout/Label.cpp index 07bef35fea..f37f78440b 100644 --- a/Userland/Libraries/LibWeb/Layout/Label.cpp +++ b/Userland/Libraries/LibWeb/Layout/Label.cpp @@ -120,7 +120,7 @@ Label* Label::label_for_control_node(LabelableNode& control) if (id.is_empty()) return label; - control.document().layout_node()->for_each_in_subtree_of_type