layout: Lay out collapsed table rows and columns, but don't paint them (#39027)

It's expected that script queries be able to interact with collapsed
table rows and columns, so this change starts laying them out. They
still do not affect table dimensions, nor are they painted.

This does not fix all interaction with collapsed rows and columns. For
instance, setting scroll offsets of contained scrolling nodes does not
work properly. It does fix the panic though, which is the most important
thing.


Testing: this change includes a new WPT crash test.
Fixes: #37421.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-09-01 05:58:36 -07:00 committed by GitHub
parent 236e28aeab
commit fc30a26005
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 59 additions and 8 deletions

View file

@ -178,6 +178,9 @@ bitflags! {
const IS_ROOT_ELEMENT = 1 << 9;
/// If element has propagated the overflow value to viewport.
const PROPAGATED_OVERFLOW_TO_VIEWPORT = 1 << 10;
/// Whether or not this is a table cell that is part of a collapsed row or column.
/// In that case it should not be painted.
const IS_COLLAPSED = 1 << 11;
}
}

View file

@ -6,6 +6,7 @@ use app_units::{Au, MAX_AU, MIN_AU};
use atomic_refcell::AtomicRefCell;
use base::id::ScrollTreeNodeId;
use base::print_tree::PrintTree;
use euclid::Rect;
use malloc_size_of_derive::MallocSizeOf;
use servo_arc::Arc as ServoArc;
use servo_geometry::f32_rect_to_au_rect;
@ -291,6 +292,15 @@ impl BoxFragment {
acc.union(&scrollable_overflow_from_child)
});
// Fragments with `IS_COLLAPSED` (currently only table cells that are part of
// table tracks with `visibility: collapse`) should not contribute to scrollable
// overflow. This behavior matches Chrome, but not Firefox.
// See https://github.com/w3c/csswg-drafts/issues/12689
if self.base.flags.contains(FragmentFlags::IS_COLLAPSED) {
self.scrollable_overflow = Some(Rect::zero());
return;
}
self.scrollable_overflow = Some(scrollable_overflow)
}