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

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeMacOverlayAPI.mm

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Sprinkle in some tests 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/scroll/ScrollbarThemeMacOverlayAPI.mm
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMacOverlayAPI.mm b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMacOverlayAPI.mm
index 2e9004653d016bf95d71723fbfaed01b3bdb9c2b..2806ef9d003fac7ce4cf8bf1695da117664a8739 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMacOverlayAPI.mm
+++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMacOverlayAPI.mm
@@ -133,7 +133,7 @@ void ScrollbarThemeMacOverlayAPI::setNewPainterForScrollbar(ScrollbarThemeClient
updateScrollbarOverlayStyle(scrollbar);
}
-ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(const ScrollbarThemeClient* scrollbar)
+ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(const ScrollbarThemeClient* scrollbar) const
{
return [scrollbarPainterMap()->get(const_cast<ScrollbarThemeClient*>(scrollbar)).get() painter];
}
@@ -155,8 +155,13 @@ void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context,
[scrollbarPainter setEnabled:scrollbar->enabled()];
[scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)];
+ CGFloat oldTrackAlpha = [scrollbarPainter trackAlpha];
+ [scrollbarPainter setTrackAlpha:1];
+
NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.height);
[scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO];
+
+ [scrollbarPainter setTrackAlpha:oldTrackAlpha];
}
void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, const ScrollbarThemeClient* scrollbar, const IntRect& rect) {
@@ -179,12 +184,17 @@ void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, const Scr
[scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())];
[scrollbarPainter setDoubleValue:0];
[scrollbarPainter setKnobProportion:1];
+
+ CGFloat oldKnobAlpha = [scrollbarPainter knobAlpha];
+ [scrollbarPainter setKnobAlpha:1];
+
if (scrollbar->enabled())
[scrollbarPainter drawKnob];
// If this state is not set, then moving the cursor over the scrollbar area will only cause the
// scrollbar to engorge when moved over the top of the scrollbar area.
[scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().size())];
+ [scrollbarPainter setKnobAlpha:oldKnobAlpha];
}
int ScrollbarThemeMacOverlayAPI::scrollbarThickness(ScrollbarControlSize controlSize)
@@ -266,5 +276,15 @@ void ScrollbarThemeMacOverlayAPI::updateEnabledState(const ScrollbarThemeClient*
[painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()];
}
+float ScrollbarThemeMacOverlayAPI::trackOpacity(const ScrollbarThemeClient* scrollbar) const {
+ ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar);
+ return [scrollbarPainter trackAlpha];
+}
+
+float ScrollbarThemeMacOverlayAPI::thumbOpacity(const ScrollbarThemeClient* scrollbar) const {
+ ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar);
+ return [scrollbarPainter knobAlpha];
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698