Make scrollable viewport size no longer depend on clip layer.
In non-solid-color mode, the scrollable viewport size calculation was
ignoring device_viewport_size and using the clip layer size instead, in
order to take into account non-overlay-scrollbars. This was weird and
was going to behave incorrectly with desktop pinch zoom. This patch
changes the non-overlay-scrollbar size to be added to the max scroll
offset instead.
NOTRY=true
BUG=259141
Review URL: https://chromiumcodereview.appspot.com/18202006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211496 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 25cd58a6..e5aef8a30 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -136,7 +136,6 @@
}
LayerImpl* LayerTreeImpl::RootScrollLayer() const {
- DCHECK(IsActiveTree());
return root_scroll_layer_;
}
@@ -209,12 +208,22 @@
}
void LayerTreeImpl::UpdateMaxScrollOffset() {
- if (!root_scroll_layer_ || !root_scroll_layer_->children().size())
+ LayerImpl* root_scroll = RootScrollLayer();
+ if (!root_scroll || !root_scroll->children().size())
return;
gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() -
gfx::RectF(ScrollableViewportSize()).bottom_right();
+ // The scrollable viewport size is based on device viewport instead of Blink's
+ // container layer, so we need to adjust for non-overlay scrollbars.
+ ScrollbarLayerImpl* horiz = root_scroll->horizontal_scrollbar_layer();
+ ScrollbarLayerImpl* vertical = root_scroll->vertical_scrollbar_layer();
+ if (horiz && !horiz->is_overlay_scrollbar())
+ max_scroll.set_y(max_scroll.y() + horiz->thumb_thickness());
+ if (vertical && !vertical->is_overlay_scrollbar())
+ max_scroll.set_x(max_scroll.x() + vertical->thumb_thickness());
+
// The viewport may be larger than the contents in some cases, such as
// having a vertical scrollbar but no horizontal overflow.
max_scroll.SetToMax(gfx::Vector2dF());