CSS Grid: percentage sizing fixes (#34948)

This applies some fixes for CSS Grid percentage sizing. These fixes are
mostly within Taffy, but there are some changes in Servo to allow it to
communicate whether an item is replaced to Taffy.

It also updates Taffy to v0.8.0. Taffy has switched to a tagged pointer
representation of length/size styles. Much of the diff here is updating
Servo's type conversion code to use the new representation.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes OR

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
Nico Burns 2025-06-08 16:17:10 +01:00 committed by GitHub
parent bd6639aadb
commit 1b5a10a55f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 111 additions and 105 deletions

View file

@ -107,7 +107,7 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
Self: 'a;
fn get_core_container_style(&self, _node_id: taffy::NodeId) -> Self::CoreContainerStyle<'_> {
TaffyStyloStyle(self.style)
TaffyStyloStyle::new(self.style, false /* is_replaced */)
}
fn set_unrounded_layout(&mut self, node_id: taffy::NodeId, layout: &taffy::Layout) {
@ -311,7 +311,7 @@ impl taffy::LayoutGridContainer for TaffyContainerContext<'_> {
&self,
_node_id: taffy::prelude::NodeId,
) -> Self::GridContainerStyle<'_> {
TaffyStyloStyle(self.style)
TaffyStyloStyle::new(self.style, false /* is_replaced */)
}
fn get_grid_child_style(
@ -320,7 +320,10 @@ impl taffy::LayoutGridContainer for TaffyContainerContext<'_> {
) -> Self::GridItemStyle<'_> {
let id = usize::from(child_node_id);
let child = (*self.source_child_nodes[id]).borrow();
TaffyStyloStyle(AtomicRef::map(child, |c| &*c.style))
// TODO: account for non-replaced elements that are "compressible replaced"
let is_replaced = child.is_in_flow_replaced();
let stylo_style = AtomicRef::map(child, |c| &*c.style);
TaffyStyloStyle::new(stylo_style, is_replaced)
}
fn set_detailed_grid_info(