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

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

Issue 1511003003: Use refs for non-null GraphicsContext, Scrollbar, etc. in scrollbar related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarRemove
Patch Set: yet another mac fix 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/platform/mac/ScrollAnimatorMac.mm
diff --git a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
index fb411cf29ddad9c06e2d7eca394129d6ae74b791..8c3cb76774eb05ff7136c65c4f7ab217539aae3e 100644
--- a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
+++ b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
@@ -66,11 +66,11 @@ static bool supportsContentAreaScrolledInDirection()
static ScrollbarThemeMacOverlayAPI* macOverlayScrollbarTheme()
{
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScrollbarThemeMacCommon::isOverlayAPIAvailable());
- ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
- return !scrollbarTheme->isMockTheme() ? static_cast<ScrollbarThemeMacOverlayAPI*>(scrollbarTheme) : 0;
+ ScrollbarTheme& scrollbarTheme = ScrollbarTheme::theme();
+ return !scrollbarTheme.isMockTheme() ? static_cast<ScrollbarThemeMacOverlayAPI*>(&scrollbarTheme) : nil;
}
-static ScrollbarPainter scrollbarPainterForScrollbar(Scrollbar* scrollbar)
+static ScrollbarPainter scrollbarPainterForScrollbar(Scrollbar& scrollbar)
{
if (ScrollbarThemeMacOverlayAPI* scrollbarTheme = macOverlayScrollbarTheme())
return scrollbarTheme->painterForScrollbar(scrollbar);
@@ -237,7 +237,7 @@ static NSSize abs(NSSize size)
if (!_scrollableArea || !scrollerImp)
return NSZeroPoint;
- blink::Scrollbar* scrollbar = 0;
+ blink::Scrollbar* scrollbar = nil;
if ([scrollerImp isHorizontal])
scrollbar = _scrollableArea->horizontalScrollbar();
else
@@ -251,7 +251,7 @@ static NSSize abs(NSSize size)
if (!scrollbar)
return NSZeroPoint;
- ASSERT(scrollerImp == scrollbarPainterForScrollbar(scrollbar));
+ ASSERT(scrollerImp == scrollbarPainterForScrollbar(*scrollbar));
return scrollbar->convertFromContainingWidget(blink::IntPoint(pointInContentArea));
}
@@ -264,7 +264,7 @@ static NSSize abs(NSSize size)
if (!_scrollableArea->scrollbarsCanBeActive())
return;
- _scrollableArea->scrollAnimator()->contentAreaWillPaint();
+ _scrollableArea->scrollAnimator().contentAreaWillPaint();
}
- (void)scrollerImpPair:(id)scrollerImpPair updateScrollerStyleForNewRecommendedScrollerStyle:(NSScrollerStyle)newRecommendedScrollerStyle
@@ -281,7 +281,7 @@ static NSSize abs(NSSize size)
[scrollerImpPair setScrollerStyle:newRecommendedScrollerStyle];
- static_cast<ScrollAnimatorMac*>(_scrollableArea->scrollAnimator())->updateScrollerStyle();
+ static_cast<ScrollAnimatorMac&>(_scrollableArea->scrollAnimator()).updateScrollerStyle();
}
@end
@@ -390,7 +390,7 @@ private:
{
ASSERT(_scrollbar);
- _scrollbarPainter = scrollbarPainterForScrollbar(_scrollbar);
+ _scrollbarPainter = scrollbarPainterForScrollbar(*_scrollbar);
_timer->start();
}
@@ -486,7 +486,7 @@ private:
- (void)updateVisibilityImmediately:(bool)show
{
[self cancelAnimations];
- [scrollbarPainterForScrollbar(_scrollbar) setKnobAlpha:(show ? 1.0 : 0.0)];
+ [scrollbarPainterForScrollbar(*_scrollbar) setKnobAlpha:(show ? 1.0 : 0.0)];
}
- (void)cancelAnimations
@@ -499,9 +499,9 @@ private:
END_BLOCK_OBJC_EXCEPTIONS;
}
-- (ScrollAnimatorMac*)scrollAnimator
+- (ScrollAnimatorMac&)scrollAnimator
{
- return static_cast<ScrollAnimatorMac*>(_scrollbar->scrollableArea()->scrollAnimator());
+ return static_cast<ScrollAnimatorMac&>(_scrollbar->scrollableArea()->scrollAnimator());
}
- (NSRect)convertRectToBacking:(NSRect)aRect
@@ -519,7 +519,7 @@ private:
if (!_scrollbar)
return NSZeroPoint;
- ASSERT_UNUSED(scrollerImp, scrollerImp == scrollbarPainterForScrollbar(_scrollbar));
+ ASSERT_UNUSED(scrollerImp, scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
return _scrollbar->convertFromContainingWidget(_scrollbar->scrollableArea()->lastKnownMousePosition());
}
@@ -528,18 +528,18 @@ private:
{
// If the user has scrolled the page, then the scrollbars must be animated here.
// This overrides the early returns.
- bool mustAnimate = [self scrollAnimator]->haveScrolledSincePageLoad();
+ bool mustAnimate = [self scrollAnimator].haveScrolledSincePageLoad();
- if ([self scrollAnimator]->scrollbarPaintTimerIsActive() && !mustAnimate)
+ if ([self scrollAnimator].scrollbarPaintTimerIsActive() && !mustAnimate)
return;
if (_scrollbar->scrollableArea()->shouldSuspendScrollAnimations() && !mustAnimate) {
- [self scrollAnimator]->startScrollbarPaintTimer();
+ [self scrollAnimator].startScrollbarPaintTimer();
return;
}
// At this point, we are definitely going to animate now, so stop the timer.
- [self scrollAnimator]->stopScrollbarPaintTimer();
+ [self scrollAnimator].stopScrollbarPaintTimer();
// If we are currently animating, stop
if (scrollbarPartAnimation) {
@@ -550,9 +550,9 @@ private:
if (part == blink::ThumbPart && _scrollbar->orientation() == VerticalScrollbar) {
if (newAlpha == 1) {
IntRect thumbRect = IntRect([scrollerPainter rectForPart:NSScrollerKnob]);
- [self scrollAnimator]->setVisibleScrollerThumbRect(thumbRect);
+ [self scrollAnimator].setVisibleScrollerThumbRect(thumbRect);
} else
- [self scrollAnimator]->setVisibleScrollerThumbRect(IntRect());
+ [self scrollAnimator].setVisibleScrollerThumbRect(IntRect());
}
scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
@@ -568,7 +568,7 @@ private:
if (!_scrollbar)
return;
- ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar));
+ ASSERT(scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
[self setUpAlphaAnimation:_knobAlphaAnimation scrollerPainter:scrollerPainter part:blink::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
@@ -579,7 +579,7 @@ private:
if (!_scrollbar)
return;
- ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar));
+ ASSERT(scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
[self setUpAlphaAnimation:_trackAlphaAnimation scrollerPainter:scrollerPainter part:blink::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
@@ -593,7 +593,7 @@ private:
if (!supportsUIStateTransitionProgress())
return;
- ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar));
+ ASSERT(scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
ScrollbarPainter scrollbarPainter = (ScrollbarPainter)scrollerImp;
@@ -623,7 +623,7 @@ private:
if (!supportsExpansionTransitionProgress())
return;
- ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar));
+ ASSERT(scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
ScrollbarPainter scrollbarPainter = (ScrollbarPainter)scrollerImp;
@@ -730,9 +730,9 @@ void ScrollAnimatorMac::dispose()
ScrollResultOneDimensional ScrollAnimatorMac::userScroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float delta)
{
- bool scrollAnimationEnabledForSystem = static_cast<ScrollbarThemeMacCommon*>(
+ bool scrollAnimationEnabledForSystem = static_cast<ScrollbarThemeMacCommon&>(
ScrollbarTheme::theme())
- ->scrollAnimationEnabledForSystem();
+ .scrollAnimationEnabledForSystem();
m_haveScrolledSincePageLoad = true;
if (!scrollAnimationEnabledForSystem || !m_scrollableArea->scrollAnimatorEnabled())
@@ -830,7 +830,7 @@ void ScrollAnimatorMac::mouseMovedInContentArea() const
[m_scrollbarPainterController.get() mouseMovedInContentArea];
}
-void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const
+void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar& scrollbar) const
{
if (!scrollableArea()->scrollbarsCanBeActive())
return;
@@ -843,7 +843,7 @@ void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const
}
}
-void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar* scrollbar) const
+void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar& scrollbar) const
{
if (!scrollableArea()->scrollbarsCanBeActive())
return;
@@ -930,7 +930,7 @@ void ScrollAnimatorMac::finishCurrentScrollAnimations()
}
}
-void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
+void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar& scrollbar)
{
if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
return;
@@ -940,7 +940,7 @@ void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
return;
ASSERT(!m_verticalScrollbarPainterDelegate);
- m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]);
+ m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:&scrollbar]);
[painter setDelegate:m_verticalScrollbarPainterDelegate.get()];
[m_scrollbarPainterController.get() setVerticalScrollerImp:painter];
@@ -948,7 +948,7 @@ void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
[painter setKnobAlpha:1];
}
-void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
+void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar& scrollbar)
{
if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
return;
@@ -965,7 +965,7 @@ void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
[m_scrollbarPainterController.get() setVerticalScrollerImp:nil];
}
-void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
+void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar& scrollbar)
{
if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
return;
@@ -975,7 +975,7 @@ void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
return;
ASSERT(!m_horizontalScrollbarPainterDelegate);
- m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]);
+ m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:&scrollbar]);
[painter setDelegate:m_horizontalScrollbarPainterDelegate.get()];
[m_scrollbarPainterController.get() setHorizontalScrollerImp:painter];
@@ -983,7 +983,7 @@ void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
[painter setKnobAlpha:1];
}
-void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
+void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar& scrollbar)
{
if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
return;
@@ -1000,7 +1000,7 @@ void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
[m_scrollbarPainterController.get() setHorizontalScrollerImp:nil];
}
-bool ScrollAnimatorMac::shouldScrollbarParticipateInHitTesting(Scrollbar* scrollbar)
+bool ScrollAnimatorMac::shouldScrollbarParticipateInHitTesting(Scrollbar& scrollbar)
{
// Non-overlay scrollbars should always participate in hit testing.
if (ScrollbarThemeMacCommon::recommendedScrollerStyle() != NSScrollerStyleOverlay)
@@ -1009,7 +1009,7 @@ bool ScrollAnimatorMac::shouldScrollbarParticipateInHitTesting(Scrollbar* scroll
if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
return true;
- if (scrollbar->isAlphaLocked())
+ if (scrollbar.isAlphaLocked())
return true;
// Overlay scrollbars should participate in hit testing whenever they are at all visible.
@@ -1112,7 +1112,7 @@ void ScrollAnimatorMac::updateScrollerStyle()
horizontal:NO
replacingScrollerImp:oldVerticalPainter];
[m_scrollbarPainterController.get() setVerticalScrollerImp:newVerticalPainter];
- macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainter);
+ macTheme->setNewPainterForScrollbar(*verticalScrollbar, newVerticalPainter);
// 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
@@ -1132,7 +1132,7 @@ void ScrollAnimatorMac::updateScrollerStyle()
horizontal:YES
replacingScrollerImp:oldHorizontalPainter];
[m_scrollbarPainterController.get() setHorizontalScrollerImp:newHorizontalPainter];
- macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPainter);
+ macTheme->setNewPainterForScrollbar(*horizontalScrollbar, newHorizontalPainter);
// 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

Powered by Google App Engine
This is Rietveld 408576698