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

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: override scrollAnimatorEnabled in VisualViewport 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 6bc56742629f03c8eac56ce52cf05704c2ab6741..b69d09726ea23fe3f1f698c699a2a919e776288a 100644
--- a/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
+++ b/third_party/WebKit/Source/core/frame/RootFrameViewport.cpp
@@ -246,8 +246,41 @@ ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical
else
orientation = HorizontalScrollbar;
- if (layoutViewport().userInputScrollable(orientation) && visualViewport().userInputScrollable(orientation))
- return ScrollableArea::userScroll(direction, granularity, delta);
+ if (layoutViewport().userInputScrollable(orientation) && visualViewport().userInputScrollable(orientation)) {
+ // Distribute the scroll between the visual and layout viewport.
+ ScrollbarOrientation orientation = scrollbarOrientationFromDirection(direction);
+ float step = scrollStep(granularity, orientation);
+
+ 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
+ // simply give it the total delta so that the unused delta it reports
+ // back can be applied to the secondary viewport.
+ delta *= step;
bokan 2015/12/04 19:39:02 I don't think you need to do this. I believe the f
ymalik 2015/12/04 20:11:01 So the current flow is as follows delta -> delta *
bokan 2015/12/04 20:42:52 Ok, just had a look at ScrollAnimatorMac and it se
ymalik 2015/12/07 17:53:14 Hmm, so the ScrollAnimator::userScroll returns 0 f
+
+ cancelProgrammaticScrollAnimation();
+
+ ScrollableArea& primary = !m_invertScrollOrder ? layoutViewport() : visualViewport();
bokan 2015/12/04 20:42:52 Replace primary with visual and secondary with lay
ymalik 2015/12/07 17:53:14 Done.
+ ScrollableArea& secondary = !m_invertScrollOrder ? visualViewport() : layoutViewport();
+
+ ScrollResultOneDimensional pResult = primary.scrollAnimator()->userScroll(
+ orientation, granularity, /* step */ 1, delta);
+
+ // Scroll the secondary viewport if all of the scroll was not applied to the
+ // primary viewport.
+ if (pResult.unusedScrollDelta == 0)
bokan 2015/12/04 19:39:02 Use ScrollResultOneDimensional::didScroll for this
ymalik 2015/12/04 20:13:54 didScroll can be true while we still want to distr
bokan 2015/12/04 20:42:52 Right, right, my bad.
+ return pResult;
+
+ ScrollResultOneDimensional sResult = secondary.scrollAnimator()->userScroll(
+ orientation, granularity, /* step */ 1, pResult.unusedScrollDelta);
+
+ if (!pResult.didScroll && !sResult.didScroll)
+ return ScrollResultOneDimensional(false, pResult.unusedScrollDelta / step);
+
+ return ScrollResultOneDimensional(true, sResult.unusedScrollDelta / step);
bokan 2015/12/04 19:39:02 You can merge the last two returns together in the
bokan 2015/12/04 20:42:52 You can still merge these two together (in fact, y
ymalik 2015/12/07 17:53:14 Merged. layoutResult.unusedScrollDelta is the amou
+ }
if (visualViewport().userInputScrollable(orientation))
return visualViewport().userScroll(direction, granularity, delta);
@@ -282,6 +315,13 @@ void RootFrameViewport::updateCompositorScrollAnimations()
visualViewport().updateCompositorScrollAnimations();
}
+void RootFrameViewport::cancelProgrammaticScrollAnimation()
+{
+ ScrollableArea::cancelProgrammaticScrollAnimation();
+ layoutViewport().cancelProgrammaticScrollAnimation();
+ visualViewport().cancelProgrammaticScrollAnimation();
+}
+
DEFINE_TRACE(RootFrameViewport)
{
visitor->trace(m_visualViewport);

Powered by Google App Engine
This is Rietveld 408576698