mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Move IFC result measurement from IFC to BFC
Before this change, IFC would first generate all of its line boxes and then measure them. It would then write some of the values into the state of the IFC's containing block. We now move that up to BFC::layout_inline_children() instead, which is a much more natural place to decide metrics for the block.
This commit is contained in:
parent
fd68be29ab
commit
66d08d2417
Notes:
sideshowbarker
2024-07-17 09:30:44 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/66d08d2417
@ -396,6 +396,22 @@ void BlockFormattingContext::layout_inline_children(BlockContainer const& block_
|
||||
|
||||
InlineFormattingContext context(m_state, block_container, *this);
|
||||
context.run(block_container, layout_mode);
|
||||
|
||||
float max_line_width = 0;
|
||||
float content_height = 0;
|
||||
|
||||
auto& block_container_state = m_state.get_mutable(block_container);
|
||||
|
||||
for (auto& line_box : block_container_state.line_boxes) {
|
||||
max_line_width = max(max_line_width, line_box.width());
|
||||
content_height += line_box.height();
|
||||
}
|
||||
|
||||
if (layout_mode != LayoutMode::Normal) {
|
||||
block_container_state.content_width = max_line_width;
|
||||
}
|
||||
|
||||
block_container_state.content_height = content_height;
|
||||
}
|
||||
|
||||
void BlockFormattingContext::layout_block_level_children(BlockContainer const& block_container, LayoutMode layout_mode)
|
||||
|
@ -66,24 +66,7 @@ float InlineFormattingContext::available_space_for_line(float y) const
|
||||
void InlineFormattingContext::run(Box const&, LayoutMode layout_mode)
|
||||
{
|
||||
VERIFY(containing_block().children_are_inline());
|
||||
|
||||
generate_line_boxes(layout_mode);
|
||||
|
||||
float max_line_width = 0;
|
||||
float content_height = 0;
|
||||
|
||||
for (auto& line_box : m_state.get(containing_block()).line_boxes) {
|
||||
max_line_width = max(max_line_width, line_box.width());
|
||||
content_height += line_box.height();
|
||||
}
|
||||
|
||||
auto& containing_block_state = m_state.get_mutable(containing_block());
|
||||
|
||||
if (layout_mode != LayoutMode::Normal) {
|
||||
containing_block_state.content_width = max_line_width;
|
||||
}
|
||||
|
||||
containing_block_state.content_height = content_height;
|
||||
}
|
||||
|
||||
void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode layout_mode)
|
||||
|
Loading…
Reference in New Issue
Block a user