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:
Emilio Cobos Álvarez 2019-07-22 12:49:39 +02:00
parent 2ff7cb5a37
commit 3d57c22e9c
133 changed files with 686 additions and 596 deletions

View file

@ -4,7 +4,7 @@
use crate::display_list::border;
use app_units::Au;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D};
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
use style::computed_values::background_clip::single_value::T as BackgroundClip;
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;

View file

@ -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),
)
}

View file

@ -32,7 +32,10 @@ use crate::table_cell::CollapsedBordersForCell;
use app_units::{Au, AU_PER_PX};
use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg};
use embedder_traits::Cursor;
use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedRect, TypedSize2D};
use euclid::{
default::{Point2D, Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D},
rect, SideOffsets2D,
};
use fnv::FnvHashMap;
use gfx::text::glyph::ByteIndex;
use gfx::text::TextRun;
@ -874,7 +877,7 @@ impl Fragment {
) -> Option<WebRenderImageInfo> {
let device_pixel_ratio = state.layout_context.style_context.device_pixel_ratio();
let size_in_px =
TypedSize2D::new(size_in_au.width.to_f32_px(), size_in_au.height.to_f32_px());
euclid::Size2D::new(size_in_au.width.to_f32_px(), size_in_au.height.to_f32_px());
// TODO: less copying.
let name = paint_worklet.name.clone();
@ -1169,7 +1172,7 @@ impl Fragment {
base: BaseDisplayItem,
bounds: Rect<Au>,
image: &Image,
border_width: SideOffsets2D<Au>,
border_width: UntypedSideOffsets2D<Au>,
) -> Option<()> {
let border_style_struct = style.get_border();
let border_image_outset =
@ -1238,11 +1241,13 @@ impl Fragment {
_ => return None,
};
// FIXME(emilio): WR expects device pixels here... somehow?
let size = euclid::Size2D::new(width as i32, height as i32);
let details = BorderDetails::NinePatch(NinePatchBorder {
source,
width: width as i32,
height: height as i32,
slice: border::image_slice(border_image_slice, width as i32, height as i32),
slice: border::image_slice(border_image_slice, size),
fill: border_image_fill,
repeat_horizontal: border_image_repeat.0.to_layout(),
repeat_vertical: border_image_repeat.1.to_layout(),
@ -1660,7 +1665,7 @@ impl Fragment {
// of this fragment's background but behind its content. This ensures that any
// hit tests inside the content box but not on actual content target the current
// scrollable ancestor.
let content_size = TypedRect::new(stacking_relative_border_box.origin, content_size);
let content_size = Rect::new(stacking_relative_border_box.origin, content_size);
let base = state.create_base_display_item_with_clipping_and_scrolling(
content_size,
self.node,
@ -1810,10 +1815,9 @@ impl Fragment {
// XXXjdm: This sleight-of-hand to convert LayoutRect -> Size2D<CSSPixel>
// looks bogus.
let size = Size2D::new(bounds.size.width, bounds.size.height);
state.iframe_sizes.push(IFrameSize {
id: browsing_context_id,
size: TypedSize2D::from_untyped(&size),
size: euclid::Size2D::new(bounds.size.width, bounds.size.height),
});
state.add_display_item(item);
@ -1926,13 +1930,13 @@ impl Fragment {
// First, compute the offset of our border box (including relative positioning)
// from our flow origin, since that is what `BaseFlow::overflow` is relative to.
let border_box_offset = border_box
.translate(&-base_flow.stacking_relative_position)
.translate(-base_flow.stacking_relative_position)
.origin;
// Then, using that, compute our overflow region relative to our border box.
let overflow = base_flow
.overflow
.paint
.translate(&-border_box_offset.to_vector());
.translate(-border_box_offset.to_vector());
// Create the filter pipeline.
let effects = self.style().get_effects();
@ -2269,7 +2273,7 @@ impl BlockFlow {
.fragment
.perspective_matrix(&border_box)
.unwrap_or(LayoutTransform::identity());
let transform = transform.pre_mul(&perspective).inverse();
let transform = transform.pre_transform(&perspective).inverse();
let origin = border_box.origin;
let transform_clip = |clip: Rect<Au>| {
@ -3016,7 +3020,7 @@ trait ToF32Px {
fn to_f32_px(&self) -> Self::Output;
}
impl ToF32Px for TypedRect<Au> {
impl ToF32Px for Rect<Au> {
type Output = LayoutRect;
fn to_f32_px(&self) -> LayoutRect {
LayoutRect::from_untyped(&servo_geometry::au_rect_to_f32_rect(*self))

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use app_units::Au;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
use style::computed_values::image_rendering::T as ImageRendering;
use style::computed_values::mix_blend_mode::T as MixBlendMode;
use style::computed_values::transform_style::T as TransformStyle;

View file

@ -4,7 +4,7 @@
use crate::display_list::ToLayout;
use app_units::Au;
use euclid::{Point2D, Size2D, Vector2D};
use euclid::default::{Point2D, Size2D, Vector2D};
use style::properties::ComputedValues;
use style::values::computed::image::{EndingShape, LineDirection};
use style::values::computed::{Angle, GradientItem, LengthPercentage, Percentage, Position};

View file

@ -24,7 +24,7 @@ use std::f32;
use std::fmt;
use style::computed_values::_servo_top_layer::T as InTopLayer;
use webrender_api as wr;
use webrender_api::units::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform};
use webrender_api::units::{LayoutPixel, LayoutPoint, LayoutRect, LayoutSize, LayoutTransform};
use webrender_api::{BorderRadius, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion};
use webrender_api::{ExternalScrollId, FilterOp, GlyphInstance, GradientStop, ImageKey};
use webrender_api::{MixBlendMode, ScrollSensitivity, Shadow, SpatialId};
@ -343,7 +343,7 @@ impl fmt::Debug for StackingContext {
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct StickyFrameData {
pub margins: SideOffsets2D<Option<f32>>,
pub margins: SideOffsets2D<Option<f32>, LayoutPixel>,
pub vertical_offset_bounds: StickyOffsetBounds,
pub horizontal_offset_bounds: StickyOffsetBounds,
}
@ -792,4 +792,4 @@ impl WebRenderImageInfo {
}
/// The type of the scroll offset list. This is only populated if WebRender is in use.
pub type ScrollOffsetMap = HashMap<ExternalScrollId, Vector2D<f32>>;
pub type ScrollOffsetMap = HashMap<ExternalScrollId, Vector2D<f32, LayoutPixel>>;

View file

@ -189,7 +189,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
),
(Some(t), None) => (t, ReferenceFrameKind::Transform),
(Some(t), Some(p)) => (
t.pre_mul(&p),
t.pre_transform(&p),
ReferenceFrameKind::Perspective {
scrolling_relative_to: None,
},