diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2015-03-05 08:43:36 -0800 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2015-03-09 14:22:36 -0700 |
commit | cabbbcc97801e53dff4d1111cba66b0054216ee3 (patch) | |
tree | 2f10735e89010ad3f45c654448bd1ee34f0c85c5 /components/layout | |
parent | 8221bfc3ef854d90ecb9a0df3aa490310cbe8469 (diff) | |
download | servo-cabbbcc97801e53dff4d1111cba66b0054216ee3.tar.gz servo-cabbbcc97801e53dff4d1111cba66b0054216ee3.zip |
Keep track of the containing block writing mode.
This is necessary for correctly converting `relative_containing_block_size`
to physical coordinates.
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/block.rs | 7 | ||||
-rw-r--r-- | components/layout/display_list_builder.rs | 18 | ||||
-rw-r--r-- | components/layout/flow.rs | 4 | ||||
-rw-r--r-- | components/layout/fragment.rs | 7 | ||||
-rw-r--r-- | components/layout/inline.rs | 6 |
5 files changed, 38 insertions, 4 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 356232f90f8..456ee73d09b 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1804,6 +1804,7 @@ impl Flow for BlockFlow { stacking_relative_position_of_absolute_containing_block: stacking_relative_position_of_absolute_containing_block_for_children, relative_containing_block_size: self.fragment.content_box().size, + relative_containing_block_mode: self.base.writing_mode, layers_needed_for_positioned_flows: self.base .flags .contains(LAYERS_NEEDED_FOR_DESCENDANTS), @@ -1836,6 +1837,9 @@ impl Flow for BlockFlow { &self.base .absolute_position_info .relative_containing_block_size, + self.base + .absolute_position_info + .relative_containing_block_mode, CoordinateSystem::Self); let clip = self.fragment.clipping_region_for_children(&clip_in_child_coordinate_system, &stacking_relative_border_box); @@ -1939,6 +1943,9 @@ impl Flow for BlockFlow { &self.base .absolute_position_info .relative_containing_block_size, + self.base + .absolute_position_info + .relative_containing_block_mode, CoordinateSystem::Parent) .translate(stacking_context_position)); } diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index c9e82e7eb8e..b5985a8a937 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -39,7 +39,7 @@ use msg::constellation_msg::ConstellationChan; use net::image::holder::ImageHolder; use util::cursor::Cursor; use util::geometry::{self, Au, ZERO_POINT, to_px, to_frac_px}; -use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize}; +use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use util::opts; use std::cmp; use std::default::Default; @@ -181,6 +181,7 @@ pub trait FragmentDisplayListBuilding { layout_context: &LayoutContext, stacking_relative_flow_origin: &Point2D<Au>, relative_containing_block_size: &LogicalSize<Au>, + relative_containing_block_mode: WritingMode, background_and_border_level: BackgroundAndBorderLevel, clip: &ClippingRegion); @@ -785,6 +786,7 @@ impl FragmentDisplayListBuilding for Fragment { layout_context: &LayoutContext, stacking_relative_flow_origin: &Point2D<Au>, relative_containing_block_size: &LogicalSize<Au>, + relative_containing_block_mode: WritingMode, background_and_border_level: BackgroundAndBorderLevel, clip: &ClippingRegion) { // Compute the fragment position relative to the parent stacking context. If the fragment @@ -793,6 +795,7 @@ impl FragmentDisplayListBuilding for Fragment { let stacking_relative_border_box = self.stacking_relative_border_box(stacking_relative_flow_origin, relative_containing_block_size, + relative_containing_block_mode, CoordinateSystem::Self); debug!("Fragment::build_display_list at rel={:?}, abs={:?}, dirty={:?}, flow origin={:?}: \ @@ -1254,6 +1257,9 @@ impl BlockFlowDisplayListBuilding for BlockFlow { &self.base .absolute_position_info .relative_containing_block_size, + self.base + .absolute_position_info + .relative_containing_block_mode, background_border_level, &self.base.clip); @@ -1357,6 +1363,9 @@ impl BlockFlowDisplayListBuilding for BlockFlow { &self.base .absolute_position_info .relative_containing_block_size, + self.base + .absolute_position_info + .relative_containing_block_mode, CoordinateSystem::Parent); // FIXME(pcwalton): Is this vertical-writing-direction-safe? @@ -1399,6 +1408,9 @@ impl InlineFlowDisplayListBuilding for InlineFlow { &self.base .absolute_position_info .relative_containing_block_size, + self.base + .absolute_position_info + .relative_containing_block_mode, BackgroundAndBorderLevel::Content, &self.base.clip); match fragment.specific { @@ -1448,6 +1460,10 @@ impl ListItemFlowDisplayListBuilding for ListItemFlow { .base .absolute_position_info .relative_containing_block_size, + self.block_flow + .base + .absolute_position_info + .relative_containing_block_mode, BackgroundAndBorderLevel::Content, &self.block_flow.base.clip); } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 0633ee43b7d..6049afa8634 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -683,6 +683,9 @@ pub struct AbsolutePositionInfo { /// The size of the containing block for relatively-positioned descendants. pub relative_containing_block_size: LogicalSize<Au>, + /// The writing mode for `relative_containing_block_size`. + pub relative_containing_block_mode: WritingMode, + /// The position of the absolute containing block relative to the nearest ancestor stacking /// context. If the absolute containing block establishes the stacking context for this flow, /// and this flow is not itself absolutely-positioned, then this is (0, 0). @@ -700,6 +703,7 @@ impl AbsolutePositionInfo { // of the root layer. AbsolutePositionInfo { relative_containing_block_size: LogicalSize::zero(writing_mode), + relative_containing_block_mode: writing_mode, stacking_relative_position_of_absolute_containing_block: Point2D::zero(), layers_needed_for_positioned_flows: false, } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 1a32b813488..4faa266217c 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -34,7 +34,7 @@ use msg::constellation_msg::{ConstellationChan, Msg, PipelineId, SubpageId}; use net::image::holder::ImageHolder; use net::local_image_cache::LocalImageCache; use util::geometry::{self, Au, ZERO_POINT}; -use util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin}; +use util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin, WritingMode}; use util::range::*; use util::smallvec::SmallVec; use util::str::is_whitespace; @@ -1973,10 +1973,11 @@ impl Fragment { pub fn stacking_relative_border_box(&self, stacking_relative_flow_origin: &Point2D<Au>, relative_containing_block_size: &LogicalSize<Au>, + relative_containing_block_mode: WritingMode, coordinate_system: CoordinateSystem) -> Rect<Au> { - // FIXME (mbrubeck): Get the real container size, taking vertical writing modes into account. - let container_size = Size2D(relative_containing_block_size.inline, relative_containing_block_size.block); + let container_size = + relative_containing_block_size.to_physical(relative_containing_block_mode); let border_box = self.border_box.to_physical(self.style.writing_mode, container_size); if coordinate_system == CoordinateSystem::Self && self.establishes_stacking_context() { return Rect(ZERO_POINT, border_box.size) diff --git a/components/layout/inline.rs b/components/layout/inline.rs index e5087c4d6a8..679a8eae608 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1332,6 +1332,9 @@ impl Flow for InlineFlow { &self.base .absolute_position_info .relative_containing_block_size, + self.base + .absolute_position_info + .relative_containing_block_mode, CoordinateSystem::Self); let clip = fragment.clipping_region_for_children(&self.base.clip, &stacking_relative_border_box); @@ -1386,9 +1389,12 @@ impl Flow for InlineFlow { let stacking_relative_position = &self.base.stacking_relative_position; let relative_containing_block_size = &self.base.absolute_position_info.relative_containing_block_size; + let relative_containing_block_mode = + self.base.absolute_position_info.relative_containing_block_mode; iterator.process(fragment, &fragment.stacking_relative_border_box(stacking_relative_position, relative_containing_block_size, + relative_containing_block_mode, CoordinateSystem::Parent) .translate(stacking_context_position)) } |