1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibWeb: Rename "for_each_in_subtree(_of_type)" to "for_each_in_inclusive_subtree(_of_type)"

This is because it includes the initial node that the function was
called on, which makes it "inclusive" as according to the spec.

This is important as there are non-inclusive variants, particularly
used in the node mutation algorithms.
This commit is contained in:
Luke 2021-04-06 18:38:10 +01:00 committed by Andreas Kling
parent f482628fe5
commit ca71ac484b
12 changed files with 29 additions and 29 deletions

View file

@ -48,7 +48,7 @@ void InitialContainingBlockBox::build_stacking_context_tree()
set_stacking_context(make<StackingContext>(*this, nullptr));
for_each_in_subtree_of_type<Box>([&](Box& box) {
for_each_in_inclusive_subtree_of_type<Box>([&](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) {

View file

@ -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<Label>([&](auto& node) {
control.document().layout_node()->for_each_in_inclusive_subtree_of_type<Label>([&](auto& node) {
if (node.dom_node().for_() == id) {
label = &node;
return IterationDecision::Break;
@ -144,7 +144,7 @@ LabelableNode* Label::control_node()
if (for_.is_empty())
return control;
document().layout_node()->for_each_in_subtree_of_type<LabelableNode>([&](auto& node) {
document().layout_node()->for_each_in_inclusive_subtree_of_type<LabelableNode>([&](auto& node) {
if (node.dom_node().attribute(HTML::AttributeNames::id) == for_) {
control = &node;
return IterationDecision::Break;

View file

@ -139,7 +139,7 @@ void RadioButton::set_checked_within_group()
dom_node().set_checked(true);
String name = dom_node().name();
document().for_each_in_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
document().for_each_in_inclusive_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
if (element.checked() && (element.layout_node() != this) && (element.name() == name))
element.set_checked(false);
return IterationDecision::Continue;

View file

@ -155,7 +155,7 @@ RefPtr<Node> TreeBuilder::build(DOM::Node& dom_node)
template<CSS::Display display, typename Callback>
void TreeBuilder::for_each_in_tree_with_display(NodeWithStyle& root, Callback callback)
{
root.for_each_in_subtree_of_type<Box>([&](auto& box) {
root.for_each_in_inclusive_subtree_of_type<Box>([&](auto& box) {
if (box.computed_values().display() == display)
callback(box);
return IterationDecision::Continue;