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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 2118773002: Respect main thread scrolling reasons for fallback to root layer scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer comments. Created 4 years, 5 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_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 8c4e7498c3110a67a0ec37387251717a43ad5e70..bfdaf86963f4e4360932efba81ab615385687c8e 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2538,6 +2538,21 @@ InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll(
return scroll_status;
}
+static bool IsMainThreadScrolling(const InputHandler::ScrollStatus& status,
+ const ScrollNode* scroll_node) {
+ if (status.thread == InputHandler::SCROLL_ON_MAIN_THREAD) {
+ if (!!scroll_node->data.main_thread_scrolling_reasons) {
+ DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons(
+ status.main_thread_scrolling_reasons));
+ } else {
+ DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons(
+ status.main_thread_scrolling_reasons));
+ }
+ return true;
+ }
+ return false;
+}
+
LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
const gfx::PointF& device_viewport_point,
InputHandler::ScrollInputType type,
@@ -2550,9 +2565,9 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
MainThreadScrollingReason::kNotScrollingOnMain;
// Walk up the hierarchy and look for a scrollable layer.
+ ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
LayerImpl* potentially_scrolling_layer_impl = NULL;
if (layer_impl) {
- ScrollTree& 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)) {
@@ -2560,15 +2575,7 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
// thread.
ScrollStatus status =
TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
- if (status.thread == SCROLL_ON_MAIN_THREAD) {
- if (!!scroll_node->data.main_thread_scrolling_reasons) {
- DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons(
- status.main_thread_scrolling_reasons));
- } else {
- DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons(
- status.main_thread_scrolling_reasons));
- }
-
+ if (IsMainThreadScrolling(status, scroll_node)) {
*scroll_on_main_thread = true;
*main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
return NULL;
@@ -2581,10 +2588,10 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
}
}
}
+
// Falling back to the root scroll layer ensures generation of root overscroll
- // notifications while preventing scroll updates from being unintentionally
- // forwarded to the main thread. The inner viewport layer represents the
- // viewport during scrolling.
+ // notifications. The inner viewport layer represents the viewport during
+ // scrolling.
if (!potentially_scrolling_layer_impl)
potentially_scrolling_layer_impl = InnerViewportScrollLayer();
@@ -2592,6 +2599,19 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
if (potentially_scrolling_layer_impl == OuterViewportScrollLayer())
potentially_scrolling_layer_impl = InnerViewportScrollLayer();
+ if (potentially_scrolling_layer_impl) {
+ // Ensure that final layer scrolls on impl thread (crbug.com/625100)
+ ScrollNode* scroll_node =
+ scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index());
+ ScrollStatus status =
+ TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
+ if (IsMainThreadScrolling(status, scroll_node)) {
+ *scroll_on_main_thread = true;
+ *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
+ return NULL;
+ }
+ }
+
return potentially_scrolling_layer_impl;
}
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698