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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 2702143002: Refactor IsScrolledBy and IsClosestScrollAncestor to use ScrollNode ids (Closed)
Patch Set: Switch to using layer_id_to_scroll_node_index Created 3 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index fc53daf99b314b0c4d096eb16acb2a0f3d827e85..5174826f2af15359fc2e70f425425f03a7f0e804 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -154,18 +154,23 @@ void RecordCompositorSlowScrollMetric(InputHandler::ScrollInputType type,
}
}
-// Return true if scrollable 'ancestor' is the same layer as 'child' or its
+// Return true if scrollable node for 'ancestor' is the same as 'child' or an
// ancestor along the scroll tree.
bool IsScrolledBy(LayerImpl* child, LayerImpl* ancestor) {
DCHECK(ancestor && ancestor->scrollable());
if (!child)
return false;
- ScrollTree& scroll_tree =
- child->layer_tree_impl()->property_trees()->scroll_tree;
+ auto* property_trees = child->layer_tree_impl()->property_trees();
+ auto ancestor_scroll_id =
+ property_trees->layer_id_to_scroll_node_index.find(ancestor->id());
ajuma 2017/02/23 14:19:00 Is the idea that for SPv2, we'd potentially have m
pdr. 2017/02/23 19:19:18 Yeah, here's my mental model of a usecase and how
+ if (ancestor_scroll_id == property_trees->layer_id_to_scroll_node_index.end())
+ return false;
+
+ ScrollTree& scroll_tree = property_trees->scroll_tree;
for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
scroll_node; scroll_node = scroll_tree.parent(scroll_node)) {
- if (scroll_node->owning_layer_id == ancestor->id())
+ if (scroll_node->id == ancestor_scroll_id->second)
return true;
}
return false;
@@ -2628,13 +2633,19 @@ static bool IsClosestScrollAncestor(LayerImpl* child,
DCHECK(scroll_ancestor);
if (!child)
return false;
- ScrollTree& scroll_tree =
- child->layer_tree_impl()->property_trees()->scroll_tree;
+
+ auto* property_trees = child->layer_tree_impl()->property_trees();
+ auto ancestor_scroll_id =
+ property_trees->layer_id_to_scroll_node_index.find(scroll_ancestor->id());
+ if (ancestor_scroll_id == property_trees->layer_id_to_scroll_node_index.end())
+ return false;
+
+ ScrollTree& scroll_tree = property_trees->scroll_tree;
ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
for (; scroll_tree.parent(scroll_node);
scroll_node = scroll_tree.parent(scroll_node)) {
if (scroll_node->scrollable)
- return scroll_node->owning_layer_id == scroll_ancestor->id();
+ return scroll_node->id == ancestor_scroll_id->second;
}
return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698