mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Always add line boxes through LayoutBlock::add_line_box()
Let's not append directly to the line box vector all over the place.
This commit is contained in:
parent
7b356c33cb
commit
72347205c4
Notes:
sideshowbarker
2024-07-19 04:08:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/72347205c46
2 changed files with 5 additions and 6 deletions
|
@ -757,7 +757,7 @@ NonnullRefPtr<CSS::StyleProperties> LayoutBlock::style_for_anonymous_block() con
|
|||
LineBox& LayoutBlock::ensure_last_line_box()
|
||||
{
|
||||
if (m_line_boxes.is_empty())
|
||||
m_line_boxes.append(LineBox());
|
||||
return add_line_box();
|
||||
return m_line_boxes.last();
|
||||
}
|
||||
|
||||
|
|
|
@ -188,8 +188,7 @@ void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode la
|
|||
float space_width = font.glyph_width(' ') + font.glyph_spacing();
|
||||
|
||||
auto& line_boxes = container.line_boxes();
|
||||
if (line_boxes.is_empty())
|
||||
line_boxes.append(LineBox());
|
||||
container.ensure_last_line_box();
|
||||
float available_width = container.width() - line_boxes.last().width();
|
||||
|
||||
// Collapse whitespace into single spaces
|
||||
|
@ -255,7 +254,7 @@ void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode la
|
|||
chunk_width = font.width(chunk.view) + font.glyph_spacing();
|
||||
|
||||
if (line_boxes.last().width() > 0 && chunk_width > available_width) {
|
||||
line_boxes.append(LineBox());
|
||||
container.add_line_box();
|
||||
available_width = container.width();
|
||||
}
|
||||
if (need_collapse & line_boxes.last().fragments().is_empty())
|
||||
|
@ -269,14 +268,14 @@ void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode la
|
|||
|
||||
if (do_wrap_lines) {
|
||||
if (available_width < 0) {
|
||||
line_boxes.append(LineBox());
|
||||
container.add_line_box();
|
||||
available_width = container.width();
|
||||
}
|
||||
}
|
||||
|
||||
if (do_wrap_breaks) {
|
||||
if (chunk.is_break) {
|
||||
line_boxes.append(LineBox());
|
||||
container.add_line_box();
|
||||
available_width = container.width();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue