diff options
author | Oriol Brufau <oriol-bugzilla@hotmail.com> | 2022-12-06 19:08:51 +0000 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-11-04 08:17:09 +0100 |
commit | 0c36795e204bb43d65e61faaab7a1d3bb65ce5e4 (patch) | |
tree | 579038eb6f509c86f1781db5b0adfa75588fbadb /components/style | |
parent | 1beb9880a9b2815b523a9ab6d35535a5d83b8cc9 (diff) | |
download | servo-0c36795e204bb43d65e61faaab7a1d3bb65ce5e4.tar.gz servo-0c36795e204bb43d65e61faaab7a1d3bb65ce5e4.zip |
style: Evaluate size feature to unknown if the container lacks size containment
For example, inline elements may have container-type:size but they don't
support size containment, so @container(width >= 0) shouldn't match.
Differential Revision: https://phabricator.services.mozilla.com/D163936
Diffstat (limited to 'components/style')
-rw-r--r-- | components/style/dom.rs | 6 | ||||
-rw-r--r-- | components/style/gecko/wrapper.rs | 34 | ||||
-rw-r--r-- | components/style/stylesheets/container_rule.rs | 4 |
3 files changed, 14 insertions, 30 deletions
diff --git a/components/style/dom.rs b/components/style/dom.rs index 98246ae562c..3f0924cf77e 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -943,8 +943,10 @@ pub trait TElement: fn namespace(&self) -> &<SelectorImpl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl; - /// Returns the size of the primary box of the element. - fn primary_content_box_size(&self) -> euclid::default::Size2D<Option<app_units::Au>>; + /// Returns the size of the element to be used in container size queries. + /// This will usually be the size of the content area of the primary box, + /// but can be None if there is no box or if some axis lacks size containment. + fn query_container_size(&self) -> euclid::default::Size2D<Option<app_units::Au>>; } /// TNode and TElement aren't Send because we want to be careful and explicit diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index e7afd518c0b..69272b15417 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -322,11 +322,6 @@ impl<'ln> GeckoNode<'ln> { self.flags() & (NODE_IS_IN_SHADOW_TREE as u32) != 0 } - #[inline] - fn is_connected(&self) -> bool { - self.get_bool_flag(nsINode_BooleanFlag::IsConnected) - } - /// WARNING: This logic is duplicated in Gecko's FlattenedTreeParentIsParent. /// Make sure to mirror any modifications in both places. #[inline] @@ -1041,29 +1036,16 @@ impl<'le> TElement for GeckoElement<'le> { } #[inline] - fn primary_content_box_size(&self) -> Size2D<Option<Au>> { - if !self.as_node().is_connected() { - return Size2D::new(None, None) - } - + fn query_container_size(&self) -> Size2D<Option<Au>> { + let mut width = -1; + let mut height = -1; unsafe { - let frame = self - .0 - ._base - ._base - ._base - .__bindgen_anon_1 - .mPrimaryFrame - .as_ref(); - if frame.is_null() { - return Size2D::new(None, None) - } - let mut width = 0; - let mut height = 0; - bindings::Gecko_ContentSize(*frame, &mut width, &mut height); - // FIXME: Should use None if there isn't size containment. - Size2D::new(Some(Au(width)), Some(Au(height))) + bindings::Gecko_GetQueryContainerSize(self.0, &mut width, &mut height); } + Size2D::new( + if width >= 0 { Some(Au(width)) } else { None }, + if height >= 0 { Some(Au(height)) } else { None }, + ) } /// Return the list of slotted nodes of this node. diff --git a/components/style/stylesheets/container_rule.rs b/components/style/stylesheets/container_rule.rs index aab9e64d56d..8e9babff28c 100644 --- a/components/style/stylesheets/container_rule.rs +++ b/components/style/stylesheets/container_rule.rs @@ -201,7 +201,7 @@ impl ContainerCondition { } } - let size = potential_container.primary_content_box_size(); + let size = potential_container.query_container_size(); let style = style.clone(); TraversalResult::Done(ContainerLookupResult { element: potential_container, @@ -464,7 +464,7 @@ impl<'a> ContainerSizeQuery<'a> { let box_style = style.get_box(); let container_type = box_style.clone_container_type(); - let size = e.primary_content_box_size(); + let size = e.query_container_size(); match container_type { ContainerType::Size => { TraversalResult::Done( |