From 441cc479a3111a823d1ba9055baef0e1c135e243 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 28 Sep 2015 11:13:51 -0700 Subject: [PATCH] Use the correct container size in compute_overflow Fixes #7768 - positioning of RTL stacking contexts. --- components/layout/block.rs | 7 ++++--- components/layout/fragment.rs | 9 ++++++--- components/layout/inline.rs | 3 ++- tests/wpt/mozilla/meta/MANIFEST.json | 14 ++++++++++++- .../tests/css/stacking_context_rtl-ref.html | 16 +++++++++++++++ .../tests/css/stacking_context_rtl.html | 20 +++++++++++++++++++ 6 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 tests/wpt/mozilla/tests/css/stacking_context_rtl-ref.html create mode 100644 tests/wpt/mozilla/tests/css/stacking_context_rtl.html diff --git a/components/layout/block.rs b/components/layout/block.rs index 1083c174979..890353b7a10 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -2126,9 +2126,10 @@ impl Flow for BlockFlow { } fn compute_overflow(&self) -> Rect { - self.fragment.compute_overflow(&self.base - .early_absolute_position_info - .relative_containing_block_size) + self.fragment.compute_overflow(&self.base.early_absolute_position_info + .relative_containing_block_size, + self.base.early_absolute_position_info + .relative_containing_block_mode) } fn iterate_through_fragment_border_boxes(&self, diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 5981f13b7ab..c6cea07b77b 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -2160,9 +2160,12 @@ impl Fragment { } /// Computes the overflow rect of this fragment relative to the start of the flow. - pub fn compute_overflow(&self, relative_containing_block_size: &LogicalSize) -> Rect { - // FIXME(pcwalton, #2795): Get the real container size. - let container_size = Size2D::zero(); + pub fn compute_overflow(&self, + relative_containing_block_size: &LogicalSize, + relative_containing_block_mode: WritingMode) + -> Rect { + let container_size = + relative_containing_block_size.to_physical(relative_containing_block_mode); let mut border_box = self.border_box.to_physical(self.style.writing_mode, container_size); // Relative position can cause us to draw outside our border box. diff --git a/components/layout/inline.rs b/components/layout/inline.rs index cdcc46e2ad9..5692ffa93df 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1775,7 +1775,8 @@ impl Flow for InlineFlow { let mut overflow = ZERO_RECT; for fragment in &self.fragments.fragments { overflow = overflow.union(&fragment.compute_overflow( - &self.base.early_absolute_position_info.relative_containing_block_size)) + &self.base.early_absolute_position_info.relative_containing_block_size, + self.base.early_absolute_position_info.relative_containing_block_mode)); } overflow } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 1449da68159..5f0453b175e 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -111,6 +111,18 @@ "url": "/_mozilla/css/setpropertypriority.html" } ], + "css/stacking_context_rtl.html": [ + { + "path": "css/stacking_context_rtl.html", + "references": [ + [ + "/_mozilla/css/stacking_context_rtl-ref.html", + "==" + ] + ], + "url": "/_mozilla/css/stacking_context_rtl.html" + } + ], "css/word-spacing.html": [ { "path": "css/word-spacing.html", @@ -1118,4 +1130,4 @@ "rev": null, "url_base": "/_mozilla/", "version": 2 -} \ No newline at end of file +} diff --git a/tests/wpt/mozilla/tests/css/stacking_context_rtl-ref.html b/tests/wpt/mozilla/tests/css/stacking_context_rtl-ref.html new file mode 100644 index 00000000000..1ad1875d756 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/stacking_context_rtl-ref.html @@ -0,0 +1,16 @@ + + + + + + + + Test passes if there is a green rectangle below. +
+ + diff --git a/tests/wpt/mozilla/tests/css/stacking_context_rtl.html b/tests/wpt/mozilla/tests/css/stacking_context_rtl.html new file mode 100644 index 00000000000..2bd24384710 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/stacking_context_rtl.html @@ -0,0 +1,20 @@ + + + + + + + + + Test passes if there is a green rectangle below. +
+ +