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 ca294bf786ab2a1c533314c7a626ab1c66886511..48a672bd7965be56de7ba44be57c726595757138 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -2770,6 +2770,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; |
dtapuska
2017/05/30 15:20:38
Why is this an early return? It avoids the uma met
sahel
2017/05/30 15:36:14
I want GSB handling to return ignored when there i
|
+ } |
+ |
client_->RenewTreePriority(); |
RecordCompositorSlowScrollMetric(type, CC_THREAD); |
@@ -2896,7 +2905,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; |
@@ -2914,16 +2923,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; |
@@ -2951,7 +2956,6 @@ gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( |
scroll_tree.current_scroll_offset(scroll_node->owning_layer_id); |
gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( |
old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); |
- |
gfx::ScrollOffset scrolled = new_offset - old_offset; |
return gfx::Vector2dF(scrolled.x(), scrolled.y()); |
} |
@@ -3289,31 +3293,81 @@ void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { |
ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
ScrollNode* viewport_scroll_node = OuterViewportScrollNode(); |
+ LOG(ERROR) << "in distribute scroll delta before for loop"; |
dtapuska
2017/05/30 15:20:38
Why log errors?
sahel
2017/05/30 15:36:14
This is a debug version I was trying to figure out
|
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? |
for (; scroll_tree.parent(scroll_node); |
scroll_node = scroll_tree.parent(scroll_node)) { |
+ LOG(ERROR) << "scroll node id ib DistributeScrollDelta:\t" |
+ << scroll_node->id; |
if (scroll_node == viewport_scroll_node) { |
// Don't chain scrolls past the outer viewport scroll layer. Once we |
// reach that, we should scroll the viewport which is represented by the |
// main viewport scroll layer. |
DCHECK(viewport_scroll_node); |
- current_scroll_chain.push_front(viewport_scroll_node); |
+ if (CanConsumeDelta(viewport_scroll_node, *scroll_state)) |
+ current_scroll_chain.push_front(viewport_scroll_node); |
break; |
} |
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) { |
+ LOG(ERROR) << "node id in can consume:\t" << scroll_node->id; |
+ 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()) { |
+ LOG(ERROR) << "true because scroll delta is zero"; |
+ return true; |
+ } |
+ |
+ if (ComputeScrollDelta(scroll_node, delta_to_scroll) != gfx::Vector2dF()) |
+ return true; |
+ |
+ if ((OuterViewportScrollNode() && |
+ OuterViewportScrollNode()->id == scroll_node->id && |
+ active_tree_->InnerViewportScrollLayer()) || |
+ scroll_node->scrolls_inner_viewport) { |
+ ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
+ ScrollNode* inner_viewport_scroll_node = scroll_tree.Node( |
+ active_tree_->InnerViewportScrollLayer()->scroll_tree_index()); |
+ if (!inner_viewport_scroll_node) |
+ return false; |
+ LOG(ERROR) << "return value in newly added code:\t" |
+ << (ComputeScrollDelta(inner_viewport_scroll_node, |
+ delta_to_scroll) != gfx::Vector2dF()); |
+ |
+ return ComputeScrollDelta(inner_viewport_scroll_node, delta_to_scroll) != |
+ gfx::Vector2dF(); |
+ } |
+ |
+ return false; |
+} |
+ |
InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
ScrollState* scroll_state) { |
DCHECK(scroll_state); |
@@ -3344,6 +3398,7 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
ScrollNode* current_scrolling_node = |
scroll_state->current_native_scrolling_node(); |
+ LOG(ERROR) << "currently scrolling node id:\t" << current_scrolling_node->id; |
active_tree_->SetCurrentlyScrollingNode(current_scrolling_node); |
did_lock_scrolling_layer_ = |
scroll_state->delta_consumed_for_scroll_sequence(); |