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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
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 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static bool PointHitsLayer(LayerImpl* layer,
2441 const gfx::PointF& screen_space_point) {
2442 gfx::RectF content_rect(layer->content_bounds());
2443 if (!PointHitsRect(
2444 screen_space_point, layer->screen_space_transform(), content_rect))
2445 return false;
2446
2447 // At this point, we think the point does hit the layer, but we need to walk
2448 // up the parents to ensure that the layer was not clipped in such a way
2449 // that the hit point actually should not hit the layer.
2450 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer))
2451 return false;
2452
2453 // Skip the HUD layer.
2454 if (layer == layer->layer_tree_impl()->hud_layer())
2455 return false;
2456
2457 return true;
2458 }
2459
2460 LayerImpl* LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint(
2461 const gfx::PointF& screen_space_point,
2462 const LayerImplList& render_surface_layer_list) {
2463 typedef LayerIterator<LayerImpl> LayerIteratorType;
2464 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list);
2465 for (LayerIteratorType it =
2466 LayerIteratorType::Begin(&render_surface_layer_list);
2467 it != end;
2468 ++it) {
2469 // We don't want to consider render_surfaces for hit testing.
2470 if (!it.represents_itself())
2471 continue;
2472
2473 LayerImpl* current_layer = (*it);
2474 if (!PointHitsLayer(current_layer, screen_space_point))
2475 continue;
2476
2477 if (current_layer->scrollable())
2478 return current_layer;
2479 }
2480
2481 return NULL;
2482 }
2483
2440 LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint( 2484 LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint(
2441 const gfx::PointF& screen_space_point, 2485 const gfx::PointF& screen_space_point,
2442 const LayerImplList& render_surface_layer_list) { 2486 const LayerImplList& render_surface_layer_list) {
2443 LayerImpl* found_layer = NULL; 2487 LayerImpl* found_layer = NULL;
2444 2488
2445 typedef LayerIterator<LayerImpl> LayerIteratorType; 2489 typedef LayerIterator<LayerImpl> LayerIteratorType;
2446 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); 2490 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list);
2447 for (LayerIteratorType 2491 for (LayerIteratorType
2448 it = LayerIteratorType::Begin(&render_surface_layer_list); 2492 it = LayerIteratorType::Begin(&render_surface_layer_list);
2449 it != end; 2493 it != end;
2450 ++it) { 2494 ++it) {
2451 // We don't want to consider render_surfaces for hit testing. 2495 // We don't want to consider render_surfaces for hit testing.
2452 if (!it.represents_itself()) 2496 if (!it.represents_itself())
2453 continue; 2497 continue;
2454 2498
2455 LayerImpl* current_layer = (*it); 2499 LayerImpl* current_layer = (*it);
2456 2500 if (!PointHitsLayer(current_layer, screen_space_point))
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.
2470 if (current_layer == current_layer->layer_tree_impl()->hud_layer())
2471 continue; 2501 continue;
2472 2502
2473 found_layer = current_layer; 2503 found_layer = current_layer;
2474 break; 2504 break;
2475 } 2505 }
2476 2506
2477 // This can potentially return NULL, which means the screen_space_point did 2507 // This can potentially return NULL, which means the screen_space_point did
2478 // not successfully hit test any layers, not even the root layer. 2508 // not successfully hit test any layers, not even the root layer.
2479 return found_layer; 2509 return found_layer;
2480 } 2510 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 // At this point, we think the point does hit the touch event handler region 2545 // 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 2546 // 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 2547 // was not clipped in such a way that the hit point actually should not hit
2518 // the layer. 2548 // the layer.
2519 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2549 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2520 return false; 2550 return false;
2521 2551
2522 return true; 2552 return true;
2523 } 2553 }
2524 } // namespace cc 2554 } // namespace cc
OLDNEW
« 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