diff options
author | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-27 00:27:34 +0000 |
---|---|---|
committer | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-27 00:27:34 +0000 |
commit | 489eb9989d3ae31fd8de41a5f500e685ff0f34ea (patch) | |
tree | 23a7a323e91c653bc288dc8ccfe6f03b7315550c /cc | |
parent | 8869e7a5e8bea53434ce3a8243f3c1df3445ee31 (diff) | |
download | chromium_src-489eb9989d3ae31fd8de41a5f500e685ff0f34ea.zip chromium_src-489eb9989d3ae31fd8de41a5f500e685ff0f34ea.tar.gz chromium_src-489eb9989d3ae31fd8de41a5f500e685ff0f34ea.tar.bz2 |
Relax touch hit testing in CC to look at all layers under a point
CC touch hit testing now (as of http://crrev.com/264395 does a ray cast
through all layers under the touched point. We included an optimization
to stop searching once you reach a layer we know is opaque to hit testing.
This breaks the common case of sites with a touch handler on the document
because blink has an optimization to effectively disable touch hit testing
in that scenario (since there's no benefit to be had to expensive rect
computation) by marking just the entire root layer with a handler region.
This change removes this opaque-to-hit-testing optimization. There's some
risk that we'll block on main more often, but it should be rare (you'd
need a scrolling layer without a handler over top of a layer with a
handler).
This also fixes the case where a layer has a region that is supposed to
be transparent to hit-testing with the CSS pointer-events: none property.
BUG=366034, 269598
Review URL: https://codereview.chromium.org/250663003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 14 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 19 |
2 files changed, 11 insertions, 22 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 99923d0..59e55ed 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -2526,12 +2526,6 @@ LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint( return found_layer; } -// This may be generalized in the future, but we know at the very least that -// hits cannot pass through scrolling nor opaque layers. -static bool OpaqueToHitTesting(const LayerImpl* layer) { - return layer->scrollable() || layer->contents_opaque(); -} - LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( const gfx::PointF& screen_space_point, const LayerImplList& render_surface_layer_list) { @@ -2553,8 +2547,12 @@ LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( current_layer)) return current_layer; - if (OpaqueToHitTesting(current_layer)) - break; + // Note that we could stop searching if we hit a layer we know to be + // opaque to hit-testing, but knowing that reliably is tricky (eg. due to + // CSS pointer-events: none). Also blink has an optimization for the + // common case of an entire document having handlers where it doesn't + // report any rects for child layers (since it knows they can't exceed + // the document bounds). } return NULL; } diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 920279e..7896a22 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -6026,20 +6026,11 @@ TEST_F(LayerTreeHostCommonTest, LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( test_point, render_surface_layer_list); - // In this case we should abort searching for touch handlers at the opaque - // occluder and not find the region behind it. - EXPECT_FALSE(result_layer); - - host_impl.active_tree()->LayerById(1234)->SetContentsOpaque(true); - host_impl.active_tree()->LayerById(1234)->SetScrollClipLayer(1); - - result_layer = - LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point, render_surface_layer_list); - - // In this case we should abort searching for touch handlers at the scroller - // (which is opaque to hit testing) and not find the region behind it. - EXPECT_FALSE(result_layer); + // Even with an opaque layer in the middle, we should still find the layer + // with + // the touch handler behind it (since we can't assume that opaque layers are + // opaque to hit testing). + EXPECT_TRUE(result_layer); test_point = gfx::Point(35, 15); result_layer = |