Index: cc/trees/layer_tree_host_common.h |
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h |
index 05affee8f31d58da72b20647ce06fc1736726711..19ca98841eddc8d774cd9c5bfe147e6064f2e445 100644 |
--- a/cc/trees/layer_tree_host_common.h |
+++ b/cc/trees/layer_tree_host_common.h |
@@ -118,6 +118,9 @@ class CC_EXPORT LayerTreeHostCommon { |
template <typename LayerType> |
static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); |
+ template <typename LayerType> |
+ static LayerType* FindFirstScrollableLayer(LayerType* root_layer); |
+ |
static Layer* get_child_as_raw_ptr( |
const LayerList& children, |
size_t index) { |
@@ -184,6 +187,24 @@ LayerType* LayerTreeHostCommon::FindLayerInSubtree(LayerType* root_layer, |
} |
template <typename LayerType> |
+LayerType* LayerTreeHostCommon::FindFirstScrollableLayer(LayerType* layer) { |
+ if (!layer) |
+ return NULL; |
+ |
+ if (layer->scrollable()) |
+ return layer; |
+ |
+ for (size_t i = 0; i < layer->children().size(); ++i) { |
+ LayerType* current = get_child_as_raw_ptr(layer->children(), i); |
+ LayerType* found = FindFirstScrollableLayer(current); |
+ if (found) |
+ return found; |
+ } |
+ |
+ return NULL; |
+} |
+ |
+template <typename LayerType> |
void LayerTreeHostCommon::CallFunctionForSubtree( |
LayerType* root_layer, |
const base::Callback<void(LayerType* layer)>& function) { |