OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 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 12 matching lines...) Expand all Loading... |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "platform/scroll/ScrollbarTheme.h" | 27 #include "platform/scroll/ScrollbarTheme.h" |
28 | 28 |
29 #include "platform/PlatformMouseEvent.h" | 29 #include "platform/PlatformMouseEvent.h" |
30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
31 #include "platform/graphics/Color.h" | 31 #include "platform/graphics/Color.h" |
32 #include "platform/graphics/GraphicsContext.h" | 32 #include "platform/graphics/GraphicsContext.h" |
| 33 #include "platform/graphics/paint/CullRect.h" |
33 #include "platform/graphics/paint/DrawingDisplayItem.h" | 34 #include "platform/graphics/paint/DrawingDisplayItem.h" |
34 #include "platform/graphics/paint/DrawingRecorder.h" | 35 #include "platform/graphics/paint/DrawingRecorder.h" |
35 #include "platform/graphics/paint/PaintController.h" | 36 #include "platform/graphics/paint/PaintController.h" |
36 #include "platform/scroll/ScrollbarThemeClient.h" | 37 #include "platform/scroll/ScrollbarThemeClient.h" |
37 #include "platform/scroll/ScrollbarThemeMock.h" | 38 #include "platform/scroll/ScrollbarThemeMock.h" |
38 #include "platform/scroll/ScrollbarThemeOverlayMock.h" | 39 #include "platform/scroll/ScrollbarThemeOverlayMock.h" |
39 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
40 #include "public/platform/WebPoint.h" | 41 #include "public/platform/WebPoint.h" |
41 #include "public/platform/WebRect.h" | 42 #include "public/platform/WebRect.h" |
42 #include "public/platform/WebScrollbarBehavior.h" | 43 #include "public/platform/WebScrollbarBehavior.h" |
43 | 44 |
44 #if !OS(MACOSX) | 45 #if !OS(MACOSX) |
45 #include "public/platform/WebRect.h" | 46 #include "public/platform/WebRect.h" |
46 #include "public/platform/WebThemeEngine.h" | 47 #include "public/platform/WebThemeEngine.h" |
47 #endif | 48 #endif |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 | 51 |
51 bool ScrollbarTheme::gMockScrollbarsEnabled = false; | 52 bool ScrollbarTheme::gMockScrollbarsEnabled = false; |
52 | 53 |
53 static inline bool shouldPaintScrollbarPart(const IntRect& partRect, const IntRe
ct& damageRect) | 54 static inline bool shouldPaintScrollbarPart(const IntRect& partRect, const CullR
ect& cullRect) |
54 { | 55 { |
55 return (!partRect.isEmpty()) || damageRect.intersects(partRect); | 56 return (!partRect.isEmpty()) || cullRect.intersectsCullRect(partRect); |
56 } | 57 } |
57 | 58 |
58 bool ScrollbarTheme::paint(const ScrollbarThemeClient* scrollbar, GraphicsContex
t* graphicsContext, const IntRect& damageRect) | 59 bool ScrollbarTheme::paint(const ScrollbarThemeClient* scrollbar, GraphicsContex
t* graphicsContext, const CullRect& cullRect) |
59 { | 60 { |
60 // Create the ScrollbarControlPartMask based on the damageRect | 61 // Create the ScrollbarControlPartMask based on the cullRect |
61 ScrollbarControlPartMask scrollMask = NoPart; | 62 ScrollbarControlPartMask scrollMask = NoPart; |
62 | 63 |
63 IntRect backButtonStartPaintRect; | 64 IntRect backButtonStartPaintRect; |
64 IntRect backButtonEndPaintRect; | 65 IntRect backButtonEndPaintRect; |
65 IntRect forwardButtonStartPaintRect; | 66 IntRect forwardButtonStartPaintRect; |
66 IntRect forwardButtonEndPaintRect; | 67 IntRect forwardButtonEndPaintRect; |
67 if (hasButtons(scrollbar)) { | 68 if (hasButtons(scrollbar)) { |
68 backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart
, true); | 69 backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart
, true); |
69 if (shouldPaintScrollbarPart(backButtonStartPaintRect, damageRect)) | 70 if (shouldPaintScrollbarPart(backButtonStartPaintRect, cullRect)) |
70 scrollMask |= BackButtonStartPart; | 71 scrollMask |= BackButtonStartPart; |
71 backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, tr
ue); | 72 backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, tr
ue); |
72 if (shouldPaintScrollbarPart(backButtonEndPaintRect, damageRect)) | 73 if (shouldPaintScrollbarPart(backButtonEndPaintRect, cullRect)) |
73 scrollMask |= BackButtonEndPart; | 74 scrollMask |= BackButtonEndPart; |
74 forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButton
StartPart, true); | 75 forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButton
StartPart, true); |
75 if (shouldPaintScrollbarPart(forwardButtonStartPaintRect, damageRect)) | 76 if (shouldPaintScrollbarPart(forwardButtonStartPaintRect, cullRect)) |
76 scrollMask |= ForwardButtonStartPart; | 77 scrollMask |= ForwardButtonStartPart; |
77 forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEn
dPart, true); | 78 forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEn
dPart, true); |
78 if (shouldPaintScrollbarPart(forwardButtonEndPaintRect, damageRect)) | 79 if (shouldPaintScrollbarPart(forwardButtonEndPaintRect, cullRect)) |
79 scrollMask |= ForwardButtonEndPart; | 80 scrollMask |= ForwardButtonEndPart; |
80 } | 81 } |
81 | 82 |
82 IntRect startTrackRect; | 83 IntRect startTrackRect; |
83 IntRect thumbRect; | 84 IntRect thumbRect; |
84 IntRect endTrackRect; | 85 IntRect endTrackRect; |
85 IntRect trackPaintRect = trackRect(scrollbar, true); | 86 IntRect trackPaintRect = trackRect(scrollbar, true); |
86 scrollMask |= TrackBGPart; | 87 scrollMask |= TrackBGPart; |
87 bool thumbPresent = hasThumb(scrollbar); | 88 bool thumbPresent = hasThumb(scrollbar); |
88 if (thumbPresent) { | 89 if (thumbPresent) { |
89 IntRect track = trackRect(scrollbar); | 90 IntRect track = trackRect(scrollbar); |
90 splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect); | 91 splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect); |
91 if (shouldPaintScrollbarPart(thumbRect, damageRect)) | 92 if (shouldPaintScrollbarPart(thumbRect, cullRect)) |
92 scrollMask |= ThumbPart; | 93 scrollMask |= ThumbPart; |
93 if (shouldPaintScrollbarPart(startTrackRect, damageRect)) | 94 if (shouldPaintScrollbarPart(startTrackRect, cullRect)) |
94 scrollMask |= BackTrackPart; | 95 scrollMask |= BackTrackPart; |
95 if (shouldPaintScrollbarPart(endTrackRect, damageRect)) | 96 if (shouldPaintScrollbarPart(endTrackRect, cullRect)) |
96 scrollMask |= ForwardTrackPart; | 97 scrollMask |= ForwardTrackPart; |
97 } | 98 } |
98 | 99 |
99 // Paint the scrollbar background (only used by custom CSS scrollbars). | 100 // Paint the scrollbar background (only used by custom CSS scrollbars). |
100 paintScrollbarBackground(graphicsContext, scrollbar); | 101 paintScrollbarBackground(graphicsContext, scrollbar); |
101 | 102 |
102 // Paint the back and forward buttons. | 103 // Paint the back and forward buttons. |
103 if (scrollMask & BackButtonStartPart) | 104 if (scrollMask & BackButtonStartPart) |
104 paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackBu
ttonStartPart); | 105 paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackBu
ttonStartPart); |
105 if (scrollMask & BackButtonEndPart) | 106 if (scrollMask & BackButtonEndPart) |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 return DisplayItem::ScrollbarBackTrack; | 372 return DisplayItem::ScrollbarBackTrack; |
372 case ForwardTrackPart: | 373 case ForwardTrackPart: |
373 return DisplayItem::ScrollbarForwardTrack; | 374 return DisplayItem::ScrollbarForwardTrack; |
374 default: | 375 default: |
375 ASSERT_NOT_REACHED(); | 376 ASSERT_NOT_REACHED(); |
376 return DisplayItem::ScrollbarBackTrack; | 377 return DisplayItem::ScrollbarBackTrack; |
377 } | 378 } |
378 } | 379 } |
379 | 380 |
380 } // namespace blink | 381 } // namespace blink |
OLD | NEW |