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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebScrollbarThemePainter.cpp

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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 void WebScrollbarThemePainter::paintScrollbarBackground(WebCanvas* canvas, const WebRect& rect) 52 void WebScrollbarThemePainter::paintScrollbarBackground(WebCanvas* canvas, const WebRect& rect)
53 { 53 {
54 SkRect clip = SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height); 54 SkRect clip = SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height);
55 canvas->clipRect(clip); 55 canvas->clipRect(clip);
56 56
57 IntRect intRect(rect); 57 IntRect intRect(rect);
58 SkPictureBuilder pictureBuilder(intRect); 58 SkPictureBuilder pictureBuilder(intRect);
59 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 59 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
60 m_theme->paintScrollbarBackground(&pictureBuilder.context(), m_scrollbar.get ()); 60 m_theme->paintScrollbarBackground(pictureBuilder.context(), *m_scrollbar);
61 pictureBuilder.endRecording()->playback(canvas); 61 pictureBuilder.endRecording()->playback(canvas);
62 } 62 }
63 63
64 void WebScrollbarThemePainter::paintTrackBackground(WebCanvas* canvas, const Web Rect& rect) 64 void WebScrollbarThemePainter::paintTrackBackground(WebCanvas* canvas, const Web Rect& rect)
65 { 65 {
66 IntRect intRect(rect); 66 IntRect intRect(rect);
67 SkPictureBuilder pictureBuilder(intRect); 67 SkPictureBuilder pictureBuilder(intRect);
68 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 68 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
69 m_theme->paintTrackBackground(&pictureBuilder.context(), m_scrollbar.get(), intRect); 69 m_theme->paintTrackBackground(pictureBuilder.context(), *m_scrollbar, intRec t);
70 pictureBuilder.endRecording()->playback(canvas); 70 pictureBuilder.endRecording()->playback(canvas);
71 if (!m_theme->shouldRepaintAllPartsOnInvalidation()) 71 if (!m_theme->shouldRepaintAllPartsOnInvalidation())
72 m_scrollbar->setTrackNeedsRepaint(false); 72 m_scrollbar->setTrackNeedsRepaint(false);
73 } 73 }
74 74
75 void WebScrollbarThemePainter::paintBackTrackPart(WebCanvas* canvas, const WebRe ct& rect) 75 void WebScrollbarThemePainter::paintBackTrackPart(WebCanvas* canvas, const WebRe ct& rect)
76 { 76 {
77 IntRect intRect(rect); 77 IntRect intRect(rect);
78 SkPictureBuilder pictureBuilder(intRect); 78 SkPictureBuilder pictureBuilder(intRect);
79 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 79 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
80 m_theme->paintTrackPiece(&pictureBuilder.context(), m_scrollbar.get(), intRe ct, BackTrackPart); 80 m_theme->paintTrackPiece(pictureBuilder.context(), *m_scrollbar, intRect, Ba ckTrackPart);
81 pictureBuilder.endRecording()->playback(canvas); 81 pictureBuilder.endRecording()->playback(canvas);
82 } 82 }
83 83
84 void WebScrollbarThemePainter::paintForwardTrackPart(WebCanvas* canvas, const We bRect& rect) 84 void WebScrollbarThemePainter::paintForwardTrackPart(WebCanvas* canvas, const We bRect& rect)
85 { 85 {
86 IntRect intRect(rect); 86 IntRect intRect(rect);
87 SkPictureBuilder pictureBuilder(intRect); 87 SkPictureBuilder pictureBuilder(intRect);
88 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 88 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
89 m_theme->paintTrackPiece(&pictureBuilder.context(), m_scrollbar.get(), intRe ct, ForwardTrackPart); 89 m_theme->paintTrackPiece(pictureBuilder.context(), *m_scrollbar, intRect, Fo rwardTrackPart);
90 pictureBuilder.endRecording()->playback(canvas); 90 pictureBuilder.endRecording()->playback(canvas);
91 } 91 }
92 92
93 void WebScrollbarThemePainter::paintBackButtonStart(WebCanvas* canvas, const Web Rect& rect) 93 void WebScrollbarThemePainter::paintBackButtonStart(WebCanvas* canvas, const Web Rect& rect)
94 { 94 {
95 IntRect intRect(rect); 95 IntRect intRect(rect);
96 SkPictureBuilder pictureBuilder(intRect); 96 SkPictureBuilder pictureBuilder(intRect);
97 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 97 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
98 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, BackButtonStartPart); 98 m_theme->paintButton(pictureBuilder.context(), *m_scrollbar, intRect, BackBu ttonStartPart);
99 pictureBuilder.endRecording()->playback(canvas); 99 pictureBuilder.endRecording()->playback(canvas);
100 } 100 }
101 101
102 void WebScrollbarThemePainter::paintBackButtonEnd(WebCanvas* canvas, const WebRe ct& rect) 102 void WebScrollbarThemePainter::paintBackButtonEnd(WebCanvas* canvas, const WebRe ct& rect)
103 { 103 {
104 IntRect intRect(rect); 104 IntRect intRect(rect);
105 SkPictureBuilder pictureBuilder(intRect); 105 SkPictureBuilder pictureBuilder(intRect);
106 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 106 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
107 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, BackButtonEndPart); 107 m_theme->paintButton(pictureBuilder.context(), *m_scrollbar, intRect, BackBu ttonEndPart);
108 pictureBuilder.endRecording()->playback(canvas); 108 pictureBuilder.endRecording()->playback(canvas);
109 } 109 }
110 110
111 void WebScrollbarThemePainter::paintForwardButtonStart(WebCanvas* canvas, const WebRect& rect) 111 void WebScrollbarThemePainter::paintForwardButtonStart(WebCanvas* canvas, const WebRect& rect)
112 { 112 {
113 IntRect intRect(rect); 113 IntRect intRect(rect);
114 SkPictureBuilder pictureBuilder(intRect); 114 SkPictureBuilder pictureBuilder(intRect);
115 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 115 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
116 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, ForwardButtonStartPart); 116 m_theme->paintButton(pictureBuilder.context(), *m_scrollbar, intRect, Forwar dButtonStartPart);
117 pictureBuilder.endRecording()->playback(canvas); 117 pictureBuilder.endRecording()->playback(canvas);
118 } 118 }
119 119
120 void WebScrollbarThemePainter::paintForwardButtonEnd(WebCanvas* canvas, const We bRect& rect) 120 void WebScrollbarThemePainter::paintForwardButtonEnd(WebCanvas* canvas, const We bRect& rect)
121 { 121 {
122 IntRect intRect(rect); 122 IntRect intRect(rect);
123 SkPictureBuilder pictureBuilder(intRect); 123 SkPictureBuilder pictureBuilder(intRect);
124 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 124 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
125 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, ForwardButtonEndPart); 125 m_theme->paintButton(pictureBuilder.context(), *m_scrollbar, intRect, Forwar dButtonEndPart);
126 pictureBuilder.endRecording()->playback(canvas); 126 pictureBuilder.endRecording()->playback(canvas);
127 } 127 }
128 128
129 void WebScrollbarThemePainter::paintTickmarks(WebCanvas* canvas, const WebRect& rect) 129 void WebScrollbarThemePainter::paintTickmarks(WebCanvas* canvas, const WebRect& rect)
130 { 130 {
131 IntRect intRect(rect); 131 IntRect intRect(rect);
132 SkPictureBuilder pictureBuilder(intRect); 132 SkPictureBuilder pictureBuilder(intRect);
133 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 133 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
134 m_theme->paintTickmarks(&pictureBuilder.context(), m_scrollbar.get(), intRec t); 134 m_theme->paintTickmarks(pictureBuilder.context(), *m_scrollbar, intRect);
135 pictureBuilder.endRecording()->playback(canvas); 135 pictureBuilder.endRecording()->playback(canvas);
136 } 136 }
137 137
138 void WebScrollbarThemePainter::paintThumb(WebCanvas* canvas, const WebRect& rect ) 138 void WebScrollbarThemePainter::paintThumb(WebCanvas* canvas, const WebRect& rect )
139 { 139 {
140 IntRect intRect(rect); 140 IntRect intRect(rect);
141 SkPictureBuilder pictureBuilder(intRect); 141 SkPictureBuilder pictureBuilder(intRect);
142 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor); 142 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
143 m_theme->paintThumb(&pictureBuilder.context(), m_scrollbar.get(), intRect); 143 m_theme->paintThumb(pictureBuilder.context(), *m_scrollbar, intRect);
144 pictureBuilder.endRecording()->playback(canvas); 144 pictureBuilder.endRecording()->playback(canvas);
145 if (!m_theme->shouldRepaintAllPartsOnInvalidation()) 145 if (!m_theme->shouldRepaintAllPartsOnInvalidation())
146 m_scrollbar->setThumbNeedsRepaint(false); 146 m_scrollbar->setThumbNeedsRepaint(false);
147 } 147 }
148 148
149 WebScrollbarThemePainter::WebScrollbarThemePainter(ScrollbarTheme* theme, Scroll bar* scrollbar, float deviceScaleFactor) 149 WebScrollbarThemePainter::WebScrollbarThemePainter(ScrollbarTheme& theme, Scroll bar& scrollbar, float deviceScaleFactor)
150 : m_theme(theme) 150 : m_theme(&theme)
151 , m_scrollbar(scrollbar) 151 , m_scrollbar(&scrollbar)
152 , m_deviceScaleFactor(deviceScaleFactor) 152 , m_deviceScaleFactor(deviceScaleFactor)
153 { 153 {
154 } 154 }
155 155
156 float WebScrollbarThemePainter::thumbOpacity() const 156 float WebScrollbarThemePainter::thumbOpacity() const
157 { 157 {
158 return m_theme->thumbOpacity(m_scrollbar.get()); 158 return m_theme->thumbOpacity(*m_scrollbar);
159 } 159 }
160 160
161 bool WebScrollbarThemePainter::trackNeedsRepaint() const 161 bool WebScrollbarThemePainter::trackNeedsRepaint() const
162 { 162 {
163 return m_scrollbar->trackNeedsRepaint(); 163 return m_scrollbar->trackNeedsRepaint();
164 } 164 }
165 165
166 bool WebScrollbarThemePainter::thumbNeedsRepaint() const 166 bool WebScrollbarThemePainter::thumbNeedsRepaint() const
167 { 167 {
168 return m_scrollbar->thumbNeedsRepaint(); 168 return m_scrollbar->thumbNeedsRepaint();
169 } 169 }
170 170
171 } // namespace blink 171 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698