layout: Enable using cached fragments when there is a BoxTree update point (#36404)

This starts to enable the fragment cache for all layout modes, except
grid. The main tricky bit here is that update points are absolutes and
these need to be laid out again in their containing blocks. We punt a
little bit on this, by forcing ancestors of update points to rebuild
their Fragments. This is just the first step.

Testing: We do not currently have layout performance tests, but will try
to run some tests manually later. Behavior is covered by the WPT.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-04-09 15:32:07 +02:00 committed by GitHub
parent 15cac97ada
commit 2d001e2c85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 188 additions and 48 deletions

View file

@ -196,6 +196,30 @@ pub(crate) enum InlineItem {
),
}
impl InlineItem {
pub(crate) fn invalidate_cached_fragment(&self) {
match self {
InlineItem::StartInlineBox(..) | InlineItem::EndInlineBox | InlineItem::TextRun(..) => {
},
InlineItem::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
positioned_box
.borrow()
.context
.base
.invalidate_cached_fragment();
},
InlineItem::OutOfFlowFloatBox(float_box) => {
float_box.contents.base.invalidate_cached_fragment()
},
InlineItem::Atomic(independent_formatting_context, ..) => {
independent_formatting_context
.base
.invalidate_cached_fragment();
},
}
}
}
/// Information about the current line under construction for a particular
/// [`InlineFormattingContextLayout`]. This tracks position and size information while
/// [`LineItem`]s are collected and is used as input when those [`LineItem`]s are