diff options
author | Martin Robinson <mrobinson@igalia.com> | 2017-03-20 10:47:12 +0100 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2017-03-27 08:43:07 +0200 |
commit | feac76701f21d3515e51375ab7c33d482a02e90e (patch) | |
tree | dd5a824f03ee28d2dd075ade11de1669345a3e5d | |
parent | d77fceaf241843d0fee246c1c910072fe041a69e (diff) | |
download | servo-feac76701f21d3515e51375ab7c33d482a02e90e.tar.gz servo-feac76701f21d3515e51375ab7c33d482a02e90e.zip |
Fix scroll root of absolutely positioned elements
Absolutely positioned elements should be given the scroll root of their
containing block and not necessarily the scroll root of their parent.
This fixes several CSS tests, though others are still failing pending a
similar fix for inherited clipping rectangles.
Fixes #13530.
8 files changed, 22 insertions, 22 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 456acf95c86..f97c3ad63b1 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -157,6 +157,11 @@ pub struct DisplayListBuildState<'a> { /// recursively building and processing the display list. pub current_scroll_root_id: ScrollRootId, + /// The scroll root id of the first ancestor which defines a containing block. + /// This is necessary because absolutely positioned items should be clipped + /// by their containing block's scroll root. + pub containing_block_scroll_root_id: ScrollRootId, + /// Vector containing iframe sizes, used to inform the constellation about /// new iframe sizes pub iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, CSSPixel>)>, @@ -173,6 +178,7 @@ impl<'a> DisplayListBuildState<'a> { processing_scroll_root_element: false, current_stacking_context_id: StackingContextId::root(), current_scroll_root_id: ScrollRootId::root(), + containing_block_scroll_root_id: ScrollRootId::root(), iframe_sizes: Vec::new(), } } @@ -1907,6 +1913,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow { state.current_stacking_context_id = self.base.stacking_context_id; let original_scroll_root_id = state.current_scroll_root_id; + let original_containing_block_scroll_root = state.containing_block_scroll_root_id; // We are getting the id of the scroll root that contains us here, not the id of // any scroll root that we create. If we create a scroll root, its id will be @@ -1931,12 +1938,19 @@ impl BlockFlowDisplayListBuilding for BlockFlow { } state.current_scroll_root_id = original_scroll_root_id; + state.containing_block_scroll_root_id = original_containing_block_scroll_root; state.current_stacking_context_id = parent_stacking_context_id; } fn setup_scroll_root_for_block(&mut self, state: &mut DisplayListBuildState) -> ScrollRootId { - let containing_scroll_root_id = state.current_scroll_root_id; + // If this block is absolutely positioned, we should be clipped and positioned by + // the scroll root of our nearest ancestor that establishes a containing block. + let containing_scroll_root_id = match self.positioning() { + position::T::absolute => state.containing_block_scroll_root_id, + _ => state.current_scroll_root_id, + }; self.base.scroll_root_id = containing_scroll_root_id; + state.current_scroll_root_id = containing_scroll_root_id; if !self.style_permits_scrolling_overflow() { return containing_scroll_root_id; @@ -1977,6 +1991,13 @@ impl BlockFlowDisplayListBuilding for BlockFlow { self.base.scroll_root_id = new_scroll_root_id; state.current_scroll_root_id = new_scroll_root_id; + + match self.positioning() { + position::T::absolute | position::T::relative | position::T::fixed => + state.containing_block_scroll_root_id = new_scroll_root_id, + _ => {} + } + containing_scroll_root_id } diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-001.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-001.htm.ini deleted file mode 100644 index fd062e21561..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-001.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-001.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-002.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-002.htm.ini deleted file mode 100644 index 65aae5f847d..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-002.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-002.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-003.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-003.htm.ini deleted file mode 100644 index eddd72c242f..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-003.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-003.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-007.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-007.htm.ini deleted file mode 100644 index 6c620e848f8..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-007.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-007.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-008.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-008.htm.ini deleted file mode 100644 index 2bcd4417a78..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-008.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-008.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-009.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-009.htm.ini deleted file mode 100644 index cabe875e59f..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-009.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-009.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-012.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-012.htm.ini deleted file mode 100644 index 9b77e69d1de..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/abspos-overflow-012.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[abspos-overflow-012.htm] - type: reftest - expected: FAIL |