Fix servo build.

This commit is contained in:
Emilio Cobos Álvarez 2019-02-23 20:52:08 -08:00
parent f6b6465ec6
commit 44ae191e72
4 changed files with 23 additions and 35 deletions

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 crate::display_list::border;
use app_units::Au; use app_units::Au;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; 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::computed_values::background_origin::single_value::T as BackgroundOrigin;
use style::properties::style_structs::Background; use style::properties::style_structs::Background;
use style::values::computed::{BackgroundSize, NonNegativeLengthPercentageOrAuto}; use style::values::computed::{BackgroundSize, NonNegativeLengthPercentageOrAuto};
use style::values::generics::background::BackgroundSize as GenericBackgroundSize;
use style::values::specified::background::BackgroundRepeatKeyword; use style::values::specified::background::BackgroundRepeatKeyword;
use webrender_api::BorderRadius; use webrender_api::BorderRadius;
@ -56,8 +53,8 @@ fn compute_background_image_size(
) -> Size2D<Au> { ) -> Size2D<Au> {
match intrinsic_size { match intrinsic_size {
None => match bg_size { None => match bg_size {
GenericBackgroundSize::Cover | GenericBackgroundSize::Contain => bounds_size, BackgroundSize::Cover | BackgroundSize::Contain => bounds_size,
GenericBackgroundSize::Explicit { width, height } => Size2D::new( BackgroundSize::ExplicitSize { width, height } => Size2D::new(
width width
.to_used_value(bounds_size.width) .to_used_value(bounds_size.width)
.unwrap_or(bounds_size.width), .unwrap_or(bounds_size.width),
@ -73,20 +70,16 @@ fn compute_background_image_size(
let bounds_aspect_ratio = let bounds_aspect_ratio =
bounds_size.width.to_f32_px() / bounds_size.height.to_f32_px(); bounds_size.width.to_f32_px() / bounds_size.height.to_f32_px();
match (bg_size, image_aspect_ratio < bounds_aspect_ratio) { match (bg_size, image_aspect_ratio < bounds_aspect_ratio) {
(GenericBackgroundSize::Contain, false) | (GenericBackgroundSize::Cover, true) => { (BackgroundSize::Contain, false) | (BackgroundSize::Cover, true) => Size2D::new(
Size2D::new( bounds_size.width,
bounds_size.width, bounds_size.width.scale_by(image_aspect_ratio.recip()),
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),
(GenericBackgroundSize::Contain, true) | (GenericBackgroundSize::Cover, false) => { bounds_size.height,
Size2D::new( ),
bounds_size.height.scale_by(image_aspect_ratio),
bounds_size.height,
)
},
( (
GenericBackgroundSize::Explicit { BackgroundSize::ExplicitSize {
width, width,
height: NonNegativeLengthPercentageOrAuto::Auto, height: NonNegativeLengthPercentageOrAuto::Auto,
}, },
@ -98,7 +91,7 @@ fn compute_background_image_size(
Size2D::new(width, width.scale_by(image_aspect_ratio.recip())) Size2D::new(width, width.scale_by(image_aspect_ratio.recip()))
}, },
( (
GenericBackgroundSize::Explicit { BackgroundSize::ExplicitSize {
width: NonNegativeLengthPercentageOrAuto::Auto, width: NonNegativeLengthPercentageOrAuto::Auto,
height, height,
}, },
@ -109,7 +102,7 @@ fn compute_background_image_size(
.unwrap_or(own_size.height); .unwrap_or(own_size.height);
Size2D::new(height.scale_by(image_aspect_ratio), height) Size2D::new(height.scale_by(image_aspect_ratio), height)
}, },
(GenericBackgroundSize::Explicit { width, height }, _) => Size2D::new( (BackgroundSize::ExplicitSize { width, height }, _) => Size2D::new(
width width
.to_used_value(bounds_size.width) .to_used_value(bounds_size.width)
.unwrap_or(own_size.width), .unwrap_or(own_size.width),

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 crate::display_list::ToLayout;
use app_units::Au; use app_units::Au;
use euclid::{Rect, SideOffsets2D, Size2D}; 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::properties::style_structs::Border;
use style::values::computed::NumberOrPercentage; use style::values::computed::NumberOrPercentage;
use style::values::computed::{BorderCornerRadius, BorderImageWidth}; use style::values::computed::{BorderCornerRadius, BorderImageWidth};
use style::values::computed::{BorderImageSideWidth, LengthOrNumber}; use style::values::computed::{BorderImageSideWidth, NonNegativeLengthOrNumber};
use style::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
use style::values::generics::rect::Rect as StyleRect; use style::values::generics::rect::Rect as StyleRect;
use style::values::generics::NonNegative; use style::values::generics::NonNegative;
use style::values::Either;
use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF}; use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF};
use webrender_api::{LayoutSideOffsets, LayoutSize, NormalBorder}; 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 { match outset {
Either::First(length) => length.into(), NonNegativeLengthOrNumber::Length(length) => length.into(),
Either::Second(factor) => border_width.scale_by(factor), NonNegativeLengthOrNumber::Number(factor) => border_width.scale_by(factor.0),
} }
} }
@ -163,9 +159,9 @@ fn side_image_width(
total_length: Au, total_length: Au,
) -> f32 { ) -> f32 {
match border_image_width { match border_image_width {
GenericBorderImageSideWidth::Length(v) => v.to_used_value(total_length).to_f32_px(), BorderImageSideWidth::Length(v) => v.to_used_value(total_length).to_f32_px(),
GenericBorderImageSideWidth::Number(x) => border_width * x.0, BorderImageSideWidth::Number(x) => border_width * x.0,
GenericBorderImageSideWidth::Auto => border_width, BorderImageSideWidth::Auto => border_width,
} }
} }

View file

@ -763,7 +763,7 @@ impl Fragment {
let background_size = let background_size =
get_cyclic(&style.get_background().background_size.0, i).clone(); get_cyclic(&style.get_background().background_size.0, i).clone();
let size = match background_size { let size = match background_size {
BackgroundSize::Explicit { width, height } => Size2D::new( BackgroundSize::ExplicitSize { width, height } => Size2D::new(
width width
.to_used_value(bounding_box_size.width) .to_used_value(bounding_box_size.width)
.unwrap_or(bounding_box_size.width), .unwrap_or(bounding_box_size.width),

View file

@ -30,7 +30,6 @@ use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::flex::FlexBasis; use style::values::computed::flex::FlexBasis;
use style::values::computed::{MaxSize, Size}; 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 /// The size of an axis. May be a specified size, a min/max
/// constraint, or an unlimited size /// constraint, or an unlimited size
@ -61,8 +60,8 @@ impl AxisSize {
/// is definite after flex size resolving. /// is definite after flex size resolving.
fn from_flex_basis(flex_basis: FlexBasis, main_length: Size, containing_length: Au) -> MaybeAuto { fn from_flex_basis(flex_basis: FlexBasis, main_length: Size, containing_length: Au) -> MaybeAuto {
let width = match flex_basis { let width = match flex_basis {
GenericFlexBasis::Content => return MaybeAuto::Auto, FlexBasis::Content => return MaybeAuto::Auto,
GenericFlexBasis::Width(width) => width, FlexBasis::Size(width) => width,
}; };
let width = match width { let width = match width {