diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-05 22:49:13 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-05 22:51:03 +0100 |
commit | 2f38d94c702ef6ab67f4cdce5bf467860465eee0 (patch) | |
tree | 9daa0fc27dbcc09b31b6c43144931ac148ba35a9 /Libraries/LibWeb/Layout/TextNode.cpp | |
parent | 2e5e4be212e58c92dc98a7fd1487f70484d84978 (diff) | |
download | serenity-2f38d94c702ef6ab67f4cdce5bf467860465eee0.zip |
LibWeb: Fix off-by-one when computing available space between floats
Whoops, this explains why things were not lining up correctly. :^)
Diffstat (limited to 'Libraries/LibWeb/Layout/TextNode.cpp')
-rw-r--r-- | Libraries/LibWeb/Layout/TextNode.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibWeb/Layout/TextNode.cpp b/Libraries/LibWeb/Layout/TextNode.cpp index 0433167093..5438054e9d 100644 --- a/Libraries/LibWeb/Layout/TextNode.cpp +++ b/Libraries/LibWeb/Layout/TextNode.cpp @@ -198,7 +198,7 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou auto& line_boxes = containing_block.line_boxes(); containing_block.ensure_last_line_box(); - float available_width = context.available_width_at_line(line_boxes.size()) - line_boxes.last().width(); + float available_width = context.available_width_at_line(line_boxes.size() - 1) - line_boxes.last().width(); // Collapse whitespace into single spaces if (do_collapse) { @@ -264,7 +264,7 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou if (line_boxes.last().width() > 0 && chunk_width > available_width) { containing_block.add_line_box(); - available_width = context.available_width_at_line(line_boxes.size()); + available_width = context.available_width_at_line(line_boxes.size() - 1); } if (need_collapse & line_boxes.last().fragments().is_empty()) continue; @@ -278,14 +278,14 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou if (do_wrap_lines) { if (available_width < 0) { containing_block.add_line_box(); - available_width = context.available_width_at_line(line_boxes.size()); + available_width = context.available_width_at_line(line_boxes.size() - 1); } } if (do_wrap_breaks) { if (chunk.is_break) { containing_block.add_line_box(); - available_width = context.available_width_at_line(line_boxes.size()); + available_width = context.available_width_at_line(line_boxes.size() - 1); } } } |