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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 26112002: cc: Fix hit-testing in zero-opacity layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: child is zero-opacity no-handler, grandchild has handler 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.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 d483cc697bd76d44e0b7d9353dbb0974c6fdfc5d..8a6812e7b7d5a0842d691fbf47e8a2759338b635 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -63,6 +63,25 @@ static gfx::Vector2dF GetEffectiveTotalScrollOffset(LayerType* layer) {
return offset;
}
+template <typename LayerType>
+static inline bool LayerCanAcceptInput(LayerType* layer) {
+ return !layer->touch_event_handler_region().IsEmpty() ||
+ layer->have_wheel_event_handlers();
+}
+
+template <typename LayerType>
+static bool LayerSubtreeCanAcceptInput(LayerType* layer) {
sadrul 2013/10/05 07:57:32 This should be called only for subtrees where the
enne (OOO) 2013/10/05 16:40:18 What about setting a flag in the prerecursion, lik
sadrul 2013/10/05 21:09:05 Oh, cool. That looks much better. Done.
+ if (LayerCanAcceptInput(layer))
+ return true;
+ for (size_t i = 0; i < layer->children().size(); ++i) {
+ LayerType* child =
+ LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i);
+ if (LayerSubtreeCanAcceptInput(child))
+ return true;
+ }
+ return false;
+}
+
inline gfx::Rect CalculateVisibleRectWithCachedLayerRect(
gfx::Rect target_surface_rect,
gfx::Rect layer_bound_rect,
@@ -454,9 +473,7 @@ static bool LayerShouldBeSkipped(LayerType* layer,
// The layer is visible to events. If it's subject to hit testing, then
// we can't skip it.
- bool can_accept_input = !layer->touch_event_handler_region().IsEmpty() ||
- layer->have_wheel_event_handlers();
- if (!layer->DrawsContent() && !can_accept_input)
+ if (!layer->DrawsContent() && !LayerCanAcceptInput(layer))
return true;
return false;
@@ -481,9 +498,9 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer,
// The opacity of a layer always applies to its children (either implicitly
// via a render surface or explicitly if the parent preserves 3D), so the
- // entire subtree can be skipped if this layer is fully transparent.
- // TODO(sad): Don't skip layers used for hit testing crbug.com/295295.
- return !layer->opacity();
+ // entire subtree can be skipped if this layer is fully transparent, and none
+ // of layers in the subtree has event handlers.
+ return !layer->opacity() && !LayerSubtreeCanAcceptInput(layer);
}
static inline bool SubtreeShouldBeSkipped(Layer* layer,
@@ -503,9 +520,9 @@ static inline bool SubtreeShouldBeSkipped(Layer* layer,
// In particular, it should not cause the subtree to be skipped.
// Similarly, for layers that might animate opacity using an impl-only
// animation, their subtree should also not be skipped.
- // TODO(sad): Don't skip layers used for hit testing crbug.com/295295.
return !layer->opacity() && !layer->OpacityIsAnimating() &&
- !layer->OpacityCanAnimateOnImplThread();
+ !layer->OpacityCanAnimateOnImplThread() &&
+ !LayerSubtreeCanAcceptInput(layer);
}
// Called on each layer that could be drawn after all information from
« 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