summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraelias <aelias@chromium.org>2015-11-03 12:24:22 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-03 20:26:16 +0000
commit2b363bf9893e193fbce9ed93821c8fcdb961668b (patch)
treefad3c76425c211a1b2c481e9126d0e33e304605f
parent4d229dea13c0dddbfc619174ba9723f8ee4ac856 (diff)
downloadchromium_src-2b363bf9893e193fbce9ed93821c8fcdb961668b.zip
chromium_src-2b363bf9893e193fbce9ed93821c8fcdb961668b.tar.gz
chromium_src-2b363bf9893e193fbce9ed93821c8fcdb961668b.tar.bz2
Clamp clip layer to outer viewport size for scrollbars.
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. BUG=547668 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1414573007 Cr-Commit-Position: refs/heads/master@{#357613}
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc34
-rw-r--r--cc/trees/layer_tree_host_unittest_scroll.cc3
-rw-r--r--cc/trees/layer_tree_impl.cc1
3 files changed, 36 insertions, 2 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_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index 6e8d3ed..93bbcee 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -1034,8 +1034,7 @@ class LayerTreeHostScrollTestScrollZeroMaxScrollOffset
void AfterTest() override {}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostScrollTestScrollZeroMaxScrollOffset);
+MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollZeroMaxScrollOffset);
class ThreadCheckingInputHandlerClient : public InputHandlerClient {
public:
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 6ba1153..5015d9d 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -177,6 +177,7 @@ 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();
+ clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling());
clip_size.Scale(1 / current_page_scale_factor());
}