summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoryusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-13 02:19:05 +0000
committeryusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-13 02:19:05 +0000
commit35d2edd2e2def89bafe671d5ff212e2e97241c1b (patch)
tree2b9363d5af1354584585ec01bd7e4b22cac4b717 /cc
parentac1da2fed3b77141fee1108763a2111c6895c080 (diff)
downloadchromium_src-35d2edd2e2def89bafe671d5ff212e2e97241c1b.zip
chromium_src-35d2edd2e2def89bafe671d5ff212e2e97241c1b.tar.gz
chromium_src-35d2edd2e2def89bafe671d5ff212e2e97241c1b.tar.bz2
Check whether a touch point hits touch event handler regions in root layer
Instead of doing one search over the render surface layer list, find the layer that the points hits first and then walk up the layer hierarchy testing for a hit in touch event handler regions. This enables us to use one touch event handlere region in the root layer. BUG=135818 Review URL: https://chromiumcodereview.appspot.com/11534024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172778 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layer_tree_host_common.cc26
-rw-r--r--cc/layer_tree_host_common.h2
-rw-r--r--cc/layer_tree_host_impl.cc9
3 files changed, 24 insertions, 13 deletions
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index 5c024ae..f2c0ba2 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -1054,16 +1054,7 @@ LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(co
LayerImpl* currentLayer = (*it);
- if (currentLayer->touchEventHandlerRegion().IsEmpty())
- continue;
-
- if (!pointHitsRegion(screenSpacePoint, currentLayer->screenSpaceTransform(), currentLayer->touchEventHandlerRegion(), currentLayer->contentsScaleX(), currentLayer->contentsScaleY()))
- continue;
-
- // At this point, we think the point does hit the touch event handler region on the layer, but we need to walk up
- // the parents to ensure that the layer was not clipped in such a way that the
- // hit point actually should not hit the layer.
- if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer))
+ if (!layerHasTouchEventHandlersAt(screenSpacePoint, currentLayer))
continue;
foundLayer = currentLayer;
@@ -1074,4 +1065,19 @@ LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(co
return foundLayer;
}
+bool LayerTreeHostCommon::layerHasTouchEventHandlersAt(const gfx::PointF& screenSpacePoint, LayerImpl* layerImpl) {
+ if (layerImpl->touchEventHandlerRegion().IsEmpty())
+ return false;
+
+ if (!pointHitsRegion(screenSpacePoint, layerImpl->screenSpaceTransform(), layerImpl->touchEventHandlerRegion(), layerImpl->contentsScaleX(), layerImpl->contentsScaleY()))
+ return false;;
+
+ // At this point, we think the point does hit the touch event handler region on the layer, but we need to walk up
+ // the parents to ensure that the layer was not clipped in such a way that the
+ // hit point actually should not hit the layer.
+ if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
+ return false;
+
+ return true;
+}
} // namespace cc
diff --git a/cc/layer_tree_host_common.h b/cc/layer_tree_host_common.h
index 21dc295..abc03b09 100644
--- a/cc/layer_tree_host_common.h
+++ b/cc/layer_tree_host_common.h
@@ -29,6 +29,8 @@ public:
static LayerImpl* findLayerThatIsHitByPointInTouchHandlerRegion(const gfx::PointF& screenSpacePoint, std::vector<LayerImpl*>& renderSurfaceLayerList);
+ static bool layerHasTouchEventHandlersAt(const gfx::PointF& screenSpacePoint, LayerImpl* layerImpl);
+
template<typename LayerType> static bool renderSurfaceContributesToTarget(LayerType*, int targetSurfaceLayerID);
// Returns a layer with the given id if one exists in the subtree starting
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 01c2d28..bf61227 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -358,10 +358,13 @@ bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint
// First find out which layer was hit from the saved list of visible layers
// in the most recent frame.
- LayerImpl* layerImplHitByPointInTouchHandlerRegion = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(deviceViewportPoint, m_renderSurfaceLayerList);
+ LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(deviceViewportPoint, m_renderSurfaceLayerList);
- if (layerImplHitByPointInTouchHandlerRegion)
- return true;
+ // Walk up the hierarchy and look for a layer with a touch event handler region that the given point hits.
+ for (; layerImpl; layerImpl = layerImpl->parent()) {
+ if (LayerTreeHostCommon::layerHasTouchEventHandlersAt(deviceViewportPoint,layerImpl))
+ return true;
+ }
return false;
}