Skip to content

Commit 997608f

Browse files
committed
Make BaseFlow::stacking_relative_position a vector.
1 parent 8617320 commit 997608f

File tree

9 files changed

+23
-24
lines changed

9 files changed

+23
-24
lines changed

components/layout/block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ impl Flow for BlockFlow {
20002000
self.base
20012001
.late_absolute_position_info
20022002
.stacking_relative_position_of_absolute_containing_block =
2003-
self.base.stacking_relative_position +
2003+
self.base.stacking_relative_position.to_point() +
20042004
(border_box_origin + relative_offset).to_physical(self.base.writing_mode,
20052005
container_size).to_vector()
20062006
}
@@ -2021,7 +2021,7 @@ impl Flow for BlockFlow {
20212021
// `transform` set.) In this case, absolutely-positioned children will not be
20222022
// positioned relative to us but will instead be positioned relative to our
20232023
// containing block.
2024-
position - self.base.stacking_relative_position.to_vector()
2024+
position - self.base.stacking_relative_position
20252025
}
20262026
} else {
20272027
self.base
@@ -2036,7 +2036,7 @@ impl Flow for BlockFlow {
20362036
self.base.position.size.to_physical(self.base.writing_mode);
20372037

20382038
// Compute the origin and clipping rectangle for children.
2039-
let relative_offset = relative_offset.to_physical(self.base.writing_mode);
2039+
let relative_offset = relative_offset.to_physical(self.base.writing_mode).to_vector();
20402040
let is_stacking_context = self.fragment.establishes_stacking_context();
20412041
let origin_for_children = if is_stacking_context {
20422042
// We establish a stacking context, so the position of our children is vertically
@@ -2048,7 +2048,7 @@ impl Flow for BlockFlow {
20482048
let margin = self.fragment.margin.to_physical(self.base.writing_mode);
20492049
Point2D::new(-margin.left, Au(0))
20502050
} else {
2051-
self.base.stacking_relative_position + relative_offset
2051+
self.base.stacking_relative_position.to_point() + relative_offset
20522052
};
20532053

20542054
// Process children.

components/layout/display_list_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ pub trait FragmentDisplayListBuilding {
501501
/// * `clip`: The region to clip the display items to.
502502
fn build_display_list(&mut self,
503503
state: &mut DisplayListBuildState,
504-
stacking_relative_flow_origin: &Point2D<Au>,
504+
stacking_relative_flow_origin: &Vector2D<Au>,
505505
relative_containing_block_size: &LogicalSize<Au>,
506506
relative_containing_block_mode: WritingMode,
507507
border_painting_mode: BorderPaintingMode,
@@ -1707,7 +1707,7 @@ impl FragmentDisplayListBuilding for Fragment {
17071707

17081708
fn build_display_list(&mut self,
17091709
state: &mut DisplayListBuildState,
1710-
stacking_relative_flow_origin: &Point2D<Au>,
1710+
stacking_relative_flow_origin: &Vector2D<Au>,
17111711
relative_containing_block_size: &LogicalSize<Au>,
17121712
relative_containing_block_mode: WritingMode,
17131713
border_painting_mode: BorderPaintingMode,
@@ -1999,7 +1999,7 @@ impl FragmentDisplayListBuilding for Fragment {
19991999
// First, compute the offset of our border box (including relative positioning)
20002000
// from our flow origin, since that is what `BaseFlow::overflow` is relative to.
20012001
let border_box_offset =
2002-
border_box.translate(&-base_flow.stacking_relative_position.to_vector()).origin;
2002+
border_box.translate(&-base_flow.stacking_relative_position).origin;
20032003
// Then, using that, compute our overflow region relative to our border box.
20042004
let overflow = base_flow.overflow.paint.translate(&-border_box_offset.to_vector());
20052005

@@ -2818,7 +2818,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
28182818

28192819
let thread_id = self.thread_id;
28202820
let stacking_context_relative_bounds =
2821-
Rect::new(self.stacking_relative_position,
2821+
Rect::new(self.stacking_relative_position.to_point(),
28222822
self.position.size.to_physical(self.writing_mode));
28232823

28242824
let mut color = THREAD_TINT_COLORS[thread_id as usize % THREAD_TINT_COLORS.len()];

components/layout/flow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use app_units::Au;
2929
use block::{BlockFlow, FormattingContextType};
3030
use context::LayoutContext;
3131
use display_list_builder::DisplayListBuildState;
32-
use euclid::{Transform3D, Point2D, Rect, Size2D};
32+
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D};
3333
use flex::FlexFlow;
3434
use floats::{Floats, SpeculatedFloatPlacement};
3535
use flow_list::{FlowList, MutFlowListIterator};
@@ -917,7 +917,7 @@ pub struct BaseFlow {
917917

918918
/// The position of this flow relative to the start of the nearest ancestor stacking context.
919919
/// This is computed during the top-down pass of display list construction.
920-
pub stacking_relative_position: Point2D<Au>, // TODO: this should be a Vector2D<Au>
920+
pub stacking_relative_position: Vector2D<Au>,
921921

922922
/// Details about descendants with position 'absolute' or 'fixed' for which we are the
923923
/// containing block. This is in tree order. This includes any direct children.
@@ -1098,7 +1098,7 @@ impl BaseFlow {
10981098
parallel: FlowParallelInfo::new(),
10991099
floats: Floats::new(writing_mode),
11001100
collapsible_margins: CollapsibleMargins::new(),
1101-
stacking_relative_position: Point2D::zero(),
1101+
stacking_relative_position: Vector2D::zero(),
11021102
abs_descendants: AbsoluteDescendants::new(),
11031103
speculated_float_placement_in: SpeculatedFloatPlacement::zero(),
11041104
speculated_float_placement_out: SpeculatedFloatPlacement::zero(),

components/layout/fragment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ impl Fragment {
24222422
/// This is the method you should use for display list construction as well as
24232423
/// `getBoundingClientRect()` and so forth.
24242424
pub fn stacking_relative_border_box(&self,
2425-
stacking_relative_flow_origin: &Point2D<Au>,
2425+
stacking_relative_flow_origin: &Vector2D<Au>,
24262426
relative_containing_block_size: &LogicalSize<Au>,
24272427
relative_containing_block_mode: WritingMode,
24282428
coordinate_system: CoordinateSystem)
@@ -2440,7 +2440,7 @@ impl Fragment {
24402440
// this.
24412441
let relative_position = self.relative_position(relative_containing_block_size);
24422442
border_box.translate_by_size(&relative_position.to_physical(self.style.writing_mode))
2443-
.translate(&stacking_relative_flow_origin.to_vector())
2443+
.translate(&stacking_relative_flow_origin)
24442444
}
24452445

24462446
/// Given the stacking-context-relative border box, returns the stacking-context-relative

components/layout/inline.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,11 +1600,11 @@ impl Flow for InlineFlow {
16001600
block_flow.base
16011601
.late_absolute_position_info
16021602
.stacking_relative_position_of_absolute_containing_block =
1603-
stacking_relative_position + padding_box_origin.to_vector();
1603+
*padding_box_origin + stacking_relative_position;
16041604
}
16051605

16061606
block_flow.base.stacking_relative_position =
1607-
stacking_relative_content_box.origin;
1607+
stacking_relative_content_box.origin.to_vector();
16081608

16091609
// Write the clip in our coordinate system into the child flow. (The kid will
16101610
// fix it up to be in its own coordinate system if necessary.)
@@ -1617,7 +1617,7 @@ impl Flow for InlineFlow {
16171617
self.base.late_absolute_position_info;
16181618

16191619
block_flow.base.stacking_relative_position =
1620-
stacking_relative_border_box.origin;
1620+
stacking_relative_border_box.origin.to_vector();
16211621

16221622
// As above, this is in our coordinate system for now.
16231623
block_flow.base.clip = self.base.clip.clone()
@@ -1633,10 +1633,10 @@ impl Flow for InlineFlow {
16331633
block_flow.base
16341634
.late_absolute_position_info
16351635
.stacking_relative_position_of_absolute_containing_block =
1636-
stacking_relative_position + padding_box_origin.to_vector();
1636+
*padding_box_origin + stacking_relative_position;
16371637

16381638
block_flow.base.stacking_relative_position =
1639-
stacking_relative_border_box.origin;
1639+
stacking_relative_border_box.origin.to_vector();
16401640

16411641
// As above, this is in our coordinate system for now.
16421642
block_flow.base.clip = self.base.clip.clone()

components/layout/multicol.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use app_units::Au;
1111
use block::BlockFlow;
1212
use context::LayoutContext;
1313
use display_list_builder::DisplayListBuildState;
14-
use euclid::Point2D;
15-
use euclid::Size2D;
14+
use euclid::{Point2D, Vector2D};
1615
use floats::FloatKind;
1716
use flow::{Flow, FlowClass, OpaqueFlow, mut_base, FragmentationContext};
1817
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
@@ -173,7 +172,7 @@ impl Flow for MulticolFlow {
173172
let pitch = pitch.to_physical(self.block_flow.base.writing_mode);
174173
for (i, child) in self.block_flow.base.children.iter_mut().enumerate() {
175174
let point = &mut mut_base(child).stacking_relative_position;
176-
*point = *point + Size2D::new(pitch.width * i as i32, pitch.height * i as i32);
175+
*point = *point + Vector2D::new(pitch.width * i as i32, pitch.height * i as i32);
177176
}
178177
}
179178

components/layout/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ fn process_resolved_style_request_internal<'a, N>(requested_node: N,
772772
let position = maybe_data.map_or(Point2D::zero(), |data| {
773773
match (*data).flow_construction_result {
774774
ConstructionResult::Flow(ref flow_ref, _) =>
775-
flow::base(flow_ref.deref()).stacking_relative_position,
775+
flow::base(flow_ref.deref()).stacking_relative_position.to_point(),
776776
// TODO(dzbarsky) search parents until we find node with a flow ref.
777777
// https://github.com/servo/servo/issues/8307
778778
_ => Point2D::zero()

components/layout/sequential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut Flow, iterator
108108
let mut stacking_context_position = *stacking_context_position;
109109
if kid.is_block_flow() && kid.as_block().fragment.establishes_stacking_context() {
110110
stacking_context_position = Point2D::new(kid.as_block().fragment.margin.inline_start, Au(0)) +
111-
flow::base(kid).stacking_relative_position.to_vector() +
111+
flow::base(kid).stacking_relative_position +
112112
stacking_context_position.to_vector();
113113
let relative_position = kid.as_block()
114114
.stacking_relative_position(CoordinateSystem::Own);

components/layout_thread/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ impl LayoutThread {
907907
|| {
908908
flow::mut_base(layout_root).stacking_relative_position =
909909
LogicalPoint::zero(writing_mode).to_physical(writing_mode,
910-
self.viewport_size);
910+
self.viewport_size).to_vector();
911911

912912
flow::mut_base(layout_root).clip = data.page_clip_rect;
913913

0 commit comments

Comments
 (0)