| 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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "cc/animation/keyframed_animation_curve.h" | 11 #include "cc/animation/keyframed_animation_curve.h" |
| 12 #include "cc/animation/scrollbar_animation_controller.h" | 12 #include "cc/animation/scrollbar_animation_controller.h" |
| 13 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 13 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
| 14 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 14 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
| 15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
| 16 #include "cc/base/util.h" | 16 #include "cc/base/util.h" |
| 17 #include "cc/debug/traced_value.h" | 17 #include "cc/debug/traced_value.h" |
| 18 #include "cc/layers/heads_up_display_layer_impl.h" | 18 #include "cc/layers/heads_up_display_layer_impl.h" |
| 19 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
| 20 #include "cc/layers/layer_iterator.h" | 20 #include "cc/layers/layer_iterator.h" |
| 21 #include "cc/layers/render_surface_impl.h" | 21 #include "cc/layers/render_surface_impl.h" |
| 22 #include "cc/layers/scrollbar_layer_impl_base.h" | 22 #include "cc/layers/scrollbar_layer_impl_base.h" |
| 23 #include "cc/resources/ui_resource_request.h" | 23 #include "cc/resources/ui_resource_request.h" |
| 24 #include "cc/trees/layer_tree_host_common.h" | 24 #include "cc/trees/layer_tree_host_common.h" |
| 25 #include "cc/trees/layer_tree_host_impl.h" | 25 #include "cc/trees/layer_tree_host_impl.h" |
| 26 #include "ui/gfx/point_conversions.h" | 26 #include "ui/gfx/point_conversions.h" |
| 27 #include "ui/gfx/rect_conversions.h" |
| 27 #include "ui/gfx/size_conversions.h" | 28 #include "ui/gfx/size_conversions.h" |
| 28 #include "ui/gfx/vector2d_conversions.h" | 29 #include "ui/gfx/vector2d_conversions.h" |
| 29 | 30 |
| 30 namespace cc { | 31 namespace cc { |
| 31 | 32 |
| 32 // This class exists to split the LayerScrollOffsetDelegate between the | 33 // This class exists to split the LayerScrollOffsetDelegate between the |
| 33 // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner | 34 // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner |
| 34 // that never requires the embedder or LayerImpl to know about. | 35 // that never requires the embedder or LayerImpl to know about. |
| 35 class LayerScrollOffsetDelegateProxy : public LayerImpl::ScrollOffsetDelegate { | 36 class LayerScrollOffsetDelegateProxy : public LayerImpl::ScrollOffsetDelegate { |
| 36 public: | 37 public: |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 | 1089 |
| 1089 // If ProjectPoint could not project to a valid value, then we assume that | 1090 // If ProjectPoint could not project to a valid value, then we assume that |
| 1090 // this point doesn't hit this region. | 1091 // this point doesn't hit this region. |
| 1091 if (clipped) | 1092 if (clipped) |
| 1092 return false; | 1093 return false; |
| 1093 | 1094 |
| 1094 return layer_space_region.Contains( | 1095 return layer_space_region.Contains( |
| 1095 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); | 1096 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); |
| 1096 } | 1097 } |
| 1097 | 1098 |
| 1099 static LayerImpl* GetNextClippingLayer(LayerImpl* layer) { |
| 1100 if (layer->scroll_parent()) |
| 1101 return layer->scroll_parent(); |
| 1102 if (layer->clip_parent()) |
| 1103 return layer->clip_parent(); |
| 1104 return layer->parent(); |
| 1105 } |
| 1106 |
| 1098 static bool PointIsClippedBySurfaceOrClipRect( | 1107 static bool PointIsClippedBySurfaceOrClipRect( |
| 1099 const gfx::PointF& screen_space_point, | 1108 const gfx::PointF& screen_space_point, |
| 1100 LayerImpl* layer) { | 1109 LayerImpl* layer) { |
| 1101 LayerImpl* current_layer = layer; | |
| 1102 | |
| 1103 // Walk up the layer tree and hit-test any render_surfaces and any layer | 1110 // Walk up the layer tree and hit-test any render_surfaces and any layer |
| 1104 // clip rects that are active. | 1111 // clip rects that are active. |
| 1105 while (current_layer) { | 1112 for (; layer; layer = GetNextClippingLayer(layer)) { |
| 1106 if (current_layer->render_surface() && | 1113 if (layer->render_surface() && |
| 1107 !PointHitsRect( | 1114 !PointHitsRect(screen_space_point, |
| 1108 screen_space_point, | 1115 layer->render_surface()->screen_space_transform(), |
| 1109 current_layer->render_surface()->screen_space_transform(), | 1116 layer->render_surface()->content_rect(), |
| 1110 current_layer->render_surface()->content_rect(), | 1117 NULL)) |
| 1111 NULL)) | |
| 1112 return true; | 1118 return true; |
| 1113 | 1119 |
| 1114 // Note that drawable content rects are actually in target surface space, so | 1120 if (LayerClipsSubtree(layer) && |
| 1115 // the transform we have to provide is the target surface's | 1121 !PointHitsRect(screen_space_point, |
| 1116 // screen_space_transform. | 1122 layer->screen_space_transform(), |
| 1117 LayerImpl* render_target = current_layer->render_target(); | 1123 gfx::Rect(layer->content_bounds()), |
| 1118 if (LayerClipsSubtree(current_layer) && | 1124 NULL)) |
| 1119 !PointHitsRect( | |
| 1120 screen_space_point, | |
| 1121 render_target->render_surface()->screen_space_transform(), | |
| 1122 current_layer->drawable_content_rect(), | |
| 1123 NULL)) | |
| 1124 return true; | 1125 return true; |
| 1125 | |
| 1126 current_layer = current_layer->parent(); | |
| 1127 } | 1126 } |
| 1128 | 1127 |
| 1129 // If we have finished walking all ancestors without having already exited, | 1128 // If we have finished walking all ancestors without having already exited, |
| 1130 // then the point is not clipped by any ancestors. | 1129 // then the point is not clipped by any ancestors. |
| 1131 return false; | 1130 return false; |
| 1132 } | 1131 } |
| 1133 | 1132 |
| 1134 static bool PointHitsLayer(LayerImpl* layer, | 1133 static bool PointHitsLayer(LayerImpl* layer, |
| 1135 const gfx::PointF& screen_space_point, | 1134 const gfx::PointF& screen_space_point, |
| 1136 float* distance_to_intersection) { | 1135 float* distance_to_intersection) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1268 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1270 const gfx::PointF& screen_space_point) { | 1269 const gfx::PointF& screen_space_point) { |
| 1271 FindTouchEventLayerFunctor func = {screen_space_point}; | 1270 FindTouchEventLayerFunctor func = {screen_space_point}; |
| 1272 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1271 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1273 FindClosestMatchingLayer( | 1272 FindClosestMatchingLayer( |
| 1274 screen_space_point, root_layer(), func, &data_for_recursion); | 1273 screen_space_point, root_layer(), func, &data_for_recursion); |
| 1275 return data_for_recursion.closest_match; | 1274 return data_for_recursion.closest_match; |
| 1276 } | 1275 } |
| 1277 | 1276 |
| 1278 } // namespace cc | 1277 } // namespace cc |
| OLD | NEW |