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

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

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Remove track opacity Created 5 years, 1 month 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 30ed5ed59630a4863d5f2201f1bfb097c143656d..892dd15283139501cc7c770b4e297263b50b3658 100644
--- a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
+++ b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
@@ -430,12 +430,16 @@ private:
break;
case TrackAlpha:
[_scrollbarPainter.get() setTrackAlpha:currentValue];
+ _scrollbar->setTrackNeedsRepaint(true);
break;
case UIStateTransition:
[_scrollbarPainter.get() setUiStateTransitionProgress:currentValue];
+ _scrollbar->setThumbNeedsRepaint(true);
+ _scrollbar->setTrackNeedsRepaint(true);
break;
case ExpansionTransition:
[_scrollbarPainter.get() setExpansionTransitionProgress:currentValue];
+ _scrollbar->setThumbNeedsRepaint(true);
break;
}
@@ -460,6 +464,7 @@ private:
RetainPtr<WebScrollbarPartAnimation> _trackAlphaAnimation;
RetainPtr<WebScrollbarPartAnimation> _uiStateTransitionAnimation;
RetainPtr<WebScrollbarPartAnimation> _expansionTransitionAnimation;
+ BOOL _hasExpandedSinceInvisible;
}
- (id)initWithScrollbar:(blink::Scrollbar*)scrollbar;
- (void)updateVisibilityImmediately:(bool)show;
@@ -642,6 +647,20 @@ private:
- (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState
{
+ enum {
chrishtr 2015/11/25 00:28:49 Please document that these are reverse-engineered.
ccameron 2015/11/25 00:34:32 Done.
+ NSScrollerStateInvisible = 0,
+ NSScrollerStateKnob = 1,
+ NSScrollerStateExpanded = 2
+ };
+ // We do not receive notifications about the thumb un-expanding when the scrollbar fades away. Ensure
+ // that we re-paint the thumb the next time that we transition away from being invisible, so that
+ // the thumb doesn't stick in an expanded state.
+ if (newOverlayScrollerState == NSScrollerStateExpanded) {
+ _hasExpandedSinceInvisible = YES;
+ } else if (newOverlayScrollerState != NSScrollerStateInvisible && _hasExpandedSinceInvisible) {
+ _scrollbar->setThumbNeedsRepaint(true);
+ _hasExpandedSinceInvisible = NO;
+ }
}
- (void)invalidate
@@ -1069,6 +1088,8 @@ void ScrollAnimatorMac::updateScrollerStyle()
NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle];
if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) {
+ verticalScrollbar->setTrackNeedsRepaint(true);
+ verticalScrollbar->setThumbNeedsRepaint(true);
verticalScrollbar->setNeedsPaintInvalidation();
ScrollbarPainter oldVerticalPainter = [m_scrollbarPainterController.get() verticalScrollerImp];
@@ -1087,6 +1108,8 @@ void ScrollAnimatorMac::updateScrollerStyle()
}
if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()) {
+ horizontalScrollbar->setTrackNeedsRepaint(true);
+ horizontalScrollbar->setThumbNeedsRepaint(true);
horizontalScrollbar->setNeedsPaintInvalidation();
ScrollbarPainter oldHorizontalPainter = [m_scrollbarPainterController.get() horizontalScrollerImp];

Powered by Google App Engine
This is Rietveld 408576698