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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 2723553003: Revert of Refactor unreliable hit test code to avoid owning_layers (Closed)
Patch Set: 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 | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_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_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index f99af61cec2f13da73bae0bf17244f7fe536c3cf..132616ef303232e01822a4a4dd03ebb7dd1dbb86 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -162,10 +162,15 @@
return false;
auto* property_trees = child->layer_tree_impl()->property_trees();
+ auto ancestor_scroll_id =
+ property_trees->layer_id_to_scroll_node_index.find(ancestor->id());
+ 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->id == ancestor->scroll_tree_index())
+ if (scroll_node->id == ancestor_scroll_id->second)
return true;
}
return false;
@@ -2624,6 +2629,28 @@
return active_tree_->LayerById(impl_scroll_node->owning_layer_id);
}
+static bool IsClosestScrollAncestor(LayerImpl* child,
+ LayerImpl* scroll_ancestor) {
+ DCHECK(scroll_ancestor);
+ if (!child)
+ return false;
+
+ 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->id == ancestor_scroll_id->second;
+ }
+ return false;
+}
+
InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
ScrollState* scroll_state,
LayerImpl* scrolling_layer_impl,
@@ -2697,7 +2724,11 @@
active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
if (layer_impl) {
- if (!IsInitialScrollHitTestReliable(layer_impl, device_viewport_point)) {
+ LayerImpl* scroll_layer_impl =
+ active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint(
+ device_viewport_point);
+ if (scroll_layer_impl &&
+ !IsClosestScrollAncestor(layer_impl, scroll_layer_impl)) {
scroll_status.thread = SCROLL_UNKNOWN;
scroll_status.main_thread_scrolling_reasons =
MainThreadScrollingReason::kFailedHitTest;
@@ -2721,46 +2752,6 @@
}
return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type);
-}
-
-// Some initial scroll tests are known to be unreliable and require falling
-// back to main thread scrolling.
-bool LayerTreeHostImpl::IsInitialScrollHitTestReliable(
- LayerImpl* layer_impl,
- const gfx::PointF& device_viewport_point) {
- LayerImpl* first_scrolling_layer_or_drawn_scrollbar =
- active_tree_->FindFirstScrollingLayerOrDrawnScrollbarThatIsHitByPoint(
- device_viewport_point);
- if (!first_scrolling_layer_or_drawn_scrollbar)
- return true;
-
- ScrollNode* closest_scroll_node = nullptr;
- auto& scroll_tree = active_tree_->property_trees()->scroll_tree;
- ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index());
- for (; scroll_tree.parent(scroll_node);
- scroll_node = scroll_tree.parent(scroll_node)) {
- if (scroll_node->scrollable) {
- closest_scroll_node = scroll_node;
- break;
- }
- }
- if (!closest_scroll_node)
- return false;
-
- // If |first_scrolling_layer_or_drawn_scrollbar| is scrollable, it will
- // create a scroll node. If this scroll node corresponds to first scrollable
- // ancestor along the scroll tree for |layer_impl|, the hit test has not
- // escaped to other areas of the scroll tree and is reliable.
- if (first_scrolling_layer_or_drawn_scrollbar->scrollable()) {
- return closest_scroll_node->id ==
- first_scrolling_layer_or_drawn_scrollbar->scroll_tree_index();
- }
-
- // If |first_scrolling_layer_or_drawn_scrollbar| is not scrollable, it must
- // be a drawn scrollbar. These hit tests require falling back to main-thread
- // scrolling.
- DCHECK(first_scrolling_layer_or_drawn_scrollbar->IsDrawnScrollbar());
- return false;
}
InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin(
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698