Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1909)

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 238803005: Scroll on main if impl-hit testing isn't guaranteed to be correct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding some breaks. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 4dc35522a28d6ca42ad70936f73eedb5b48ac3d8..11c21dc4d8b0f35506ffaf888f76bc2fc174cfc3 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -2437,6 +2437,50 @@ static bool PointIsClippedBySurfaceOrClipRect(
return false;
}
+static bool PointHitsLayer(LayerImpl* layer,
+ const gfx::PointF& screen_space_point) {
+ gfx::RectF content_rect(layer->content_bounds());
+ if (!PointHitsRect(
+ screen_space_point, layer->screen_space_transform(), content_rect))
+ return false;
+
+ // 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 (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer))
+ return false;
+
+ // Skip the HUD layer.
+ if (layer == layer->layer_tree_impl()->hud_layer())
+ return false;
+
+ return true;
+}
+
+LayerImpl* LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint(
+ const gfx::PointF& screen_space_point,
+ const LayerImplList& render_surface_layer_list) {
+ typedef LayerIterator<LayerImpl> LayerIteratorType;
+ LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list);
+ for (LayerIteratorType it =
+ LayerIteratorType::Begin(&render_surface_layer_list);
+ it != end;
+ ++it) {
+ // We don't want to consider render_surfaces for hit testing.
+ if (!it.represents_itself())
+ continue;
+
+ LayerImpl* current_layer = (*it);
+ if (!PointHitsLayer(current_layer, screen_space_point))
+ continue;
+
+ if (current_layer->scrollable())
+ return current_layer;
+ }
+
+ return NULL;
+}
+
LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint(
const gfx::PointF& screen_space_point,
const LayerImplList& render_surface_layer_list) {
@@ -2453,21 +2497,7 @@ LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint(
continue;
LayerImpl* current_layer = (*it);
-
- gfx::RectF content_rect(current_layer->content_bounds());
- if (!PointHitsRect(screen_space_point,
- current_layer->screen_space_transform(),
- content_rect))
- 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 (PointIsClippedBySurfaceOrClipRect(screen_space_point, current_layer))
- continue;
-
- // Skip the HUD layer.
- if (current_layer == current_layer->layer_tree_impl()->hud_layer())
+ if (!PointHitsLayer(current_layer, screen_space_point))
continue;
found_layer = current_layer;
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698