mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:57:36 +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
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()
|
LineBox& LayoutBlock::ensure_last_line_box()
|
||||||
{
|
{
|
||||||
if (m_line_boxes.is_empty())
|
if (m_line_boxes.is_empty())
|
||||||
m_line_boxes.append(LineBox());
|
return add_line_box();
|
||||||
return m_line_boxes.last();
|
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();
|
float space_width = font.glyph_width(' ') + font.glyph_spacing();
|
||||||
|
|
||||||
auto& line_boxes = container.line_boxes();
|
auto& line_boxes = container.line_boxes();
|
||||||
if (line_boxes.is_empty())
|
container.ensure_last_line_box();
|
||||||
line_boxes.append(LineBox());
|
|
||||||
float available_width = container.width() - line_boxes.last().width();
|
float available_width = container.width() - line_boxes.last().width();
|
||||||
|
|
||||||
// Collapse whitespace into single spaces
|
// 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();
|
chunk_width = font.width(chunk.view) + font.glyph_spacing();
|
||||||
|
|
||||||
if (line_boxes.last().width() > 0 && chunk_width > available_width) {
|
if (line_boxes.last().width() > 0 && chunk_width > available_width) {
|
||||||
line_boxes.append(LineBox());
|
container.add_line_box();
|
||||||
available_width = container.width();
|
available_width = container.width();
|
||||||
}
|
}
|
||||||
if (need_collapse & line_boxes.last().fragments().is_empty())
|
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 (do_wrap_lines) {
|
||||||
if (available_width < 0) {
|
if (available_width < 0) {
|
||||||
line_boxes.append(LineBox());
|
container.add_line_box();
|
||||||
available_width = container.width();
|
available_width = container.width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_wrap_breaks) {
|
if (do_wrap_breaks) {
|
||||||
if (chunk.is_break) {
|
if (chunk.is_break) {
|
||||||
line_boxes.append(LineBox());
|
container.add_line_box();
|
||||||
available_width = container.width();
|
available_width = container.width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue