| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 if (rect.height() <= 0 || rect.width() <= 0) | 182 if (rect.height() <= 0 || rect.width() <= 0) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 Vector<IntRect> tickmarks; | 185 Vector<IntRect> tickmarks; |
| 186 scrollbar.getTickmarks(tickmarks); | 186 scrollbar.getTickmarks(tickmarks); |
| 187 if (!tickmarks.size()) | 187 if (!tickmarks.size()) |
| 188 return; | 188 return; |
| 189 | 189 |
| 190 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarTickmarks)) | 190 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::kScrollbarTickmarks)) |
| 191 return; | 191 return; |
| 192 | 192 |
| 193 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarTickmarks
, rect); | 193 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTickmark
s, rect); |
| 194 | 194 |
| 195 // Inset a bit. | 195 // Inset a bit. |
| 196 IntRect tickmarkTrackRect = rect; | 196 IntRect tickmarkTrackRect = rect; |
| 197 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 197 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
| 198 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 198 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
| 199 paintGivenTickmarks(context.canvas(), scrollbar, tickmarkTrackRect, tickmark
s); | 199 paintGivenTickmarks(context.canvas(), scrollbar, tickmarkTrackRect, tickmark
s); |
| 200 } | 200 } |
| 201 | 201 |
| 202 ScrollbarThemeMac::~ScrollbarThemeMac() | 202 ScrollbarThemeMac::~ScrollbarThemeMac() |
| 203 { | 203 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 updateEnabledState(scrollbar); | 285 updateEnabledState(scrollbar); |
| 286 updateScrollbarOverlayStyle(scrollbar); | 286 updateScrollbarOverlayStyle(scrollbar); |
| 287 } | 287 } |
| 288 | 288 |
| 289 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar(const ScrollbarThemeClie
nt& scrollbar) const | 289 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar(const ScrollbarThemeClie
nt& scrollbar) const |
| 290 { | 290 { |
| 291 return [scrollbarPainterMap().get(const_cast<ScrollbarThemeClient*>(&scrollb
ar)).get() painter]; | 291 return [scrollbarPainterMap().get(const_cast<ScrollbarThemeClient*>(&scrollb
ar)).get() painter]; |
| 292 } | 292 } |
| 293 | 293 |
| 294 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext& context, const Scr
ollbar& scrollbar, const IntRect& rect) { | 294 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext& context, const Scr
ollbar& scrollbar, const IntRect& rect) { |
| 295 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarTrackBackground)) | 295 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::kScrollbarTrackBackground)) |
| 296 return; | 296 return; |
| 297 | 297 |
| 298 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarTrackBack
ground, rect); | 298 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTrackBac
kground, rect); |
| 299 | 299 |
| 300 GraphicsContextStateSaver stateSaver(context); | 300 GraphicsContextStateSaver stateSaver(context); |
| 301 context.translate(rect.x(), rect.y()); | 301 context.translate(rect.x(), rect.y()); |
| 302 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 302 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
| 303 | 303 |
| 304 CGRect frameRect = scrollbar.frameRect(); | 304 CGRect frameRect = scrollbar.frameRect(); |
| 305 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 305 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 306 [scrollbarPainter setEnabled:scrollbar.enabled()]; | 306 [scrollbarPainter setEnabled:scrollbar.enabled()]; |
| 307 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; | 307 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; |
| 308 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); | 308 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); |
| 309 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; | 309 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; |
| 310 } | 310 } |
| 311 | 311 |
| 312 void ScrollbarThemeMac::paintThumb(GraphicsContext& context, const Scrollbar& sc
rollbar, const IntRect& rect) { | 312 void ScrollbarThemeMac::paintThumb(GraphicsContext& context, const Scrollbar& sc
rollbar, const IntRect& rect) { |
| 313 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarThumb)) | 313 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::kScrollbarThumb)) |
| 314 return; | 314 return; |
| 315 | 315 |
| 316 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. | 316 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. |
| 317 IntRect dirtyRect = IntRect(rect); | 317 IntRect dirtyRect = IntRect(rect); |
| 318 dirtyRect.inflate(1); | 318 dirtyRect.inflate(1); |
| 319 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarThumb, di
rtyRect); | 319 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarThumb, d
irtyRect); |
| 320 | 320 |
| 321 GraphicsContextStateSaver stateSaver(context); | 321 GraphicsContextStateSaver stateSaver(context); |
| 322 context.translate(rect.x(), rect.y()); | 322 context.translate(rect.x(), rect.y()); |
| 323 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 323 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
| 324 | 324 |
| 325 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 325 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 326 [scrollbarPainter setEnabled:scrollbar.enabled()]; | 326 [scrollbarPainter setEnabled:scrollbar.enabled()]; |
| 327 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; | 327 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; |
| 328 [scrollbarPainter setDoubleValue:0]; | 328 [scrollbarPainter setDoubleValue:0]; |
| 329 [scrollbarPainter setKnobProportion:1]; | 329 [scrollbarPainter setKnobProportion:1]; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 426 |
| 427 // static | 427 // static |
| 428 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() | 428 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() |
| 429 { | 429 { |
| 430 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) | 430 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) |
| 431 return NSScrollerStyleOverlay; | 431 return NSScrollerStyleOverlay; |
| 432 return gPreferredScrollerStyle; | 432 return gPreferredScrollerStyle; |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace blink | 435 } // namespace blink |
| OLD | NEW |