mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: @container(width:0) shouldn't match elements with no box
Depends on D163879 Differential Revision: https://phabricator.services.mozilla.com/D163844
This commit is contained in:
parent
6c02e9fdaa
commit
647d813c6b
3 changed files with 17 additions and 16 deletions
|
@ -944,7 +944,7 @@ pub trait TElement:
|
||||||
-> &<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 primary box of the element.
|
||||||
fn primary_content_box_size(&self) -> euclid::default::Size2D<app_units::Au>;
|
fn primary_content_box_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
|
||||||
|
|
|
@ -1041,9 +1041,9 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn primary_content_box_size(&self) -> Size2D<Au> {
|
fn primary_content_box_size(&self) -> Size2D<Option<Au>> {
|
||||||
if !self.as_node().is_connected() {
|
if !self.as_node().is_connected() {
|
||||||
return Size2D::zero();
|
return Size2D::new(None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1056,12 +1056,13 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
.mPrimaryFrame
|
.mPrimaryFrame
|
||||||
.as_ref();
|
.as_ref();
|
||||||
if frame.is_null() {
|
if frame.is_null() {
|
||||||
return Size2D::zero();
|
return Size2D::new(None, None)
|
||||||
}
|
}
|
||||||
let mut width = 0;
|
let mut width = 0;
|
||||||
let mut height = 0;
|
let mut height = 0;
|
||||||
bindings::Gecko_ContentSize(*frame, &mut width, &mut height);
|
bindings::Gecko_ContentSize(*frame, &mut width, &mut height);
|
||||||
Size2D::new(Au(width), Au(height))
|
// FIXME: Should use None if there isn't size containment.
|
||||||
|
Size2D::new(Some(Au(width)), Some(Au(height)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,25 +258,25 @@ impl ContainerCondition {
|
||||||
/// Information needed to evaluate an individual container query.
|
/// Information needed to evaluate an individual container query.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct ContainerInfo {
|
pub struct ContainerInfo {
|
||||||
size: Size2D<Au>,
|
size: Size2D<Option<Au>>,
|
||||||
wm: WritingMode,
|
wm: WritingMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_width(context: &Context) -> Option<CSSPixelLength> {
|
fn eval_width(context: &Context) -> Option<CSSPixelLength> {
|
||||||
let info = context.container_info.as_ref()?;
|
let info = context.container_info.as_ref()?;
|
||||||
Some(CSSPixelLength::new(info.size.width.to_f32_px()))
|
Some(CSSPixelLength::new(info.size.width?.to_f32_px()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_height(context: &Context) -> Option<CSSPixelLength> {
|
fn eval_height(context: &Context) -> Option<CSSPixelLength> {
|
||||||
let info = context.container_info.as_ref()?;
|
let info = context.container_info.as_ref()?;
|
||||||
Some(CSSPixelLength::new(info.size.height.to_f32_px()))
|
Some(CSSPixelLength::new(info.size.height?.to_f32_px()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_inline_size(context: &Context) -> Option<CSSPixelLength> {
|
fn eval_inline_size(context: &Context) -> Option<CSSPixelLength> {
|
||||||
let info = context.container_info.as_ref()?;
|
let info = context.container_info.as_ref()?;
|
||||||
Some(CSSPixelLength::new(
|
Some(CSSPixelLength::new(
|
||||||
LogicalSize::from_physical(info.wm, info.size)
|
LogicalSize::from_physical(info.wm, info.size)
|
||||||
.inline
|
.inline?
|
||||||
.to_f32_px(),
|
.to_f32_px(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -285,14 +285,14 @@ fn eval_block_size(context: &Context) -> Option<CSSPixelLength> {
|
||||||
let info = context.container_info.as_ref()?;
|
let info = context.container_info.as_ref()?;
|
||||||
Some(CSSPixelLength::new(
|
Some(CSSPixelLength::new(
|
||||||
LogicalSize::from_physical(info.wm, info.size)
|
LogicalSize::from_physical(info.wm, info.size)
|
||||||
.block
|
.block?
|
||||||
.to_f32_px(),
|
.to_f32_px(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_aspect_ratio(context: &Context) -> Option<Ratio> {
|
fn eval_aspect_ratio(context: &Context) -> Option<Ratio> {
|
||||||
let info = context.container_info.as_ref()?;
|
let info = context.container_info.as_ref()?;
|
||||||
Some(Ratio::new(info.size.width.0 as f32, info.size.height.0 as f32))
|
Some(Ratio::new(info.size.width?.0 as f32, info.size.height?.0 as f32))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_orientation(context: &Context, value: Option<Orientation>) -> bool {
|
fn eval_orientation(context: &Context, value: Option<Orientation>) -> bool {
|
||||||
|
@ -466,11 +466,11 @@ impl<'a> ContainerSizeQuery<'a> {
|
||||||
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.primary_content_box_size();
|
||||||
match container_type {
|
match container_type {
|
||||||
ContainerType::Size=> {
|
ContainerType::Size => {
|
||||||
TraversalResult::Done(
|
TraversalResult::Done(
|
||||||
ContainerSizeQueryResult {
|
ContainerSizeQueryResult {
|
||||||
width: Some(size.width),
|
width: size.width,
|
||||||
height: Some(size.height)
|
height: size.height,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -478,7 +478,7 @@ impl<'a> ContainerSizeQuery<'a> {
|
||||||
if wm.is_horizontal() {
|
if wm.is_horizontal() {
|
||||||
TraversalResult::Done(
|
TraversalResult::Done(
|
||||||
ContainerSizeQueryResult {
|
ContainerSizeQueryResult {
|
||||||
width: Some(size.width),
|
width: size.width,
|
||||||
height: None,
|
height: None,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -486,7 +486,7 @@ impl<'a> ContainerSizeQuery<'a> {
|
||||||
TraversalResult::Done(
|
TraversalResult::Done(
|
||||||
ContainerSizeQueryResult {
|
ContainerSizeQueryResult {
|
||||||
width: None,
|
width: None,
|
||||||
height: Some(size.height),
|
height: size.height,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue