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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 27718006: cc: Fix touch hit-testing for overlapping layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 700bca43eafee460b8ea28a1e991e8f267a59c77..db2181aeedba2ca0f21a03769c8d5a27fb578ed0 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -6025,6 +6025,90 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(456, result_layer->id());
}
+TEST_F(LayerTreeHostCommonTest,
+ HitCheckingTouchHandlerOverlappingRegions) {
+ gfx::Transform identity_matrix;
+ gfx::PointF anchor;
+
+ FakeImplProxy proxy;
+ FakeLayerTreeHostImpl host_impl(&proxy);
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ gfx::PointF(),
+ gfx::Size(100, 100),
+ false);
+ {
+ scoped_ptr<LayerImpl> touch_layer =
+ LayerImpl::Create(host_impl.active_tree(), 123);
+ // this layer is positioned, and hit testing should correctly know where the
+ // layer is located.
+ gfx::PointF position;
+ gfx::Size bounds(50, 50);
+ SetLayerPropertiesForTesting(touch_layer.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ position,
+ bounds,
+ false);
+ touch_layer->SetDrawsContent(true);
+ touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
+ root->AddChild(touch_layer.Pass());
+ }
+
+ {
+ scoped_ptr<LayerImpl> notouch_layer =
+ LayerImpl::Create(host_impl.active_tree(), 1234);
+ // this layer is positioned, and hit testing should correctly know where the
+ // layer is located.
+ gfx::PointF position(0, 25);
+ gfx::Size bounds(50, 50);
+ SetLayerPropertiesForTesting(notouch_layer.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ position,
+ bounds,
+ false);
+ notouch_layer->SetDrawsContent(true);
+ root->AddChild(notouch_layer.Pass());
+ }
+
+ LayerImplList render_surface_layer_list;
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
+ root.get(), root->bounds(), &render_surface_layer_list);
+ inputs.can_adjust_raster_scales = true;
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+
+ // Sanity check the scenario we just created.
+ ASSERT_EQ(1u, render_surface_layer_list.size());
+ ASSERT_EQ(2u, root->render_surface()->layer_list().size());
+ ASSERT_EQ(123, root->render_surface()->layer_list().at(0)->id());
+ ASSERT_EQ(1234, root->render_surface()->layer_list().at(1)->id());
+
+ gfx::Point test_point(35, 35);
+ LayerImpl* result_layer =
+ LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
+ test_point, render_surface_layer_list);
+ EXPECT_FALSE(result_layer);
+
+ test_point = gfx::Point(35, 15);
+ result_layer =
+ LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
+ test_point, render_surface_layer_list);
+ ASSERT_TRUE(result_layer);
+ EXPECT_EQ(123, result_layer->id());
+
+ test_point = gfx::Point(35, 65);
+ result_layer =
+ LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
+ test_point, render_surface_layer_list);
+ EXPECT_FALSE(result_layer);
+}
+
class NoScaleContentLayer : public ContentLayer {
public:
static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) {
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698