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_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 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2430 return true; | 2430 return true; |
2431 | 2431 |
2432 current_layer = current_layer->parent(); | 2432 current_layer = current_layer->parent(); |
2433 } | 2433 } |
2434 | 2434 |
2435 // If we have finished walking all ancestors without having already exited, | 2435 // If we have finished walking all ancestors without having already exited, |
2436 // then the point is not clipped by any ancestors. | 2436 // then the point is not clipped by any ancestors. |
2437 return false; | 2437 return false; |
2438 } | 2438 } |
2439 | 2439 |
2440 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. :)
| |
2441 const gfx::PointF& screen_space_point, | |
2442 const LayerImplList& render_surface_layer_list) { | |
2443 LayerImpl* found_layer = NULL; | |
2444 | |
2445 typedef LayerIterator<LayerImpl> LayerIteratorType; | |
2446 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); | |
2447 for (LayerIteratorType it = | |
2448 LayerIteratorType::Begin(&render_surface_layer_list); | |
2449 it != end; | |
2450 ++it) { | |
2451 // We don't want to consider render_surfaces for hit testing. | |
2452 if (!it.represents_itself()) | |
2453 continue; | |
2454 | |
2455 LayerImpl* current_layer = (*it); | |
2456 | |
2457 gfx::RectF content_rect(current_layer->content_bounds()); | |
2458 if (!PointHitsRect(screen_space_point, | |
2459 current_layer->screen_space_transform(), | |
2460 content_rect)) | |
2461 continue; | |
2462 | |
2463 // At this point, we think the point does hit the layer, but we need to walk | |
2464 // up the parents to ensure that the layer was not clipped in such a way | |
2465 // that the hit point actually should not hit the layer. | |
2466 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, current_layer)) | |
2467 continue; | |
2468 | |
2469 // Skip the HUD layer. | |
enne (OOO)
2014/04/15 21:25:54
Sadness.
Ian Vollick
2014/04/15 23:27:27
yeh.
| |
2470 if (current_layer == current_layer->layer_tree_impl()->hud_layer()) | |
2471 continue; | |
2472 | |
2473 if (current_layer->scrollable()) { | |
2474 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.
| |
2475 break; | |
2476 } | |
2477 | |
2478 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
| |
2479 break; | |
2480 } | |
2481 | |
2482 // This can potentially return NULL, which means the screen_space_point did | |
2483 // not successfully hit test any layers, not even the root layer. | |
2484 return found_layer; | |
2485 } | |
2486 | |
2440 LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 2487 LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
2441 const gfx::PointF& screen_space_point, | 2488 const gfx::PointF& screen_space_point, |
2442 const LayerImplList& render_surface_layer_list) { | 2489 const LayerImplList& render_surface_layer_list) { |
2443 LayerImpl* found_layer = NULL; | 2490 LayerImpl* found_layer = NULL; |
2444 | 2491 |
2445 typedef LayerIterator<LayerImpl> LayerIteratorType; | 2492 typedef LayerIterator<LayerImpl> LayerIteratorType; |
2446 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); | 2493 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); |
2447 for (LayerIteratorType | 2494 for (LayerIteratorType |
2448 it = LayerIteratorType::Begin(&render_surface_layer_list); | 2495 it = LayerIteratorType::Begin(&render_surface_layer_list); |
2449 it != end; | 2496 it != end; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2515 // At this point, we think the point does hit the touch event handler region | 2562 // At this point, we think the point does hit the touch event handler region |
2516 // on the layer, but we need to walk up the parents to ensure that the layer | 2563 // on the layer, but we need to walk up the parents to ensure that the layer |
2517 // was not clipped in such a way that the hit point actually should not hit | 2564 // was not clipped in such a way that the hit point actually should not hit |
2518 // the layer. | 2565 // the layer. |
2519 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2566 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
2520 return false; | 2567 return false; |
2521 | 2568 |
2522 return true; | 2569 return true; |
2523 } | 2570 } |
2524 } // namespace cc | 2571 } // namespace cc |
OLD | NEW |