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

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: 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
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..ee8e864eff66f89eba3362ec95a3e2de0c535e90 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -2437,6 +2437,53 @@ static bool PointIsClippedBySurfaceOrClipRect(
return false;
}
+LayerImpl* LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint(
enne (OOO) 2014/04/15 21:25:54 Ew, code duplication. You're going to want someth
Ian Vollick 2014/04/15 23:27:27 Yeah, it's pretty gross. Haste makes.. this cl. :)
+ const gfx::PointF& screen_space_point,
+ const LayerImplList& render_surface_layer_list) {
+ LayerImpl* found_layer = NULL;
+
+ 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);
+
+ 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.
enne (OOO) 2014/04/15 21:25:54 Sadness.
Ian Vollick 2014/04/15 23:27:27 yeh.
+ if (current_layer == current_layer->layer_tree_impl()->hud_layer())
+ continue;
+
+ if (current_layer->scrollable()) {
+ found_layer = current_layer;
enne (OOO) 2014/04/15 21:25:54 readability/debuggability nit: just return current
Ian Vollick 2014/04/15 23:27:27 Done.
+ break;
+ }
+
+ if (current_layer->contents_opaque())
enne (OOO) 2014/04/15 21:25:54 I think for correctness, it is always ok to return
Ian Vollick 2014/04/15 23:27:27 Good point. This was a stale idea from the algorit
+ break;
+ }
+
+ // This can potentially return NULL, which means the screen_space_point did
+ // not successfully hit test any layers, not even the root layer.
+ return found_layer;
+}
+
LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint(
const gfx::PointF& screen_space_point,
const LayerImplList& render_surface_layer_list) {

Powered by Google App Engine
This is Rietveld 408576698