summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibWeb/Layout/BlockBox.cpp2
-rw-r--r--Libraries/LibWeb/Layout/ReplacedBox.cpp2
-rw-r--r--Libraries/LibWeb/Layout/TextNode.cpp8
3 files changed, 6 insertions, 6 deletions
diff --git a/Libraries/LibWeb/Layout/BlockBox.cpp b/Libraries/LibWeb/Layout/BlockBox.cpp
index ed10978314..dc4855975d 100644
--- a/Libraries/LibWeb/Layout/BlockBox.cpp
+++ b/Libraries/LibWeb/Layout/BlockBox.cpp
@@ -113,7 +113,7 @@ void BlockBox::split_into_lines(InlineFormattingContext& context, LayoutMode lay
auto& container = context.context_box();
auto* line_box = &container.ensure_last_line_box();
- float available_width = context.available_width_at_line(container.line_boxes().size());
+ float available_width = context.available_width_at_line(container.line_boxes().size() - 1);
if (layout_mode != LayoutMode::OnlyRequiredLineBreaks && line_box->width() > 0 && line_box->width() + width() > available_width) {
line_box = &container.add_line_box();
diff --git a/Libraries/LibWeb/Layout/ReplacedBox.cpp b/Libraries/LibWeb/Layout/ReplacedBox.cpp
index be2b4d77ec..9b801ba8f1 100644
--- a/Libraries/LibWeb/Layout/ReplacedBox.cpp
+++ b/Libraries/LibWeb/Layout/ReplacedBox.cpp
@@ -129,7 +129,7 @@ void ReplacedBox::split_into_lines(InlineFormattingContext& context, LayoutMode)
auto height = calculate_height();
auto* line_box = &containing_block.ensure_last_line_box();
- if (line_box->width() > 0 && line_box->width() + width > context.available_width_at_line(containing_block.line_boxes().size()))
+ if (line_box->width() > 0 && line_box->width() + width > context.available_width_at_line(containing_block.line_boxes().size() - 1))
line_box = &containing_block.add_line_box();
line_box->add_fragment(*this, 0, 0, width, height);
}
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);
}
}
}