mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 03:08:13 +00:00
LibWeb: Store bottom edge location with each LineBox
Previously we were computing the bottom edge of a line box by finding the bottommost fragment on the line. That method didn't give correct results for line boxes with no fragments (which is exactly what you get when inserting a bunch of <br> elements.) To cover all situations, we now keep track of the bottommost edge in the LineBox object itself.
This commit is contained in:
parent
4b6295e667
commit
c6cf240f9a
4 changed files with 11 additions and 8 deletions
|
@ -96,7 +96,7 @@ void LineBuilder::update_last_line()
|
|||
|
||||
auto text_align = m_context.containing_block().computed_values().text_align();
|
||||
float x_offset = m_context.available_space_for_line(m_current_y).left;
|
||||
|
||||
float bottom = m_current_y + m_context.containing_block().line_height();
|
||||
float excess_horizontal_space = m_containing_block_state.content_width - line_box.width();
|
||||
|
||||
switch (text_align) {
|
||||
|
@ -175,6 +175,8 @@ void LineBuilder::update_last_line()
|
|||
last_fragment_x_adjustment = new_fragment_x - fragment.offset().x();
|
||||
fragment.set_offset({ new_fragment_x, new_fragment_y });
|
||||
|
||||
bottom = max(bottom, new_fragment_y + fragment.height() + fragment.border_box_bottom());
|
||||
|
||||
if (text_align == CSS::TextAlign::Justify
|
||||
&& fragment.is_justifiable_whitespace()
|
||||
&& fragment.width() != justified_space_width) {
|
||||
|
@ -191,6 +193,8 @@ void LineBuilder::update_last_line()
|
|||
|
||||
if (!line_box.fragments().is_empty())
|
||||
line_box.m_width += last_fragment_x_adjustment;
|
||||
|
||||
line_box.m_bottom = bottom;
|
||||
}
|
||||
|
||||
void LineBuilder::remove_last_line_if_empty()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue