From 3dc4b5d94df83ab7925fb03f7381b326a87ed0f6 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 14 Oct 2016 23:47:24 -0500 Subject: [PATCH] servo: Merge #13765 - layout: Make percentages in `top` and `bottom` for relative positions relative to height, not width (from pcwalton:relative-position-vertical-percentage); r=emilio Improves etsy.com. Closes #13760. r? @mbrubeck Source-Repo: https://github.com/servo/servo Source-Revision: 759185abe05c31c2851d9ac586ddc2d065aa755f --- servo/components/layout/block.rs | 25 ++++++++++++++----------- servo/components/layout/fragment.rs | 4 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/servo/components/layout/block.rs b/servo/components/layout/block.rs index d3b42c2ded02..1c1ff0287daa 100644 --- a/servo/components/layout/block.rs +++ b/servo/components/layout/block.rs @@ -753,6 +753,17 @@ impl BlockFlow { } } + /// Writes in the size of the relative containing block for children. (This information + /// is also needed to handle RTL.) + fn propagate_early_absolute_position_info_to_children(&mut self) { + for kid in self.base.child_iter_mut() { + flow::mut_base(kid).early_absolute_position_info = EarlyAbsolutePositionInfo { + relative_containing_block_size: self.fragment.content_box().size, + relative_containing_block_mode: self.fragment.style().writing_mode, + } + } + } + /// Assign block-size for current flow. /// /// * Collapse margins for flow's children and set in-flow child flows' block offsets now that @@ -1011,16 +1022,9 @@ impl BlockFlow { self.fragment.border_box.size.block = block_size; } - // Write in the size of the relative containing block for children. (This information - // is also needed to handle RTL.) - for kid in self.base.child_iter_mut() { - flow::mut_base(kid).early_absolute_position_info = EarlyAbsolutePositionInfo { - relative_containing_block_size: self.fragment.content_box().size, - relative_containing_block_mode: self.fragment.style().writing_mode, - }; - } if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { + self.propagate_early_absolute_position_info_to_children(); return None } @@ -1050,10 +1054,9 @@ impl BlockFlow { // position. self.fragment.border_box.size.block = cur_b; self.fragment.border_box.start.b = Au(0); + self.base.position.size.block = cur_b; - if !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { - self.base.position.size.block = cur_b; - } + self.propagate_early_absolute_position_info_to_children(); // Translate the current set of floats back into the parent coordinate system in the // inline direction, and store them in the flow so that flows that come later in the diff --git a/servo/components/layout/fragment.rs b/servo/components/layout/fragment.rs index 1fa29bac16be..7693e1113472 100644 --- a/servo/components/layout/fragment.rs +++ b/servo/components/layout/fragment.rs @@ -1379,10 +1379,10 @@ impl Fragment { }; let offset_b = if offsets.block_start != LengthOrPercentageOrAuto::Auto { MaybeAuto::from_style(offsets.block_start, - container_size.inline).specified_or_zero() + container_size.block).specified_or_zero() } else { -MaybeAuto::from_style(offsets.block_end, - container_size.inline).specified_or_zero() + container_size.block).specified_or_zero() }; LogicalSize::new(style.writing_mode, offset_i, offset_b) }