Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1568)

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 30793002: cc: Do not allow gesture-scrolling 'overflow[-{x|y}]:hidden' layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: needs-commit Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | webkit/renderer/compositor_bindings/web_layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index d761c89f09a68166faf9cab5f7d0191444ef5448..f6350255b1f02cede3dcdf02cbec46f320ed7648 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -759,6 +759,61 @@ TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) {
gfx::Point(), SCROLL_BACKWARD));
}
+TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
+ host_impl_->SetViewportSize(gfx::Size(100, 100));
+
+ gfx::Size overflow_size(400, 400);
+ ASSERT_EQ(1u, scroll_layer->children().size());
+ LayerImpl* overflow = scroll_layer->children()[0];
+ overflow->SetBounds(overflow_size);
+ overflow->SetContentBounds(overflow_size);
+ overflow->SetScrollable(true);
+ overflow->SetMaxScrollOffset(gfx::Vector2d(overflow_size.width(),
+ overflow_size.height()));
+ overflow->SetScrollOffset(gfx::Vector2d());
+ overflow->SetPosition(gfx::PointF());
+ overflow->SetAnchorPoint(gfx::PointF());
+
+ InitializeRendererAndDrawFrame();
+ gfx::Point scroll_position(10, 10);
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset());
+
+ gfx::Vector2dF scroll_delta(10, 10);
+ host_impl_->ScrollBy(scroll_position, scroll_delta);
+ host_impl_->ScrollEnd();
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset());
+
+ overflow->set_user_scrollable_horizontal(false);
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset());
+
+ host_impl_->ScrollBy(scroll_position, scroll_delta);
+ host_impl_->ScrollEnd();
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset());
+
+ overflow->set_user_scrollable_vertical(false);
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset());
+
+ host_impl_->ScrollBy(scroll_position, scroll_delta);
+ host_impl_->ScrollEnd();
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset());
+}
+
TEST_F(LayerTreeHostImplTest,
ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) {
SetupScrollAndContentsLayers(gfx::Size(100, 100));
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | webkit/renderer/compositor_bindings/web_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698