mirror of
https://github.com/servo/servo.git
synced 2025-06-18 13:24:29 +00:00
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
This commit is contained in:
parent
1beb9880a9
commit
0c36795e20
3 changed files with 14 additions and 30 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue