1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:08:12 +00:00

LibWeb: Fix child wrapping in table fix up

- Wrapped sequence should be inserted before first non-match
node instead of next sibling of first non-match node
- If sequence is not empty after sibling traversal it should be
wrapped
This commit is contained in:
Aliaksandr Kalenik 2022-12-09 13:53:51 +03:00 committed by Andreas Kling
parent 1a81521dd9
commit 2e1113cb88

View file

@ -460,20 +460,18 @@ static void for_each_sequence_of_consecutive_children_matching(NodeWithStyle& pa
return true;
};
Node* next_sibling = nullptr;
for (auto child = parent.first_child(); child; child = next_sibling) {
next_sibling = child->next_sibling();
for (auto child = parent.first_child(); child; child = child->next_sibling()) {
if (matcher(*child)) {
sequence.append(*child);
} else {
if (!sequence.is_empty()) {
if (!sequence_is_all_ignorable_whitespace())
callback(sequence, next_sibling);
callback(sequence, child);
sequence.clear();
}
}
}
if (sequence.is_empty() && !sequence_is_all_ignorable_whitespace())
if (!sequence.is_empty() && !sequence_is_all_ignorable_whitespace())
callback(sequence, nullptr);
}