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 07bce7263a2ba7a975f2183082cafc9ec10c2322..7b266998aeac440158320c9f8a4a865a78b8affb 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -2793,6 +2793,15 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( |
// scroll customization callbacks are invoked. |
DistributeScrollDelta(scroll_state); |
+ // If the CurrentlyScrollingNode doesn't exist after distributing scroll |
+ // delta, no scroller can scroll in the given delta hint direction(s). |
+ if (!active_tree_->CurrentlyScrollingNode()) { |
+ scroll_status.thread = InputHandler::SCROLL_IGNORED; |
+ scroll_status.main_thread_scrolling_reasons = |
+ MainThreadScrollingReason::kNotScrollingOnMain; |
+ return scroll_status; |
+ } |
+ |
client_->RenewTreePriority(); |
RecordCompositorSlowScrollMetric(type, CC_THREAD); |
@@ -2920,7 +2929,7 @@ bool LayerTreeHostImpl::IsInitialScrollHitTestReliable( |
} |
InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( |
- const gfx::Point& viewport_point) { |
+ ScrollState* scroll_state) { |
InputHandler::ScrollStatus scroll_status; |
scroll_status.main_thread_scrolling_reasons = |
MainThreadScrollingReason::kNotScrollingOnMain; |
@@ -2938,16 +2947,12 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( |
} |
return scroll_status; |
} |
- ScrollStateData scroll_state_data; |
- scroll_state_data.position_x = viewport_point.x(); |
- scroll_state_data.position_y = viewport_point.y(); |
- ScrollState scroll_state(scroll_state_data); |
// ScrollAnimated is used for animated wheel scrolls. We find the first layer |
// that can scroll and set up an animation of its scroll offset. Note that |
// this does not currently go through the scroll customization machinery |
// that ScrollBy uses for non-animated wheel scrolls. |
- scroll_status = ScrollBegin(&scroll_state, WHEEL); |
+ scroll_status = ScrollBegin(scroll_state, WHEEL); |
if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
scroll_animating_latched_node_id_ = ScrollTree::kInvalidNodeId; |
ScrollStateData scroll_state_end_data; |
@@ -3312,7 +3317,10 @@ void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { |
std::list<ScrollNode*> current_scroll_chain; |
ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
- ScrollNode* viewport_scroll_node = OuterViewportScrollNode(); |
+ ScrollNode* viewport_scroll_node = |
+ viewport()->MainScrollLayer() |
+ ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) |
+ : nullptr; |
if (scroll_node) { |
// TODO(bokan): The loop checks for a null parent but don't we still want to |
// distribute to the root scroll node? |
@@ -3330,14 +3338,52 @@ void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { |
if (!scroll_node->scrollable) |
continue; |
- current_scroll_chain.push_front(scroll_node); |
+ if (CanConsumeDelta(scroll_node, *scroll_state)) |
+ current_scroll_chain.push_front(scroll_node); |
} |
} |
+ active_tree_->SetCurrentlyScrollingNode( |
+ current_scroll_chain.empty() ? nullptr : current_scroll_chain.back()); |
scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, |
active_tree()); |
scroll_state->DistributeToScrollChainDescendant(); |
} |
+bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node, |
+ const ScrollState& scroll_state) { |
+ gfx::Vector2dF delta_to_scroll; |
+ if (scroll_state.is_beginning()) { |
+ if (scroll_state.ignore_delta_hints()) |
+ return true; |
+ |
+ delta_to_scroll = gfx::Vector2dF(scroll_state.delta_x_hint(), |
+ scroll_state.delta_y_hint()); |
+ } else { |
+ delta_to_scroll = |
+ gfx::Vector2dF(scroll_state.delta_x(), scroll_state.delta_y()); |
+ } |
+ |
+ if (delta_to_scroll == gfx::Vector2dF()) |
+ return true; |
+ |
+ if (ComputeScrollDelta(scroll_node, delta_to_scroll) != gfx::Vector2dF()) |
+ return true; |
+ |
+ if (scroll_node->scrolls_inner_viewport) { |
bokan
2017/06/19 21:43:17
I don't think you need this special case, at least
sahel
2017/06/22 16:34:17
I don't think ComputeScrollDelta checks for viewpo
bokan
2017/06/22 21:44:37
Sorry, I meant that we should add it to ComputeScr
sahel
2017/06/23 18:22:03
I deleted this special case, as we discussed alway
bokan
2017/06/23 18:56:44
Acknowledged.
|
+ ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
+ ScrollNode* viewport_scroll_node = |
+ viewport()->MainScrollLayer() |
+ ? scroll_tree.Node( |
+ viewport()->MainScrollLayer()->scroll_tree_index()) |
+ : nullptr; |
+ if (viewport_scroll_node) |
+ return ComputeScrollDelta(viewport_scroll_node, delta_to_scroll) != |
+ gfx::Vector2dF(); |
+ } |
+ |
+ return false; |
+} |
+ |
InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
ScrollState* scroll_state) { |
DCHECK(scroll_state); |