summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoraelias <aelias@chromium.org>2015-11-03 16:12:50 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-04 00:14:24 +0000
commit14d87e0c931bff8ba92b146aea20fa74af4183b3 (patch)
tree24fc5b2ba3907c534970b6ce668fac53e7fad132 /cc
parent1b3c3b36b8efb090463560e74d298fe055dc0065 (diff)
downloadchromium_src-14d87e0c931bff8ba92b146aea20fa74af4183b3.zip
chromium_src-14d87e0c931bff8ba92b146aea20fa74af4183b3.tar.gz
chromium_src-14d87e0c931bff8ba92b146aea20fa74af4183b3.tar.bz2
Clamp clip layer to outer viewport size for scrollbars (2nd land)
When there is a nonoverlay scrollbar, the inner viewport is larger than the outer by the size of the scrollbar. The outer viewport can still be free to scroll within the content area, so we should take the minimum of both sizes. This version adds a NULL check due to single-threaded layout tests needing it. BUG=547668 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1414573007 Cr-Commit-Position: refs/heads/master@{#357680}
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc34
-rw-r--r--cc/trees/layer_tree_impl.cc2
2 files changed, 36 insertions, 0 deletions
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 2f98767..dc94e6e 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -2385,6 +2385,40 @@ TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) {
RunTest(LayerTreeSettings::THINNING);
}
+TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) {
+ LayerTreeSettings settings;
+ CreateHostImpl(settings, CreateOutputSurface());
+
+ gfx::Size inner_viewport_size(315, 200);
+ gfx::Size outer_viewport_size(300, 200);
+ gfx::Size content_size(1000, 1000);
+
+ const int horiz_id = 11;
+ const int child_clip_id = 14;
+ const int child_scroll_id = 15;
+
+ CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
+ host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
+ inner_viewport_size);
+ host_impl_->active_tree()->OuterViewportContainerLayer()->SetBounds(
+ outer_viewport_size);
+ LayerImpl* root_scroll =
+ host_impl_->active_tree()->OuterViewportScrollLayer();
+ scoped_ptr<SolidColorScrollbarLayerImpl> horiz_scrollbar =
+ SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), horiz_id,
+ HORIZONTAL, 5, 5, true, true);
+ scoped_ptr<LayerImpl> child =
+ LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
+ child->SetBounds(content_size);
+ scoped_ptr<LayerImpl> child_clip =
+ LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
+ child->SetBounds(inner_viewport_size);
+
+ horiz_scrollbar->SetScrollLayerId(root_scroll->id());
+
+ EXPECT_EQ(300, horiz_scrollbar->clip_layer_length());
+}
+
TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) {
LayerTreeSettings settings;
settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE;
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 6ba1153..c9b4dbc 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -177,6 +177,8 @@ void LayerTreeImpl::UpdateScrollbars(int scroll_layer_id, int clip_layer_id) {
gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset();
if (IsViewportLayerId(scroll_layer_id)) {
current_offset += InnerViewportScrollLayer()->CurrentScrollOffset();
+ if (OuterViewportContainerLayer())
+ clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling());
clip_size.Scale(1 / current_page_scale_factor());
}