diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index 368818471d5..c6fa1691e46 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.rs @@ -2,8 +2,6 @@ * 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/. */ -// FIXME(rust-lang/rust#26264): Remove GenericBackgroundSize. - use crate::display_list::border; use app_units::Au; use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; @@ -12,7 +10,6 @@ use style::computed_values::background_clip::single_value::T as BackgroundClip; use style::computed_values::background_origin::single_value::T as BackgroundOrigin; use style::properties::style_structs::Background; use style::values::computed::{BackgroundSize, NonNegativeLengthPercentageOrAuto}; -use style::values::generics::background::BackgroundSize as GenericBackgroundSize; use style::values::specified::background::BackgroundRepeatKeyword; use webrender_api::BorderRadius; @@ -56,8 +53,8 @@ fn compute_background_image_size( ) -> Size2D { match intrinsic_size { None => match bg_size { - GenericBackgroundSize::Cover | GenericBackgroundSize::Contain => bounds_size, - GenericBackgroundSize::Explicit { width, height } => Size2D::new( + BackgroundSize::Cover | BackgroundSize::Contain => bounds_size, + BackgroundSize::ExplicitSize { width, height } => Size2D::new( width .to_used_value(bounds_size.width) .unwrap_or(bounds_size.width), @@ -73,20 +70,16 @@ fn compute_background_image_size( let bounds_aspect_ratio = bounds_size.width.to_f32_px() / bounds_size.height.to_f32_px(); match (bg_size, image_aspect_ratio < bounds_aspect_ratio) { - (GenericBackgroundSize::Contain, false) | (GenericBackgroundSize::Cover, true) => { - Size2D::new( - bounds_size.width, - bounds_size.width.scale_by(image_aspect_ratio.recip()), - ) - }, - (GenericBackgroundSize::Contain, true) | (GenericBackgroundSize::Cover, false) => { - Size2D::new( - bounds_size.height.scale_by(image_aspect_ratio), - bounds_size.height, - ) - }, + (BackgroundSize::Contain, false) | (BackgroundSize::Cover, true) => Size2D::new( + bounds_size.width, + bounds_size.width.scale_by(image_aspect_ratio.recip()), + ), + (BackgroundSize::Contain, true) | (BackgroundSize::Cover, false) => Size2D::new( + bounds_size.height.scale_by(image_aspect_ratio), + bounds_size.height, + ), ( - GenericBackgroundSize::Explicit { + BackgroundSize::ExplicitSize { width, height: NonNegativeLengthPercentageOrAuto::Auto, }, @@ -98,7 +91,7 @@ fn compute_background_image_size( Size2D::new(width, width.scale_by(image_aspect_ratio.recip())) }, ( - GenericBackgroundSize::Explicit { + BackgroundSize::ExplicitSize { width: NonNegativeLengthPercentageOrAuto::Auto, height, }, @@ -109,7 +102,7 @@ fn compute_background_image_size( .unwrap_or(own_size.height); Size2D::new(height.scale_by(image_aspect_ratio), height) }, - (GenericBackgroundSize::Explicit { width, height }, _) => Size2D::new( + (BackgroundSize::ExplicitSize { width, height }, _) => Size2D::new( width .to_used_value(bounds_size.width) .unwrap_or(own_size.width), diff --git a/components/layout/display_list/border.rs b/components/layout/display_list/border.rs index d5909abee84..dcbef4473fe 100644 --- a/components/layout/display_list/border.rs +++ b/components/layout/display_list/border.rs @@ -2,8 +2,6 @@ * 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/. */ -// FIXME(rust-lang/rust#26264): Remove GenericBorderImageSideWidth. - use crate::display_list::ToLayout; use app_units::Au; use euclid::{Rect, SideOffsets2D, Size2D}; @@ -11,11 +9,9 @@ use style::computed_values::border_image_outset::T as BorderImageOutset; use style::properties::style_structs::Border; use style::values::computed::NumberOrPercentage; use style::values::computed::{BorderCornerRadius, BorderImageWidth}; -use style::values::computed::{BorderImageSideWidth, LengthOrNumber}; -use style::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth; +use style::values::computed::{BorderImageSideWidth, NonNegativeLengthOrNumber}; use style::values::generics::rect::Rect as StyleRect; use style::values::generics::NonNegative; -use style::values::Either; use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF}; use webrender_api::{LayoutSideOffsets, LayoutSize, NormalBorder}; @@ -140,10 +136,10 @@ pub fn simple(color: ColorF, style: BorderStyle) -> NormalBorder { } } -fn side_image_outset(outset: LengthOrNumber, border_width: Au) -> Au { +fn side_image_outset(outset: NonNegativeLengthOrNumber, border_width: Au) -> Au { match outset { - Either::First(length) => length.into(), - Either::Second(factor) => border_width.scale_by(factor), + NonNegativeLengthOrNumber::Length(length) => length.into(), + NonNegativeLengthOrNumber::Number(factor) => border_width.scale_by(factor.0), } } @@ -163,9 +159,9 @@ fn side_image_width( total_length: Au, ) -> f32 { match border_image_width { - GenericBorderImageSideWidth::Length(v) => v.to_used_value(total_length).to_f32_px(), - GenericBorderImageSideWidth::Number(x) => border_width * x.0, - GenericBorderImageSideWidth::Auto => border_width, + BorderImageSideWidth::Length(v) => v.to_used_value(total_length).to_f32_px(), + BorderImageSideWidth::Number(x) => border_width * x.0, + BorderImageSideWidth::Auto => border_width, } } diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 6de5ac8498c..d26cd6b9c32 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -763,7 +763,7 @@ impl Fragment { let background_size = get_cyclic(&style.get_background().background_size.0, i).clone(); let size = match background_size { - BackgroundSize::Explicit { width, height } => Size2D::new( + BackgroundSize::ExplicitSize { width, height } => Size2D::new( width .to_used_value(bounding_box_size.width) .unwrap_or(bounding_box_size.width), diff --git a/components/layout/flex.rs b/components/layout/flex.rs index f761bc95dff..82dd9533175 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -30,7 +30,6 @@ use style::properties::ComputedValues; use style::servo::restyle_damage::ServoRestyleDamage; use style::values::computed::flex::FlexBasis; 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 /// constraint, or an unlimited size @@ -61,8 +60,8 @@ impl AxisSize { /// is definite after flex size resolving. 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, + FlexBasis::Content => return MaybeAuto::Auto, + FlexBasis::Size(width) => width, }; let width = match width {