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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2471523002: Make touch events uncancelable during fling when they are on the current active scroll layer (Closed)
Patch Set: fling layer Created 4 years, 1 month 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') | content/renderer/input/input_handler_manager.cc » ('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 4a8082a07b816ef2258b3f5ef884fb5c6a2803d8..7776f3a2b216179fcf99f5eee9a5331478657f1b 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -809,7 +809,8 @@ TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
// Touch handler regions determine whether touch events block scroll.
root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
- EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10)));
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10)));
// But they don't influence the actual handling of the scroll gestures.
InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
@@ -819,11 +820,14 @@ TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
status.main_thread_scrolling_reasons);
host_impl_->ScrollEnd(EndState().get());
- EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)));
root->SetTouchEventHandlerRegion(gfx::Rect());
- EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::NO_HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)));
child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
- EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)));
}
TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) {
@@ -9977,6 +9981,73 @@ TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) {
EXPECT_FALSE(last_on_draw_frame_->has_no_damage);
}
+// We will force the touch event handler to be passive if we touch on a
+// layer which is the current scrolling layer or its descendant.
+TEST_F(LayerTreeHostImplTest, TouchInsideOrOutsideFlingLayer) {
+ gfx::Size surface_size(100, 100);
+ gfx::Size inner_size(50, 50);
+
+ LayerImpl* root =
+ CreateBasicVirtualViewportLayers(surface_size, surface_size);
+ root->test_properties()->force_render_surface = true;
+
+ std::unique_ptr<LayerImpl> child =
+ CreateScrollableLayer(26, surface_size, root);
+ LayerImpl* child_layer = child.get();
+
+ std::unique_ptr<LayerImpl> grand_child =
+ CreateScrollableLayer(27, inner_size, root);
+ LayerImpl* grand_child_layer = grand_child.get();
+ child->test_properties()->AddChild(std::move(grand_child));
+ root->test_properties()->AddChild(std::move(child));
+
+ host_impl_->active_tree()->BuildPropertyTreesForTesting();
+ host_impl_->active_tree()->DidBecomeActive();
+ DrawFrame();
+
+ {
+ // Touch on a layer which does not have a handler will return kNone.
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::NO_HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10)));
+ child_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
+ grand_child_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10)));
+ // Flinging the child layer.
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_
+ ->ScrollBegin(BeginState(gfx::Point(60, 60)).get(),
+ InputHandler::TOUCHSCREEN)
+ .thread);
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->FlingScrollBegin().thread);
+ EXPECT_EQ(child_layer, host_impl_->CurrentlyScrollingLayer());
+ // Touch on the child layer, which is an active fling layer, the touch
+ // event handler will force to be passive.
+ EXPECT_EQ(
+ InputHandler::TouchStartEventListenerType::HANDLER_ON_SCROLLING_LAYER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(70, 80)));
+ // Touch on the grand child layer, which is a descendant of an active fling
+ // layer, the touch event handler will force to be passive.
+ EXPECT_EQ(
+ InputHandler::TouchStartEventListenerType::HANDLER_ON_SCROLLING_LAYER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(20, 30)));
+
+ // Now flinging on the grand child layer.
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_
+ ->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
+ InputHandler::TOUCHSCREEN)
+ .thread);
+ EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->FlingScrollBegin().thread);
+ EXPECT_EQ(grand_child_layer, host_impl_->CurrentlyScrollingLayer());
+ // Touch on the child layer, the touch event handler will still be blocking.
+ EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER,
+ host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(60, 60)));
+ }
+}
+
class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest {
protected:
std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override {
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | content/renderer/input/input_handler_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698