mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Resolve block height correctly after line break with clear: ..
If a block with inline children ends with a line break clearing any floats, we not only need to take the introduced clearance into account for the next line box, but the containing block needs to set the correct height as well. Since the spec calls for using the last line box' bottom as the resolved height (if treated as auto), we now correctly apply the clearance to the previous line box' bottom coordinate. Fixes #4058.
This commit is contained in:
parent
e5db913b0d
commit
6d911a6baa
Notes:
github-actions[bot]
2025-04-01 14:03:58 +00:00
Author: https://github.com/gmta
Commit: 6d911a6baa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4168
7 changed files with 85 additions and 16 deletions
|
@ -75,9 +75,8 @@ void LineBuilder::begin_new_line(bool increment_y, bool is_first_break_in_sequen
|
|||
m_last_line_needs_update = true;
|
||||
|
||||
// FIXME: Support text-indent with "each-line".
|
||||
if (m_containing_block_used_values.line_boxes.size() <= 1) {
|
||||
if (m_containing_block_used_values.line_boxes.size() <= 1)
|
||||
ensure_last_line_box().m_inline_length += m_text_indent;
|
||||
}
|
||||
}
|
||||
|
||||
LineBox& LineBuilder::ensure_last_line_box()
|
||||
|
@ -417,4 +416,22 @@ void LineBuilder::recalculate_available_space()
|
|||
m_containing_block_used_values.line_boxes.last().m_original_available_width = m_available_width_for_current_line;
|
||||
}
|
||||
|
||||
void LineBuilder::did_introduce_clearance(CSSPixels clearance)
|
||||
{
|
||||
// If clearance was introduced but our current line box starts beyond it, we don't need to do anything.
|
||||
if (clearance <= m_current_block_offset)
|
||||
return;
|
||||
|
||||
// Increase the height of the previous line box so it matches the clearance, because the element's height is first
|
||||
// determined by the bottom of the last line box (after trimming empty/whitespace boxes).
|
||||
auto& line_boxes = m_containing_block_used_values.line_boxes;
|
||||
if (line_boxes.size() > 1) {
|
||||
auto& previous_line_box = line_boxes[line_boxes.size() - 2];
|
||||
previous_line_box.m_bottom = clearance;
|
||||
}
|
||||
|
||||
// The current line box will start directly after any cleared floats.
|
||||
m_current_block_offset = clearance;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue