OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 | 127 |
128 void ScrollbarThemeMacOverlayAPI::setNewPainterForScrollbar(ScrollbarThemeClient
* scrollbar, ScrollbarPainter newPainter) | 128 void ScrollbarThemeMacOverlayAPI::setNewPainterForScrollbar(ScrollbarThemeClient
* scrollbar, ScrollbarPainter newPainter) |
129 { | 129 { |
130 RetainPtr<WebCoreScrollbarObserver> observer = [[WebCoreScrollbarObserver al
loc] initWithScrollbar:scrollbar painter:newPainter]; | 130 RetainPtr<WebCoreScrollbarObserver> observer = [[WebCoreScrollbarObserver al
loc] initWithScrollbar:scrollbar painter:newPainter]; |
131 scrollbarPainterMap()->set(scrollbar, observer); | 131 scrollbarPainterMap()->set(scrollbar, observer); |
132 updateEnabledState(scrollbar); | 132 updateEnabledState(scrollbar); |
133 updateScrollbarOverlayStyle(scrollbar); | 133 updateScrollbarOverlayStyle(scrollbar); |
134 } | 134 } |
135 | 135 |
136 ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(const Scrollba
rThemeClient* scrollbar) | 136 ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(const Scrollba
rThemeClient* scrollbar) const |
137 { | 137 { |
138 return [scrollbarPainterMap()->get(const_cast<ScrollbarThemeClient*>(scrollb
ar)).get() painter]; | 138 return [scrollbarPainterMap()->get(const_cast<ScrollbarThemeClient*>(scrollb
ar)).get() painter]; |
139 } | 139 } |
140 | 140 |
141 void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context,
const ScrollbarThemeClient* scrollbar, const IntRect& rect) { | 141 void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context,
const ScrollbarThemeClient* scrollbar, const IntRect& rect) { |
142 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarTrackBackground)) | 142 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarTrackBackground)) |
143 return; | 143 return; |
144 | 144 |
145 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa
ckground, rect); | 145 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa
ckground, rect); |
146 | 146 |
147 ASSERT(isOverlayAPIAvailable()); | 147 ASSERT(isOverlayAPIAvailable()); |
148 | 148 |
149 GraphicsContextStateSaver stateSaver(*context); | 149 GraphicsContextStateSaver stateSaver(*context); |
150 context->translate(rect.x(), rect.y()); | 150 context->translate(rect.x(), rect.y()); |
151 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 151 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
152 | 152 |
153 CGRect frameRect = scrollbar->frameRect(); | 153 CGRect frameRect = scrollbar->frameRect(); |
154 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 154 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
155 [scrollbarPainter setEnabled:scrollbar->enabled()]; | 155 [scrollbarPainter setEnabled:scrollbar->enabled()]; |
156 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; | 156 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; |
157 | 157 |
| 158 CGFloat oldTrackAlpha = [scrollbarPainter trackAlpha]; |
| 159 [scrollbarPainter setTrackAlpha:1]; |
| 160 |
158 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); | 161 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); |
159 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; | 162 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; |
| 163 |
| 164 [scrollbarPainter setTrackAlpha:oldTrackAlpha]; |
160 } | 165 } |
161 | 166 |
162 void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, const Scr
ollbarThemeClient* scrollbar, const IntRect& rect) { | 167 void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, const Scr
ollbarThemeClient* scrollbar, const IntRect& rect) { |
163 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarThumb)) | 168 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarThumb)) |
164 return; | 169 return; |
165 | 170 |
166 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. | 171 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. |
167 IntRect dirtyRect = IntRect(rect); | 172 IntRect dirtyRect = IntRect(rect); |
168 dirtyRect.inflate(1); | 173 dirtyRect.inflate(1); |
169 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb,
dirtyRect); | 174 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb,
dirtyRect); |
170 | 175 |
171 ASSERT(isOverlayAPIAvailable()); | 176 ASSERT(isOverlayAPIAvailable()); |
172 | 177 |
173 GraphicsContextStateSaver stateSaver(*context); | 178 GraphicsContextStateSaver stateSaver(*context); |
174 context->translate(rect.x(), rect.y()); | 179 context->translate(rect.x(), rect.y()); |
175 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 180 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
176 | 181 |
177 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 182 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
178 [scrollbarPainter setEnabled:scrollbar->enabled()]; | 183 [scrollbarPainter setEnabled:scrollbar->enabled()]; |
179 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; | 184 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; |
180 [scrollbarPainter setDoubleValue:0]; | 185 [scrollbarPainter setDoubleValue:0]; |
181 [scrollbarPainter setKnobProportion:1]; | 186 [scrollbarPainter setKnobProportion:1]; |
| 187 |
| 188 CGFloat oldKnobAlpha = [scrollbarPainter knobAlpha]; |
| 189 [scrollbarPainter setKnobAlpha:1]; |
| 190 |
182 if (scrollbar->enabled()) | 191 if (scrollbar->enabled()) |
183 [scrollbarPainter drawKnob]; | 192 [scrollbarPainter drawKnob]; |
184 | 193 |
185 // If this state is not set, then moving the cursor over the scrollbar area
will only cause the | 194 // If this state is not set, then moving the cursor over the scrollbar area
will only cause the |
186 // scrollbar to engorge when moved over the top of the scrollbar area. | 195 // scrollbar to engorge when moved over the top of the scrollbar area. |
187 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().siz
e())]; | 196 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().siz
e())]; |
| 197 [scrollbarPainter setKnobAlpha:oldKnobAlpha]; |
188 } | 198 } |
189 | 199 |
190 int ScrollbarThemeMacOverlayAPI::scrollbarThickness(ScrollbarControlSize control
Size) | 200 int ScrollbarThemeMacOverlayAPI::scrollbarThickness(ScrollbarControlSize control
Size) |
191 { | 201 { |
192 NSControlSize nsControlSize = static_cast<NSControlSize>(controlSize); | 202 NSControlSize nsControlSize = static_cast<NSControlSize>(controlSize); |
193 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scr
ollerImpWithStyle:recommendedScrollerStyle() controlSize:nsControlSize horizonta
l:NO replacingScrollerImp:nil]; | 203 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scr
ollerImpWithStyle:recommendedScrollerStyle() controlSize:nsControlSize horizonta
l:NO replacingScrollerImp:nil]; |
194 BOOL wasExpanded = NO; | 204 BOOL wasExpanded = NO; |
195 if (supportsExpandedScrollbars()) { | 205 if (supportsExpandedScrollbars()) { |
196 wasExpanded = [scrollbarPainter isExpanded]; | 206 wasExpanded = [scrollbarPainter isExpanded]; |
197 [scrollbarPainter setExpanded:YES]; | 207 [scrollbarPainter setExpanded:YES]; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 int ScrollbarThemeMacOverlayAPI::minimumThumbLength(const ScrollbarThemeClient*
scrollbar) | 269 int ScrollbarThemeMacOverlayAPI::minimumThumbLength(const ScrollbarThemeClient*
scrollbar) |
260 { | 270 { |
261 return [painterForScrollbar(scrollbar) knobMinLength]; | 271 return [painterForScrollbar(scrollbar) knobMinLength]; |
262 } | 272 } |
263 | 273 |
264 void ScrollbarThemeMacOverlayAPI::updateEnabledState(const ScrollbarThemeClient*
scrollbar) | 274 void ScrollbarThemeMacOverlayAPI::updateEnabledState(const ScrollbarThemeClient*
scrollbar) |
265 { | 275 { |
266 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; | 276 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; |
267 } | 277 } |
268 | 278 |
| 279 float ScrollbarThemeMacOverlayAPI::trackOpacity(const ScrollbarThemeClient* scro
llbar) const { |
| 280 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 281 return [scrollbarPainter trackAlpha]; |
| 282 } |
| 283 |
| 284 float ScrollbarThemeMacOverlayAPI::thumbOpacity(const ScrollbarThemeClient* scro
llbar) const { |
| 285 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 286 return [scrollbarPainter knobAlpha]; |
| 287 } |
| 288 |
269 } // namespace blink | 289 } // namespace blink |
270 | 290 |
OLD | NEW |