Make LineItems a token stream on the root (#30608)

Flattening the LineItem tree into a token stream will allow for handling
the case where an unbreakable line segment spans multiple inline boxes
which might have different hierarchies. This change also fixes the
handling of the second anonymous fragment of a block-in-inline-split.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2023-10-25 17:54:44 +02:00 committed by GitHub
parent c9d25963a7
commit 95e32f8372
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 127 additions and 163 deletions

View file

@ -475,8 +475,8 @@ where
self.ongoing_inline_boxes_stack.push(InlineBox {
base_fragment_info: info.into(),
style: info.style.clone(),
first_fragment: true,
last_fragment: false,
is_first_fragment: true,
is_last_fragment: false,
children: vec![],
});
@ -498,7 +498,7 @@ where
.ongoing_inline_boxes_stack
.pop()
.expect("no ongoing inline level box found");
inline_box.last_fragment = true;
inline_box.is_last_fragment = true;
ArcRefCell::new(InlineLevelBox::InlineBox(inline_box))
} else {
self.ongoing_inline_formatting_context.ends_with_whitespace = false;
@ -537,13 +537,13 @@ where
let fragmented = InlineBox {
base_fragment_info: ongoing.base_fragment_info,
style: ongoing.style.clone(),
first_fragment: ongoing.first_fragment,
is_first_fragment: ongoing.is_first_fragment,
// The fragmented boxes before the block level element
// are obviously not the last fragment.
last_fragment: false,
is_last_fragment: false,
children: std::mem::take(&mut ongoing.children),
};
ongoing.first_fragment = false;
ongoing.is_first_fragment = false;
fragmented
});