mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make BaseFlow::stacking_relative_position a vector.
This commit is contained in:
parent
8617320500
commit
997608f11f
9 changed files with 23 additions and 24 deletions
|
@ -2000,7 +2000,7 @@ impl Flow for BlockFlow {
|
||||||
self.base
|
self.base
|
||||||
.late_absolute_position_info
|
.late_absolute_position_info
|
||||||
.stacking_relative_position_of_absolute_containing_block =
|
.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,
|
(border_box_origin + relative_offset).to_physical(self.base.writing_mode,
|
||||||
container_size).to_vector()
|
container_size).to_vector()
|
||||||
}
|
}
|
||||||
|
@ -2021,7 +2021,7 @@ impl Flow for BlockFlow {
|
||||||
// `transform` set.) In this case, absolutely-positioned children will not be
|
// `transform` set.) In this case, absolutely-positioned children will not be
|
||||||
// positioned relative to us but will instead be positioned relative to our
|
// positioned relative to us but will instead be positioned relative to our
|
||||||
// containing block.
|
// containing block.
|
||||||
position - self.base.stacking_relative_position.to_vector()
|
position - self.base.stacking_relative_position
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.base
|
self.base
|
||||||
|
@ -2036,7 +2036,7 @@ impl Flow for BlockFlow {
|
||||||
self.base.position.size.to_physical(self.base.writing_mode);
|
self.base.position.size.to_physical(self.base.writing_mode);
|
||||||
|
|
||||||
// Compute the origin and clipping rectangle for children.
|
// 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 is_stacking_context = self.fragment.establishes_stacking_context();
|
||||||
let origin_for_children = if is_stacking_context {
|
let origin_for_children = if is_stacking_context {
|
||||||
// We establish a stacking context, so the position of our children is vertically
|
// 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);
|
let margin = self.fragment.margin.to_physical(self.base.writing_mode);
|
||||||
Point2D::new(-margin.left, Au(0))
|
Point2D::new(-margin.left, Au(0))
|
||||||
} else {
|
} else {
|
||||||
self.base.stacking_relative_position + relative_offset
|
self.base.stacking_relative_position.to_point() + relative_offset
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process children.
|
// Process children.
|
||||||
|
|
|
@ -501,7 +501,7 @@ pub trait FragmentDisplayListBuilding {
|
||||||
/// * `clip`: The region to clip the display items to.
|
/// * `clip`: The region to clip the display items to.
|
||||||
fn build_display_list(&mut self,
|
fn build_display_list(&mut self,
|
||||||
state: &mut DisplayListBuildState,
|
state: &mut DisplayListBuildState,
|
||||||
stacking_relative_flow_origin: &Point2D<Au>,
|
stacking_relative_flow_origin: &Vector2D<Au>,
|
||||||
relative_containing_block_size: &LogicalSize<Au>,
|
relative_containing_block_size: &LogicalSize<Au>,
|
||||||
relative_containing_block_mode: WritingMode,
|
relative_containing_block_mode: WritingMode,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
|
@ -1707,7 +1707,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
|
|
||||||
fn build_display_list(&mut self,
|
fn build_display_list(&mut self,
|
||||||
state: &mut DisplayListBuildState,
|
state: &mut DisplayListBuildState,
|
||||||
stacking_relative_flow_origin: &Point2D<Au>,
|
stacking_relative_flow_origin: &Vector2D<Au>,
|
||||||
relative_containing_block_size: &LogicalSize<Au>,
|
relative_containing_block_size: &LogicalSize<Au>,
|
||||||
relative_containing_block_mode: WritingMode,
|
relative_containing_block_mode: WritingMode,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
|
@ -1999,7 +1999,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
// First, compute the offset of our border box (including relative positioning)
|
// First, compute the offset of our border box (including relative positioning)
|
||||||
// from our flow origin, since that is what `BaseFlow::overflow` is relative to.
|
// from our flow origin, since that is what `BaseFlow::overflow` is relative to.
|
||||||
let border_box_offset =
|
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.
|
// Then, using that, compute our overflow region relative to our border box.
|
||||||
let overflow = base_flow.overflow.paint.translate(&-border_box_offset.to_vector());
|
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 thread_id = self.thread_id;
|
||||||
let stacking_context_relative_bounds =
|
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));
|
self.position.size.to_physical(self.writing_mode));
|
||||||
|
|
||||||
let mut color = THREAD_TINT_COLORS[thread_id as usize % THREAD_TINT_COLORS.len()];
|
let mut color = THREAD_TINT_COLORS[thread_id as usize % THREAD_TINT_COLORS.len()];
|
||||||
|
|
|
@ -29,7 +29,7 @@ use app_units::Au;
|
||||||
use block::{BlockFlow, FormattingContextType};
|
use block::{BlockFlow, FormattingContextType};
|
||||||
use context::LayoutContext;
|
use context::LayoutContext;
|
||||||
use display_list_builder::DisplayListBuildState;
|
use display_list_builder::DisplayListBuildState;
|
||||||
use euclid::{Transform3D, Point2D, Rect, Size2D};
|
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D};
|
||||||
use flex::FlexFlow;
|
use flex::FlexFlow;
|
||||||
use floats::{Floats, SpeculatedFloatPlacement};
|
use floats::{Floats, SpeculatedFloatPlacement};
|
||||||
use flow_list::{FlowList, MutFlowListIterator};
|
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.
|
/// 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.
|
/// 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
|
/// 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.
|
/// containing block. This is in tree order. This includes any direct children.
|
||||||
|
@ -1098,7 +1098,7 @@ impl BaseFlow {
|
||||||
parallel: FlowParallelInfo::new(),
|
parallel: FlowParallelInfo::new(),
|
||||||
floats: Floats::new(writing_mode),
|
floats: Floats::new(writing_mode),
|
||||||
collapsible_margins: CollapsibleMargins::new(),
|
collapsible_margins: CollapsibleMargins::new(),
|
||||||
stacking_relative_position: Point2D::zero(),
|
stacking_relative_position: Vector2D::zero(),
|
||||||
abs_descendants: AbsoluteDescendants::new(),
|
abs_descendants: AbsoluteDescendants::new(),
|
||||||
speculated_float_placement_in: SpeculatedFloatPlacement::zero(),
|
speculated_float_placement_in: SpeculatedFloatPlacement::zero(),
|
||||||
speculated_float_placement_out: SpeculatedFloatPlacement::zero(),
|
speculated_float_placement_out: SpeculatedFloatPlacement::zero(),
|
||||||
|
|
|
@ -2422,7 +2422,7 @@ impl Fragment {
|
||||||
/// This is the method you should use for display list construction as well as
|
/// This is the method you should use for display list construction as well as
|
||||||
/// `getBoundingClientRect()` and so forth.
|
/// `getBoundingClientRect()` and so forth.
|
||||||
pub fn stacking_relative_border_box(&self,
|
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_size: &LogicalSize<Au>,
|
||||||
relative_containing_block_mode: WritingMode,
|
relative_containing_block_mode: WritingMode,
|
||||||
coordinate_system: CoordinateSystem)
|
coordinate_system: CoordinateSystem)
|
||||||
|
@ -2440,7 +2440,7 @@ impl Fragment {
|
||||||
// this.
|
// this.
|
||||||
let relative_position = self.relative_position(relative_containing_block_size);
|
let relative_position = self.relative_position(relative_containing_block_size);
|
||||||
border_box.translate_by_size(&relative_position.to_physical(self.style.writing_mode))
|
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
|
/// Given the stacking-context-relative border box, returns the stacking-context-relative
|
||||||
|
|
|
@ -1600,11 +1600,11 @@ impl Flow for InlineFlow {
|
||||||
block_flow.base
|
block_flow.base
|
||||||
.late_absolute_position_info
|
.late_absolute_position_info
|
||||||
.stacking_relative_position_of_absolute_containing_block =
|
.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 =
|
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
|
// 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.)
|
// 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;
|
self.base.late_absolute_position_info;
|
||||||
|
|
||||||
block_flow.base.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.
|
// As above, this is in our coordinate system for now.
|
||||||
block_flow.base.clip = self.base.clip.clone()
|
block_flow.base.clip = self.base.clip.clone()
|
||||||
|
@ -1633,10 +1633,10 @@ impl Flow for InlineFlow {
|
||||||
block_flow.base
|
block_flow.base
|
||||||
.late_absolute_position_info
|
.late_absolute_position_info
|
||||||
.stacking_relative_position_of_absolute_containing_block =
|
.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 =
|
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.
|
// As above, this is in our coordinate system for now.
|
||||||
block_flow.base.clip = self.base.clip.clone()
|
block_flow.base.clip = self.base.clip.clone()
|
||||||
|
|
|
@ -11,8 +11,7 @@ use app_units::Au;
|
||||||
use block::BlockFlow;
|
use block::BlockFlow;
|
||||||
use context::LayoutContext;
|
use context::LayoutContext;
|
||||||
use display_list_builder::DisplayListBuildState;
|
use display_list_builder::DisplayListBuildState;
|
||||||
use euclid::Point2D;
|
use euclid::{Point2D, Vector2D};
|
||||||
use euclid::Size2D;
|
|
||||||
use floats::FloatKind;
|
use floats::FloatKind;
|
||||||
use flow::{Flow, FlowClass, OpaqueFlow, mut_base, FragmentationContext};
|
use flow::{Flow, FlowClass, OpaqueFlow, mut_base, FragmentationContext};
|
||||||
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
|
@ -173,7 +172,7 @@ impl Flow for MulticolFlow {
|
||||||
let pitch = pitch.to_physical(self.block_flow.base.writing_mode);
|
let pitch = pitch.to_physical(self.block_flow.base.writing_mode);
|
||||||
for (i, child) in self.block_flow.base.children.iter_mut().enumerate() {
|
for (i, child) in self.block_flow.base.children.iter_mut().enumerate() {
|
||||||
let point = &mut mut_base(child).stacking_relative_position;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -772,7 +772,7 @@ fn process_resolved_style_request_internal<'a, N>(requested_node: N,
|
||||||
let position = maybe_data.map_or(Point2D::zero(), |data| {
|
let position = maybe_data.map_or(Point2D::zero(), |data| {
|
||||||
match (*data).flow_construction_result {
|
match (*data).flow_construction_result {
|
||||||
ConstructionResult::Flow(ref flow_ref, _) =>
|
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.
|
// TODO(dzbarsky) search parents until we find node with a flow ref.
|
||||||
// https://github.com/servo/servo/issues/8307
|
// https://github.com/servo/servo/issues/8307
|
||||||
_ => Point2D::zero()
|
_ => Point2D::zero()
|
||||||
|
|
|
@ -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;
|
let mut stacking_context_position = *stacking_context_position;
|
||||||
if kid.is_block_flow() && kid.as_block().fragment.establishes_stacking_context() {
|
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)) +
|
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();
|
stacking_context_position.to_vector();
|
||||||
let relative_position = kid.as_block()
|
let relative_position = kid.as_block()
|
||||||
.stacking_relative_position(CoordinateSystem::Own);
|
.stacking_relative_position(CoordinateSystem::Own);
|
||||||
|
|
|
@ -907,7 +907,7 @@ impl LayoutThread {
|
||||||
|| {
|
|| {
|
||||||
flow::mut_base(layout_root).stacking_relative_position =
|
flow::mut_base(layout_root).stacking_relative_position =
|
||||||
LogicalPoint::zero(writing_mode).to_physical(writing_mode,
|
LogicalPoint::zero(writing_mode).to_physical(writing_mode,
|
||||||
self.viewport_size);
|
self.viewport_size).to_vector();
|
||||||
|
|
||||||
flow::mut_base(layout_root).clip = data.page_clip_rect;
|
flow::mut_base(layout_root).clip = data.page_clip_rect;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue