Chromium Code Reviews| Index: cc/layer_tree_host_impl.cc |
| diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc |
| index e09233ddb8feeaf1323ba89df05d7f82971579fe..f546596c894770a73f39036406592fcf3c98e358 100644 |
| --- a/cc/layer_tree_host_impl.cc |
| +++ b/cc/layer_tree_host_impl.cc |
| @@ -325,7 +325,7 @@ 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* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(deviceViewportPoint, activeTree()->RenderSurfaceLayerList()); |
| + LayerImpl* layerImpl = findLayerThatIsHitByPoint(deviceViewportPoint, activeTree()->RenderSurfaceLayerList()); |
| // 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()) { |
| @@ -1189,7 +1189,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp |
| // First find out which layer was hit from the saved list of visible layers |
| // in the most recent frame. |
| - LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(deviceViewportPoint, activeTree()->RenderSurfaceLayerList()); |
| + LayerImpl* layerImpl = findLayerThatIsHitByPoint(deviceViewportPoint, activeTree()->RenderSurfaceLayerList()); |
| // Walk up the hierarchy and look for a scrollable layer. |
| LayerImpl* potentiallyScrollingLayerImpl = 0; |
| @@ -1230,6 +1230,42 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp |
| return ScrollIgnored; |
| } |
| +LayerImpl* LayerTreeHostImpl::findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList) |
| +{ |
| + LayerImpl* foundLayer = 0; |
| + |
| + typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; |
| + LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); |
| + for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { |
| + // We don't want to consider renderSurfaces for hit testing. |
| + if (!it.representsItself()) |
| + continue; |
| + |
| + LayerImpl* currentLayer = (*it); |
| + |
| + // Don't consider the hud layer as a viable target for hits. |
| + if (currentLayer == activeTree()->hud_layer()) |
|
danakj
2013/02/18 19:18:49
I don't understand why we would need to move aroun
|
| + continue; |
| + |
| + gfx::RectF contentRect(gfx::PointF(), currentLayer->contentBounds()); |
| + if (!MathUtil::pointHitsRect(screenSpacePoint, currentLayer->screenSpaceTransform(), contentRect)) |
| + continue; |
| + |
| + // At this point, we think the point does hit 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 (LayerTreeHostCommon::pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer)) |
| + continue; |
| + |
| + foundLayer = currentLayer; |
| + break; |
| + } |
| + |
| + // This can potentially return 0, which means the screenSpacePoint did not successfully hit test any layers, not even the root layer. |
| + return foundLayer; |
| +} |
| + |
| + |
| gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewportDelta) |
| { |
| // Layers with non-invertible screen space transforms should not have passed the scroll hit |