| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 static bool globalSupportsExpandedScrollbars = [NSClassFromString(@"NSScroll
erImp") instancesRespondToSelector:@selector(setExpanded:)]; | 130 static bool globalSupportsExpandedScrollbars = [NSClassFromString(@"NSScroll
erImp") instancesRespondToSelector:@selector(setExpanded:)]; |
| 131 return globalSupportsExpandedScrollbars; | 131 return globalSupportsExpandedScrollbars; |
| 132 } | 132 } |
| 133 | 133 |
| 134 ScrollbarTheme& ScrollbarTheme::nativeTheme() | 134 ScrollbarTheme& ScrollbarTheme::nativeTheme() |
| 135 { | 135 { |
| 136 DEFINE_STATIC_LOCAL(ScrollbarThemeMac, overlayTheme, ()); | 136 DEFINE_STATIC_LOCAL(ScrollbarThemeMac, overlayTheme, ()); |
| 137 return overlayTheme; | 137 return overlayTheme; |
| 138 } | 138 } |
| 139 | 139 |
| 140 void ScrollbarThemeMac::paintGivenTickmarks(SkCanvas* canvas, const ScrollbarThe
meClient& scrollbar, const IntRect& rect, const Vector<IntRect>& tickmarks) | 140 void ScrollbarThemeMac::paintGivenTickmarks(SkCanvas* canvas, const Scrollbar& s
crollbar, const IntRect& rect, const Vector<IntRect>& tickmarks) |
| 141 { | 141 { |
| 142 if (scrollbar.orientation() != VerticalScrollbar) | 142 if (scrollbar.orientation() != VerticalScrollbar) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 if (rect.height() <= 0 || rect.width() <= 0) | 145 if (rect.height() <= 0 || rect.width() <= 0) |
| 146 return; // nothing to draw on. | 146 return; // nothing to draw on. |
| 147 | 147 |
| 148 if (!tickmarks.size()) | 148 if (!tickmarks.size()) |
| 149 return; | 149 return; |
| 150 | 150 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 169 // Calculate how far down (in pixels) the tick-mark should appear. | 169 // Calculate how far down (in pixels) the tick-mark should appear. |
| 170 const int yPos = rect.y() + (rect.height() * percent); | 170 const int yPos = rect.y() + (rect.height() * percent); |
| 171 | 171 |
| 172 // Paint. | 172 // Paint. |
| 173 FloatRect tickRect(rect.x(), yPos, rect.width(), 2); | 173 FloatRect tickRect(rect.x(), yPos, rect.width(), 2); |
| 174 canvas->drawRect(tickRect, fillPaint); | 174 canvas->drawRect(tickRect, fillPaint); |
| 175 canvas->drawRect(tickRect, strokePaint); | 175 canvas->drawRect(tickRect, strokePaint); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ScrollbarThemeMac::paintTickmarks(GraphicsContext& context, const Scrollbar
ThemeClient& scrollbar, const IntRect& rect) | 179 void ScrollbarThemeMac::paintTickmarks(GraphicsContext& context, const Scrollbar
& scrollbar, const IntRect& rect) |
| 180 { | 180 { |
| 181 // Note: This is only used for css-styled scrollbars on mac. | 181 // Note: This is only used for css-styled scrollbars on mac. |
| 182 if (scrollbar.orientation() != VerticalScrollbar) | 182 if (scrollbar.orientation() != VerticalScrollbar) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 if (rect.height() <= 0 || rect.width() <= 0) | 185 if (rect.height() <= 0 || rect.width() <= 0) |
| 186 return; | 186 return; |
| 187 | 187 |
| 188 Vector<IntRect> tickmarks; | 188 Vector<IntRect> tickmarks; |
| 189 scrollbar.getTickmarks(tickmarks); | 189 scrollbar.getTickmarks(tickmarks); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 scrollbarPainterMap().set(&scrollbar, observer); | 286 scrollbarPainterMap().set(&scrollbar, observer); |
| 287 updateEnabledState(scrollbar); | 287 updateEnabledState(scrollbar); |
| 288 updateScrollbarOverlayStyle(scrollbar); | 288 updateScrollbarOverlayStyle(scrollbar); |
| 289 } | 289 } |
| 290 | 290 |
| 291 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar(const ScrollbarThemeClie
nt& scrollbar) const | 291 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar(const ScrollbarThemeClie
nt& scrollbar) const |
| 292 { | 292 { |
| 293 return [scrollbarPainterMap().get(const_cast<ScrollbarThemeClient*>(&scrollb
ar)).get() painter]; | 293 return [scrollbarPainterMap().get(const_cast<ScrollbarThemeClient*>(&scrollb
ar)).get() painter]; |
| 294 } | 294 } |
| 295 | 295 |
| 296 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext& context, const Scr
ollbarThemeClient& scrollbar, const IntRect& rect) { | 296 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext& context, const Scr
ollbar& scrollbar, const IntRect& rect) { |
| 297 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarTrackBackground)) | 297 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarTrackBackground)) |
| 298 return; | 298 return; |
| 299 | 299 |
| 300 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarTrackBack
ground, rect); | 300 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarTrackBack
ground, rect); |
| 301 | 301 |
| 302 GraphicsContextStateSaver stateSaver(context); | 302 GraphicsContextStateSaver stateSaver(context); |
| 303 context.translate(rect.x(), rect.y()); | 303 context.translate(rect.x(), rect.y()); |
| 304 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 304 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
| 305 | 305 |
| 306 CGRect frameRect = scrollbar.frameRect(); | 306 CGRect frameRect = scrollbar.frameRect(); |
| 307 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 307 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 308 [scrollbarPainter setEnabled:scrollbar.enabled()]; | 308 [scrollbarPainter setEnabled:scrollbar.enabled()]; |
| 309 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; | 309 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; |
| 310 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); | 310 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); |
| 311 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; | 311 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; |
| 312 } | 312 } |
| 313 | 313 |
| 314 void ScrollbarThemeMac::paintThumb(GraphicsContext& context, const ScrollbarThem
eClient& scrollbar, const IntRect& rect) { | 314 void ScrollbarThemeMac::paintThumb(GraphicsContext& context, const Scrollbar& sc
rollbar, const IntRect& rect) { |
| 315 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarThumb)) | 315 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayI
tem::ScrollbarThumb)) |
| 316 return; | 316 return; |
| 317 | 317 |
| 318 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. | 318 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. |
| 319 IntRect dirtyRect = IntRect(rect); | 319 IntRect dirtyRect = IntRect(rect); |
| 320 dirtyRect.inflate(1); | 320 dirtyRect.inflate(1); |
| 321 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarThumb, di
rtyRect); | 321 DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarThumb, di
rtyRect); |
| 322 | 322 |
| 323 GraphicsContextStateSaver stateSaver(context); | 323 GraphicsContextStateSaver stateSaver(context); |
| 324 context.translate(rect.x(), rect.y()); | 324 context.translate(rect.x(), rect.y()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 // static | 429 // static |
| 430 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() | 430 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() |
| 431 { | 431 { |
| 432 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) | 432 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) |
| 433 return NSScrollerStyleOverlay; | 433 return NSScrollerStyleOverlay; |
| 434 return gPreferredScrollerStyle; | 434 return gPreferredScrollerStyle; |
| 435 } | 435 } |
| 436 | 436 |
| 437 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |