fix: root element not establishing stacking context (#35390) (#36174)

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #35390 
- [X] There are tests for these changes

[Successful WPT
run](https://github.com/reesmichael1/servo/actions/runs/14097679625)
(which includes the new test files)

(I didn't make the formatting changes intentionally--those came from
`mach format` following `mach test-tidy`.)

---------

Signed-off-by: Michael Rees <mrees@noeontheend.com>
This commit is contained in:
Michael Rees 2025-04-03 12:30:42 -05:00 committed by GitHub
parent f29c182929
commit dfcd9de138
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 53 additions and 0 deletions

View file

@ -105,6 +105,7 @@ where
if element.is_body_element_of_html_element_root() {
flags.insert(FragmentFlags::IS_BODY_ELEMENT_OF_HTML_ELEMENT_ROOT);
}
match element.get_local_name() {
&local_name!("br") => {
flags.insert(FragmentFlags::IS_BR_ELEMENT);
@ -123,6 +124,10 @@ where
) {
flags.insert(FragmentFlags::IS_TEXT_CONTROL);
}
if ThreadSafeLayoutElement::is_root(&element) {
flags.insert(FragmentFlags::IS_ROOT_ELEMENT);
}
};
Self {

View file

@ -102,6 +102,8 @@ bitflags! {
/// and the fragment can be a flex item. This flag is used to cache items during flex
/// layout.
const SIZE_DEPENDS_ON_BLOCK_CONSTRAINTS_AND_CAN_BE_CHILD_OF_FLEX_ITEM = 1 << 8;
/// Whether or not the node that created this fragment is the root element.
const IS_ROOT_ELEMENT = 1 << 9;
}
}

View file

@ -746,6 +746,12 @@ impl ComputedValuesExt for ComputedValues {
return true;
}
// From https://www.w3.org/TR/CSS22/visuren.html#z-index:
// > The root element forms the root stacking context.
if fragment_flags.contains(FragmentFlags::IS_ROOT_ELEMENT) {
return true;
}
// TODO: We need to handle CSS Contain here.
false
}