diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/Cargo.toml | 4 | ||||
-rw-r--r-- | components/layout/block.rs | 20 | ||||
-rw-r--r-- | components/layout/display_list_builder.rs | 35 | ||||
-rw-r--r-- | components/layout/flex.rs | 4 | ||||
-rw-r--r-- | components/layout/floats.rs | 2 | ||||
-rw-r--r-- | components/layout/flow.rs | 14 | ||||
-rw-r--r-- | components/layout/fragment.rs | 64 | ||||
-rw-r--r-- | components/layout/inline.rs | 12 | ||||
-rw-r--r-- | components/layout/list_item.rs | 2 | ||||
-rw-r--r-- | components/layout/model.rs | 14 | ||||
-rw-r--r-- | components/layout/multicol.rs | 5 | ||||
-rw-r--r-- | components/layout/query.rs | 10 | ||||
-rw-r--r-- | components/layout/sequential.rs | 10 | ||||
-rw-r--r-- | components/layout/table.rs | 2 | ||||
-rw-r--r-- | components/layout/table_row.rs | 2 | ||||
-rw-r--r-- | components/layout/webrender_helpers.rs | 14 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 11 |
17 files changed, 114 insertions, 111 deletions
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index e9679887da6..effcbe0d4f0 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -14,7 +14,7 @@ app_units = "0.4.1" atomic_refcell = "0.1" bitflags = "0.7" canvas_traits = {path = "../canvas_traits"} -euclid = "0.13" +euclid = "0.14.4" fnv = "1.0" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} @@ -29,7 +29,7 @@ ordered-float = "0.4" parking_lot = "0.3.3" profile_traits = {path = "../profile_traits"} range = {path = "../range"} -rayon = "0.7.1" +rayon = "0.8" script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} selectors = { path = "../selectors" } diff --git a/components/layout/block.rs b/components/layout/block.rs index 9cd6978097e..6a3db5a6141 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -322,7 +322,7 @@ impl CandidateBSizeIterator { let block_size = match (fragment.style.content_block_size(), block_container_block_size) { (LengthOrPercentageOrAuto::Percentage(percent), Some(block_container_block_size)) => { - MaybeAuto::Specified(block_container_block_size.scale_by(percent)) + MaybeAuto::Specified(block_container_block_size.scale_by(percent.0)) } (LengthOrPercentageOrAuto::Calc(calc), _) => { MaybeAuto::from_option(calc.to_used_value(block_container_block_size)) @@ -333,7 +333,7 @@ impl CandidateBSizeIterator { }; let max_block_size = match (fragment.style.max_block_size(), block_container_block_size) { (LengthOrPercentageOrNone::Percentage(percent), Some(block_container_block_size)) => { - Some(block_container_block_size.scale_by(percent)) + Some(block_container_block_size.scale_by(percent.0)) } (LengthOrPercentageOrNone::Calc(calc), _) => { calc.to_used_value(block_container_block_size) @@ -344,7 +344,7 @@ impl CandidateBSizeIterator { }; let min_block_size = match (fragment.style.min_block_size(), block_container_block_size) { (LengthOrPercentage::Percentage(percent), Some(block_container_block_size)) => { - block_container_block_size.scale_by(percent) + block_container_block_size.scale_by(percent.0) } (LengthOrPercentage::Calc(calc), _) => { calc.to_used_value(block_container_block_size).unwrap_or(Au(0)) @@ -1178,7 +1178,7 @@ impl BlockFlow { } (LengthOrPercentageOrAuto::Length(length), _) => Some(length), (LengthOrPercentageOrAuto::Percentage(percent), Some(container_size)) => { - Some(container_size.scale_by(percent)) + Some(container_size.scale_by(percent.0)) } (LengthOrPercentageOrAuto::Percentage(_), None) | (LengthOrPercentageOrAuto::Auto, None) => { @@ -1967,7 +1967,7 @@ impl Flow for BlockFlow { // flow w.r.t. the containing block. self.base .late_absolute_position_info - .stacking_relative_position_of_absolute_containing_block + position_start + .stacking_relative_position_of_absolute_containing_block + position_start.to_vector() }; if !self.base.writing_mode.is_vertical() { @@ -2000,9 +2000,9 @@ impl Flow for BlockFlow { self.base .late_absolute_position_info .stacking_relative_position_of_absolute_containing_block = - self.base.stacking_relative_position + + self.base.stacking_relative_position.to_point() + (border_box_origin + relative_offset).to_physical(self.base.writing_mode, - container_size) + container_size).to_vector() } // Compute absolute position info for children. @@ -2036,7 +2036,7 @@ impl Flow for BlockFlow { self.base.position.size.to_physical(self.base.writing_mode); // Compute the origin and clipping rectangle for children. - let relative_offset = relative_offset.to_physical(self.base.writing_mode); + let relative_offset = relative_offset.to_physical(self.base.writing_mode).to_vector(); let is_stacking_context = self.fragment.establishes_stacking_context(); let origin_for_children = if is_stacking_context { // We establish a stacking context, so the position of our children is vertically @@ -2048,7 +2048,7 @@ impl Flow for BlockFlow { let margin = self.fragment.margin.to_physical(self.base.writing_mode); Point2D::new(-margin.left, Au(0)) } else { - self.base.stacking_relative_position + relative_offset + self.base.stacking_relative_position.to_point() + relative_offset }; // Process children. @@ -2171,7 +2171,7 @@ impl Flow for BlockFlow { .early_absolute_position_info .relative_containing_block_mode, CoordinateSystem::Own) - .translate(stacking_context_position)); + .translate(&stacking_context_position.to_vector())); } fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index b97aeb4c1fa..1adce80ade2 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -14,7 +14,7 @@ use app_units::{AU_PER_PX, Au}; use block::{BlockFlow, BlockStackingContextType}; use canvas_traits::{CanvasData, CanvasMsg, FromLayoutMsg}; use context::LayoutContext; -use euclid::{Matrix4D, Point2D, Rect, SideOffsets2D, Size2D, TypedSize2D}; +use euclid::{Transform3D, Point2D, Vector2D, Rect, SideOffsets2D, Size2D, TypedSize2D}; use flex::FlexFlow; use flow::{BaseFlow, Flow, IS_ABSOLUTELY_POSITIONED}; use flow_ref::FlowRef; @@ -65,6 +65,7 @@ use style::values::generics::image::{Circle, Ellipse, EndingShape as GenericEndi use style::values::generics::image::{GradientItem as GenericGradientItem, GradientKind}; use style::values::generics::image::{Image, ShapeExtent}; use style::values::generics::image::PaintWorklet; +use style::values::specified::length::Percentage; use style::values::specified::position::{X, Y}; use style_traits::CSSPixel; use style_traits::cursor::Cursor; @@ -501,7 +502,7 @@ pub trait FragmentDisplayListBuilding { /// * `clip`: The region to clip the display items to. fn build_display_list(&mut self, state: &mut DisplayListBuildState, - stacking_relative_flow_origin: &Point2D<Au>, + stacking_relative_flow_origin: &Vector2D<Au>, relative_containing_block_size: &LogicalSize<Au>, relative_containing_block_mode: WritingMode, border_painting_mode: BorderPaintingMode, @@ -653,14 +654,14 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], { let first = stop_items.first_mut().unwrap(); if first.position.is_none() { - first.position = Some(LengthOrPercentage::Percentage(0.0)); + first.position = Some(LengthOrPercentage::Percentage(Percentage(0.0))); } } // If the last color stop does not have a position, set its position to 100%. { let last = stop_items.last_mut().unwrap(); if last.position.is_none() { - last.position = Some(LengthOrPercentage::Percentage(1.0)); + last.position = Some(LengthOrPercentage::Percentage(Percentage(1.0))); } } @@ -1223,8 +1224,8 @@ impl FragmentDisplayListBuilding for Fragment { // This is the vector between the center and the ending point; i.e. half // of the distance between the starting point and the ending point. - let delta = Point2D::new(Au::from_f32_px(dir.x * inv_dir_length * line_length / 2.0), - Au::from_f32_px(dir.y * inv_dir_length * line_length / 2.0)); + let delta = Vector2D::new(Au::from_f32_px(dir.x * inv_dir_length * line_length / 2.0), + Au::from_f32_px(dir.y * inv_dir_length * line_length / 2.0)); // This is the length of the gradient line. let length = Au::from_f32_px( @@ -1347,8 +1348,8 @@ impl FragmentDisplayListBuilding for Fragment { // NB: According to CSS-BACKGROUNDS, box shadows render in *reverse* order (front to back). for box_shadow in style.get_effects().box_shadow.0.iter().rev() { let bounds = - shadow_bounds(&absolute_bounds.translate(&Point2D::new(box_shadow.offset_x, - box_shadow.offset_y)), + shadow_bounds(&absolute_bounds.translate(&Vector2D::new(box_shadow.offset_x, + box_shadow.offset_y)), box_shadow.blur_radius, box_shadow.spread_radius); @@ -1362,7 +1363,7 @@ impl FragmentDisplayListBuilding for Fragment { base: base, box_bounds: *absolute_bounds, color: style.resolve_color(box_shadow.color).to_gfx_color(), - offset: Point2D::new(box_shadow.offset_x, box_shadow.offset_y), + offset: Vector2D::new(box_shadow.offset_x, box_shadow.offset_y), blur_radius: box_shadow.blur_radius, spread_radius: box_shadow.spread_radius, border_radius: model::specified_border_radius(style.get_border() @@ -1707,7 +1708,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list(&mut self, state: &mut DisplayListBuildState, - stacking_relative_flow_origin: &Point2D<Au>, + stacking_relative_flow_origin: &Vector2D<Au>, relative_containing_block_size: &LogicalSize<Au>, relative_containing_block_mode: WritingMode, border_painting_mode: BorderPaintingMode, @@ -2001,7 +2002,7 @@ impl FragmentDisplayListBuilding for Fragment { let border_box_offset = border_box.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); + let overflow = base_flow.overflow.paint.translate(&-border_box_offset.to_vector()); // Create the filter pipeline. let effects = self.style().get_effects(); @@ -2046,7 +2047,7 @@ impl FragmentDisplayListBuilding for Fragment { } else { self.style().get_color().color }; - let offset = text_shadow.map(|s| Point2D::new(s.offset_x, s.offset_y)).unwrap_or_else(Point2D::zero); + let offset = text_shadow.map(|s| Vector2D::new(s.offset_x, s.offset_y)).unwrap_or_else(Vector2D::zero); let shadow_blur_radius = text_shadow.map(|s| s.blur_radius).unwrap_or(Au(0)); // Determine the orientation and cursor to use. @@ -2068,7 +2069,7 @@ impl FragmentDisplayListBuilding for Fragment { LogicalPoint::new(self.style.writing_mode, Au(0), metrics.ascent).to_physical(self.style.writing_mode, - container_size); + container_size).to_vector(); // Create the text display item. let base = state.create_base_display_item(&stacking_relative_content_box, @@ -2158,7 +2159,7 @@ impl FragmentDisplayListBuilding for Fragment { base: base, box_bounds: stacking_relative_box, color: color.to_gfx_color(), - offset: Point2D::zero(), + offset: Vector2D::zero(), blur_radius: blur_radius, spread_radius: Au(0), border_radius: Au(0), @@ -2300,7 +2301,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow { }; let perspective = self.fragment.perspective_matrix(&border_box) - .unwrap_or_else(Matrix4D::identity); + .unwrap_or_else(Transform3D::identity); let transform = transform.pre_mul(&perspective).inverse(); let origin = &border_box.origin; @@ -2818,7 +2819,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow { let thread_id = self.thread_id; let stacking_context_relative_bounds = - Rect::new(self.stacking_relative_position, + Rect::new(self.stacking_relative_position.to_point(), self.position.size.to_physical(self.writing_mode)); let mut color = THREAD_TINT_COLORS[thread_id as usize % THREAD_TINT_COLORS.len()]; @@ -2871,7 +2872,7 @@ struct StopRun { fn position_to_offset(position: LengthOrPercentage, total_length: Au) -> f32 { match position { LengthOrPercentage::Length(Au(length)) => length as f32 / total_length.0 as f32, - LengthOrPercentage::Percentage(percentage) => percentage as f32, + LengthOrPercentage::Percentage(percentage) => percentage.0 as f32, LengthOrPercentage::Calc(calc) => { calc.to_used_value(Some(total_length)).unwrap().0 as f32 / total_length.0 as f32 }, diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 0abd32b6dc0..e2bd1c0838d 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -46,7 +46,7 @@ impl AxisSize { LengthOrPercentageOrAuto::Length(length) => AxisSize::Definite(length), LengthOrPercentageOrAuto::Percentage(percent) => { match content_size { - Some(size) => AxisSize::Definite(size.scale_by(percent)), + Some(size) => AxisSize::Definite(size.scale_by(percent.0)), None => AxisSize::Infinite } } @@ -74,7 +74,7 @@ fn from_flex_basis(flex_basis: LengthOrPercentageOrAutoOrContent, (LengthOrPercentageOrAutoOrContent::Length(length), _) => MaybeAuto::Specified(length), (LengthOrPercentageOrAutoOrContent::Percentage(percent), Some(size)) => - MaybeAuto::Specified(size.scale_by(percent)), + MaybeAuto::Specified(size.scale_by(percent.0)), (LengthOrPercentageOrAutoOrContent::Percentage(_), None) => MaybeAuto::Auto, (LengthOrPercentageOrAutoOrContent::Calc(calc), _) => diff --git a/components/layout/floats.rs b/components/layout/floats.rs index aa3c02d1d3f..43d05e4bad4 100644 --- a/components/layout/floats.rs +++ b/components/layout/floats.rs @@ -505,7 +505,7 @@ impl SpeculatedFloatPlacement { // might flow around this float. if let LengthOrPercentageOrAuto::Percentage(percentage) = flow.as_block().fragment.style.content_inline_size() { - if percentage > 0.0 { + if percentage.0 > 0.0 { float_inline_size = Au::from_px(1) } } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 1944f0decbd..5930df5dd81 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -29,7 +29,7 @@ use app_units::Au; use block::{BlockFlow, FormattingContextType}; use context::LayoutContext; use display_list_builder::DisplayListBuildState; -use euclid::{Matrix4D, Point2D, Rect, Size2D}; +use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D}; use flex::FlexFlow; use floats::{Floats, SpeculatedFloatPlacement}; use flow_list::{FlowList, MutFlowListIterator}; @@ -260,7 +260,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { match self.class() { FlowClass::Block | FlowClass::TableCaption | FlowClass::TableCell => {} _ => { - overflow.translate(&position.origin); + overflow.translate(&position.origin.to_vector()); return overflow; } } @@ -285,7 +285,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { if !self.as_block().fragment.establishes_stacking_context() || self.as_block().fragment.style.get_box().transform.0.is_none() { - overflow.translate(&position.origin); + overflow.translate(&position.origin.to_vector()); return overflow; } @@ -294,7 +294,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { let transform_2d = self.as_block() .fragment .transform_matrix(&position) - .unwrap_or(Matrix4D::identity()) + .unwrap_or(Transform3D::identity()) .to_2d(); let transformed_overflow = Overflow { paint: f32_rect_to_au_rect(transform_2d.transform_rect( @@ -308,7 +308,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { // unnecessary once we are taking into account 3D transformations above. overflow.union(&transformed_overflow); - overflow.translate(&position.origin); + overflow.translate(&position.origin.to_vector()); overflow } @@ -917,7 +917,7 @@ pub struct BaseFlow { /// The position of this flow relative to the start of the nearest ancestor stacking context. /// This is computed during the top-down pass of display list construction. - pub stacking_relative_position: Point2D<Au>, + pub stacking_relative_position: Vector2D<Au>, /// Details about descendants with position 'absolute' or 'fixed' for which we are the /// containing block. This is in tree order. This includes any direct children. @@ -1098,7 +1098,7 @@ impl BaseFlow { parallel: FlowParallelInfo::new(), floats: Floats::new(writing_mode), collapsible_margins: CollapsibleMargins::new(), - stacking_relative_position: Point2D::zero(), + stacking_relative_position: Vector2D::zero(), abs_descendants: AbsoluteDescendants::new(), speculated_float_placement_in: SpeculatedFloatPlacement::zero(), speculated_float_placement_out: SpeculatedFloatPlacement::zero(), diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index c0d766dc544..3eb403b98a9 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -10,7 +10,7 @@ use StyleArc; use app_units::Au; use canvas_traits::CanvasMsg; use context::{LayoutContext, with_thread_local_font_context}; -use euclid::{Matrix4D, Point2D, Radians, Rect, Size2D}; +use euclid::{Transform3D, Point2D, Vector2D, Radians, Rect, Size2D}; use floats::ClearType; use flow::{self, ImmutableFlowUtils}; use flow_ref::FlowRef; @@ -2234,7 +2234,7 @@ impl Fragment { } vertical_align::T::LengthOrPercentage(LengthOrPercentage::Percentage( percentage)) => { - offset -= minimum_line_metrics.space_needed().scale_by(percentage) + offset -= minimum_line_metrics.space_needed().scale_by(percentage.0) } vertical_align::T::LengthOrPercentage(LengthOrPercentage::Calc(formula)) => { offset -= formula.to_used_value(Some(minimum_line_metrics.space_needed())).unwrap() @@ -2422,7 +2422,7 @@ impl Fragment { /// This is the method you should use for display list construction as well as /// `getBoundingClientRect()` and so forth. pub fn stacking_relative_border_box(&self, - stacking_relative_flow_origin: &Point2D<Au>, + stacking_relative_flow_origin: &Vector2D<Au>, relative_containing_block_size: &LogicalSize<Au>, relative_containing_block_mode: WritingMode, coordinate_system: CoordinateSystem) @@ -2440,7 +2440,7 @@ impl Fragment { // this. let relative_position = self.relative_position(relative_containing_block_size); border_box.translate_by_size(&relative_position.to_physical(self.style.writing_mode)) - .translate(stacking_relative_flow_origin) + .translate(&stacking_relative_flow_origin) } /// Given the stacking-context-relative border box, returns the stacking-context-relative @@ -2551,7 +2551,7 @@ impl Fragment { // Box shadows cause us to draw outside our border box. for box_shadow in &self.style().get_effects().box_shadow.0 { - let offset = Point2D::new(box_shadow.offset_x, box_shadow.offset_y); + let offset = Vector2D::new(box_shadow.offset_x, box_shadow.offset_y); let inflation = box_shadow.spread_radius + box_shadow.blur_radius * BLUR_INFLATION_FACTOR; overflow.paint = overflow.paint.union(&border_box.translate(&offset) @@ -2842,13 +2842,13 @@ impl Fragment { } /// Returns the 4D matrix representing this fragment's transform. - pub fn transform_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Matrix4D<f32>> { + pub fn transform_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Transform3D<f32>> { let operations = match self.style.get_box().transform.0 { None => return None, Some(ref operations) => operations, }; - let mut transform = Matrix4D::identity(); + let mut transform = Transform3D::identity(); let transform_origin = &self.style.get_box().transform_origin; let transform_origin_x = transform_origin.horizontal @@ -2860,30 +2860,30 @@ impl Fragment { .to_f32_px(); let transform_origin_z = transform_origin.depth.to_f32_px(); - let pre_transform = Matrix4D::create_translation(transform_origin_x, - transform_origin_y, - transform_origin_z); - let post_transform = Matrix4D::create_translation(-transform_origin_x, - -transform_origin_y, - -transform_origin_z); + let pre_transform = Transform3D::create_translation(transform_origin_x, + transform_origin_y, + transform_origin_z); + let post_transform = Transform3D::create_translation(-transform_origin_x, + -transform_origin_y, + -transform_origin_z); for operation in operations { let matrix = match *operation { transform::ComputedOperation::Rotate(ax, ay, az, theta) => { let theta = 2.0f32 * f32::consts::PI - theta.radians(); - Matrix4D::create_rotation(ax, ay, az, Radians::new(theta)) + Transform3D::create_rotation(ax, ay, az, Radians::new(theta)) } transform::ComputedOperation::Perspective(d) => { create_perspective_matrix(d) } transform::ComputedOperation::Scale(sx, sy, sz) => { - Matrix4D::create_scale(sx, sy, sz) + Transform3D::create_scale(sx, sy, sz) } transform::ComputedOperation::Translate(tx, ty, tz) => { let tx = tx.to_used_value(stacking_relative_border_box.size.width).to_f32_px(); let ty = ty.to_used_value(stacking_relative_border_box.size.height).to_f32_px(); let tz = tz.to_f32_px(); - Matrix4D::create_translation(tx, ty, tz) + Transform3D::create_translation(tx, ty, tz) } transform::ComputedOperation::Matrix(m) => { m.to_gfx_matrix() @@ -2893,14 +2893,14 @@ impl Fragment { unreachable!() } transform::ComputedOperation::Skew(theta_x, theta_y) => { - Matrix4D::create_skew(Radians::new(theta_x.radians()), + Transform3D::create_skew(Radians::new(theta_x.radians()), Radians::new(theta_y.radians())) } transform::ComputedOperation::InterpolateMatrix { .. } | transform::ComputedOperation::AccumulateMatrix { .. } => { - // TODO: Convert InterpolateMatrix/AccmulateMatrix into a valid Matrix4D by + // TODO: Convert InterpolateMatrix/AccmulateMatrix into a valid Transform3D by // the reference box. - Matrix4D::identity() + Transform3D::identity() } }; @@ -2911,7 +2911,7 @@ impl Fragment { } /// Returns the 4D matrix representing this fragment's perspective. - pub fn perspective_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Matrix4D<f32>> { + pub fn perspective_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Transform3D<f32>> { match self.style().get_box().perspective { Either::First(length) => { let perspective_origin = self.style().get_box().perspective_origin; @@ -2924,12 +2924,12 @@ impl Fragment { .to_used_value(stacking_relative_border_box.size.height) .to_f32_px()); - let pre_transform = Matrix4D::create_translation(perspective_origin.x, - perspective_origin.y, - 0.0); - let post_transform = Matrix4D::create_translation(-perspective_origin.x, - -perspective_origin.y, - 0.0); + let pre_transform = Transform3D::create_translation(perspective_origin.x, + perspective_origin.y, + 0.0); + let post_transform = Transform3D::create_translation(-perspective_origin.x, + -perspective_origin.y, + 0.0); let perspective_matrix = create_perspective_matrix(length); @@ -3099,9 +3099,9 @@ impl Overflow { self.paint = self.paint.union(&other.paint); } - pub fn translate(&mut self, point: &Point2D<Au>) { - self.scroll = self.scroll.translate(point); - self.paint = self.paint.translate(point); + pub fn translate(&mut self, by: &Vector2D<Au>) { + self.scroll = self.scroll.translate(by); + self.paint = self.paint.translate(by); } } @@ -3184,11 +3184,11 @@ impl Serialize for DebugId { // and behaves as it does in other browsers. // See https://lists.w3.org/Archives/Public/www-style/2016Jan/0020.html for more details. #[inline] -fn create_perspective_matrix(d: Au) -> Matrix4D<f32> { +fn create_perspective_matrix(d: Au) -> Transform3D<f32> { let d = d.to_f32_px(); if d <= 0.0 { - Matrix4D::identity() + Transform3D::identity() } else { - Matrix4D::create_perspective(d) + Transform3D::create_perspective(d) } } diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 8a54eac9e64..6e76cac5ddd 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1600,11 +1600,11 @@ impl Flow for InlineFlow { block_flow.base .late_absolute_position_info .stacking_relative_position_of_absolute_containing_block = - stacking_relative_position + *padding_box_origin; + *padding_box_origin + stacking_relative_position; } block_flow.base.stacking_relative_position = - stacking_relative_content_box.origin; + stacking_relative_content_box.origin.to_vector(); // Write the clip in our coordinate system into the child flow. (The kid will // fix it up to be in its own coordinate system if necessary.) @@ -1617,7 +1617,7 @@ impl Flow for InlineFlow { self.base.late_absolute_position_info; block_flow.base.stacking_relative_position = - stacking_relative_border_box.origin; + stacking_relative_border_box.origin.to_vector(); // As above, this is in our coordinate system for now. block_flow.base.clip = self.base.clip.clone() @@ -1633,10 +1633,10 @@ impl Flow for InlineFlow { block_flow.base .late_absolute_position_info .stacking_relative_position_of_absolute_containing_block = - stacking_relative_position + *padding_box_origin; + *padding_box_origin + stacking_relative_position; block_flow.base.stacking_relative_position = - stacking_relative_border_box.origin; + stacking_relative_border_box.origin.to_vector(); // As above, this is in our coordinate system for now. block_flow.base.clip = self.base.clip.clone() @@ -1694,7 +1694,7 @@ impl Flow for InlineFlow { relative_containing_block_size, relative_containing_block_mode, CoordinateSystem::Own) - .translate(stacking_context_position)) + .translate(&stacking_context_position.to_vector())) } } diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index 8a79aaa40b7..cb8cd27df70 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -197,7 +197,7 @@ impl Flow for ListItemFlow { .early_absolute_position_info .relative_containing_block_mode, CoordinateSystem::Own) - .translate(stacking_context_position)); + .translate(&stacking_context_position.to_vector())); } } } diff --git a/components/layout/model.rs b/components/layout/model.rs index 97fb5cbc43e..7f564a599ab 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -7,7 +7,7 @@ #![deny(unsafe_code)] use app_units::Au; -use euclid::{Matrix4D, SideOffsets2D, Size2D}; +use euclid::{Transform3D, SideOffsets2D, Size2D}; use fragment::Fragment; use std::cmp::{max, min}; use std::fmt; @@ -144,7 +144,7 @@ impl MarginCollapseInfo { LengthOrPercentageOrAuto::Auto => true, LengthOrPercentageOrAuto::Length(Au(v)) => v == 0, LengthOrPercentageOrAuto::Percentage(v) => { - v == 0. || containing_block_size.is_none() + v.0 == 0. || containing_block_size.is_none() } LengthOrPercentageOrAuto::Calc(_) => false, }; @@ -154,7 +154,7 @@ impl MarginCollapseInfo { LengthOrPercentage::Length(Au(0)) => { FinalMarginState::MarginsCollapseThrough }, - LengthOrPercentage::Percentage(v) if v == 0. => { + LengthOrPercentage::Percentage(v) if v.0 == 0. => { FinalMarginState::MarginsCollapseThrough }, _ => { @@ -408,7 +408,7 @@ impl MaybeAuto { match length { LengthOrPercentageOrAuto::Auto => MaybeAuto::Auto, LengthOrPercentageOrAuto::Percentage(percent) => { - MaybeAuto::Specified(containing_length.scale_by(percent)) + MaybeAuto::Specified(containing_length.scale_by(percent.0)) } LengthOrPercentageOrAuto::Calc(calc) => { MaybeAuto::from_option(calc.to_used_value(Some(containing_length))) @@ -509,12 +509,12 @@ pub fn specified_margin_from_style(style: &ServoComputedValues, } pub trait ToGfxMatrix { - fn to_gfx_matrix(&self) -> Matrix4D<f32>; + fn to_gfx_matrix(&self) -> Transform3D<f32>; } impl ToGfxMatrix for ComputedMatrix { - fn to_gfx_matrix(&self) -> Matrix4D<f32> { - Matrix4D::row_major( + fn to_gfx_matrix(&self) -> Transform3D<f32> { + Transform3D::row_major( self.m11 as f32, self.m12 as f32, self.m13 as f32, self.m14 as f32, self.m21 as f32, self.m22 as f32, self.m23 as f32, self.m24 as f32, self.m31 as f32, self.m32 as f32, self.m33 as f32, self.m34 as f32, diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index b43a6eb17ff..afe45c2aea7 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -11,8 +11,7 @@ use app_units::Au; use block::BlockFlow; use context::LayoutContext; use display_list_builder::DisplayListBuildState; -use euclid::Point2D; -use euclid::Size2D; +use euclid::{Point2D, Vector2D}; use floats::FloatKind; use flow::{Flow, FlowClass, OpaqueFlow, mut_base, FragmentationContext}; use fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; @@ -173,7 +172,7 @@ impl Flow for MulticolFlow { let pitch = pitch.to_physical(self.block_flow.base.writing_mode); for (i, child) in self.block_flow.base.children.iter_mut().enumerate() { let point = &mut mut_base(child).stacking_relative_position; - *point = *point + Size2D::new(pitch.width * i as i32, pitch.height * i as i32); + *point = *point + Vector2D::new(pitch.width * i as i32, pitch.height * i as i32); } } diff --git a/components/layout/query.rs b/components/layout/query.rs index da10696ec29..ae7a506124b 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -7,9 +7,7 @@ use app_units::Au; use construct::ConstructionResult; use context::LayoutContext; -use euclid::point::Point2D; -use euclid::rect::Rect; -use euclid::size::Size2D; +use euclid::{Point2D, Vector2D, Rect, Size2D}; use flow::{self, Flow}; use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo}; use gfx::display_list::{DisplayItemMetadata, DisplayList, OpaqueNode, ScrollOffsetMap}; @@ -613,7 +611,7 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator { Some(ParentBorderBoxInfo { node_address: fragment.node, - origin: border_box.origin + Point2D::new(border_width.left, border_width.top), + origin: border_box.origin + Vector2D::new(border_width.left, border_width.top), }) } else { None @@ -774,7 +772,7 @@ fn process_resolved_style_request_internal<'a, N>(requested_node: N, let position = maybe_data.map_or(Point2D::zero(), |data| { match (*data).flow_construction_result { ConstructionResult::Flow(ref flow_ref, _) => - flow::base(flow_ref.deref()).stacking_relative_position, + flow::base(flow_ref.deref()).stacking_relative_position.to_point(), // TODO(dzbarsky) search parents until we find node with a flow ref. // https://github.com/servo/servo/issues/8307 _ => Point2D::zero() @@ -852,7 +850,7 @@ pub fn process_offset_parent_query<N: LayoutNode>(requested_node: N, layout_root let parent_info = iterator.parent_nodes.into_iter().rev().filter_map(|info| info).next(); match (node_offset_box, parent_info) { (Some(node_offset_box), Some(parent_info)) => { - let origin = node_offset_box.offset - parent_info.origin; + let origin = node_offset_box.offset - parent_info.origin.to_vector(); let size = node_offset_box.rectangle.size; OffsetParentResponse { node_address: Some(parent_info.node_address.to_untrusted_node_address()), diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index 404d29a44d1..f6f8ce429e4 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -7,7 +7,7 @@ use app_units::Au; use context::LayoutContext; use display_list_builder::DisplayListBuildState; -use euclid::point::Point2D; +use euclid::{Point2D, Vector2D}; use floats::SpeculatedFloatPlacement; use flow::{self, Flow, ImmutableFlowUtils, InorderFlowTraversal, MutableFlowUtils}; use flow::{PostorderFlowTraversal, PreorderFlowTraversal}; @@ -109,16 +109,16 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut Flow, iterator if kid.is_block_flow() && kid.as_block().fragment.establishes_stacking_context() { stacking_context_position = Point2D::new(kid.as_block().fragment.margin.inline_start, Au(0)) + flow::base(kid).stacking_relative_position + - stacking_context_position; + stacking_context_position.to_vector(); let relative_position = kid.as_block() .stacking_relative_position(CoordinateSystem::Own); if let Some(matrix) = kid.as_block() .fragment .transform_matrix(&relative_position) { - let transform_matrix = matrix.transform_point(&Point2D::zero()); + let transform_matrix = matrix.transform_point2d(&Point2D::zero()); stacking_context_position = stacking_context_position + - Point2D::new(Au::from_f32_px(transform_matrix.x), - Au::from_f32_px(transform_matrix.y)) + Vector2D::new(Au::from_f32_px(transform_matrix.x), + Au::from_f32_px(transform_matrix.y)) } } doit(kid, level + 1, iterator, &stacking_context_position); diff --git a/components/layout/table.rs b/components/layout/table.rs index c3ba52a305b..d199b059a69 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -253,7 +253,7 @@ impl Flow for TableFlow { LengthOrPercentageOrAuto::Auto | LengthOrPercentageOrAuto::Calc(_) | LengthOrPercentageOrAuto::Length(_) => 0.0, - LengthOrPercentageOrAuto::Percentage(percentage) => percentage, + LengthOrPercentageOrAuto::Percentage(percentage) => percentage.0, }, preferred: Au(0), constrained: false, diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 2fb61a336de..45b47ee8de5 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -310,7 +310,7 @@ impl Flow for TableRowFlow { LengthOrPercentageOrAuto::Auto | LengthOrPercentageOrAuto::Calc(_) | LengthOrPercentageOrAuto::Length(_) => 0.0, - LengthOrPercentageOrAuto::Percentage(percentage) => percentage, + LengthOrPercentageOrAuto::Percentage(percentage) => percentage.0, }, preferred: child_base.intrinsic_inline_sizes.preferred_inline_size, constrained: match child_specified_inline_size { diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs index 537d5f04267..dc8bf7bc9a5 100644 --- a/components/layout/webrender_helpers.rs +++ b/components/layout/webrender_helpers.rs @@ -8,7 +8,7 @@ // completely converting layout to directly generate WebRender display lists, for example. use app_units::Au; -use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; +use euclid::{Point2D, Vector2D, Rect, SideOffsets2D, Size2D}; use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClippingRegion}; use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal, StackingContextType}; use msg::constellation_msg::PipelineId; @@ -86,12 +86,22 @@ trait ToPointF { fn to_pointf(&self) -> webrender_traits::LayoutPoint; } +trait ToVectorF { + fn to_vectorf(&self) -> webrender_traits::LayoutVector2D; +} + impl ToPointF for Point2D<Au> { fn to_pointf(&self) -> webrender_traits::LayoutPoint { webrender_traits::LayoutPoint::new(self.x.to_f32_px(), self.y.to_f32_px()) } } +impl ToVectorF for Vector2D<Au> { + fn to_vectorf(&self) -> webrender_traits::LayoutVector2D { + webrender_traits::LayoutVector2D::new(self.x.to_f32_px(), self.y.to_f32_px()) + } +} + impl ToSizeF for Size2D<Au> { fn to_sizef(&self) -> webrender_traits::LayoutSize { webrender_traits::LayoutSize::new(self.width.to_f32_px(), self.height.to_f32_px()) @@ -450,7 +460,7 @@ impl WebRenderDisplayItemConverter for DisplayItem { builder.push_box_shadow(rect, clip, box_bounds, - item.offset.to_pointf(), + item.offset.to_vectorf(), item.color, item.blur_radius.to_f32_px(), item.spread_radius.to_f32_px(), diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 4ae7c403e37..87fe65bb3b9 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -171,19 +171,14 @@ impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T { let damage = { let data = node.get_raw_data().unwrap(); - if let Some(r) = data.style_data.element_data.borrow().get_restyle() { - // We're reflowing a node that just got a restyle, and so the - // damage has been computed and stored in the RestyleData. - r.damage - } else if !data.layout_data.borrow().flags.contains(::data::HAS_BEEN_TRAVERSED) { + + if !data.layout_data.borrow().flags.contains(::data::HAS_BEEN_TRAVERSED) { // We're reflowing a node that was styled for the first time and // has never been visited by layout. Return rebuild_and_reflow, // because that's what the code expects. RestyleDamage::rebuild_and_reflow() } else { - // We're reflowing a node whose style data didn't change, but whose - // layout may change due to changes in ancestors or descendants. - RestyleDamage::empty() + data.style_data.element_data.borrow().restyle.damage } }; |