From 3d57c22e9cda982923dd184152d3f187910d7b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 22 Jul 2019 12:49:39 +0200 Subject: Update euclid. There are a few canvas2d-related dependencies that haven't updated, but they only use euclid internally so that's not blocking landing the rest of the changes. Given the size of this patch, I think it's useful to get this landed as-is. --- components/layout/display_list/border.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'components/layout/display_list/border.rs') diff --git a/components/layout/display_list/border.rs b/components/layout/display_list/border.rs index fff18fcf6c0..4970b2a34de 100644 --- a/components/layout/display_list/border.rs +++ b/components/layout/display_list/border.rs @@ -4,7 +4,8 @@ use crate::display_list::ToLayout; use app_units::Au; -use euclid::{Rect, SideOffsets2D, Size2D}; +use euclid::default::{Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D as UntypedSize2D}; +use euclid::{SideOffsets2D, Size2D}; use style::computed_values::border_image_outset::T as BorderImageOutset; use style::properties::style_structs::Border; use style::values::computed::NumberOrPercentage; @@ -23,7 +24,10 @@ use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, NormalBorder} /// > Percentages: Refer to corresponding dimension of the border box. /// /// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius -fn corner_radius(radius: BorderCornerRadius, containing_size: Size2D) -> Size2D { +fn corner_radius( + radius: BorderCornerRadius, + containing_size: UntypedSize2D, +) -> UntypedSize2D { let w = radius.0.width().to_used_value(containing_size.width); let h = radius.0.height().to_used_value(containing_size.height); Size2D::new(w, h) @@ -105,7 +109,7 @@ pub fn radii(abs_bounds: Rect, border_style: &Border) -> BorderRadius { /// the inner radii need to be smaller depending on the line width. /// /// This is used to determine clipping areas. -pub fn inner_radii(mut radii: BorderRadius, offsets: SideOffsets2D) -> BorderRadius { +pub fn inner_radii(mut radii: BorderRadius, offsets: UntypedSideOffsets2D) -> BorderRadius { fn inner_length(x: f32, offset: Au) -> f32 { 0.0_f32.max(x - offset.to_f32_px()) } @@ -144,7 +148,10 @@ fn side_image_outset(outset: NonNegativeLengthOrNumber, border_width: Au) -> Au } /// Compute the additional border-image area. -pub fn image_outset(outset: BorderImageOutset, border: SideOffsets2D) -> SideOffsets2D { +pub fn image_outset( + outset: BorderImageOutset, + border: UntypedSideOffsets2D, +) -> UntypedSideOffsets2D { SideOffsets2D::new( side_image_outset(outset.0, border.top), side_image_outset(outset.1, border.right), @@ -168,7 +175,7 @@ fn side_image_width( pub fn image_width( width: &BorderImageWidth, border: LayoutSideOffsets, - border_area: Size2D, + border_area: UntypedSize2D, ) -> LayoutSideOffsets { LayoutSideOffsets::new( side_image_width(width.0, border.top, border_area.height), @@ -185,15 +192,14 @@ fn resolve_percentage(value: NonNegative, length: i32) -> i3 } } -pub fn image_slice( +pub fn image_slice( border_image_slice: &StyleRect>, - width: i32, - height: i32, -) -> SideOffsets2D { + size: Size2D, +) -> SideOffsets2D { SideOffsets2D::new( - resolve_percentage(border_image_slice.0, height), - resolve_percentage(border_image_slice.1, width), - resolve_percentage(border_image_slice.2, height), - resolve_percentage(border_image_slice.3, width), + resolve_percentage(border_image_slice.0, size.height), + resolve_percentage(border_image_slice.1, size.width), + resolve_percentage(border_image_slice.2, size.height), + resolve_percentage(border_image_slice.3, size.width), ) } -- cgit v1.2.3