From 39600f9f4e1415d27df5a03530fd637c1b10f16f Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 4 Apr 2017 19:00:26 +0200 Subject: [PATCH] Update to support new clipping coordinates change --- components/gfx/display_list/mod.rs | 4 ++-- components/layout/display_list_builder.rs | 21 +++++++++++++-------- components/layout/webrender_helpers.rs | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index ee3494e1b95..e43767ddadd 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -510,8 +510,8 @@ pub struct ScrollRoot { /// The position of this scroll root's frame in the parent stacking context. pub clip: Rect, - /// The size of the contents that can be scrolled inside of the scroll root. - pub size: Size2D, + /// The rect of the contents that can be scrolled inside of the scroll root. + pub content_rect: Rect, } impl ScrollRoot { diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 94e388dff72..8c390487f5c 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -1963,24 +1963,29 @@ impl BlockFlowDisplayListBuilding for BlockFlow { &self.base.early_absolute_position_info.relative_containing_block_size, self.base.early_absolute_position_info.relative_containing_block_mode, coordinate_system); - let clip = self.fragment.stacking_relative_content_box(&border_box); + let content_box = self.fragment.stacking_relative_content_box(&border_box); - let has_scrolling_overflow = self.base.overflow.scroll.origin != Point2D::zero() || - self.base.overflow.scroll.size.width > clip.size.width || - self.base.overflow.scroll.size.height > clip.size.height; - self.mark_scrolling_overflow(has_scrolling_overflow); - if !has_scrolling_overflow { + // If we don't overflow our box at all, we can avoid creating a scroll root. + if self.base.overflow.scroll.origin == Point2D::zero() && + self.base.overflow.scroll.size.width <= content_box.size.width && + self.base.overflow.scroll.size.height <= content_box.size.height { + self.mark_scrolling_overflow(false); return containing_scroll_root_id; } + self.mark_scrolling_overflow(true); + let new_scroll_root_id = ScrollRootId::new_of_type(self.fragment.node.id() as usize, self.fragment.fragment_type()); + + let content_size = self.base.overflow.scroll.origin + self.base.overflow.scroll.size; state.add_scroll_root( ScrollRoot { id: new_scroll_root_id, parent_id: containing_scroll_root_id, - clip: clip, - size: self.base.overflow.scroll.size, + clip: Rect::new(Point2D::zero(), content_box.size), + content_rect: Rect::new(content_box.origin, + Size2D::new(content_size.x, content_size.y)), }, self.base.stacking_context_id ); diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs index 8f1f76f413f..355c5ebb7fc 100644 --- a/components/layout/webrender_helpers.rs +++ b/components/layout/webrender_helpers.rs @@ -425,8 +425,8 @@ impl WebRenderDisplayItemConverter for DisplayItem { None); let provided_id = ScrollLayerId::new(item.scroll_root.id.0 as u64, builder.pipeline_id); - let id = builder.define_clip(clip, - item.scroll_root.size.to_sizef(), + let id = builder.define_clip(item.scroll_root.content_rect.to_rectf(), + clip, Some(provided_id)); debug_assert!(provided_id == id); }