1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:17:35 +00:00

LibWeb: Improve variable name in HTMLTableElement

The variables 'child_to_append_after' are used to specify the child
before which new elements will be inserted, its name is misleading.
These variables are always passed as 'child' to pre_insert.
This commit is contained in:
Quentin Ligier 2022-12-16 19:14:26 +01:00 committed by Andreas Kling
parent 0f2ca95b5e
commit 588994bb00

View file

@ -130,7 +130,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement*
// or at the end of the table if there are no such elements. // or at the end of the table if there are no such elements.
// We insert the new thead after any <caption> or <colgroup> elements // We insert the new thead after any <caption> or <colgroup> elements
DOM::Node* child_to_append_after = nullptr; DOM::Node* child_to_insert_before = nullptr;
for (auto* child = first_child(); child; child = child->next_sibling()) { for (auto* child = first_child(); child; child = child->next_sibling()) {
if (!is<HTMLElement>(*child)) if (!is<HTMLElement>(*child))
continue; continue;
@ -143,11 +143,11 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement*
} }
// We have found an element which is not a <caption> or <colgroup>, we'll insert before this // We have found an element which is not a <caption> or <colgroup>, we'll insert before this
child_to_append_after = child; child_to_insert_before = child;
break; break;
} }
TRY(pre_insert(*thead, child_to_append_after)); TRY(pre_insert(*thead, child_to_insert_before));
return {}; return {};
} }
@ -162,7 +162,7 @@ JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_head()
auto thead = DOM::create_element(document(), TagNames::thead, Namespace::HTML); auto thead = DOM::create_element(document(), TagNames::thead, Namespace::HTML);
// We insert the new thead after any <caption> or <colgroup> elements // We insert the new thead after any <caption> or <colgroup> elements
DOM::Node* child_to_append_after = nullptr; DOM::Node* child_to_insert_before = nullptr;
for (auto* child = first_child(); child; child = child->next_sibling()) { for (auto* child = first_child(); child; child = child->next_sibling()) {
if (!is<HTMLElement>(*child)) if (!is<HTMLElement>(*child))
continue; continue;
@ -175,11 +175,11 @@ JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_head()
} }
// We have found an element which is not a <caption> or <colgroup>, we'll insert before this // We have found an element which is not a <caption> or <colgroup>, we'll insert before this
child_to_append_after = child; child_to_insert_before = child;
break; break;
} }
MUST(pre_insert(thead, child_to_append_after)); MUST(pre_insert(thead, child_to_insert_before));
return static_cast<HTMLTableSectionElement&>(*thead); return static_cast<HTMLTableSectionElement&>(*thead);
} }
@ -268,7 +268,7 @@ JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_body()
auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML); auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML);
// We insert the new tbody after the last <tbody> element // We insert the new tbody after the last <tbody> element
DOM::Node* child_to_append_after = nullptr; DOM::Node* child_to_insert_before = nullptr;
for (auto* child = last_child(); child; child = child->previous_sibling()) { for (auto* child = last_child(); child; child = child->previous_sibling()) {
if (!is<HTMLElement>(*child)) if (!is<HTMLElement>(*child))
continue; continue;
@ -276,13 +276,13 @@ JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_body()
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child); auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
if (table_section_element->local_name() == TagNames::tbody) { if (table_section_element->local_name() == TagNames::tbody) {
// We have found an element which is a <tbody> we'll insert after this // We have found an element which is a <tbody> we'll insert after this
child_to_append_after = child->next_sibling(); child_to_insert_before = child->next_sibling();
break; break;
} }
} }
} }
MUST(pre_insert(tbody, child_to_append_after)); MUST(pre_insert(tbody, child_to_insert_before));
return static_cast<HTMLTableSectionElement&>(*tbody); return static_cast<HTMLTableSectionElement&>(*tbody);
} }