mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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.
This commit is contained in:
parent
2ff7cb5a37
commit
3d57c22e9c
133 changed files with 686 additions and 596 deletions
|
@ -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<Au>) -> Size2D<Au> {
|
||||
fn corner_radius(
|
||||
radius: BorderCornerRadius,
|
||||
containing_size: UntypedSize2D<Au>,
|
||||
) -> UntypedSize2D<Au> {
|
||||
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<Au>, 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<Au>) -> BorderRadius {
|
||||
pub fn inner_radii(mut radii: BorderRadius, offsets: UntypedSideOffsets2D<Au>) -> 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<Au>) -> SideOffsets2D<Au> {
|
||||
pub fn image_outset(
|
||||
outset: BorderImageOutset,
|
||||
border: UntypedSideOffsets2D<Au>,
|
||||
) -> UntypedSideOffsets2D<Au> {
|
||||
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<Au>,
|
||||
border_area: UntypedSize2D<Au>,
|
||||
) -> LayoutSideOffsets {
|
||||
LayoutSideOffsets::new(
|
||||
side_image_width(width.0, border.top, border_area.height),
|
||||
|
@ -185,15 +192,14 @@ fn resolve_percentage(value: NonNegative<NumberOrPercentage>, length: i32) -> i3
|
|||
}
|
||||
}
|
||||
|
||||
pub fn image_slice(
|
||||
pub fn image_slice<U>(
|
||||
border_image_slice: &StyleRect<NonNegative<NumberOrPercentage>>,
|
||||
width: i32,
|
||||
height: i32,
|
||||
) -> SideOffsets2D<i32> {
|
||||
size: Size2D<i32, U>,
|
||||
) -> SideOffsets2D<i32, U> {
|
||||
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),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue