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 4a945a224384de89251c3b1d7a2b888f932c4999..2724f543974c5d87f7b0b3aeec37932ba5f88b8e 100644 |
| --- a/cc/trees/layer_tree_host_impl.cc |
| +++ b/cc/trees/layer_tree_host_impl.cc |
| @@ -2140,6 +2140,20 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
| return potentially_scrolling_layer_impl; |
| } |
| +// Similar to LayerImpl::HasAncestor, but takes into account scroll parents. |
| +static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { |
| + if (!scroll_ancestor) |
| + return false; |
| + |
| + LayerImpl* ancestor = child; |
|
enne (OOO)
2014/04/15 21:25:54
style nit: don't put this out of scope just to avo
|
| + for (; ancestor; ancestor = NextScrollLayer(ancestor)) { |
| + if (ancestor == scroll_ancestor) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
| const gfx::Point& viewport_point, |
| InputHandler::ScrollInputType type) { |
| @@ -2159,6 +2173,15 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
| LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| device_viewport_point, |
| active_tree_->RenderSurfaceLayerList()); |
| + |
| + if (layer_impl) { |
| + LayerImpl* scroll_layer_impl = |
| + LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint( |
| + device_viewport_point, active_tree_->RenderSurfaceLayerList()); |
| + if (!HasScrollAncestor(layer_impl, scroll_layer_impl)) |
| + return ScrollOnMainThread; |
| + } |
| + |
| bool scroll_on_main_thread = false; |
| LayerImpl* potentially_scrolling_layer_impl = |
| FindScrollLayerForDeviceViewportPoint(device_viewport_point, |