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

Unified Diff: Source/core/platform/ScrollAnimator.cpp

Issue 16982005: Allow objects without scrollbars to be scrollable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Mac Build Fix Created 7 years, 6 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: Source/core/platform/ScrollAnimator.cpp
diff --git a/Source/core/platform/ScrollAnimator.cpp b/Source/core/platform/ScrollAnimator.cpp
index 2924a2b6252131a508dd6457804c3c14a152f8f4..2b36c18f50074776a2b1cee265bdb65a1fdc2ba8 100644
--- a/Source/core/platform/ScrollAnimator.cpp
+++ b/Source/core/platform/ScrollAnimator.cpp
@@ -76,13 +76,13 @@ void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
{
- Scrollbar* horizontalScrollbar = m_scrollableArea->horizontalScrollbar();
- Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar();
+ bool canScrollX = m_scrollableArea->isHorizontallyScrollable();
+ bool canScrollY = m_scrollableArea->isVerticallyScrollable();
- // Accept the event if we have a scrollbar in that direction and can still
+ // Accept the event if we are scrollable in that direction and can still
// scroll any further.
- float deltaX = horizontalScrollbar ? e.deltaX() : 0;
- float deltaY = verticalScrollbar ? e.deltaY() : 0;
+ float deltaX = canScrollX ? e.deltaX() : 0;
+ float deltaY = canScrollY ? e.deltaY() : 0;
bool handled = false;
@@ -107,7 +107,13 @@ bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
if (negative)
deltaY = -deltaY;
}
- scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY);
+
+ float step = 1;
+ Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar();
+ if (verticalScrollbar)
+ step = verticalScrollbar->pixelStep();
+
+ scroll(VerticalScrollbar, granularity, step, -deltaY);
}
if (deltaX) {
@@ -117,7 +123,13 @@ bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
if (negative)
deltaX = -deltaX;
}
- scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX);
+
+ float step = 1;
+ Scrollbar* horizontalScrollbar = m_scrollableArea->horizontalScrollbar();
+ if (horizontalScrollbar)
+ step = horizontalScrollbar->pixelStep();
+
+ scroll(HorizontalScrollbar, granularity, step, -deltaX);
}
}
return handled;

Powered by Google App Engine
This is Rietveld 408576698