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

LibWeb: Refactor should_skip_anonymous_text_runs

This same function was being copied in the {Flex,Grid}FormattingContext,
so unify them in the parent FormattingContext.
This commit is contained in:
Tom 2022-12-28 10:11:54 +01:00 committed by Andreas Kling
parent 97dde51a9b
commit 0bbf7a1b54
4 changed files with 21 additions and 29 deletions

View file

@ -1473,4 +1473,21 @@ bool FormattingContext::should_treat_height_as_auto(Box const& box, AvailableSpa
|| (box.computed_values().height().contains_percentage() && !available_space.height.is_definite());
}
bool FormattingContext::can_skip_is_anonymous_text_run(Box& box)
{
if (box.is_anonymous() && !box.is_generated() && !box.first_child_of_type<BlockContainer>()) {
bool contains_only_white_space = true;
box.for_each_in_subtree([&](auto const& node) {
if (!is<TextNode>(node) || !static_cast<TextNode const&>(node).dom_node().data().is_whitespace()) {
contains_only_white_space = false;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
if (contains_only_white_space)
return true;
}
return false;
}
}