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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeMock.cpp

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Rebase and resolve 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #include "config.h" 26 #include "config.h"
27 #include "platform/scroll/ScrollbarThemeMock.h" 27 #include "platform/scroll/ScrollbarThemeMock.h"
28 28
29 #include "platform/RuntimeEnabledFeatures.h" 29 #include "platform/RuntimeEnabledFeatures.h"
30 #include "platform/graphics/GraphicsContext.h" 30 #include "platform/graphics/GraphicsContext.h"
31 #include "platform/graphics/paint/DrawingRecorder.h" 31 #include "platform/graphics/paint/DrawingRecorder.h"
32 #include "platform/scroll/ScrollbarThemeClient.h" 32 #include "platform/scroll/ScrollbarThemeClient.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 static bool gShouldRepaintAllPartsOnInvalidation = true;
37
38 void ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(bool shouldRepai nt)
39 {
40 gShouldRepaintAllPartsOnInvalidation = shouldRepaint;
41 }
42
36 static int cScrollbarThickness[] = { 15, 11 }; 43 static int cScrollbarThickness[] = { 15, 11 };
37 44
38 IntRect ScrollbarThemeMock::trackRect(const ScrollbarThemeClient* scrollbar, boo l)
39 {
40 return scrollbar->frameRect();
41 }
42
43 int ScrollbarThemeMock::scrollbarThickness(ScrollbarControlSize controlSize) 45 int ScrollbarThemeMock::scrollbarThickness(ScrollbarControlSize controlSize)
44 { 46 {
45 return cScrollbarThickness[controlSize]; 47 return cScrollbarThickness[controlSize];
46 } 48 }
47 49
48 bool ScrollbarThemeMock::usesOverlayScrollbars() const 50 bool ScrollbarThemeMock::usesOverlayScrollbars() const
49 { 51 {
50 return RuntimeEnabledFeatures::overlayScrollbarsEnabled(); 52 return RuntimeEnabledFeatures::overlayScrollbarsEnabled();
51 } 53 }
52 54
55 bool ScrollbarThemeMock::shouldRepaintAllPartsOnInvalidation() const
56 {
57 return gShouldRepaintAllPartsOnInvalidation;
58 }
59
60 IntRect ScrollbarThemeMock::trackRect(const ScrollbarThemeClient* scrollbar, boo l)
61 {
62 return scrollbar->frameRect();
63 }
64
65
53 void ScrollbarThemeMock::paintTrackBackground(GraphicsContext* context, const Sc rollbarThemeClient* scrollbar, const IntRect& trackRect) 66 void ScrollbarThemeMock::paintTrackBackground(GraphicsContext* context, const Sc rollbarThemeClient* scrollbar, const IntRect& trackRect)
54 { 67 {
55 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa yItem::ScrollbarTrackBackground)) 68 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa yItem::ScrollbarTrackBackground))
56 return; 69 return;
57 70
58 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa ckground, trackRect); 71 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa ckground, trackRect);
59 context->fillRect(trackRect, scrollbar->enabled() ? Color::lightGray : Color (0xFFE0E0E0)); 72 context->fillRect(trackRect, scrollbar->enabled() ? Color::lightGray : Color (0xFFE0E0E0));
60 } 73 }
61 74
62 void ScrollbarThemeMock::paintThumb(GraphicsContext* context, const ScrollbarThe meClient* scrollbar, const IntRect& thumbRect) 75 void ScrollbarThemeMock::paintThumb(GraphicsContext* context, const ScrollbarThe meClient* scrollbar, const IntRect& thumbRect)
63 { 76 {
64 if (!scrollbar->enabled()) 77 if (!scrollbar->enabled())
65 return; 78 return;
66 79
67 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa yItem::ScrollbarThumb)) 80 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa yItem::ScrollbarThumb))
68 return; 81 return;
69 82
70 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb, thumbRect); 83 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb, thumbRect);
71 context->fillRect(thumbRect, Color::darkGray); 84 context->fillRect(thumbRect, Color::darkGray);
72 } 85 }
73 86
74 } 87 }
75 88
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698