OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/layer.h" | 10 #include "cc/layer.h" |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; | 992 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
993 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); | 993 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); |
994 | 994 |
995 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { | 995 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { |
996 // We don't want to consider renderSurfaces for hit testing. | 996 // We don't want to consider renderSurfaces for hit testing. |
997 if (!it.representsItself()) | 997 if (!it.representsItself()) |
998 continue; | 998 continue; |
999 | 999 |
1000 LayerImpl* currentLayer = (*it); | 1000 LayerImpl* currentLayer = (*it); |
1001 | 1001 |
1002 if (currentLayer->touchEventHandlerRegion().IsEmpty()) | 1002 if (!layerHasTouchEventHandlersAt(screenSpacePoint, currentLayer)) |
1003 continue; | |
1004 | |
1005 if (!pointHitsRegion(screenSpacePoint, currentLayer->screenSpaceTransfor
m(), currentLayer->touchEventHandlerRegion(), currentLayer->contentsScaleX(), cu
rrentLayer->contentsScaleY())) | |
1006 continue; | |
1007 | |
1008 // At this point, we think the point does hit the touch event handler re
gion on the layer, but we need to walk up | |
1009 // the parents to ensure that the layer was not clipped in such a way th
at the | |
1010 // hit point actually should not hit the layer. | |
1011 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer)) | |
1012 continue; | 1003 continue; |
1013 | 1004 |
1014 foundLayer = currentLayer; | 1005 foundLayer = currentLayer; |
1015 break; | 1006 break; |
1016 } | 1007 } |
1017 | 1008 |
1018 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 1009 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
1019 return foundLayer; | 1010 return foundLayer; |
1020 } | 1011 } |
1021 | 1012 |
| 1013 bool LayerTreeHostCommon::layerHasTouchEventHandlersAt(const gfx::PointF& screen
SpacePoint, LayerImpl* layerImpl) { |
| 1014 if (layerImpl->touchEventHandlerRegion().IsEmpty()) |
| 1015 return false; |
| 1016 |
| 1017 if (!pointHitsRegion(screenSpacePoint, layerImpl->screenSpaceTransform(), laye
rImpl->touchEventHandlerRegion(), layerImpl->contentsScaleX(), layerImpl->conten
tsScaleY())) |
| 1018 return false;; |
| 1019 |
| 1020 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up |
| 1021 // the parents to ensure that the layer was not clipped in such a way that the |
| 1022 // hit point actually should not hit the layer. |
| 1023 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
| 1024 return false; |
| 1025 |
| 1026 return true; |
| 1027 } |
1022 } // namespace cc | 1028 } // namespace cc |
OLD | NEW |