Chromium Code Reviews| 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 |