summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-07 20:48:26 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-07 20:48:26 +0100
commit70de5fd0568ce76811cab1e7f19e32abe4d85b1c (patch)
treefdd2c621cd6e97fff38066c5bff00aa038857347 /Libraries/LibWeb/Layout/InlineFormattingContext.cpp
parentbe18ac36b28154491992f040644cc19a0c1835fc (diff)
downloadserenity-70de5fd0568ce76811cab1e7f19e32abe4d85b1c.zip
LibWeb: Simplify final line box width computation
The width of a line box is the distance from the left edge of the first fragment to the right edge of the last fragment. We don't have to loop over all the fragments to figure this out. :^)
Diffstat (limited to 'Libraries/LibWeb/Layout/InlineFormattingContext.cpp')
-rw-r--r--Libraries/LibWeb/Layout/InlineFormattingContext.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index eb3a01240e..46683cd735 100644
--- a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -181,11 +181,10 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode)
if (is<Box>(fragment.layout_node()))
dimension_box_on_line(downcast<Box>(fragment.layout_node()), layout_mode);
- float final_line_box_width = 0;
- for (auto& fragment : line_box.fragments())
- final_line_box_width += fragment.width();
+ float left_edge = line_box.fragments().first().offset().x();
+ float right_edge = line_box.fragments().last().offset().x() + line_box.fragments().last().width();
+ float final_line_box_width = right_edge - left_edge;
line_box.m_width = final_line_box_width;
-
max_linebox_width = max(max_linebox_width, final_line_box_width);
}