diff --git a/components/layout_2020/display_list/background.rs b/components/layout_2020/display_list/background.rs index c6608d4e09a..caa30edf43c 100644 --- a/components/layout_2020/display_list/background.rs +++ b/components/layout_2020/display_list/background.rs @@ -9,7 +9,7 @@ use style::computed_values::background_clip::single_value::T as Clip; use style::computed_values::background_origin::single_value::T as Origin; use style::properties::ComputedValues; use style::values::computed::background::BackgroundSize as Size; -use style::values::computed::{Length, LengthPercentage}; +use style::values::computed::LengthPercentage; use style::values::specified::background::{ BackgroundRepeat as RepeatXY, BackgroundRepeatKeyword as Repeat, }; @@ -204,42 +204,42 @@ pub(super) fn layout_layer( Size::Cover => size_contain_or_cover(ContainOrCover::Cover), Size::ExplicitSize { width, height } => { let mut width = width.non_auto().map(|lp| { - lp.0.percentage_relative_to(Length::new(positioning_area.size().width)) + lp.0.to_used_value(Au::from_f32_px(positioning_area.size().width)) }); let mut height = height.non_auto().map(|lp| { - lp.0.percentage_relative_to(Length::new(positioning_area.size().height)) + lp.0.to_used_value(Au::from_f32_px(positioning_area.size().height)) }); if width.is_none() && height.is_none() { // Both computed values are 'auto': // use intrinsic sizes, treating missing width or height as 'auto' - width = intrinsic.width.map(|v| v.into()); - height = intrinsic.height.map(|v| v.into()); + width = intrinsic.width; + height = intrinsic.height; } match (width, height) { - (Some(w), Some(h)) => units::LayoutSize::new(w.px(), h.px()), + (Some(w), Some(h)) => units::LayoutSize::new(w.to_f32_px(), h.to_f32_px()), (Some(w), None) => { let h = if let Some(intrinsic_ratio) = intrinsic.ratio { - w / intrinsic_ratio + w.scale_by(1.0 / intrinsic_ratio) } else if let Some(intrinsic_height) = intrinsic.height { - intrinsic_height.into() + intrinsic_height } else { // Treated as 100% - Au::from_f32_px(positioning_area.size().height).into() + Au::from_f32_px(positioning_area.size().height) }; - units::LayoutSize::new(w.px(), h.px()) + units::LayoutSize::new(w.to_f32_px(), h.to_f32_px()) }, (None, Some(h)) => { let w = if let Some(intrinsic_ratio) = intrinsic.ratio { - h * intrinsic_ratio + h.scale_by(intrinsic_ratio) } else if let Some(intrinsic_width) = intrinsic.width { - intrinsic_width.into() + intrinsic_width } else { // Treated as 100% - Au::from_f32_px(positioning_area.size().width).into() + Au::from_f32_px(positioning_area.size().width) }; - units::LayoutSize::new(w.px(), h.px()) + units::LayoutSize::new(w.to_f32_px(), h.to_f32_px()) }, // Both comptued values were 'auto', and neither intrinsic size is present (None, None) => size_contain_or_cover(ContainOrCover::Contain), @@ -299,8 +299,8 @@ fn layout_1d( } // https://drafts.csswg.org/css-backgrounds/#background-position let mut position = position - .percentage_relative_to(Length::new(positioning_area_size - *tile_size)) - .px(); + .to_used_value(Au::from_f32_px(positioning_area_size - *tile_size)) + .to_f32_px(); let mut tile_spacing = 0.0; // https://drafts.csswg.org/css-backgrounds/#background-repeat if let Repeat::Space = repeat { diff --git a/components/layout_2020/display_list/clip_path.rs b/components/layout_2020/display_list/clip_path.rs index ffb6d96dd24..299de01ad2a 100644 --- a/components/layout_2020/display_list/clip_path.rs +++ b/components/layout_2020/display_list/clip_path.rs @@ -2,9 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use app_units::Au; use style::values::computed::basic_shape::{BasicShape, ClipPath}; -use style::values::computed::length::Length; -use style::values::computed::length_percentage::{LengthPercentage, NonNegativeLengthPercentage}; +use style::values::computed::length_percentage::NonNegativeLengthPercentage; use style::values::computed::position::Position; use style::values::generics::basic_shape::{GenericShapeRadius, ShapeBox, ShapeGeometryBox}; use style::values::generics::position::GenericPositionOrAuto; @@ -74,11 +74,13 @@ fn build_simple_shape( ) -> Option { match shape { BasicShape::Rect(rect) => { + let box_height = Au::from_f32_px(layout_box.height()); + let box_width = Au::from_f32_px(layout_box.width()); let insets = LayoutSideOffsets::new( - rect.rect.0.resolve(Length::new(layout_box.height())).px(), - rect.rect.1.resolve(Length::new(layout_box.width())).px(), - rect.rect.2.resolve(Length::new(layout_box.height())).px(), - rect.rect.3.resolve(Length::new(layout_box.width())).px(), + rect.rect.0.to_used_value(box_height).to_f32_px(), + rect.rect.1.to_used_value(box_width).to_f32_px(), + rect.rect.2.to_used_value(box_height).to_f32_px(), + rect.rect.3.to_used_value(box_width).to_f32_px(), ); // `inner_rect()` will cause an assertion failure if the insets are larger than the @@ -91,13 +93,10 @@ fn build_simple_shape( layout_box.to_rect().inner_rect(insets).to_box2d() }; - let resolve = |radius: &LengthPercentage, box_size: f32| { - radius.percentage_relative_to(Length::new(box_size)).px() - }; let corner = |corner: &style::values::computed::BorderCornerRadius| { LayoutSize::new( - resolve(&corner.0.width.0, layout_box.size().width), - resolve(&corner.0.height.0, layout_box.size().height), + corner.0.width.0.to_used_value(box_width).to_f32_px(), + corner.0.height.0.to_used_value(box_height).to_f32_px(), ) }; let mut radii = webrender_api::BorderRadius { @@ -120,11 +119,15 @@ fn build_simple_shape( GenericPositionOrAuto::Position(position) => position, GenericPositionOrAuto::Auto => Position::center(), }; - let anchor_x = center.horizontal.resolve(Length::new(layout_box.width())); - let anchor_y = center.vertical.resolve(Length::new(layout_box.height())); + let anchor_x = center + .horizontal + .to_used_value(Au::from_f32_px(layout_box.width())); + let anchor_y = center + .vertical + .to_used_value(Au::from_f32_px(layout_box.height())); let center = layout_box .min - .add_size(&LayoutSize::new(anchor_x.px(), anchor_y.px())); + .add_size(&LayoutSize::new(anchor_x.to_f32_px(), anchor_y.to_f32_px())); let horizontal = compute_shape_radius(center.x, &circle.radius, layout_box.min.x, layout_box.max.x); @@ -160,11 +163,15 @@ fn build_simple_shape( GenericPositionOrAuto::Position(position) => position, GenericPositionOrAuto::Auto => Position::center(), }; - let anchor_x = center.horizontal.resolve(Length::new(layout_box.width())); - let anchor_y = center.vertical.resolve(Length::new(layout_box.height())); + let anchor_x = center + .horizontal + .to_used_value(Au::from_f32_px(layout_box.width())); + let anchor_y = center + .vertical + .to_used_value(Au::from_f32_px(layout_box.height())); let center = layout_box .min - .add_size(&LayoutSize::new(anchor_x.px(), anchor_y.px())); + .add_size(&LayoutSize::new(anchor_x.to_f32_px(), anchor_y.to_f32_px())); let width = compute_shape_radius( center.x, @@ -212,9 +219,10 @@ fn compute_shape_radius( match radius { GenericShapeRadius::FarthestSide => distance_from_min_edge.max(distance_from_max_edge), GenericShapeRadius::ClosestSide => distance_from_min_edge.min(distance_from_max_edge), - GenericShapeRadius::Length(length) => { - length.0.resolve(Length::new(max_edge - min_edge)).px() - }, + GenericShapeRadius::Length(length) => length + .0 + .to_used_value(Au::from_f32_px(max_edge - min_edge)) + .to_f32_px(), } } fn create_rect_clip_chain( diff --git a/components/layout_2020/display_list/gradient.rs b/components/layout_2020/display_list/gradient.rs index 08f2ad5e0ea..b31ec568337 100644 --- a/components/layout_2020/display_list/gradient.rs +++ b/components/layout_2020/display_list/gradient.rs @@ -2,16 +2,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use app_units::Au; use euclid::Size2D; use style::color::mix::ColorInterpolationMethod; use style::properties::ComputedValues; use style::values::computed::image::{EndingShape, Gradient, LineDirection}; -use style::values::computed::{ - Angle, AngleOrPercentage, Color, Length, LengthPercentage, Position, -}; +use style::values::computed::{Angle, AngleOrPercentage, Color, LengthPercentage, Position}; use style::values::generics::image::{ Circle, ColorStop, Ellipse, GradientFlags, GradientItem, ShapeExtent, }; +use style::Zero; use webrender_api::units::LayoutPixel; use webrender_api::{ self as wr, units, ConicGradient as WebRenderConicGradient, @@ -171,7 +171,7 @@ pub(super) fn build_linear( let end_point = center + half_gradient_line; let mut color_stops = - gradient_items_to_color_stops(style, items, Length::new(gradient_line_length)); + gradient_items_to_color_stops(style, items, Au::from_f32_px(gradient_line_length)); let stops = fixup_stops(&mut color_stops); let extend_mode = if flags.contains(GradientFlags::REPEATING) { wr::ExtendMode::Repeat @@ -201,12 +201,12 @@ pub(super) fn build_radial( let center = units::LayoutPoint::new( center .horizontal - .percentage_relative_to(Length::new(gradient_box.width)) - .px(), + .to_used_value(Au::from_f32_px(gradient_box.width)) + .to_f32_px(), center .vertical - .percentage_relative_to(Length::new(gradient_box.height)) - .px(), + .to_used_value(Au::from_f32_px(gradient_box.height)) + .to_f32_px(), ); let radii = match shape { EndingShape::Circle(circle) => { @@ -232,10 +232,10 @@ pub(super) fn build_radial( units::LayoutSize::new(radius, radius) }, EndingShape::Ellipse(Ellipse::Radii(rx, ry)) => units::LayoutSize::new( - rx.0.percentage_relative_to(Length::new(gradient_box.width)) - .px(), - ry.0.percentage_relative_to(Length::new(gradient_box.height)) - .px(), + rx.0.to_used_value(Au::from_f32_px(gradient_box.width)) + .to_f32_px(), + ry.0.to_used_value(Au::from_f32_px(gradient_box.height)) + .to_f32_px(), ), EndingShape::Ellipse(Ellipse::Extent(extent)) => match extent { ShapeExtent::ClosestSide | ShapeExtent::Contain => { @@ -275,7 +275,7 @@ pub(super) fn build_radial( let gradient_line_length = radii.width; let mut color_stops = - gradient_items_to_color_stops(style, items, Length::new(gradient_line_length)); + gradient_items_to_color_stops(style, items, Au::from_f32_px(gradient_line_length)); let stops = fixup_stops(&mut color_stops); let extend_mode = if flags.contains(GradientFlags::REPEATING) { wr::ExtendMode::Repeat @@ -305,12 +305,12 @@ fn build_conic( let center = units::LayoutPoint::new( center .horizontal - .percentage_relative_to(Length::new(gradient_box.width)) - .px(), + .to_used_value(Au::from_f32_px(gradient_box.width)) + .to_f32_px(), center .vertical - .percentage_relative_to(Length::new(gradient_box.height)) - .px(), + .to_used_value(Au::from_f32_px(gradient_box.height)) + .to_f32_px(), ); let mut color_stops = conic_gradient_items_to_color_stops(style, items); let stops = fixup_stops(&mut color_stops); @@ -367,7 +367,7 @@ fn conic_gradient_items_to_color_stops( fn gradient_items_to_color_stops( style: &ComputedValues, items: &[GradientItem], - gradient_line_length: Length, + gradient_line_length: Au, ) -> Vec> { // Remove color transititon hints, which are not supported yet. // https://drafts.csswg.org/css-images-4/#color-transition-hint @@ -389,11 +389,13 @@ fn gradient_items_to_color_stops( }), GradientItem::ComplexColorStop { color, position } => Some(ColorStop { color: super::rgba(style.resolve_color(color.clone())), - position: Some(if gradient_line_length.px() == 0. { + position: Some(if gradient_line_length.is_zero() { 0. } else { - position.percentage_relative_to(gradient_line_length).px() / - gradient_line_length.px() + position + .to_used_value(gradient_line_length) + .scale_by(1. / gradient_line_length.to_f32_px()) + .to_f32_px() }), }), // FIXME: approximate like in: diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index dcc912ef903..659825d5aa1 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -24,7 +24,7 @@ use style::properties::style_structs::Border; use style::properties::ComputedValues; use style::values::computed::image::Image; use style::values::computed::{ - BorderImageSideWidth, BorderImageWidth, BorderStyle, Color, Length, LengthPercentage, + BorderImageSideWidth, BorderImageWidth, BorderStyle, Color, LengthPercentage, LengthPercentageOrAuto, NonNegativeLengthOrNumber, NumberOrPercentage, OutlineStyle, }; use style::values::generics::rect::Rect; @@ -495,19 +495,19 @@ struct BuilderForBoxFragment<'a> { impl<'a> BuilderForBoxFragment<'a> { fn new(fragment: &'a BoxFragment, containing_block: &'a PhysicalRect) -> Self { - let border_rect: units::LayoutRect = fragment + let border_rect = fragment .border_rect() - .translate(containing_block.origin.to_vector()) - .to_webrender(); + .translate(containing_block.origin.to_vector()); + let webrender_border_rect = border_rect.to_webrender(); let border_radius = { - let resolve = |radius: &LengthPercentage, box_size: f32| { - radius.percentage_relative_to(Length::new(box_size)).px() + let resolve = |radius: &LengthPercentage, box_size: Au| { + radius.to_used_value(box_size).to_f32_px() }; let corner = |corner: &style::values::computed::BorderCornerRadius| { Size2D::new( - resolve(&corner.0.width.0, border_rect.size().width), - resolve(&corner.0.height.0, border_rect.size().height), + resolve(&corner.0.width.0, border_rect.size.width), + resolve(&corner.0.height.0, border_rect.size.height), ) }; let b = fragment.style.get_border(); @@ -517,14 +517,15 @@ impl<'a> BuilderForBoxFragment<'a> { bottom_right: corner(&b.border_bottom_right_radius), bottom_left: corner(&b.border_bottom_left_radius), }; - normalize_radii(&border_rect, &mut radius); + + normalize_radii(&webrender_border_rect, &mut radius); radius }; Self { fragment, containing_block, - border_rect, + border_rect: webrender_border_rect, border_radius, margin_rect: OnceCell::new(), padding_rect: OnceCell::new(), @@ -1343,14 +1344,14 @@ pub(super) fn compute_margin_box_radius( let width = margin .width .auto_is(LengthPercentage::zero) - .resolve(Length::new(layout_rect.width)); + .to_used_value(Au::from_f32_px(layout_rect.width)); let height = margin .height .auto_is(LengthPercentage::zero) - .resolve(Length::new(layout_rect.height)); + .to_used_value(Au::from_f32_px(layout_rect.height)); LayoutSize::new( - adjust_radius(radius.width, width.px()), - adjust_radius(radius.height, height.px()), + adjust_radius(radius.width, width.to_f32_px()), + adjust_radius(radius.height, height.to_f32_px()), ) }; wr::BorderRadius { diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs index 6809c9df577..214c280d4a8 100644 --- a/components/layout_2020/display_list/stacking_context.rs +++ b/components/layout_2020/display_list/stacking_context.rs @@ -1363,23 +1363,15 @@ impl BoxFragment { // nearest scroll frame instead of the containing block like for other types // of positioning. let position = self.style.get_position(); + let scroll_frame_height = Au::from_f32_px(scroll_frame_size_for_resolve.height); + let scroll_frame_width = Au::from_f32_px(scroll_frame_size_for_resolve.width); let offsets = PhysicalSides::::new( - position.top.map(|v| { - v.resolve(Length::new(scroll_frame_size_for_resolve.height)) - .into() - }), - position.right.map(|v| { - v.resolve(Length::new(scroll_frame_size_for_resolve.width)) - .into() - }), - position.bottom.map(|v| { - v.resolve(Length::new(scroll_frame_size_for_resolve.height)) - .into() - }), - position.left.map(|v| { - v.resolve(Length::new(scroll_frame_size_for_resolve.width)) - .into() - }), + position.top.map(|v| v.to_used_value(scroll_frame_height)), + position.right.map(|v| v.to_used_value(scroll_frame_width)), + position + .bottom + .map(|v| v.to_used_value(scroll_frame_height)), + position.left.map(|v| v.to_used_value(scroll_frame_width)), ); self.resolved_sticky_insets = Some(offsets); diff --git a/components/layout_2020/flow/float.rs b/components/layout_2020/flow/float.rs index f3c66a5febb..6a3aec1b77f 100644 --- a/components/layout_2020/flow/float.rs +++ b/components/layout_2020/flow/float.rs @@ -1268,6 +1268,6 @@ impl SequentialLayoutState { .size .to_logical(container_writing_mode), } - .to_physical(Some(&containing_block)); + .to_physical(Some(containing_block)); } } diff --git a/components/layout_2020/flow/inline/line.rs b/components/layout_2020/flow/inline/line.rs index 0484b294b9b..cb8d98a37a6 100644 --- a/components/layout_2020/flow/inline/line.rs +++ b/components/layout_2020/flow/inline/line.rs @@ -9,7 +9,6 @@ use itertools::Either; use servo_arc::Arc; use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse; use style::properties::ComputedValues; -use style::values::computed::Length; use style::values::generics::box_::{GenericVerticalAlign, VerticalAlignKeyword}; use style::values::generics::font::LineHeight; use style::values::specified::align::AlignFlags; @@ -433,7 +432,7 @@ impl<'layout_data, 'layout> LineItemLayout<'layout_data, 'layout> { let inline_box_containing_block = ContainingBlock { inline_size: content_rect.size.inline, block_size: AuOrAuto::Auto, - style: &self.layout.containing_block.style, + style: self.layout.containing_block.style, }; let fragments = inner_state .fragments @@ -515,11 +514,11 @@ impl<'layout_data, 'layout> LineItemLayout<'layout_data, 'layout> { // baseline, so we need to make it relative to the line block start. match inline_box_state.base.style.clone_vertical_align() { GenericVerticalAlign::Keyword(VerticalAlignKeyword::Top) => { - let line_height: Au = line_height(style, font_metrics).into(); + let line_height: Au = line_height(style, font_metrics); (line_height - line_gap).scale_by(0.5) }, GenericVerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => { - let line_height: Au = line_height(style, font_metrics).into(); + let line_height: Au = line_height(style, font_metrics); let half_leading = (line_height - line_gap).scale_by(0.5); self.line_metrics.block_size - line_height + half_leading }, @@ -875,13 +874,13 @@ pub(super) struct FloatLineItem { pub needs_placement: bool, } -fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Length { +fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Au { let font = parent_style.get_font(); let font_size = font.font_size.computed_size(); match font.line_height { - LineHeight::Normal => Length::from(font_metrics.line_gap), - LineHeight::Number(number) => font_size * number.0, - LineHeight::Length(length) => length.0, + LineHeight::Normal => font_metrics.line_gap, + LineHeight::Number(number) => (font_size * number.0).into(), + LineHeight::Length(length) => length.0.into(), } } diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs index 22fc1a84173..9e93644f094 100644 --- a/components/layout_2020/flow/inline/mod.rs +++ b/components/layout_2020/flow/inline/mod.rs @@ -1685,7 +1685,7 @@ impl InlineFormattingContext { FlowLayout { fragments: layout.fragments, - content_block_size: content_block_size.into(), + content_block_size: content_block_size, collapsible_margins_in_children, baselines: layout.baselines, } @@ -1865,18 +1865,12 @@ impl InlineContainerState { VerticalAlign::Keyword(VerticalAlignKeyword::Baseline) | VerticalAlign::Keyword(VerticalAlignKeyword::Top) | VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => Au::zero(), - VerticalAlign::Keyword(VerticalAlignKeyword::Sub) => Au::from_f32_px( - block_size - .resolve() - .scale_by(FONT_SUBSCRIPT_OFFSET_RATIO) - .to_f32_px(), - ), - VerticalAlign::Keyword(VerticalAlignKeyword::Super) => -Au::from_f32_px( - block_size - .resolve() - .scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO) - .to_f32_px(), - ), + VerticalAlign::Keyword(VerticalAlignKeyword::Sub) => { + block_size.resolve().scale_by(FONT_SUBSCRIPT_OFFSET_RATIO) + }, + VerticalAlign::Keyword(VerticalAlignKeyword::Super) => { + -block_size.resolve().scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO) + }, VerticalAlign::Keyword(VerticalAlignKeyword::TextTop) => { child_block_size.size_for_baseline_positioning.ascent - self.font_metrics.ascent }, @@ -1893,7 +1887,7 @@ impl InlineContainerState { child_block_size.size_for_baseline_positioning.descent }, VerticalAlign::Length(length_percentage) => { - (-length_percentage.resolve(child_block_size.line_height.into())).into() + -length_percentage.to_used_value(child_block_size.line_height) }, } } diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs index 765a0dadf91..4dc42ba7fbe 100644 --- a/components/layout_2020/flow/mod.rs +++ b/components/layout_2020/flow/mod.rs @@ -13,7 +13,7 @@ use servo_arc::Arc; use style::computed_values::clear::T as Clear; use style::computed_values::float::T as Float; use style::properties::ComputedValues; -use style::values::computed::{Length, Size}; +use style::values::computed::Size; use style::values::specified::align::AlignFlags; use style::values::specified::{Display, TextAlignKeyword}; use style::Zero; @@ -196,7 +196,7 @@ impl BlockLevelBox { pub(crate) struct FlowLayout { pub fragments: Vec, - pub content_block_size: Length, + pub content_block_size: Au, pub collapsible_margins_in_children: CollapsedBlockMargins, /// The offset of the baselines in this layout in the content area, if there were some. This is /// used to propagate inflow baselines to the ancestors of `display: inline-block` elements @@ -285,7 +285,7 @@ impl OutsideMarker { }, size: LogicalVec2 { inline: max_inline_size, - block: flow_layout.content_block_size.into(), + block: flow_layout.content_block_size, }, }; @@ -341,7 +341,7 @@ impl BlockFormattingContext { IndependentLayout { fragments: flow_layout.fragments, - content_block_size: Au::from(flow_layout.content_block_size) + + content_block_size: flow_layout.content_block_size + flow_layout.collapsible_margins_in_children.end.solve() + clearance.unwrap_or_default(), content_inline_size_for_table: None, @@ -856,7 +856,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context( sequential_layout_state.as_deref_mut(), CollapsibleWithParentStartMargin(start_margin_can_collapse_with_children), ); - let mut content_block_size: Au = flow_layout.content_block_size.into(); + let mut content_block_size: Au = flow_layout.content_block_size; // Update margins. let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin); @@ -1842,7 +1842,7 @@ impl<'container> PlacementState<'container> { } } - fn finish(mut self) -> (Length, CollapsedBlockMargins, Baselines) { + fn finish(mut self) -> (Au, CollapsedBlockMargins, Baselines) { if !self.last_in_flow_margin_collapses_with_parent_end_margin { self.current_block_direction_position += self.current_margin.solve(); self.current_margin = CollapsedMargin::zero(); @@ -1861,7 +1861,7 @@ impl<'container> PlacementState<'container> { }; ( - total_block_size.into(), + total_block_size, CollapsedBlockMargins { collapsed_through, start: self.start_margin, diff --git a/components/layout_2020/geom.rs b/components/layout_2020/geom.rs index e5a6677361a..8f902afc74b 100644 --- a/components/layout_2020/geom.rs +++ b/components/layout_2020/geom.rs @@ -9,7 +9,7 @@ use std::ops::{Add, AddAssign, Neg, Sub, SubAssign}; use app_units::Au; use serde::Serialize; use style::logical_geometry::{BlockFlowDirection, InlineBaseDirection, WritingMode}; -use style::values::computed::{CSSPixelLength, Length, LengthPercentage}; +use style::values::computed::{CSSPixelLength, LengthPercentage}; use style::values::generics::length::GenericLengthPercentageOrAuto as AutoOr; use style::Zero; use style_traits::CSSPixel; @@ -22,7 +22,6 @@ pub type PhysicalVec = euclid::Vector2D; pub type PhysicalRect = euclid::Rect; pub type PhysicalSides = euclid::SideOffsets2D; pub type AuOrAuto = AutoOr; -pub type LengthOrAuto = AutoOr; pub type LengthPercentageOrAuto<'a> = AutoOr<&'a LengthPercentage>; #[derive(Clone, Copy, PartialEq, Serialize)] @@ -152,7 +151,8 @@ impl LogicalVec2> { self.block .non_auto() .and_then(|value| value.maybe_to_used_value(containing_block_block_size)) - .map_or(AuOrAuto::Auto, AuOrAuto::LengthPercentage) + .map(AuOrAuto::LengthPercentage) + .unwrap_or(AuOrAuto::Auto) }, } } @@ -181,12 +181,14 @@ impl LogicalVec2> { .inline .non_auto() .and_then(|value| value.maybe_to_used_value(basis.inline)) - .map_or(AuOrAuto::Auto, AuOrAuto::LengthPercentage), + .map(AuOrAuto::LengthPercentage) + .unwrap_or(AuOrAuto::Auto), block: self .block .non_auto() .and_then(|value| value.maybe_to_used_value(basis.block)) - .map_or(AuOrAuto::Auto, AuOrAuto::LengthPercentage), + .map(AuOrAuto::LengthPercentage) + .unwrap_or(AuOrAuto::Auto), } } } @@ -237,10 +239,10 @@ impl fmt::Debug for LogicalRect { write!( f, "Rect(i{}×b{} @ (i{},b{}))", - self.size.inline.to_px(), - self.size.block.to_px(), - self.start_corner.inline.to_px(), - self.start_corner.block.to_px(), + self.size.inline.to_f32_px(), + self.size.block.to_f32_px(), + self.start_corner.inline.to_f32_px(), + self.start_corner.block.to_f32_px(), ) } } @@ -265,12 +267,10 @@ impl> LogicalVec2 { } else { PhysicalVec::new(-self.inline, self.block) } + } else if mode.is_inline_tb() { + PhysicalVec::new(self.block, self.inline) } else { - if mode.is_inline_tb() { - PhysicalVec::new(self.block, self.inline) - } else { - PhysicalVec::new(-self.block, self.inline) - } + PhysicalVec::new(-self.block, self.inline) } } } @@ -560,10 +560,7 @@ impl LogicalRect { } impl LogicalRect { - pub fn to_physical<'a>( - &self, - containing_block: Option<&ContainingBlock<'a>>, - ) -> PhysicalRect { + pub fn to_physical(&self, containing_block: Option<&ContainingBlock<'_>>) -> PhysicalRect { let mode = containing_block.map_or_else(WritingMode::horizontal_tb, |containing_block| { containing_block.style.writing_mode }); diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index 3b835a86403..99152d4b8e0 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -507,8 +507,8 @@ impl HoistedAbsolutelyPositionedBox { box_offsets: inline_box_offsets, static_position_rect_axis: static_position_rect.get_axis(AxisDirection::Inline), alignment: inline_alignment, - flip_anchor: !(shared_fragment.original_parent_writing_mode.is_bidi_ltr() == - indefinite_containing_block.style.writing_mode.is_bidi_ltr()), + flip_anchor: shared_fragment.original_parent_writing_mode.is_bidi_ltr() != + indefinite_containing_block.style.writing_mode.is_bidi_ltr(), }; // When the "static-position rect" doesn't come into play, we re-resolve "align-self" diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index 68b26435ede..931a1da618c 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -1160,8 +1160,7 @@ impl<'a> TableLayout<'a> { .unwrap_or_else(|| { cell.style .border_width(containing_block_for_table.style.writing_mode) - }) - .into(); + }); let padding: LogicalSides = cell .style diff --git a/tests/wpt/meta/css/CSS2/floats-clear/clear-on-replaced-element.html.ini b/tests/wpt/meta/css/CSS2/floats-clear/clear-on-replaced-element.html.ini new file mode 100644 index 00000000000..6121e32136c --- /dev/null +++ b/tests/wpt/meta/css/CSS2/floats-clear/clear-on-replaced-element.html.ini @@ -0,0 +1,2 @@ +[clear-on-replaced-element.html] + expected: FAIL diff --git a/tests/wpt/meta/css/css-images/infinite-radial-gradient-refcrash.html.ini b/tests/wpt/meta/css/css-images/infinite-radial-gradient-refcrash.html.ini deleted file mode 100644 index 5287e0f468d..00000000000 --- a/tests/wpt/meta/css/css-images/infinite-radial-gradient-refcrash.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[infinite-radial-gradient-refcrash.html] - expected: FAIL