Chromium Code Reviews| 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 0cf868ff75b5c5bb77f196d119ce0ac4063215da..49165482aec0b647991a6f7a261a75fbd5c9c214 100644 |
| --- a/cc/trees/layer_tree_host_impl.cc |
| +++ b/cc/trees/layer_tree_host_impl.cc |
| @@ -154,6 +154,22 @@ void RecordCompositorSlowScrollMetric(InputHandler::ScrollInputType type, |
| } |
| } |
| +// Return true if ancestor is same as child or its ancestor. |
| +bool isScrollingAncestor(LayerImpl* child, LayerImpl* ancestor) { |
| + DCHECK(ancestor); |
| + if (!child) |
| + return false; |
| + |
| + ScrollTree& scroll_tree = |
| + child->layer_tree_impl()->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->owner_id == ancestor->id()) |
|
weiliangc
2016/11/15 18:50:38
Another difference between this function and HasSc
bokan
2016/11/15 19:02:29
We should get rid of one of the functions because
weiliangc
2016/11/15 19:13:46
We could break out of the loop and check if scroll
weiliangc
2016/11/15 19:43:47
Oops now paid more attention to the code, I think
|
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| } // namespace |
| DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, |
| @@ -581,7 +597,7 @@ EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( |
| return active_tree_->event_listener_properties(event_class); |
| } |
| -bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( |
| +EventListenerProperties LayerTreeHostImpl::DoTouchHandlersBlockScrollAt( |
| const gfx::Point& viewport_point) { |
| gfx::PointF device_viewport_point = gfx::ScalePoint( |
| gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| @@ -591,7 +607,16 @@ bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( |
| LayerImpl* layer_impl = |
| active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| device_viewport_point); |
| - return layer_impl != NULL; |
| + if (layer_impl == NULL) |
| + return EventListenerProperties::kNone; |
| + |
| + if (!CurrentlyScrollingLayer()) |
| + return EventListenerProperties::kBlocking; |
| + |
| + bool is_ancestor = |
| + isScrollingAncestor(layer_impl, active_tree_->CurrentlyScrollingLayer()); |
| + return is_ancestor ? EventListenerProperties::kBlockingAndPassiveDueToFling |
| + : EventListenerProperties::kBlocking; |
| } |
| std::unique_ptr<SwapPromiseMonitor> |
| @@ -2578,7 +2603,7 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
| } |
| // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. |
| -static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { |
| +static bool isScrolledBy(LayerImpl* child, LayerImpl* scroll_ancestor) { |
| DCHECK(scroll_ancestor); |
| if (!child) |
| return false; |
| @@ -2662,8 +2687,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
| LayerImpl* scroll_layer_impl = |
| active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( |
| device_viewport_point); |
| - if (scroll_layer_impl && |
| - !HasScrollAncestor(layer_impl, scroll_layer_impl)) { |
| + if (scroll_layer_impl && !isScrolledBy(layer_impl, scroll_layer_impl)) { |
| scroll_status.thread = SCROLL_UNKNOWN; |
| scroll_status.main_thread_scrolling_reasons = |
| MainThreadScrollingReason::kFailedHitTest; |