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

LibWeb: Move line boxes from Layout::Box to BlockContainer

Per the spec, only a BlockContainer" can have line boxes, so let's not
clutter up every Layout::Box with line boxes.

This also allows us to establish an invariant that BFC and IFC always
operate on a Layout::BlockContainer.

Note that if BlockContainer has all block-level children, its line boxes
are not used for anything. They are only used in the all inline-level
children scenario.
This commit is contained in:
Andreas Kling 2021-10-06 21:53:25 +02:00
parent a0bea52a5f
commit f73aa8e2bd
13 changed files with 80 additions and 74 deletions

View file

@ -84,9 +84,10 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
}
if (!main_constrained && box.children_are_inline()) {
BlockFormattingContext bfc(box, this);
auto& block_container = verify_cast<BlockContainer>(box);
BlockFormattingContext bfc(block_container, this);
bfc.run(box, LayoutMode::Default);
InlineFormattingContext ifc(box, &bfc);
InlineFormattingContext ifc(block_container, &bfc);
if (is_row) {
ifc.run(box, LayoutMode::OnlyRequiredLineBreaks);
@ -236,9 +237,10 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
}
if (!cross_constrained && box.children_are_inline()) {
BlockFormattingContext bfc(box, this);
auto& block_container = verify_cast<BlockContainer>(box);
BlockFormattingContext bfc(block_container, this);
bfc.run(box, LayoutMode::Default);
InlineFormattingContext ifc(box, &bfc);
InlineFormattingContext ifc(block_container, &bfc);
ifc.run(box, LayoutMode::OnlyRequiredLineBreaks);
if (is_row)
@ -248,7 +250,7 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
if (is_row) {
return BlockFormattingContext::compute_theoretical_height(box);
} else {
BlockFormattingContext context(box, this);
BlockFormattingContext context(verify_cast<BlockContainer>(box), this);
context.compute_width(box);
return box.width();
}