mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Keep track of the containing block writing mode.
This is necessary for correctly converting `relative_containing_block_size` to physical coordinates.
This commit is contained in:
parent
8221bfc3ef
commit
cabbbcc978
5 changed files with 38 additions and 4 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue