Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/RootFrameViewport.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp b/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp |
| index 2446d420779e8101175f849d7ddfe8f001489690..9ad1acb71a76376bd47f56c333fa1780230dda32 100644 |
| --- a/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp |
| +++ b/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp |
| @@ -232,50 +232,54 @@ GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const |
| return layoutViewport().layerForVerticalScrollbar(); |
| } |
| -ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) |
| +ScrollResult RootFrameViewport::userScroll(ScrollGranularity granularity, const FloatSize& delta) |
| { |
| - updateScrollAnimator(); |
| + // TODO(bokan/ymalik): This method specialization can likely go away as a |
| + // result of the smooth scrolling work. |
|
tdresser
2016/02/29 14:53:43
I may just be lacking context, but it isn't clear
bokan
2016/03/01 05:56:24
I think it should be clearer now.
|
| - ScrollbarOrientation orientation = scrollbarOrientationFromDirection(direction); |
| + updateScrollAnimator(); |
| - if (layoutViewport().userInputScrollable(orientation) && visualViewport().userInputScrollable(orientation)) { |
| - // Distribute the scroll between the visual and layout viewport. |
| - float step = scrollStep(granularity, orientation); |
| + // Distribute the scroll between the visual and layout viewport. |
| - if (direction == ScrollUp || direction == ScrollLeft) |
| - delta = -delta; |
| + float stepX = scrollStep(granularity, HorizontalScrollbar); |
| + float stepY = scrollStep(granularity, VerticalScrollbar); |
| - // This is the total amount we need to scroll. Instead of passing step |
| - // to the scroll animator and letting it compute the total delta, we |
| - // give it the delta it should scroll. This way we can apply the |
| - // unused delta from the visual viewport to the layout viewport. |
| - delta *= step; |
| + FloatSize pixelDelta(delta); |
| + pixelDelta.scale(stepX, stepY); |
| - cancelProgrammaticScrollAnimation(); |
| + if (!layoutViewport().userInputScrollable(HorizontalScrollbar)) |
| + pixelDelta.setWidth(0); |
|
tdresser
2016/02/29 14:53:43
Can we avoid calling scrollStep in cases where we'
bokan
2016/03/01 05:56:24
Actually, we'll still want to call scrollStep so w
|
| + if (!layoutViewport().userInputScrollable(VerticalScrollbar)) |
| + pixelDelta.setHeight(0); |
| - float visualUsedDelta = visualViewport().scrollAnimator().computeDeltaToConsume(orientation, delta); |
| - ScrollResultOneDimensional visualResult = visualViewport().scrollAnimator().userScroll( |
| - orientation, granularity, visualUsedDelta); |
| + // If the layoutViewport isn't scrollable, just let the visual viewport |
| + // handle the scroll since it's always userInputScrollable. |
| + if (pixelDelta.isZero()) |
| + return visualViewport().userScroll(granularity, delta); |
|
tdresser
2016/02/29 14:53:43
If one axis didn't scroll, but the other did, this
bokan
2016/03/01 05:56:24
I'm not sure I understand. If pixelDelta.isZero()
|
| - // Scroll the layout viewport if all of the scroll was not applied to the |
| - // visual viewport. |
| - if (visualUsedDelta == delta) |
| - return visualResult; |
| + cancelProgrammaticScrollAnimation(); |
| - ScrollResultOneDimensional layoutResult = layoutViewport().scrollAnimator().userScroll( |
| - orientation, granularity, delta - visualUsedDelta); |
| + // TODO(bokan): Why do we call userScroll on the animators directly and |
| + // not through the ScrollableAreas? |
| - return ScrollResultOneDimensional(visualResult.didScroll || layoutResult.didScroll, |
| - layoutResult.unusedScrollDelta); |
| - } |
| + // Precompute the amount of possible scrolling since, when animated, |
| + // ScrollAnimator::userScroll will consume the total scroll delta even |
| + // beyond the scrolling bounds. |
| + FloatSize visualUsedDelta = visualViewport().scrollAnimator().computeDeltaToConsume(pixelDelta); |
| + ScrollResult visualResult = visualViewport().scrollAnimator().userScroll(granularity, visualUsedDelta); |
| - if (visualViewport().userInputScrollable(orientation)) |
| - return visualViewport().userScroll(direction, granularity, delta); |
| + // Scroll the layout viewport if all of the scroll was not applied to the |
| + // visual viewport. |
| + if (visualUsedDelta == pixelDelta) |
| + return visualResult; |
| - if (layoutViewport().userInputScrollable(orientation)) |
| - return layoutViewport().userScroll(direction, granularity, delta); |
| + ScrollResult layoutResult = layoutViewport().scrollAnimator().userScroll(granularity, pixelDelta - visualUsedDelta); |
|
tdresser
2016/02/29 14:53:43
I'm a bit confused about how this works. If I unde
bokan
2016/03/01 05:56:24
It's actually:
1. Try to scroll the visual viewpo
|
| - return ScrollResultOneDimensional(false, delta); |
| + return ScrollResult( |
| + visualResult.didScrollX || layoutResult.didScrollX, |
| + visualResult.didScrollY || layoutResult.didScrollY, |
| + layoutResult.unusedScrollDeltaX, |
| + layoutResult.unusedScrollDeltaY); |
| } |
| bool RootFrameViewport::scrollAnimatorEnabled() const |