diff --git a/components/layout/block.rs b/components/layout/block.rs index 3d19ed1072a..24128ca2ae7 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -67,9 +67,7 @@ use style::context::SharedStyleContext; use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use style::properties::ComputedValues; use style::servo::restyle_damage::ServoRestyleDamage; -use style::values::computed::{ - LengthPercentageOrAuto, MaxLength, NonNegativeLengthPercentageOrAuto, -}; +use style::values::computed::{LengthPercentageOrAuto, MaxSize, Size}; /// Information specific to floated blocks. #[derive(Clone, Serialize)] @@ -421,24 +419,24 @@ impl CandidateBSizeIterator { // `min-height` and `max-height`, percentage values are ignored. let block_size = match fragment.style.content_block_size() { - NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::Auto => MaybeAuto::Auto, + Size::LengthPercentage(ref lp) => { MaybeAuto::from_option(lp.maybe_to_used_value(block_container_block_size)) }, }; let max_block_size = match fragment.style.max_block_size() { - MaxLength::None => None, - MaxLength::LengthPercentage(ref lp) => { - lp.maybe_to_used_value(block_container_block_size) - }, + MaxSize::None => None, + MaxSize::LengthPercentage(ref lp) => lp.maybe_to_used_value(block_container_block_size), }; - let min_block_size = fragment - .style - .min_block_size() - .maybe_to_used_value(block_container_block_size) - .unwrap_or(Au(0)); + let min_block_size = match fragment.style.min_block_size() { + Size::Auto => MaybeAuto::Auto, + Size::LengthPercentage(ref lp) => { + MaybeAuto::from_option(lp.maybe_to_used_value(block_container_block_size)) + }, + } + .specified_or_zero(); // If the style includes `box-sizing: border-box`, subtract the border and padding. let adjustment_for_box_sizing = match fragment.style.get_position().box_sizing { @@ -1402,7 +1400,7 @@ impl BlockFlow { let content_block_size = self.fragment.style().content_block_size(); match content_block_size { - NonNegativeLengthPercentageOrAuto::Auto => { + Size::Auto => { let container_size = containing_block_size?; let (block_start, block_end) = { let position = self.fragment.style().logical_position(); @@ -1437,9 +1435,7 @@ impl BlockFlow { (_, _) => None, } }, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.maybe_to_used_value(containing_block_size) - }, + Size::LengthPercentage(ref lp) => lp.maybe_to_used_value(containing_block_size), } } @@ -1796,7 +1792,8 @@ impl BlockFlow { .fragment .style() .min_inline_size() - .to_used_value(self.base.block_container_inline_size); + .to_used_value(self.base.block_container_inline_size) + .unwrap_or(Au(0)); let specified_inline_size = self.fragment.style().content_inline_size(); let container_size = self.base.block_container_inline_size; let inline_size = match specified_inline_size.to_used_value(container_size) { @@ -2025,7 +2022,7 @@ impl BlockFlow { // If `max-width` is set, then don't perform this speculation. We guess that the // page set `max-width` in order to avoid hitting floats. The search box on Google // SERPs falls into this category. - if self.fragment.style.max_inline_size() != MaxLength::None { + if self.fragment.style.max_inline_size() != MaxSize::None { return; } @@ -2157,10 +2154,8 @@ impl Flow for BlockFlow { // rather than bubbling up children inline width. // FIXME(emilio): This should probably be writing-mode-aware. let consult_children = match self.fragment.style().get_position().width { - NonNegativeLengthPercentageOrAuto::Auto => true, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.maybe_to_used_value(None).is_none() - }, + Size::Auto => true, + Size::LengthPercentage(ref lp) => lp.maybe_to_used_value(None).is_none(), }; self.bubble_inline_sizes_for_block(consult_children); self.fragment @@ -2911,7 +2906,8 @@ pub trait ISizeAndMarginsComputer { .fragment() .style() .min_inline_size() - .to_used_value(containing_block_inline_size); + .to_used_value(containing_block_inline_size) + .unwrap_or(Au(0)); if computed_min_inline_size > solution.inline_size { input.computed_inline_size = MaybeAuto::Specified(computed_min_inline_size); solution = self.solve_inline_size_constraints(block, &input); diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 770a02c594b..f761bc95dff 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -29,9 +29,7 @@ use style::logical_geometry::{Direction, LogicalSize}; use style::properties::ComputedValues; use style::servo::restyle_damage::ServoRestyleDamage; use style::values::computed::flex::FlexBasis; -use style::values::computed::{ - MaxLength, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto, -}; +use style::values::computed::{MaxSize, Size}; use style::values::generics::flex::FlexBasis as GenericFlexBasis; /// The size of an axis. May be a specified size, a min/max @@ -46,21 +44,12 @@ enum AxisSize { impl AxisSize { /// Generate a new available cross or main axis size from the specified size of the container, /// containing block size, min constraint, and max constraint - pub fn new( - size: NonNegativeLengthPercentageOrAuto, - content_size: Option, - min: NonNegativeLengthPercentage, - max: MaxLength, - ) -> AxisSize { + pub fn new(size: Size, content_size: Option, min: Size, max: MaxSize) -> AxisSize { match size { - NonNegativeLengthPercentageOrAuto::Auto => { - AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None)) - }, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - match lp.maybe_to_used_value(content_size) { - Some(length) => AxisSize::Definite(length), - None => AxisSize::Infinite, - } + Size::Auto => AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None)), + Size::LengthPercentage(ref lp) => match lp.maybe_to_used_value(content_size) { + Some(length) => AxisSize::Definite(length), + None => AxisSize::Infinite, }, } } @@ -70,26 +59,20 @@ impl AxisSize { /// and the container size, then return the used value of flex basis. it can be used to help /// determining the flex base size and to indicate whether the main size of the item /// is definite after flex size resolving. -fn from_flex_basis( - flex_basis: FlexBasis, - main_length: NonNegativeLengthPercentageOrAuto, - containing_length: Au, -) -> MaybeAuto { +fn from_flex_basis(flex_basis: FlexBasis, main_length: Size, containing_length: Au) -> MaybeAuto { let width = match flex_basis { GenericFlexBasis::Content => return MaybeAuto::Auto, GenericFlexBasis::Width(width) => width, }; let width = match width { - NonNegativeLengthPercentageOrAuto::Auto => main_length, + Size::Auto => main_length, _ => width, }; match width { - NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - MaybeAuto::Specified(lp.to_used_value(containing_length)) - }, + Size::Auto => MaybeAuto::Auto, + Size::LengthPercentage(ref lp) => MaybeAuto::Specified(lp.to_used_value(containing_length)), } } @@ -183,7 +166,8 @@ impl FlexItem { .fragment .style .min_inline_size() - .to_used_value(containing_length); + .to_used_value(containing_length) + .unwrap_or(Au(0)); }, Direction::Block => { let basis = from_flex_basis( @@ -205,7 +189,8 @@ impl FlexItem { .fragment .style .min_block_size() - .to_used_value(containing_length); + .to_used_value(containing_length) + .unwrap_or(Au(0)); }, } } diff --git a/components/layout/floats.rs b/components/layout/floats.rs index e3274c1ed91..42df4e07dfd 100644 --- a/components/layout/floats.rs +++ b/components/layout/floats.rs @@ -10,7 +10,7 @@ use std::cmp::{max, min}; use std::fmt; use style::computed_values::float::T as StyleFloat; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; -use style::values::computed::NonNegativeLengthPercentageOrAuto; +use style::values::computed::Size; /// The kind of float: left or right. #[derive(Clone, Copy, Debug, Serialize)] @@ -549,8 +549,8 @@ impl SpeculatedFloatPlacement { // might flow around this float. let inline_size = flow.as_block().fragment.style.content_inline_size(); let fixed = match inline_size { - NonNegativeLengthPercentageOrAuto::Auto => false, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::Auto => false, + Size::LengthPercentage(ref lp) => { lp.0.is_definitely_zero() || lp.0.maybe_to_used_value(None).is_some() }, }; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 1efd40003e6..2511b5ea868 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -61,9 +61,7 @@ use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; use style::str::char_is_whitespace; use style::values::computed::counters::ContentItem; -use style::values::computed::{ - LengthPercentage, LengthPercentageOrAuto, NonNegativeLengthPercentageOrAuto, -}; +use style::values::computed::{LengthPercentage, LengthPercentageOrAuto, Size}; use style::values::generics::box_::{Perspective, VerticalAlign}; use style::values::generics::transform; use webrender_api::{self, LayoutTransform}; @@ -991,7 +989,13 @@ impl Fragment { .content_inline_size() .to_used_value(Au(0)) .unwrap_or(Au(0)); - specified = max(style.min_inline_size().to_used_value(Au(0)), specified); + specified = max( + style + .min_inline_size() + .to_used_value(Au(0)) + .unwrap_or(Au(0)), + specified, + ); if let Some(max) = style.max_inline_size().to_used_value(Au(0)) { specified = min(specified, max) } @@ -1615,10 +1619,8 @@ impl Fragment { SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Svg(_) => { let inline_size = match self.style.content_inline_size() { - NonNegativeLengthPercentageOrAuto::Auto => None, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.maybe_to_used_value(None) - }, + Size::Auto => None, + Size::LengthPercentage(ref lp) => lp.maybe_to_used_value(None), }; let mut inline_size = inline_size.unwrap_or_else(|| { diff --git a/components/layout/model.rs b/components/layout/model.rs index b5a79d8a383..17c3b625af3 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -11,10 +11,8 @@ use std::cmp::{max, min}; use std::fmt; use style::logical_geometry::{LogicalMargin, WritingMode}; use style::properties::ComputedValues; -use style::values::computed::MaxLength; -use style::values::computed::{ - LengthPercentageOrAuto, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto, -}; +use style::values::computed::MaxSize; +use style::values::computed::{LengthPercentageOrAuto, Size}; /// A collapsible margin. See CSS 2.1 ยง 8.3.1. #[derive(Clone, Copy, Debug)] @@ -137,15 +135,17 @@ impl MarginCollapseInfo { MarginCollapseState::AccumulatingCollapsibleTopMargin => { may_collapse_through = may_collapse_through && match fragment.style().content_block_size() { - NonNegativeLengthPercentageOrAuto::Auto => true, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::Auto => true, + Size::LengthPercentage(ref lp) => { lp.is_definitely_zero() || lp.maybe_to_used_value(containing_block_size).is_none() }, }; if may_collapse_through { - if fragment.style().min_block_size().is_definitely_zero() { + if fragment.style.min_block_size().is_auto() || + fragment.style().min_block_size().is_definitely_zero() + { FinalMarginState::MarginsCollapseThrough } else { // If the fragment has non-zero min-block-size, margins may not @@ -498,13 +498,10 @@ impl MaybeAuto { /// Receive an optional container size and return used value for width or height. /// /// `style_length`: content size as given in the CSS. -pub fn style_length( - style_length: NonNegativeLengthPercentageOrAuto, - container_size: Option, -) -> MaybeAuto { +pub fn style_length(style_length: Size, container_size: Option) -> MaybeAuto { match style_length { - NonNegativeLengthPercentageOrAuto::Auto => MaybeAuto::Auto, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::Auto => MaybeAuto::Auto, + Size::LengthPercentage(ref lp) => { MaybeAuto::from_option(lp.0.maybe_to_used_value(container_size)) }, } @@ -571,17 +568,20 @@ impl SizeConstraint { /// Create a `SizeConstraint` for an axis. pub fn new( container_size: Option, - min_size: NonNegativeLengthPercentage, - max_size: MaxLength, + min_size: Size, + max_size: MaxSize, border: Option, ) -> SizeConstraint { - let mut min_size = min_size - .maybe_to_used_value(container_size) - .unwrap_or(Au(0)); + let mut min_size = match min_size { + Size::Auto => Au(0), + Size::LengthPercentage(ref lp) => { + lp.maybe_to_used_value(container_size).unwrap_or(Au(0)) + }, + }; let mut max_size = match max_size { - MaxLength::None => None, - MaxLength::LengthPercentage(ref lp) => lp.maybe_to_used_value(container_size), + MaxSize::None => None, + MaxSize::LengthPercentage(ref lp) => lp.maybe_to_used_value(container_size), }; // Make sure max size is not smaller than min size. diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index feb267103b0..ca92c200d40 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -19,7 +19,7 @@ use std::fmt; use std::sync::Arc; use style::logical_geometry::LogicalSize; use style::properties::ComputedValues; -use style::values::computed::{MaxLength, NonNegativeLengthPercentageOrAuto}; +use style::values::computed::{MaxSize, Size}; use style::values::generics::column::ColumnCount; use style::values::Either; @@ -155,14 +155,12 @@ impl Flow for MulticolFlow { available_block_size: { let style = &self.block_flow.fragment.style; let size = match style.content_block_size() { - NonNegativeLengthPercentageOrAuto::Auto => None, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.maybe_to_used_value(None) - }, + Size::Auto => None, + Size::LengthPercentage(ref lp) => lp.maybe_to_used_value(None), }; let size = size.or_else(|| match style.max_block_size() { - MaxLength::None => None, - MaxLength::LengthPercentage(ref lp) => lp.maybe_to_used_value(None), + MaxSize::None => None, + MaxSize::LengthPercentage(ref lp) => lp.maybe_to_used_value(None), }); size.unwrap_or_else(|| { diff --git a/components/layout/table.rs b/components/layout/table.rs index 7aa8f2a89d4..9f6219f0980 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -33,7 +33,7 @@ use style::logical_geometry::LogicalSize; use style::properties::style_structs::Background; use style::properties::ComputedValues; use style::servo::restyle_damage::ServoRestyleDamage; -use style::values::computed::NonNegativeLengthPercentageOrAuto; +use style::values::computed::Size; use style::values::CSSFloat; #[allow(unsafe_code)] @@ -301,14 +301,14 @@ impl Flow for TableFlow { self.column_intrinsic_inline_sizes .push(ColumnIntrinsicInlineSize { minimum_length: match *specified_inline_size { - NonNegativeLengthPercentageOrAuto::Auto => Au(0), - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::Auto => Au(0), + Size::LengthPercentage(ref lp) => { lp.maybe_to_used_value(None).unwrap_or(Au(0)) }, }, percentage: match *specified_inline_size { - NonNegativeLengthPercentageOrAuto::Auto => 0.0, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::Auto => 0.0, + Size::LengthPercentage(ref lp) => { lp.0.as_percentage().map_or(0.0, |p| p.0) }, }, diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 3bcc39f0193..682a1c38ec4 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -21,7 +21,7 @@ use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use std::fmt; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::properties::ComputedValues; -use style::values::computed::length::NonNegativeLengthPercentageOrAuto; +use style::values::computed::length::Size; use style::values::computed::Color; use style::values::generics::box_::VerticalAlign; use style::values::specified::BorderStyle; @@ -203,8 +203,8 @@ impl Flow for TableCellFlow { self.block_flow.bubble_inline_sizes_for_block(true); let specified_inline_size = match self.block_flow.fragment.style().content_inline_size() { - NonNegativeLengthPercentageOrAuto::Auto => Au(0), - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => lp.to_used_value(Au(0)), + Size::Auto => Au(0), + Size::LengthPercentage(ref lp) => lp.to_used_value(Au(0)), }; if self diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 1097d6dae38..c07ad56f95a 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -14,7 +14,7 @@ use euclid::Point2D; use std::fmt; use style::logical_geometry::LogicalSize; use style::properties::ComputedValues; -use style::values::computed::NonNegativeLengthPercentageOrAuto; +use style::values::computed::Size; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableColGroupFlow {} @@ -34,7 +34,7 @@ pub struct TableColGroupFlow { /// The specified inline-sizes of table columns. (We use `LengthPercentageOrAuto` here in /// lieu of `ColumnInlineSize` because column groups do not establish minimum or preferred /// inline sizes.) - pub inline_sizes: Vec, + pub inline_sizes: Vec, } impl TableColGroupFlow { diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 78768f5a1ab..824da31edad 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -29,7 +29,7 @@ use style::computed_values::border_spacing::T as BorderSpacing; use style::computed_values::border_top_style::T as BorderStyle; use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use style::properties::ComputedValues; -use style::values::computed::{Color, NonNegativeLengthPercentageOrAuto}; +use style::values::computed::{Color, Size}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableRowFlow {} @@ -429,24 +429,18 @@ impl Flow for TableRowFlow { let child_base = kid.mut_base(); let child_column_inline_size = ColumnIntrinsicInlineSize { minimum_length: match child_specified_inline_size { - NonNegativeLengthPercentageOrAuto::Auto => None, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.0.maybe_to_used_value(None) - }, + Size::Auto => None, + Size::LengthPercentage(ref lp) => lp.0.maybe_to_used_value(None), } .unwrap_or(child_base.intrinsic_inline_sizes.minimum_inline_size), percentage: match child_specified_inline_size { - NonNegativeLengthPercentageOrAuto::Auto => 0.0, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.0.as_percentage().map_or(0.0, |p| p.0) - }, + Size::Auto => 0.0, + Size::LengthPercentage(ref lp) => lp.0.as_percentage().map_or(0.0, |p| p.0), }, preferred: child_base.intrinsic_inline_sizes.preferred_inline_size, constrained: match child_specified_inline_size { - NonNegativeLengthPercentageOrAuto::Auto => false, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { - lp.0.maybe_to_used_value(None).is_some() - }, + Size::Auto => false, + Size::LengthPercentage(ref lp) => lp.0.maybe_to_used_value(None).is_some(), }, }; min_inline_size = min_inline_size + child_column_inline_size.minimum_length; diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index b63da7d56e5..1c9c049356e 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -33,7 +33,7 @@ use style::computed_values::{position, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalRect, LogicalSize}; use style::properties::ComputedValues; -use style::values::computed::NonNegativeLengthPercentageOrAuto; +use style::values::computed::Size; use style::values::CSSFloat; #[derive(Clone, Copy, Debug, Serialize)] @@ -201,7 +201,7 @@ impl TableWrapperFlow { // says "the basic idea is the same as the shrink-to-fit width that CSS2.1 defines". So we // just use the shrink-to-fit inline size. let available_inline_size = match self.block_flow.fragment.style().content_inline_size() { - NonNegativeLengthPercentageOrAuto::Auto => { + Size::Auto => { self.block_flow .get_shrink_to_fit_inline_size(available_inline_size) - table_border_padding @@ -841,7 +841,7 @@ fn initial_computed_inline_size( table_border_padding: Au, ) -> MaybeAuto { match block.fragment.style.content_inline_size() { - NonNegativeLengthPercentageOrAuto::Auto => { + Size::Auto => { if preferred_width_of_all_columns + table_border_padding <= containing_block_inline_size { MaybeAuto::Specified(preferred_width_of_all_columns + table_border_padding) @@ -851,7 +851,7 @@ fn initial_computed_inline_size( MaybeAuto::Auto } }, - NonNegativeLengthPercentageOrAuto::LengthPercentage(ref lp) => { + Size::LengthPercentage(ref lp) => { let used = lp.to_used_value(containing_block_inline_size); MaybeAuto::Specified(max( used - table_border_padding, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index dbcab42f11f..4321540676b 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -718,11 +718,9 @@ impl LayoutElementHelpers for LayoutDom { specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size)); hints.push(from_declaration( shared_lock, - PropertyDeclaration::Width( - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Length(value), - )), - ), + PropertyDeclaration::Width(specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Length(value), + ))), )); } @@ -747,22 +745,20 @@ impl LayoutElementHelpers for LayoutDom { match width { LengthOrPercentageOrAuto::Auto => {}, LengthOrPercentageOrAuto::Percentage(percentage) => { - let width_value = - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Percentage(computed::Percentage(percentage)), - )); + let width_value = specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Percentage(computed::Percentage(percentage)), + )); hints.push(from_declaration( shared_lock, PropertyDeclaration::Width(width_value), )); }, LengthOrPercentageOrAuto::Length(length) => { - let width_value = - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Length(specified::NoCalcLength::Absolute( - specified::AbsoluteLength::Px(length.to_f32_px()), - )), - )); + let width_value = specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Length(specified::NoCalcLength::Absolute( + specified::AbsoluteLength::Px(length.to_f32_px()), + )), + )); hints.push(from_declaration( shared_lock, PropertyDeclaration::Width(width_value), @@ -783,22 +779,20 @@ impl LayoutElementHelpers for LayoutDom { match height { LengthOrPercentageOrAuto::Auto => {}, LengthOrPercentageOrAuto::Percentage(percentage) => { - let height_value = - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Percentage(computed::Percentage(percentage)), - )); + let height_value = specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Percentage(computed::Percentage(percentage)), + )); hints.push(from_declaration( shared_lock, PropertyDeclaration::Height(height_value), )); }, LengthOrPercentageOrAuto::Length(length) => { - let height_value = - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Length(specified::NoCalcLength::Absolute( - specified::AbsoluteLength::Px(length.to_f32_px()), - )), - )); + let height_value = specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Length(specified::NoCalcLength::Absolute( + specified::AbsoluteLength::Px(length.to_f32_px()), + )), + )); hints.push(from_declaration( shared_lock, PropertyDeclaration::Height(height_value), @@ -825,11 +819,9 @@ impl LayoutElementHelpers for LayoutDom { specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols)); hints.push(from_declaration( shared_lock, - PropertyDeclaration::Width( - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Length(value), - )), - ), + PropertyDeclaration::Width(specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Length(value), + ))), )); } @@ -851,11 +843,9 @@ impl LayoutElementHelpers for LayoutDom { )); hints.push(from_declaration( shared_lock, - PropertyDeclaration::Height( - specified::NonNegativeLengthPercentageOrAuto::LengthPercentage(NonNegative( - specified::LengthPercentage::Length(value), - )), - ), + PropertyDeclaration::Height(specified::Size::LengthPercentage(NonNegative( + specified::LengthPercentage::Length(value), + ))), )); } diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index ac3495a7504..33706f70537 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -14,7 +14,7 @@ use crate::media_queries::Device; use crate::values::computed::basic_shape::ShapeRadius as ComputedShapeRadius; use crate::values::computed::FlexBasis as ComputedFlexBasis; use crate::values::computed::{Angle, ExtremumLength, Length, LengthPercentage}; -use crate::values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength}; +use crate::values::computed::{MaxSize as ComputedMaxSize, Size as ComputedSize}; use crate::values::computed::{NonNegativeLengthPercentage, Percentage}; use crate::values::computed::{Number, NumberOrPercentage}; use crate::values::generics::basic_shape::ShapeRadius; @@ -22,7 +22,7 @@ use crate::values::generics::box_::Perspective; use crate::values::generics::flex::FlexBasis; use crate::values::generics::gecko::ScrollSnapPoint; use crate::values::generics::grid::{TrackBreadth, TrackKeyword}; -use crate::values::generics::length::{LengthPercentageOrAuto, MaxLength, MozLength}; +use crate::values::generics::length::{LengthPercentageOrAuto, MaxSize, Size}; use crate::values::generics::{CounterStyleOrNone, NonNegative}; use crate::values::{Auto, Either, None_, Normal}; use crate::Atom; @@ -91,7 +91,7 @@ impl GeckoStyleCoordConvertible for ComputedFlexBasis { } fn from_gecko_style_coord(coord: &T) -> Option { - if let Some(width) = ComputedMozLength::from_gecko_style_coord(coord) { + if let Some(width) = ComputedSize::from_gecko_style_coord(coord) { return Some(FlexBasis::Width(width)); } @@ -350,43 +350,43 @@ impl GeckoStyleCoordConvertible for ExtremumLength { } } -impl GeckoStyleCoordConvertible for ComputedMozLength { +impl GeckoStyleCoordConvertible for ComputedSize { fn to_gecko_style_coord(&self, coord: &mut T) { match *self { - MozLength::LengthPercentage(ref lpoa) => lpoa.to_gecko_style_coord(coord), - MozLength::Auto => coord.set_value(CoordDataValue::Auto), - MozLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord), + Size::LengthPercentage(ref lpoa) => lpoa.to_gecko_style_coord(coord), + Size::Auto => coord.set_value(CoordDataValue::Auto), + Size::ExtremumLength(ref e) => e.to_gecko_style_coord(coord), } } fn from_gecko_style_coord(coord: &T) -> Option { if let CoordDataValue::Auto = coord.as_value() { - return Some(MozLength::Auto); + return Some(Size::Auto); } if let Some(lp) = NonNegativeLengthPercentage::from_gecko_style_coord(coord) { - return Some(MozLength::LengthPercentage(lp)); + return Some(Size::LengthPercentage(lp)); } - ExtremumLength::from_gecko_style_coord(coord).map(MozLength::ExtremumLength) + ExtremumLength::from_gecko_style_coord(coord).map(Size::ExtremumLength) } } -impl GeckoStyleCoordConvertible for ComputedMaxLength { +impl GeckoStyleCoordConvertible for ComputedMaxSize { fn to_gecko_style_coord(&self, coord: &mut T) { match *self { - MaxLength::LengthPercentage(ref lpon) => lpon.to_gecko_style_coord(coord), - MaxLength::None => coord.set_value(CoordDataValue::None), - MaxLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord), + MaxSize::LengthPercentage(ref lpon) => lpon.to_gecko_style_coord(coord), + MaxSize::None => coord.set_value(CoordDataValue::None), + MaxSize::ExtremumLength(ref e) => e.to_gecko_style_coord(coord), } } fn from_gecko_style_coord(coord: &T) -> Option { if let CoordDataValue::None = coord.as_value() { - return Some(MaxLength::None); + return Some(MaxSize::None); } if let Some(lp) = NonNegativeLengthPercentage::from_gecko_style_coord(coord) { - return Some(MaxLength::LengthPercentage(lp)); + return Some(MaxSize::LengthPercentage(lp)); } - ExtremumLength::from_gecko_style_coord(coord).map(MaxLength::ExtremumLength) + ExtremumLength::from_gecko_style_coord(coord).map(MaxSize::ExtremumLength) } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 297357446a2..6baae1d9063 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1390,8 +1390,8 @@ impl Clone for ${style_struct.gecko_struct_name} { "LengthOrNormal": impl_style_coord, "LengthPercentage": impl_simple, "LengthPercentageOrAuto": impl_style_coord, - "MaxLength": impl_style_coord, - "MozLength": impl_style_coord, + "MaxSize": impl_style_coord, + "Size": impl_style_coord, "MozScriptMinSize": impl_absolute_length, "MozScriptSizeMultiplier": impl_simple, "NonNegativeLengthPercentage": impl_simple, diff --git a/components/style/properties/longhands/position.mako.rs b/components/style/properties/longhands/position.mako.rs index 2a0f86d056a..714de149b56 100644 --- a/components/style/properties/longhands/position.mako.rs +++ b/components/style/properties/longhands/position.mako.rs @@ -244,65 +244,40 @@ ${helpers.predefined_type( if logical: spec = "https://drafts.csswg.org/css-logical-props/#propdef-%s" %> - % if product == "gecko": - // width, height, block-size, inline-size - ${helpers.predefined_type( - size, - "MozLength", - "computed::MozLength::auto()", - logical=logical, - logical_group="size", - allow_quirks=not logical, - spec=spec % size, - animation_value_type="MozLength", - flags="GETCS_NEEDS_LAYOUT_FLUSH", - servo_restyle_damage="reflow", - )} - // min-width, min-height, min-block-size, min-inline-size, - ${helpers.predefined_type( - "min-%s" % size, - "MozLength", - "computed::MozLength::auto()", - logical=logical, - logical_group="min-size", - allow_quirks=not logical, - spec=spec % size, - animation_value_type="MozLength", - servo_restyle_damage="reflow", - )} - % else: - // servo versions (no keyword support) - ${helpers.predefined_type( - size, - "NonNegativeLengthPercentageOrAuto", - "computed::NonNegativeLengthPercentageOrAuto::auto()", - spec=spec % size, - logical_group="size", - allow_quirks=not logical, - animation_value_type="ComputedValue", logical = logical, - servo_restyle_damage="reflow", - )} - ${helpers.predefined_type( - "min-%s" % size, - "NonNegativeLengthPercentage", - "computed::NonNegativeLengthPercentage::zero()", - spec=spec % ("min-%s" % size), - logical_group="min-size", - animation_value_type="ComputedValue", - logical=logical, - allow_quirks=not logical, - servo_restyle_damage="reflow", - )} - % endif + // width, height, block-size, inline-size + ${helpers.predefined_type( + size, + "Size", + "computed::Size::auto()", + logical=logical, + logical_group="size", + allow_quirks=not logical, + spec=spec % size, + animation_value_type="Size", + flags="GETCS_NEEDS_LAYOUT_FLUSH", + servo_restyle_damage="reflow", + )} + // min-width, min-height, min-block-size, min-inline-size + ${helpers.predefined_type( + "min-%s" % size, + "Size", + "computed::Size::auto()", + logical=logical, + logical_group="min-size", + allow_quirks=not logical, + spec=spec % size, + animation_value_type="Size", + servo_restyle_damage="reflow", + )} ${helpers.predefined_type( "max-%s" % size, - "MaxLength", - "computed::MaxLength::none()", + "MaxSize", + "computed::MaxSize::none()", logical=logical, logical_group="max-size", allow_quirks=not logical, spec=spec % size, - animation_value_type="MaxLength", + animation_value_type="MaxSize", servo_restyle_damage="reflow", )} % endfor diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 62d27922ccb..d818306e96c 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -3016,7 +3016,7 @@ impl ComputedValuesInner { /// Get the logical computed inline size. #[inline] - pub fn content_inline_size(&self) -> computed::NonNegativeLengthPercentageOrAuto { + pub fn content_inline_size(&self) -> computed::Size { let position_style = self.get_position(); if self.writing_mode.is_vertical() { position_style.height @@ -3027,35 +3027,35 @@ impl ComputedValuesInner { /// Get the logical computed block size. #[inline] - pub fn content_block_size(&self) -> computed::NonNegativeLengthPercentageOrAuto { + pub fn content_block_size(&self) -> computed::Size { let position_style = self.get_position(); if self.writing_mode.is_vertical() { position_style.width } else { position_style.height } } /// Get the logical computed min inline size. #[inline] - pub fn min_inline_size(&self) -> computed::NonNegativeLengthPercentage { + pub fn min_inline_size(&self) -> computed::Size { let position_style = self.get_position(); if self.writing_mode.is_vertical() { position_style.min_height } else { position_style.min_width } } /// Get the logical computed min block size. #[inline] - pub fn min_block_size(&self) -> computed::NonNegativeLengthPercentage { + pub fn min_block_size(&self) -> computed::Size { let position_style = self.get_position(); if self.writing_mode.is_vertical() { position_style.min_width } else { position_style.min_height } } /// Get the logical computed max inline size. #[inline] - pub fn max_inline_size(&self) -> computed::MaxLength { + pub fn max_inline_size(&self) -> computed::MaxSize { let position_style = self.get_position(); if self.writing_mode.is_vertical() { position_style.max_height } else { position_style.max_width } } /// Get the logical computed max block size. #[inline] - pub fn max_block_size(&self) -> computed::MaxLength { + pub fn max_block_size(&self) -> computed::MaxSize { let position_style = self.get_position(); if self.writing_mode.is_vertical() { position_style.max_width } else { position_style.max_height } } diff --git a/components/style/values/computed/flex.rs b/components/style/values/computed/flex.rs index a48d7800752..c0c2703732f 100644 --- a/components/style/values/computed/flex.rs +++ b/components/style/values/computed/flex.rs @@ -4,23 +4,16 @@ //! Computed types for CSS values related to flexbox. +use crate::values::computed::Size; use crate::values::generics::flex::FlexBasis as GenericFlexBasis; -/// The `width` value type. -#[cfg(feature = "servo")] -pub type Width = crate::values::computed::NonNegativeLengthPercentageOrAuto; - -/// The `width` value type. -#[cfg(feature = "gecko")] -pub type Width = crate::values::computed::MozLength; - /// A computed value for the `flex-basis` property. -pub type FlexBasis = GenericFlexBasis; +pub type FlexBasis = GenericFlexBasis; impl FlexBasis { /// `auto` #[inline] pub fn auto() -> Self { - GenericFlexBasis::Width(Width::auto()) + GenericFlexBasis::Width(Size::auto()) } } diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 313b4151d2b..6cdf359d16a 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -8,9 +8,7 @@ use super::{Context, Number, Percentage, ToComputedValue}; use crate::values::animated::ToAnimatedValue; use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; use crate::values::generics::length as generics; -use crate::values::generics::length::{ - MaxLength as GenericMaxLength, MozLength as GenericMozLength, -}; +use crate::values::generics::length::{MaxSize as GenericMaxSize, Size as GenericSize}; use crate::values::generics::transform::IsZeroLength; use crate::values::generics::NonNegative; use crate::values::specified::length::ViewportPercentageLength; @@ -580,12 +578,36 @@ impl NonNegativeLengthPercentage { } #[cfg(feature = "servo")] -impl MaxLength { +impl MaxSize { /// Convert the computed value into used value. + #[inline] pub fn to_used_value(&self, percentage_basis: Au) -> Option { match *self { - GenericMaxLength::None => None, - GenericMaxLength::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)), + GenericMaxSize::None => None, + GenericMaxSize::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)), + } + } +} + +impl Size { + /// Convert the computed value into used value. + #[inline] + #[cfg(feature = "servo")] + pub fn to_used_value(&self, percentage_basis: Au) -> Option { + match *self { + GenericSize::Auto => None, + GenericSize::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)), + } + } + + /// Returns true if the computed value is absolute 0 or 0%. + #[inline] + pub fn is_definitely_zero(&self) -> bool { + match *self { + GenericSize::Auto => false, + GenericSize::LengthPercentage(ref lp) => lp.is_definitely_zero(), + #[cfg(feature = "gecko")] + GenericSize::ExtremumLength(..) => false, } } } @@ -821,7 +843,7 @@ pub enum ExtremumLength { } /// A computed value for `min-width`, `min-height`, `width` or `height` property. -pub type MozLength = GenericMozLength; +pub type Size = GenericSize; /// A computed value for `max-width` or `min-height` property. -pub type MaxLength = GenericMaxLength; +pub type MaxSize = GenericMaxSize; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index ab8edd2b746..8158e1a16d7 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -62,7 +62,7 @@ pub use self::gecko::ScrollSnapPoint; pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection, MozImageRect}; pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength}; pub use self::length::{Length, LengthOrNumber, LengthPercentage}; -pub use self::length::{LengthPercentageOrAuto, MaxLength, MozLength}; +pub use self::length::{LengthPercentageOrAuto, MaxSize, Size}; pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto}; #[cfg(feature = "gecko")] pub use self::list::ListStyleType; diff --git a/components/style/values/generics/length.rs b/components/style/values/generics/length.rs index 61be27e4fd2..f55db4f52c5 100644 --- a/components/style/values/generics/length.rs +++ b/components/style/values/generics/length.rs @@ -5,6 +5,7 @@ //! Generic types for CSS values related to length. use crate::parser::{Parse, ParserContext}; +#[cfg(feature = "gecko")] use crate::values::computed::ExtremumLength; use cssparser::Parser; use style_traits::ParseError; @@ -76,7 +77,7 @@ impl Parse for LengthPercentageOrAuto /// A generic value for the `width`, `height`, `min-width`, or `min-height` property. /// -/// Unlike `max-width` or `max-height` properties, a MozLength can be `auto`, +/// Unlike `max-width` or `max-height` properties, a Size can be `auto`, /// and cannot be `none`. /// /// Note that it only accepts non-negative values. @@ -95,18 +96,25 @@ impl Parse for LengthPercentageOrAuto ToComputedValue, ToCss, )] -pub enum MozLength { +pub enum Size { LengthPercentage(LengthPercentage), Auto, + #[cfg(feature = "gecko")] #[animation(error)] ExtremumLength(ExtremumLength), } -impl MozLength { +impl Size { /// `auto` value. #[inline] pub fn auto() -> Self { - MozLength::Auto + Size::Auto + } + + /// Returns whether we're the auto value. + #[inline] + pub fn is_auto(&self) -> bool { + matches!(*self, Size::Auto) } } @@ -126,7 +134,7 @@ impl MozLength { ToComputedValue, ToCss, )] -pub enum MaxLength { +pub enum MaxSize { LengthPercentage(LengthPercentage), None, #[cfg(feature = "gecko")] @@ -134,10 +142,10 @@ pub enum MaxLength { ExtremumLength(ExtremumLength), } -impl MaxLength { +impl MaxSize { /// `none` value. #[inline] pub fn none() -> Self { - MaxLength::None + MaxSize::None } } diff --git a/components/style/values/specified/flex.rs b/components/style/values/specified/flex.rs index c0b587c5a79..a1131dbff5f 100644 --- a/components/style/values/specified/flex.rs +++ b/components/style/values/specified/flex.rs @@ -6,26 +6,19 @@ use crate::parser::{Parse, ParserContext}; use crate::values::generics::flex::FlexBasis as GenericFlexBasis; +use crate::values::specified::Size; use cssparser::Parser; use style_traits::ParseError; -/// The `width` value type. -#[cfg(feature = "servo")] -pub type Width = crate::values::specified::NonNegativeLengthPercentageOrAuto; - -/// The `width` value type. -#[cfg(feature = "gecko")] -pub type Width = crate::values::specified::MozLength; - /// A specified value for the `flex-basis` property. -pub type FlexBasis = GenericFlexBasis; +pub type FlexBasis = GenericFlexBasis; impl Parse for FlexBasis { fn parse<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - if let Ok(width) = input.try(|i| Width::parse(context, i)) { + if let Ok(width) = input.try(|i| Size::parse(context, i)) { return Ok(GenericFlexBasis::Width(width)); } try_match_ident_ignore_ascii_case! { input, @@ -38,12 +31,12 @@ impl FlexBasis { /// `auto` #[inline] pub fn auto() -> Self { - GenericFlexBasis::Width(Width::auto()) + GenericFlexBasis::Width(Size::auto()) } /// `0%` #[inline] pub fn zero_percent() -> Self { - GenericFlexBasis::Width(Width::zero_percent()) + GenericFlexBasis::Width(Size::zero_percent()) } } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 9da17990078..597aa990f0c 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -9,11 +9,9 @@ use super::{AllowQuirks, Number, Percentage, ToComputedValue}; use crate::font_metrics::FontMetricsQueryResult; use crate::parser::{Parse, ParserContext}; -use crate::values::computed::{self, CSSPixelLength, Context, ExtremumLength}; +use crate::values::computed::{self, CSSPixelLength, Context}; use crate::values::generics::length as generics; -use crate::values::generics::length::{ - MaxLength as GenericMaxLength, MozLength as GenericMozLength, -}; +use crate::values::generics::length::{MaxSize as GenericMaxSize, Size as GenericSize}; use crate::values::generics::transform::IsZeroLength; use crate::values::generics::NonNegative; use crate::values::specified::calc::CalcNode; @@ -1051,56 +1049,18 @@ impl LengthOrNumber { } /// A specified value for `min-width`, `min-height`, `width` or `height` property. -pub type MozLength = GenericMozLength; +pub type Size = GenericSize; -impl Parse for MozLength { +impl Parse for Size { fn parse<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - MozLength::parse_quirky(context, input, AllowQuirks::No) + Size::parse_quirky(context, input, AllowQuirks::No) } } -impl MozLength { - /// Parses, with quirks. - pub fn parse_quirky<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - allow_quirks: AllowQuirks, - ) -> Result> { - if let Ok(l) = input.try(ExtremumLength::parse) { - return Ok(GenericMozLength::ExtremumLength(l)); - } - - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { - return Ok(GenericMozLength::Auto); - } - - let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?; - Ok(GenericMozLength::LengthPercentage(length)) - } - - /// Returns `0%`. - #[inline] - pub fn zero_percent() -> Self { - GenericMozLength::LengthPercentage(NonNegativeLengthPercentage::zero_percent()) - } -} - -/// A specified value for `max-width` or `max-height` property. -pub type MaxLength = GenericMaxLength; - -impl Parse for MaxLength { - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - MaxLength::parse_quirky(context, input, AllowQuirks::No) - } -} - -impl MaxLength { +impl Size { /// Parses, with quirks. pub fn parse_quirky<'i, 't>( context: &ParserContext, @@ -1109,16 +1069,57 @@ impl MaxLength { ) -> Result> { #[cfg(feature = "gecko")] { - if let Ok(l) = input.try(ExtremumLength::parse) { - return Ok(GenericMaxLength::ExtremumLength(l)); + if let Ok(l) = input.try(computed::ExtremumLength::parse) { + return Ok(GenericSize::ExtremumLength(l)); + } + } + + if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + return Ok(GenericSize::Auto); + } + + let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?; + Ok(GenericSize::LengthPercentage(length)) + } + + /// Returns `0%`. + #[inline] + pub fn zero_percent() -> Self { + GenericSize::LengthPercentage(NonNegativeLengthPercentage::zero_percent()) + } +} + +/// A specified value for `max-width` or `max-height` property. +pub type MaxSize = GenericMaxSize; + +impl Parse for MaxSize { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + MaxSize::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl MaxSize { + /// Parses, with quirks. + pub fn parse_quirky<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + allow_quirks: AllowQuirks, + ) -> Result> { + #[cfg(feature = "gecko")] + { + if let Ok(l) = input.try(computed::ExtremumLength::parse) { + return Ok(GenericMaxSize::ExtremumLength(l)); } } if input.try(|i| i.expect_ident_matching("none")).is_ok() { - return Ok(GenericMaxLength::None); + return Ok(GenericMaxSize::None); } let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?; - Ok(GenericMaxLength::LengthPercentage(length)) + Ok(GenericMaxSize::LengthPercentage(length)) } } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index b37d2554c34..a9582e90307 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -59,7 +59,7 @@ pub use self::image::{GradientItem, GradientKind, Image, ImageLayer, MozImageRec pub use self::length::{AbsoluteLength, CalcLengthPercentage, CharacterWidth}; pub use self::length::{FontRelativeLength, Length, LengthOrNumber}; pub use self::length::{LengthPercentage, LengthPercentageOrAuto}; -pub use self::length::{MaxLength, MozLength}; +pub use self::length::{MaxSize, Size}; pub use self::length::{NoCalcLength, ViewportPercentageLength}; pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto}; #[cfg(feature = "gecko")] diff --git a/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html.ini b/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html.ini index 4cc18af97e5..2f1915e3b6f 100644 --- a/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html.ini +++ b/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html.ini @@ -1,7 +1,7 @@ [flexbox_computedstyle_min-auto-size.html] - [Computed min-width/min-height of specified auto for flex item.] + [Computed min-width/min-height of specified auto inside display:none which would otherwise have been a flex item.] expected: FAIL - [Computed min-width/min-height of specified auto for flex item inside display:contents.] + [Computed min-width/min-height of specified auto with display:none which would otherwise have been a flex item.] expected: FAIL diff --git a/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-height-auto.html.ini b/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-height-auto.html.ini deleted file mode 100644 index f0d4f73650a..00000000000 --- a/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-height-auto.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[flexbox_computedstyle_min-height-auto.html] - type: testharness - [flexbox | computed style | min-height: auto] - expected: FAIL - diff --git a/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-width-auto.html.ini b/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-width-auto.html.ini deleted file mode 100644 index 5017c167530..00000000000 --- a/tests/wpt/metadata/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-width-auto.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[flexbox_computedstyle_min-width-auto.html] - type: testharness - [flexbox | computed style | min-width: auto] - expected: FAIL -