From f090d00c095513eac27e21f2e5fead43c6c401ae Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Mon, 28 Nov 2016 13:10:56 +0100 Subject: [PATCH] Don't scroll background and borders of overflow:scroll blocks We want them to be children of the parent scrolling root instead of the scrolling root of the particular block they belong to. Also, we adjust the scroll root to only include the content region. --- components/layout/display_list_builder.rs | 31 +++++++++++++----- tests/wpt/mozilla/meta/MANIFEST.json | 24 ++++++++++++++ .../scrolling_div_background_borders.html | 25 ++++++++++++++ ...ling_div_background_borders_background.png | Bin 0 -> 366 bytes .../scrolling_div_background_borders_ref.html | 13 ++++++++ 5 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders.html create mode 100644 tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders_background.png create mode 100644 tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders_ref.html diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 4505ac10192..0c34a147655 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -15,7 +15,6 @@ use block::{BlockFlow, BlockStackingContextType}; use canvas_traits::{CanvasData, CanvasMsg, FromLayoutMsg}; use context::SharedLayoutContext; use euclid::{Matrix4D, Point2D, Radians, Rect, SideOffsets2D, Size2D}; -use euclid::point::TypedPoint2D; use flex::FlexFlow; use flow::{BaseFlow, Flow, IS_ABSOLUTELY_POSITIONED}; use flow_ref::FlowRef; @@ -98,6 +97,7 @@ pub struct DisplayListBuildState<'a> { pub scroll_roots: HashMap, pub stacking_context_id_stack: Vec, pub scroll_root_id_stack: Vec, + pub processing_scroll_root_element: bool, } impl<'a> DisplayListBuildState<'a> { @@ -111,6 +111,7 @@ impl<'a> DisplayListBuildState<'a> { scroll_roots: HashMap::new(), stacking_context_id_stack: vec!(stacking_context_id), scroll_root_id_stack: vec!(ScrollRootId::root()), + processing_scroll_root_element: false, } } @@ -162,6 +163,14 @@ impl<'a> DisplayListBuildState<'a> { cursor: Option, section: DisplayListSection) -> BaseDisplayItem { + let scroll_root_id = if (section == DisplayListSection::BackgroundAndBorders || + section == DisplayListSection::BlockBackgroundsAndBorders) && + self.processing_scroll_root_element { + self.parent_scroll_root_id() + } else { + self.scroll_root_id() + }; + BaseDisplayItem::new(&bounds, DisplayItemMetadata { node: node, @@ -170,7 +179,7 @@ impl<'a> DisplayListBuildState<'a> { &clip, section, self.stacking_context_id(), - self.scroll_root_id()) + scroll_root_id) } pub fn to_display_list(mut self) -> DisplayList { @@ -1977,21 +1986,25 @@ impl BlockFlowDisplayListBuilding for BlockFlow { if self.has_scrolling_overflow() { let size = self.base.overflow.scroll.size; - let mut clip = self.fragment.stacking_relative_border_box( + let coordinate_system = if establishes_stacking_context { + CoordinateSystem::Own + } else { + CoordinateSystem::Parent + }; + + let border_box = self.fragment.stacking_relative_border_box( &self.base.stacking_relative_position, &self.base.early_absolute_position_info.relative_containing_block_size, self.base.early_absolute_position_info.relative_containing_block_mode, - CoordinateSystem::Parent); - if establishes_stacking_context { - clip = Rect::new(TypedPoint2D::zero(), clip.size); - } + coordinate_system); let parent_id = state.parent_scroll_root_id(); + state.processing_scroll_root_element = true; state.add_scroll_root( ScrollRoot { id: self.base.scroll_root_id, parent_id: parent_id, - clip: clip, + clip: self.fragment.stacking_relative_content_box(&border_box), size: size, } ); @@ -2012,6 +2025,8 @@ impl BlockFlowDisplayListBuilding for BlockFlow { &self.base.clip); self.base.build_display_items_for_debugging_tint(state, self.fragment.node); + + state.processing_scroll_root_element = false; } fn switch_coordinate_system_if_necessary(&mut self) { diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index d8d9a7a5ca7..bc3a420f79c 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6414,6 +6414,18 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/scrolling_div_background_borders.html": [ + { + "path": "mozilla/scrolling_div_background_borders.html", + "references": [ + [ + "/_mozilla/mozilla/scrolling_div_background_borders_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/scrolling_div_background_borders.html" + } + ], "mozilla/simple_scroll_to_fragment.html": [ { "path": "mozilla/simple_scroll_to_fragment.html", @@ -21444,6 +21456,18 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/scrolling_div_background_borders.html": [ + { + "path": "mozilla/scrolling_div_background_borders.html", + "references": [ + [ + "/_mozilla/mozilla/scrolling_div_background_borders_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/scrolling_div_background_borders.html" + } + ], "mozilla/simple_scroll_to_fragment.html": [ { "path": "mozilla/simple_scroll_to_fragment.html", diff --git a/tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders.html b/tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders.html new file mode 100644 index 00000000000..6f168aa258c --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders.html @@ -0,0 +1,25 @@ + + +Background and borders of scrolling div should not scroll + + + + + +
+
+
+ + + diff --git a/tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders_background.png b/tests/wpt/mozilla/tests/mozilla/scrolling_div_background_borders_background.png new file mode 100644 index 0000000000000000000000000000000000000000..24d8886dd9f9df9f227abcb27e01e1dcd406e972 GIT binary patch literal 366 zcmeAS@N?(olHy`uVBq!ia0vp^DL{OJgAGW^*|;18Qfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#0k;g7qJXx+3s<0!Y-UJAiF1B#Zfaf$kjuc}T$Gwv zlA5AWo>`Ki;O^-gkfN8$4ivxS>EaktaqI0xMqUO34wjAS|7@GNH%$mT6w3tGN07)_ z + + + +
+