layout: Store Fragment results in LayoutBoxBase and start using them for queries (#36583)

Start storing a link to laid-out `Fragment`s in `LayoutBoxBase`, so that
these are accessible for queries and eventually for incremental layout.
Some box tree data structures lacked a `LayoutBoxBase`, such as table
tracks and table track groups[^1].

In addition, start using these `Fragment`s for queries instead of
walking the entire `Fragment` tree. Currently, this isn't possible for
most queries as `Fragment`s do not cache their absolute offsets (which
are often necessary). This change uses the new box tree `Fragment`s for
most resolved style queries.

[^1]: Note that only rows and row groups store `Fragment`s as columsn
and
   colgroups do not produce any.

Testing: This is covered by existing tests.
Fixes: This is part of #36525.

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-18 11:40:29 +02:00 committed by GitHub
parent fc201927ae
commit 2ee8427665
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 387 additions and 222 deletions

View file

@ -728,8 +728,7 @@ where
let style = anonymous_info.style.clone();
self.push_table_row(ArcRefCell::new(TableTrack {
base_fragment_info: (&anonymous_info).into(),
style,
base: LayoutBoxBase::new((&anonymous_info).into(), style),
group_index: self.current_row_group_index,
is_anonymous: true,
}));
@ -773,8 +772,7 @@ where
let next_row_index = self.builder.table.rows.len();
let row_group = ArcRefCell::new(TableTrackGroup {
base_fragment_info: info.into(),
style: info.style.clone(),
base: LayoutBoxBase::new(info.into(), info.style.clone()),
group_type: internal.into(),
track_range: next_row_index..next_row_index,
});
@ -816,8 +814,7 @@ where
row_builder.finish();
let row = ArcRefCell::new(TableTrack {
base_fragment_info: info.into(),
style: info.style.clone(),
base: LayoutBoxBase::new(info.into(), info.style.clone()),
group_index: self.current_row_group_index,
is_anonymous: false,
});
@ -862,8 +859,7 @@ where
}
let column_group = ArcRefCell::new(TableTrackGroup {
base_fragment_info: info.into(),
style: info.style.clone(),
base: LayoutBoxBase::new(info.into(), info.style.clone()),
group_type: internal.into(),
track_range: first_column..self.builder.table.columns.len(),
});
@ -1155,8 +1151,7 @@ fn add_column<'dom, Node: NodeExt<'dom>>(
};
let column = ArcRefCell::new(TableTrack {
base_fragment_info: column_info.into(),
style: column_info.style.clone(),
base: LayoutBoxBase::new(column_info.into(), column_info.style.clone()),
group_index,
is_anonymous,
});