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 26 matching lines...) Expand all Loading... |
37 #include "platform/mac/ScrollAnimatorMac.h" | 37 #include "platform/mac/ScrollAnimatorMac.h" |
38 #include "platform/scroll/ScrollbarThemeClient.h" | 38 #include "platform/scroll/ScrollbarThemeClient.h" |
39 #include "public/platform/WebThemeEngine.h" | 39 #include "public/platform/WebThemeEngine.h" |
40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
41 #include "public/platform/WebRect.h" | 41 #include "public/platform/WebRect.h" |
42 #include "skia/ext/skia_utils_mac.h" | 42 #include "skia/ext/skia_utils_mac.h" |
43 #include "wtf/HashSet.h" | 43 #include "wtf/HashSet.h" |
44 #include "wtf/RetainPtr.h" | 44 #include "wtf/RetainPtr.h" |
45 #include "wtf/StdLibExtras.h" | 45 #include "wtf/StdLibExtras.h" |
46 | 46 |
47 // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual o
verflow. | 47 // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual |
| 48 // overflow. |
48 | 49 |
49 using namespace blink; | 50 using namespace blink; |
50 | 51 |
51 @interface NSColor (WebNSColorDetails) | 52 @interface NSColor (WebNSColorDetails) |
52 + (NSImage*)_linenPatternImage; | 53 + (NSImage*)_linenPatternImage; |
53 @end | 54 @end |
54 | 55 |
55 @interface BlinkScrollbarObserver : NSObject { | 56 @interface BlinkScrollbarObserver : NSObject { |
56 blink::ScrollbarThemeClient* _scrollbar; | 57 blink::ScrollbarThemeClient* _scrollbar; |
57 RetainPtr<ScrollbarPainter> _scrollbarPainter; | 58 RetainPtr<ScrollbarPainter> _scrollbarPainter; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 116 |
116 typedef HashMap<ScrollbarThemeClient*, RetainPtr<BlinkScrollbarObserver>> | 117 typedef HashMap<ScrollbarThemeClient*, RetainPtr<BlinkScrollbarObserver>> |
117 ScrollbarPainterMap; | 118 ScrollbarPainterMap; |
118 | 119 |
119 static ScrollbarPainterMap& scrollbarPainterMap() { | 120 static ScrollbarPainterMap& scrollbarPainterMap() { |
120 static ScrollbarPainterMap* map = new ScrollbarPainterMap; | 121 static ScrollbarPainterMap* map = new ScrollbarPainterMap; |
121 return *map; | 122 return *map; |
122 } | 123 } |
123 | 124 |
124 static bool supportsExpandedScrollbars() { | 125 static bool supportsExpandedScrollbars() { |
125 // FIXME: This is temporary until all platforms that support ScrollbarPainter
support this part of the API. | 126 // FIXME: This is temporary until all platforms that support ScrollbarPainter |
| 127 // support this part of the API. |
126 static bool globalSupportsExpandedScrollbars = | 128 static bool globalSupportsExpandedScrollbars = |
127 [NSClassFromString(@"NSScrollerImp") | 129 [NSClassFromString(@"NSScrollerImp") |
128 instancesRespondToSelector:@selector(setExpanded:)]; | 130 instancesRespondToSelector:@selector(setExpanded:)]; |
129 return globalSupportsExpandedScrollbars; | 131 return globalSupportsExpandedScrollbars; |
130 } | 132 } |
131 | 133 |
132 ScrollbarTheme& ScrollbarTheme::nativeTheme() { | 134 ScrollbarTheme& ScrollbarTheme::nativeTheme() { |
133 DEFINE_STATIC_LOCAL(ScrollbarThemeMac, overlayTheme, ()); | 135 DEFINE_STATIC_LOCAL(ScrollbarThemeMac, overlayTheme, ()); |
134 return overlayTheme; | 136 return overlayTheme; |
135 } | 137 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 const ScrollbarThemeClient&, | 241 const ScrollbarThemeClient&, |
240 const PlatformMouseEvent& event) { | 242 const PlatformMouseEvent& event) { |
241 return event.altKey(); | 243 return event.altKey(); |
242 } | 244 } |
243 | 245 |
244 int ScrollbarThemeMac::scrollbarPartToHIPressedState(ScrollbarPart part) { | 246 int ScrollbarThemeMac::scrollbarPartToHIPressedState(ScrollbarPart part) { |
245 switch (part) { | 247 switch (part) { |
246 case BackButtonStartPart: | 248 case BackButtonStartPart: |
247 return kThemeTopOutsideArrowPressed; | 249 return kThemeTopOutsideArrowPressed; |
248 case BackButtonEndPart: | 250 case BackButtonEndPart: |
249 return kThemeTopOutsideArrowPressed; // This does not make much sense. F
or some reason the outside constant is required. | 251 // This does not make much sense. For some reason the outside constant |
| 252 // is required. |
| 253 return kThemeTopOutsideArrowPressed; |
250 case ForwardButtonStartPart: | 254 case ForwardButtonStartPart: |
251 return kThemeTopInsideArrowPressed; | 255 return kThemeTopInsideArrowPressed; |
252 case ForwardButtonEndPart: | 256 case ForwardButtonEndPart: |
253 return kThemeBottomOutsideArrowPressed; | 257 return kThemeBottomOutsideArrowPressed; |
254 case ThumbPart: | 258 case ThumbPart: |
255 return kThemeThumbPressed; | 259 return kThemeThumbPressed; |
256 default: | 260 default: |
257 return 0; | 261 return 0; |
258 } | 262 } |
259 } | 263 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; | 339 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; |
336 } | 340 } |
337 | 341 |
338 void ScrollbarThemeMac::paintThumb(GraphicsContext& context, | 342 void ScrollbarThemeMac::paintThumb(GraphicsContext& context, |
339 const Scrollbar& scrollbar, | 343 const Scrollbar& scrollbar, |
340 const IntRect& rect) { | 344 const IntRect& rect) { |
341 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, | 345 if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, |
342 DisplayItem::kScrollbarThumb)) | 346 DisplayItem::kScrollbarThumb)) |
343 return; | 347 return; |
344 | 348 |
345 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thumb
size case. | 349 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thumb |
| 350 // size case. |
346 IntRect dirtyRect = IntRect(rect); | 351 IntRect dirtyRect = IntRect(rect); |
347 dirtyRect.inflate(1); | 352 dirtyRect.inflate(1); |
348 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarThumb, | 353 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarThumb, |
349 dirtyRect); | 354 dirtyRect); |
350 | 355 |
351 GraphicsContextStateSaver stateSaver(context); | 356 GraphicsContextStateSaver stateSaver(context); |
352 context.translate(rect.x(), rect.y()); | 357 context.translate(rect.x(), rect.y()); |
353 LocalCurrentGraphicsContext localContext(context, | 358 LocalCurrentGraphicsContext localContext(context, |
354 IntRect(IntPoint(), rect.size())); | 359 IntRect(IntPoint(), rect.size())); |
355 | 360 |
356 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 361 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
357 [scrollbarPainter setEnabled:scrollbar.enabled()]; | 362 [scrollbarPainter setEnabled:scrollbar.enabled()]; |
358 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; | 363 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; |
359 [scrollbarPainter setDoubleValue:0]; | 364 [scrollbarPainter setDoubleValue:0]; |
360 [scrollbarPainter setKnobProportion:1]; | 365 [scrollbarPainter setKnobProportion:1]; |
361 | 366 |
362 CGFloat oldKnobAlpha = [scrollbarPainter knobAlpha]; | 367 CGFloat oldKnobAlpha = [scrollbarPainter knobAlpha]; |
363 [scrollbarPainter setKnobAlpha:1]; | 368 [scrollbarPainter setKnobAlpha:1]; |
364 | 369 |
365 if (scrollbar.enabled()) | 370 if (scrollbar.enabled()) |
366 [scrollbarPainter drawKnob]; | 371 [scrollbarPainter drawKnob]; |
367 | 372 |
368 // If this state is not set, then moving the cursor over the scrollbar area wi
ll only cause the | 373 // If this state is not set, then moving the cursor over the scrollbar area |
369 // scrollbar to engorge when moved over the top of the scrollbar area. | 374 // will only cause the scrollbar to engorge when moved over the top of the |
| 375 // scrollbar area. |
370 [scrollbarPainter | 376 [scrollbarPainter |
371 setBoundsSize:NSSizeFromCGSize(scrollbar.frameRect().size())]; | 377 setBoundsSize:NSSizeFromCGSize(scrollbar.frameRect().size())]; |
372 [scrollbarPainter setKnobAlpha:oldKnobAlpha]; | 378 [scrollbarPainter setKnobAlpha:oldKnobAlpha]; |
373 } | 379 } |
374 | 380 |
375 int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize) { | 381 int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize) { |
376 NSControlSize nsControlSize = static_cast<NSControlSize>(controlSize); | 382 NSControlSize nsControlSize = static_cast<NSControlSize>(controlSize); |
377 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") | 383 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") |
378 scrollerImpWithStyle:recommendedScrollerStyle() | 384 scrollerImpWithStyle:recommendedScrollerStyle() |
379 controlSize:nsControlSize | 385 controlSize:nsControlSize |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 470 } |
465 | 471 |
466 // static | 472 // static |
467 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() { | 473 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() { |
468 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) | 474 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) |
469 return NSScrollerStyleOverlay; | 475 return NSScrollerStyleOverlay; |
470 return gPreferredScrollerStyle; | 476 return gPreferredScrollerStyle; |
471 } | 477 } |
472 | 478 |
473 } // namespace blink | 479 } // namespace blink |
OLD | NEW |