diff options
author | Nicolas Silva <nical@fastmail.com> | 2017-06-06 16:19:27 +0200 |
---|---|---|
committer | Nicolas Silva <nical@fastmail.com> | 2017-06-14 16:01:01 +0200 |
commit | 997608f11f6dfa79291ead25cae46a0538f2a3dc (patch) | |
tree | c231afafc66f7f3e2404769e083c176d2a13057d /components/layout | |
parent | 8617320500491fab91979404cec2087bac7ef362 (diff) | |
download | servo-997608f11f6dfa79291ead25cae46a0538f2a3dc.tar.gz servo-997608f11f6dfa79291ead25cae46a0538f2a3dc.zip |
Make BaseFlow::stacking_relative_position a vector.
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/block.rs | 8 | ||||
-rw-r--r-- | components/layout/display_list_builder.rs | 8 | ||||
-rw-r--r-- | components/layout/flow.rs | 6 | ||||
-rw-r--r-- | components/layout/fragment.rs | 4 | ||||
-rw-r--r-- | components/layout/inline.rs | 10 | ||||
-rw-r--r-- | components/layout/multicol.rs | 5 | ||||
-rw-r--r-- | components/layout/query.rs | 2 | ||||
-rw-r--r-- | components/layout/sequential.rs | 2 |
8 files changed, 22 insertions, 23 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index fe95e47fc2b..0b09b723a43 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -2000,7 +2000,7 @@ 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).to_vector() } @@ -2021,7 +2021,7 @@ impl Flow for BlockFlow { // `transform` set.) In this case, absolutely-positioned children will not be // positioned relative to us but will instead be positioned relative to our // containing block. - position - self.base.stacking_relative_position.to_vector() + position - self.base.stacking_relative_position } } else { self.base @@ -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. diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 396ccbce971..d033139e054 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -501,7 +501,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, @@ -1707,7 +1707,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, @@ -1999,7 +1999,7 @@ impl FragmentDisplayListBuilding for 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.to_vector()).origin; + 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.to_vector()); @@ -2818,7 +2818,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()]; diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 671d4287146..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::{Transform3D, Point2D, Rect, Size2D}; +use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D}; use flex::FlexFlow; use floats::{Floats, SpeculatedFloatPlacement}; use flow_list::{FlowList, MutFlowListIterator}; @@ -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>, // TODO: this should be a Vector2D<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 68f5fb30677..207ebc83e32 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -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.to_vector()) + .translate(&stacking_relative_flow_origin) } /// Given the stacking-context-relative border box, returns the stacking-context-relative diff --git a/components/layout/inline.rs b/components/layout/inline.rs index d77d7c831fd..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.to_vector(); + *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.to_vector(); + *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() 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 2f406261c2d..ae7a506124b 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -772,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() diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index c944f0adb83..f6f8ce429e4 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -108,7 +108,7 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut Flow, iterator let mut stacking_context_position = *stacking_context_position; 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.to_vector() + + flow::base(kid).stacking_relative_position + stacking_context_position.to_vector(); let relative_position = kid.as_block() .stacking_relative_position(CoordinateSystem::Own); |