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

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp

Issue 1738243002: Removed main-thread one dimensional scrolling paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removeStepFromUserScroll
Patch Set: Rebase Created 4 years, 10 months 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/platform/scroll/ScrollableArea.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
index 250f367fa21b335a07803e0e95c4c3c8ce90180e..c26e4c572410b73963328e30cc47e547de3a99e5 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
@@ -157,20 +157,37 @@ float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta
}
}
-ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta)
+ScrollResult ScrollableArea::userScroll(ScrollGranularity granularity, const FloatSize& delta)
{
- ScrollbarOrientation orientation = scrollbarOrientationFromDirection(direction);
- if (!userInputScrollable(orientation))
- return ScrollResultOneDimensional(false, delta);
+ float stepX = scrollStep(granularity, HorizontalScrollbar);
+ float stepY = scrollStep(granularity, VerticalScrollbar);
+
+ FloatSize pixelDelta(delta);
+ pixelDelta.scale(stepX, stepY);
+
+ FloatSize scrollableAxisDelta(
+ userInputScrollable(HorizontalScrollbar) ? pixelDelta.width() : 0,
+ userInputScrollable(VerticalScrollbar) ? pixelDelta.height() : 0);
+
+ if (scrollableAxisDelta.isZero()) {
+ return ScrollResult(
+ false,
+ false,
+ pixelDelta.width(),
+ pixelDelta.height());
+ }
cancelProgrammaticScrollAnimation();
- float step = scrollStep(granularity, orientation);
+ ScrollResult result = scrollAnimator().userScroll(granularity, pixelDelta);
- if (direction == ScrollUp || direction == ScrollLeft)
- delta = -delta;
+ // Delta that wasn't scrolled because the axis is !userInputScrollable
+ // should count as unusedScrollDelta.
+ FloatSize unscrollableAxisDelta = pixelDelta - scrollableAxisDelta;
+ result.unusedScrollDeltaX += unscrollableAxisDelta.width();
+ result.unusedScrollDeltaY += unscrollableAxisDelta.height();
- return scrollAnimator().userScroll(orientation, granularity, step * delta);
+ return result;
}
void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType scrollType, ScrollBehavior behavior)
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | third_party/WebKit/Source/platform/scroll/Scrollbar.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698