Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: third_party/WebKit/Source/core/frame/RootFrameViewport.cpp

Issue 1496693005: Update RootFrameViewport::userScroll to distribute scrolls between viewports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 7f4963a0f0d24bfac3d7e98e50a7c607686f4983..5d687df520a65bd3731262f9eaca72ae4a11ca77 100644
--- a/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
+++ b/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
@@ -239,15 +239,40 @@ ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical
{
updateScrollAnimator();
- ScrollbarOrientation orientation;
+ ScrollbarOrientation orientation = scrollbarOrientationFromDirection(direction);
- if (direction == ScrollUp || direction == ScrollDown)
- orientation = VerticalScrollbar;
- else
- orientation = HorizontalScrollbar;
+ if (layoutViewport().userInputScrollable(orientation) && visualViewport().userInputScrollable(orientation)) {
+ // Distribute the scroll between the visual and layout viewport.
+ float step = scrollStep(granularity, orientation);
- if (layoutViewport().userInputScrollable(orientation) && visualViewport().userInputScrollable(orientation))
- return ScrollableArea::userScroll(direction, granularity, delta);
+ if (direction == ScrollUp || direction == ScrollLeft)
+ delta = -delta;
+
+ // 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.
+ // TODO(ymalik): ScrollAnimator should return unused delta in pixles
+ // rather than in terms of steps.
+ delta *= step;
+
+ cancelProgrammaticScrollAnimation();
+
+ float visualUsedDelta = visualViewport().scrollAnimator().computeDeltaToConsume(orientation, delta);
+ ScrollResultOneDimensional visualResult = visualViewport().scrollAnimator().userScroll(
+ orientation, granularity, 1 /* step */, visualUsedDelta);
+
+ // Scroll the layout viewport if all of the scroll was not applied to the
+ // visual viewport.
+ if (visualUsedDelta == delta)
+ return visualResult;
+
+ ScrollResultOneDimensional layoutResult = layoutViewport().scrollAnimator().userScroll(
+ orientation, granularity, 1 /* step */, delta - visualUsedDelta);
+
+ return ScrollResultOneDimensional(visualResult.didScroll || layoutResult.didScroll,
+ layoutResult.unusedScrollDelta / step);
+ }
if (visualViewport().userInputScrollable(orientation))
return visualViewport().userScroll(direction, granularity, delta);
@@ -282,6 +307,13 @@ void RootFrameViewport::updateCompositorScrollAnimations()
visualViewport().updateCompositorScrollAnimations();
}
+void RootFrameViewport::cancelProgrammaticScrollAnimation()
+{
+ ScrollableArea::cancelProgrammaticScrollAnimation();
+ layoutViewport().cancelProgrammaticScrollAnimation();
+ visualViewport().cancelProgrammaticScrollAnimation();
+}
+
DEFINE_TRACE(RootFrameViewport)
{
visitor->trace(m_visualViewport);
« no previous file with comments | « third_party/WebKit/Source/core/frame/RootFrameViewport.h ('k') | third_party/WebKit/Source/core/frame/VisualViewport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698