summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-08 22:07:42 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-11 18:57:45 +0200
commit66d08d24173de26b38e647aa70353caf2e6cb64f (patch)
tree1935c7b5e3cd15c108d5afede8f5a44fe920815f /Userland
parentfd68be29ab22deac5bce73c1a3caa9a9ef631185 (diff)
downloadserenity-66d08d24173de26b38e647aa70353caf2e6cb64f.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp16
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp17
2 files changed, 16 insertions, 17 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index c84220ce51..e4be518ad8 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -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)
diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index c276de356c..d8652a0315 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -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)