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

Unified Diff: Source/platform/mac/ScrollAnimatorMac.mm

Issue 197213011: Selectively disable rubber banding on mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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/platform/mac/ScrollAnimatorMac.mm
diff --git a/Source/platform/mac/ScrollAnimatorMac.mm b/Source/platform/mac/ScrollAnimatorMac.mm
index b699f02055badc6717eb47e2828003931e5c1ea7..1f58d28b8c96bdc478f6843073d9260df7b728c6 100644
--- a/Source/platform/mac/ScrollAnimatorMac.mm
+++ b/Source/platform/mac/ScrollAnimatorMac.mm
@@ -100,7 +100,7 @@ static NSSize abs(NSSize size)
finalSize.width = -finalSize.width;
if (finalSize.height < 0)
finalSize.height = -finalSize.height;
- return finalSize;
+ return finalSize;
}
@implementation WebScrollAnimationHelperDelegate
@@ -196,7 +196,7 @@ static NSSize abs(NSSize size)
self = [super init];
if (!self)
return nil;
-
+
_scrollableArea = scrollableArea;
return self;
}
@@ -240,7 +240,7 @@ static NSSize abs(NSSize size)
WebCore::Scrollbar* scrollbar = 0;
if ([scrollerImp isHorizontal])
scrollbar = _scrollableArea->horizontalScrollbar();
- else
+ else
scrollbar = _scrollableArea->verticalScrollbar();
// It is possible to have a null scrollbar here since it is possible for this delegate
@@ -401,7 +401,7 @@ enum FeatureToAnimate {
self = [super init];
if (!self)
return nil;
-
+
_scrollbar = scrollbar;
return self;
}
@@ -443,7 +443,7 @@ enum FeatureToAnimate {
- (void)setUpAlphaAnimation:(RetainPtr<WebScrollbarPartAnimation>&)scrollbarPartAnimation scrollerPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::ScrollbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
{
- // If the user has scrolled the page, then the scrollbars must be animated here.
+ // If the user has scrolled the page, then the scrollbars must be animated here.
// This overrides the early returns.
bool mustAnimate = [self scrollAnimator]->haveScrolledSincePageLoad();
@@ -472,10 +472,10 @@ enum FeatureToAnimate {
[self scrollAnimator]->setVisibleScrollerThumbRect(IntRect());
}
- scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
+ scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
featureToAnimate:part == ThumbPart ? ThumbAlpha : TrackAlpha
animateFrom:part == ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter trackAlpha]
- animateTo:newAlpha
+ animateTo:newAlpha
duration:duration]);
[scrollbarPartAnimation.get() startAnimation];
}
@@ -497,7 +497,7 @@ enum FeatureToAnimate {
return;
ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar));
-
+
ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
[self setUpAlphaAnimation:_trackAlphaAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
}
@@ -518,7 +518,7 @@ enum FeatureToAnimate {
[scrollbarPainter setUiStateTransitionProgress:1 - [scrollerImp uiStateTransitionProgress]];
if (!_uiStateTransitionAnimation)
- _uiStateTransitionAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
+ _uiStateTransitionAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
featureToAnimate:UIStateTransition
animateFrom:[scrollbarPainter uiStateTransitionProgress]
animateTo:1.0
@@ -623,7 +623,7 @@ ScrollAnimatorMac::~ScrollAnimatorMac()
static bool scrollAnimationEnabledForSystem()
{
- NSString* scrollAnimationDefaultsKey =
+ NSString* scrollAnimationDefaultsKey =
@"AppleScrollAnimationEnabled";
static bool enabled = [[NSUserDefaults standardUserDefaults] boolForKey:scrollAnimationDefaultsKey];
return enabled;
@@ -696,7 +696,7 @@ FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint&
void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition)
{
FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
-
+
bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosition.y() != m_currentPosY;
if (!positionChanged && !scrollableArea()->scrollOriginChanged())
return;
@@ -963,7 +963,7 @@ void ScrollAnimatorMac::notifyContentAreaScrolled(const FloatSize& delta)
if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
return;
- // This function is called when a page is going into the page cache, but the page
+ // This function is called when a page is going into the page cache, but the page
// isn't really scrolling in that case. We should only pass the message on to the
// ScrollbarPainterController when we're really scrolling on an active page.
if (scrollableArea()->scrollbarsCanBeActive())
@@ -997,12 +997,12 @@ void ScrollAnimatorMac::handleWheelEventPhase(PlatformWheelEventPhase phase)
}
#if USE(RUBBER_BANDING)
-bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent, bool canRubberbandLeft, bool canRubberbandRight)
{
m_haveScrolledSincePageLoad = true;
if (!wheelEvent.hasPreciseScrollingDeltas() || !rubberBandingEnabledForSystem())
- return ScrollAnimator::handleWheelEvent(wheelEvent);
+ return ScrollAnimator::handleWheelEvent(wheelEvent, canRubberbandLeft, canRubberbandRight);
// FIXME: This is somewhat roundabout hack to allow forwarding wheel events
// up to the parent scrollable area. It takes advantage of the fact that
@@ -1010,13 +1010,13 @@ bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
// wheel event if there is nowhere to scroll.
if (fabsf(wheelEvent.deltaY()) >= fabsf(wheelEvent.deltaX())) {
if (!allowsVerticalStretching())
- return ScrollAnimator::handleWheelEvent(wheelEvent);
+ return ScrollAnimator::handleWheelEvent(wheelEvent, canRubberbandLeft, canRubberbandRight);
} else {
if (!allowsHorizontalStretching())
- return ScrollAnimator::handleWheelEvent(wheelEvent);
+ return ScrollAnimator::handleWheelEvent(wheelEvent, canRubberbandLeft, canRubberbandRight);
}
- bool didHandleEvent = m_scrollElasticityController.handleWheelEvent(wheelEvent);
+ bool didHandleEvent = m_scrollElasticityController.handleWheelEvent(wheelEvent, canRubberbandLeft, canRubberbandRight);
// The elasticity controller can return false on a phase end event if rubber banding wasn't in progress.
// In this case, the wheel phase must still be handled so that that overlay scroll bars get hidden.
@@ -1046,7 +1046,7 @@ bool ScrollAnimatorMac::pinnedInDirection(float deltaX, float deltaY)
limitDelta.setWidth(m_scrollableArea->contentsSize().width() - (m_scrollableArea->visibleContentRect().maxX() + m_scrollableArea->scrollOrigin().x()));
}
}
-
+
if ((deltaX != 0 || deltaY != 0) && (limitDelta.width() < 1 && limitDelta.height() < 1))
return true;
return false;
@@ -1193,14 +1193,14 @@ void ScrollAnimatorMac::updateScrollerStyle()
verticalScrollbar->invalidate();
ScrollbarPainter oldVerticalPainter = [m_scrollbarPainterController.get() verticalScrollerImp];
- ScrollbarPainter newVerticalPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:newStyle
- controlSize:(NSControlSize)verticalScrollbar->controlSize()
- horizontal:NO
+ ScrollbarPainter newVerticalPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:newStyle
+ controlSize:(NSControlSize)verticalScrollbar->controlSize()
+ horizontal:NO
replacingScrollerImp:oldVerticalPainter];
[m_scrollbarPainterController.get() setVerticalScrollerImp:newVerticalPainter];
macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainter);
- // The different scrollbar styles have different thicknesses, so we must re-set the
+ // The different scrollbar styles have different thicknesses, so we must re-set the
// frameRect to the new thickness, and the re-layout below will ensure the position
// and length are properly updated.
int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlSize());
@@ -1211,21 +1211,21 @@ void ScrollAnimatorMac::updateScrollerStyle()
horizontalScrollbar->invalidate();
ScrollbarPainter oldHorizontalPainter = [m_scrollbarPainterController.get() horizontalScrollerImp];
- ScrollbarPainter newHorizontalPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:newStyle
- controlSize:(NSControlSize)horizontalScrollbar->controlSize()
- horizontal:YES
+ ScrollbarPainter newHorizontalPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:newStyle
+ controlSize:(NSControlSize)horizontalScrollbar->controlSize()
+ horizontal:YES
replacingScrollerImp:oldHorizontalPainter];
[m_scrollbarPainterController.get() setHorizontalScrollerImp:newHorizontalPainter];
macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPainter);
- // The different scrollbar styles have different thicknesses, so we must re-set the
+ // The different scrollbar styles have different thicknesses, so we must re-set the
// frameRect to the new thickness, and the re-layout below will ensure the position
// and length are properly updated.
int thickness = macTheme->scrollbarThickness(horizontalScrollbar->controlSize());
horizontalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness));
}
- // If m_needsScrollerStyleUpdate is true, then the page is restoring from the page cache, and
+ // If m_needsScrollerStyleUpdate is true, then the page is restoring from the page cache, and
// a relayout will happen on its own. Otherwise, we must initiate a re-layout ourselves.
scrollableArea()->scrollbarStyleChanged(newStyle, !m_needsScrollerStyleUpdate);

Powered by Google App Engine
This is Rietveld 408576698