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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 27718006: cc: Fix touch hit-testing for overlapping layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-win Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_host_common.h" 5 #include "cc/trees/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/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 } 2370 }
2371 2371
2372 // This can potentially return NULL, which means the screen_space_point did 2372 // This can potentially return NULL, which means the screen_space_point did
2373 // not successfully hit test any layers, not even the root layer. 2373 // not successfully hit test any layers, not even the root layer.
2374 return found_layer; 2374 return found_layer;
2375 } 2375 }
2376 2376
2377 LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( 2377 LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
2378 gfx::PointF screen_space_point, 2378 gfx::PointF screen_space_point,
2379 const LayerImplList& render_surface_layer_list) { 2379 const LayerImplList& render_surface_layer_list) {
2380 LayerImpl* found_layer = NULL; 2380 // First find out which layer was hit from the saved list of visible layers
2381 // in the most recent frame.
2382 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
2383 screen_space_point,
2384 render_surface_layer_list);
2381 2385
2382 typedef LayerIterator<LayerImpl, 2386 // Walk up the hierarchy and look for a layer with a touch event handler
enne (OOO) 2013/10/18 19:18:38 Can you help me understand why you need to walk up
sadrul 2013/10/18 19:57:44 Consider this example: http://jsfiddle.net/zcjJe/3
enne (OOO) 2013/10/21 19:52:04 I understand that you need to do *a* walk and not
sadrul 2013/10/21 21:36:46 I had to look at the history of the change to figu
2383 LayerImplList, 2387 // region that the given point hits.
2384 RenderSurfaceImpl, 2388 for (; layer_impl; layer_impl = layer_impl->parent()) {
2385 LayerIteratorActions::FrontToBack> LayerIteratorType; 2389 if (LayerTreeHostCommon::LayerHasTouchEventHandlersAt(screen_space_point,
2386 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); 2390 layer_impl))
2387 2391 break;
2388 for (LayerIteratorType
2389 it = LayerIteratorType::Begin(&render_surface_layer_list);
2390 it != end;
2391 ++it) {
2392 // We don't want to consider render_surfaces for hit testing.
2393 if (!it.represents_itself())
2394 continue;
2395
2396 LayerImpl* current_layer = (*it);
2397
2398 if (!LayerHasTouchEventHandlersAt(screen_space_point, current_layer))
2399 continue;
enne (OOO) 2013/10/18 19:18:38 I would have expected the fix here to be turning t
2400
2401 found_layer = current_layer;
2402 break;
2403 } 2392 }
2404 2393 return layer_impl;
2405 // This can potentially return NULL, which means the screen_space_point did
2406 // not successfully hit test any layers, not even the root layer.
2407 return found_layer;
2408 } 2394 }
2409 2395
2410 bool LayerTreeHostCommon::LayerHasTouchEventHandlersAt( 2396 bool LayerTreeHostCommon::LayerHasTouchEventHandlersAt(
2411 gfx::PointF screen_space_point, 2397 gfx::PointF screen_space_point,
2412 LayerImpl* layer_impl) { 2398 LayerImpl* layer_impl) {
2413 if (layer_impl->touch_event_handler_region().IsEmpty()) 2399 if (layer_impl->touch_event_handler_region().IsEmpty())
2414 return false; 2400 return false;
2415 2401
2416 if (!PointHitsRegion(screen_space_point, 2402 if (!PointHitsRegion(screen_space_point,
2417 layer_impl->screen_space_transform(), 2403 layer_impl->screen_space_transform(),
2418 layer_impl->touch_event_handler_region(), 2404 layer_impl->touch_event_handler_region(),
2419 layer_impl->contents_scale_x(), 2405 layer_impl->contents_scale_x(),
2420 layer_impl->contents_scale_y())) 2406 layer_impl->contents_scale_y()))
2421 return false; 2407 return false;
2422 2408
2423 // At this point, we think the point does hit the touch event handler region 2409 // At this point, we think the point does hit the touch event handler region
2424 // on the layer, but we need to walk up the parents to ensure that the layer 2410 // on the layer, but we need to walk up the parents to ensure that the layer
2425 // was not clipped in such a way that the hit point actually should not hit 2411 // was not clipped in such a way that the hit point actually should not hit
2426 // the layer. 2412 // the layer.
2427 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2413 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2428 return false; 2414 return false;
2429 2415
2430 return true; 2416 return true;
2431 } 2417 }
2432 } // namespace cc 2418 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698