diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs index 657d36258fa..74b42e6bc8d 100644 --- a/components/layout_2020/flexbox/layout.rs +++ b/components/layout_2020/flexbox/layout.rs @@ -2389,7 +2389,7 @@ impl FlexItemBox { layout_context, config .flex_axis - .vec2_to_flex_relative(containing_block.size.map(|v| v.non_auto())), + .vec2_to_flex_relative(containing_block.size), cross_axis_is_item_block_axis, content_box_size, content_min_size_no_auto, @@ -2498,7 +2498,7 @@ impl FlexItemBox { fn automatic_min_size( &self, layout_context: &LayoutContext, - containing_block_size: FlexRelativeVec2, + containing_block_size: FlexRelativeVec2>, cross_axis_is_item_block_axis: bool, content_box_size: FlexRelativeVec2>, min_size: FlexRelativeVec2>, @@ -2520,7 +2520,6 @@ impl FlexItemBox { let specified_size_suggestion = content_box_size.main.maybe_resolve_extrinsic( containing_block_size .main - .non_auto() .map(|v| v - pbm_auto_is_zero.main), ); @@ -2535,7 +2534,6 @@ impl FlexItemBox { if content_box_size.cross.is_initial() && auto_cross_size_stretches_to_container_size { containing_block_size .cross - .non_auto() .map(|v| v - pbm_auto_is_zero.cross) } else { // TODO(#32853): handle size keywords. diff --git a/components/layout_2020/geom.rs b/components/layout_2020/geom.rs index 80898c31090..8b389a524f0 100644 --- a/components/layout_2020/geom.rs +++ b/components/layout_2020/geom.rs @@ -898,19 +898,11 @@ impl SizeConstraint { _ => None, } } - - #[inline] - pub(crate) fn to_auto_or(self) -> AutoOr { - self.to_definite() - .map_or(AutoOr::Auto, AutoOr::LengthPercentage) - } } -impl From for SizeConstraint { - fn from(size: AuOrAuto) -> Self { - size.non_auto() - .map(SizeConstraint::Definite) - .unwrap_or_default() +impl From> for SizeConstraint { + fn from(size: Option) -> Self { + size.map(SizeConstraint::Definite).unwrap_or_default() } } diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs index a3410ddff66..cf9ef4919e2 100644 --- a/components/layout_2020/lib.rs +++ b/components/layout_2020/lib.rs @@ -30,7 +30,6 @@ pub mod traversal; use app_units::Au; pub use flow::BoxTree; pub use fragment_tree::FragmentTree; -use geom::AuOrAuto; use style::logical_geometry::WritingMode; use style::properties::ComputedValues; use style::values::computed::TextDecorationLine; @@ -75,7 +74,7 @@ impl ConstraintSpace { /// Useful for code that is shared for both layout (where we know the inline size /// of the containing block) and intrinsic sizing (where we don't know it). pub(crate) struct IndefiniteContainingBlock { - pub size: LogicalVec2, + pub size: LogicalVec2>, pub writing_mode: WritingMode, } @@ -83,8 +82,8 @@ impl From<&ConstraintSpace> for IndefiniteContainingBlock { fn from(constraint_space: &ConstraintSpace) -> Self { Self { size: LogicalVec2 { - inline: AuOrAuto::Auto, - block: constraint_space.block_size.to_auto_or(), + inline: None, + block: constraint_space.block_size.to_definite(), }, writing_mode: constraint_space.writing_mode, } @@ -95,8 +94,8 @@ impl<'a> From<&'_ ContainingBlock<'a>> for IndefiniteContainingBlock { fn from(containing_block: &ContainingBlock<'a>) -> Self { Self { size: LogicalVec2 { - inline: AuOrAuto::LengthPercentage(containing_block.size.inline), - block: containing_block.size.block.to_auto_or(), + inline: Some(containing_block.size.inline), + block: containing_block.size.block.to_definite(), }, writing_mode: containing_block.style.writing_mode, } @@ -106,9 +105,7 @@ impl<'a> From<&'_ ContainingBlock<'a>> for IndefiniteContainingBlock { impl<'a> From<&'_ DefiniteContainingBlock<'a>> for IndefiniteContainingBlock { fn from(containing_block: &DefiniteContainingBlock<'a>) -> Self { Self { - size: containing_block - .size - .map(|v| AuOrAuto::LengthPercentage(*v)), + size: containing_block.size.map(|v| Some(*v)), writing_mode: containing_block.style.writing_mode, } } diff --git a/components/layout_2020/sizing.rs b/components/layout_2020/sizing.rs index 159ad8c781d..1e53eb251eb 100644 --- a/components/layout_2020/sizing.rs +++ b/components/layout_2020/sizing.rs @@ -142,7 +142,6 @@ pub(crate) fn outer_inline( let available_block_size = containing_block .size .block - .non_auto() .map(|v| Au::zero().max(v - pbm_sums.block)); let automatic_size = if content_box_sizes.block.preferred.is_initial() && auto_block_size_stretches_to_containing_block diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs index d3156298fbc..5a0b46f06f8 100644 --- a/components/layout_2020/style_ext.rs +++ b/components/layout_2020/style_ext.rs @@ -840,13 +840,12 @@ impl LayoutStyle<'_> { // indefinite percentages, we treat the entire value as the initial value of the property. // However, for min size properties, as well as for margins and paddings, // we instead resolve indefinite percentages against zero. - let containing_block_size = containing_block.size.map(|value| value.non_auto()); - let containing_block_size_auto_is_zero = - containing_block_size.map(|value| value.unwrap_or_else(Au::zero)); + let containing_block_size_or_zero = + containing_block.size.map(|value| value.unwrap_or_default()); let writing_mode = containing_block.writing_mode; let pbm = self.padding_border_margin_with_writing_mode_and_containing_block_inline_size( writing_mode, - containing_block.size.inline.auto_is(Au::zero), + containing_block_size_or_zero.inline, ); let style = self.style(); let box_size = style.box_size(writing_mode); @@ -872,15 +871,15 @@ impl LayoutStyle<'_> { depends_on_block_constraints(&max_size.block) || style.depends_on_block_constraints_due_to_relative_positioning(writing_mode); - let box_size = box_size.maybe_percentages_relative_to_basis(&containing_block_size); + let box_size = box_size.maybe_percentages_relative_to_basis(&containing_block.size); let content_box_size = style .content_box_size_for_box_size(box_size, &pbm) .map(|v| v.map(Au::from)); - let min_size = min_size.percentages_relative_to_basis(&containing_block_size_auto_is_zero); + let min_size = min_size.percentages_relative_to_basis(&containing_block_size_or_zero); let content_min_box_size = style .content_min_box_size_for_min_size(min_size, &pbm) .map(|v| v.map(Au::from)); - let max_size = max_size.maybe_percentages_relative_to_basis(&containing_block_size); + let max_size = max_size.maybe_percentages_relative_to_basis(&containing_block.size); let content_max_box_size = style .content_max_box_size_for_max_size(max_size, &pbm) .map(|v| v.map(Au::from)); diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index 526e8d68120..b581f1ce8dc 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -35,7 +35,7 @@ use crate::fragment_tree::{ PositioningFragment, SpecificLayoutInfo, }; use crate::geom::{ - AuOrAuto, LogicalRect, LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, + LogicalRect, LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalVec, Size, SizeConstraint, ToLogical, ToLogicalWithContainingBlock, }; use crate::positioned::{relative_adjustement, PositioningContext, PositioningContextLength}; @@ -704,10 +704,7 @@ impl<'a> TableLayout<'a> { /// Compute CAPMIN: fn compute_caption_minimum_inline_size(&self, layout_context: &LayoutContext) -> Au { let containing_block = IndefiniteContainingBlock { - size: LogicalVec2 { - inline: AuOrAuto::Auto, - block: AuOrAuto::Auto, - }, + size: LogicalVec2::default(), writing_mode: self.table.style.writing_mode, }; self.table