layout: Set baseline even if line box has no fragment (#39235)

`InlineFormattingContextLayout::finish_current_line_and_reset()` has an
early return in case the line has no fragment. However, if the line only
has a forced line break, then we still need to set the baseline.

Testing: Adding new test.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-09-10 07:17:25 +02:00 committed by GitHub
parent aea3467781
commit 433a6bf47b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 69 additions and 6 deletions

View file

@ -986,6 +986,12 @@ impl InlineFormattingContextLayout<'_> {
justification_adjustment,
);
if line_to_layout.has_content {
let baseline = baseline_offset + block_start_position;
self.baselines.first.get_or_insert(baseline);
self.baselines.last = Some(baseline);
}
// If the line doesn't have any fragments, we don't need to add a containing fragment for it.
if fragments.is_empty() &&
self.positioning_context.len() == start_positioning_context_length
@ -993,12 +999,6 @@ impl InlineFormattingContextLayout<'_> {
return;
}
if line_to_layout.has_content {
let baseline = baseline_offset + block_start_position;
self.baselines.first.get_or_insert(baseline);
self.baselines.last = Some(baseline);
}
// The inline part of this start offset was taken into account when determining
// the inline start of the line in `calculate_inline_start_for_current_line` so
// we do not need to include it in the `start_corner` of the line's main Fragment.