layout: Allocate inline box start space on segment (#32486)

Instead of allocating the inline padding and border space on the line,
allocate it on the segment -- which where the inline box start goes.

Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
This commit is contained in:
Martin Robinson 2024-06-18 18:19:00 +02:00 committed by GitHub
parent 63889b732f
commit 70982dfa5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 116 additions and 12 deletions

View file

@ -771,18 +771,6 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
.map(|index| &self.fonts[index].metrics),
);
if inline_box.is_first_fragment {
self.current_line.inline_position += Length::from(
inline_box_state.pbm.padding.inline_start +
inline_box_state.pbm.border.inline_start,
) + inline_box_state
.pbm
.margin
.inline_start
.auto_is(Au::zero)
.into()
}
// If we are starting a `<br>` element prepare to clear after its deferred linebreak has been
// processed. Note that a `<br>` is composed of the element itself and the inner pseudo-element
// with the actual linebreak. Both will have this `FragmentFlag`; that's why this code only
@ -796,6 +784,18 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
self.deferred_br_clear = inline_box_state.base.style.clone_clear();
}
if inline_box.is_first_fragment {
self.current_line_segment.inline_size += Length::from(
inline_box_state.pbm.padding.inline_start +
inline_box_state.pbm.border.inline_start,
) + inline_box_state
.pbm
.margin
.inline_start
.auto_is(Au::zero)
.into()
}
let line_item = inline_box_state
.layout_into_line_item(inline_box.is_first_fragment, inline_box.is_last_fragment);
self.push_line_item_to_unbreakable_segment(LineItem::StartInlineBox(line_item));