1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:22:07 +00:00

LibWeb: Avoid unnecessary layout_inside() in FFC step 1

We don't need to perform inside layout here. The only information we
need in this step is whether an anonymous block container has nothing
but empty-or-whitespace text children.

This information is already accurate after the initial layout tree
construction. Performing a layout does not change the answer. It does
however have many other side effects, so let's defer those.
This commit is contained in:
Andreas Kling 2022-02-27 09:47:01 +01:00
parent 6d2c298b66
commit 3506a91349

View file

@ -171,12 +171,11 @@ void FlexFormattingContext::generate_anonymous_flex_items()
}
flex_container().for_each_child_of_type<Box>([&](Box& child_box) {
(void)layout_inside(child_box, LayoutMode::Default);
// Skip anonymous text runs that are only whitespace.
if (child_box.is_anonymous() && !child_box.first_child_of_type<BlockContainer>()) {
bool contains_only_white_space = true;
child_box.for_each_in_inclusive_subtree_of_type<TextNode>([&contains_only_white_space](auto& text_node) {
if (!text_node.text_for_rendering().is_whitespace()) {
if (!text_node.dom_node().data().is_whitespace()) {
contains_only_white_space = false;
return IterationDecision::Break;
}