mirror of
https://github.com/servo/servo.git
synced 2025-06-18 21:34:30 +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)
|
fn namespace(&self)
|
||||||
-> &<SelectorImpl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl;
|
-> &<SelectorImpl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl;
|
||||||
|
|
||||||
/// Returns the size of the primary box of the element.
|
/// Returns the size of the element to be used in container size queries.
|
||||||
fn primary_content_box_size(&self) -> euclid::default::Size2D<Option<app_units::Au>>;
|
/// 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
|
/// 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
|
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.
|
/// WARNING: This logic is duplicated in Gecko's FlattenedTreeParentIsParent.
|
||||||
/// Make sure to mirror any modifications in both places.
|
/// Make sure to mirror any modifications in both places.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1041,29 +1036,16 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn primary_content_box_size(&self) -> Size2D<Option<Au>> {
|
fn query_container_size(&self) -> Size2D<Option<Au>> {
|
||||||
if !self.as_node().is_connected() {
|
let mut width = -1;
|
||||||
return Size2D::new(None, None)
|
let mut height = -1;
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let frame = self
|
bindings::Gecko_GetQueryContainerSize(self.0, &mut width, &mut height);
|
||||||
.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)))
|
|
||||||
}
|
}
|
||||||
|
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.
|
/// 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();
|
let style = style.clone();
|
||||||
TraversalResult::Done(ContainerLookupResult {
|
TraversalResult::Done(ContainerLookupResult {
|
||||||
element: potential_container,
|
element: potential_container,
|
||||||
|
@ -464,7 +464,7 @@ impl<'a> ContainerSizeQuery<'a> {
|
||||||
let box_style = style.get_box();
|
let box_style = style.get_box();
|
||||||
|
|
||||||
let container_type = box_style.clone_container_type();
|
let container_type = box_style.clone_container_type();
|
||||||
let size = e.primary_content_box_size();
|
let size = e.query_container_size();
|
||||||
match container_type {
|
match container_type {
|
||||||
ContainerType::Size => {
|
ContainerType::Size => {
|
||||||
TraversalResult::Done(
|
TraversalResult::Done(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue