OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 #ifndef ScrollbarTheme_h | 26 #ifndef ScrollbarTheme_h |
27 #define ScrollbarTheme_h | 27 #define ScrollbarTheme_h |
28 | 28 |
29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
30 #include "platform/geometry/IntRect.h" | 30 #include "platform/geometry/IntRect.h" |
31 #include "platform/graphics/paint/DisplayItem.h" | 31 #include "platform/graphics/paint/DisplayItem.h" |
32 #include "platform/scroll/ScrollTypes.h" | 32 #include "platform/scroll/ScrollTypes.h" |
33 #include "platform/scroll/ScrollbarThemeClient.h" | 33 #include "platform/scroll/Scrollbar.h" |
34 #include "public/platform/WebScrollbarButtonsPlacement.h" | 34 #include "public/platform/WebScrollbarButtonsPlacement.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class CullRect; | 38 class CullRect; |
39 class GraphicsContext; | 39 class GraphicsContext; |
40 class PlatformMouseEvent; | 40 class PlatformMouseEvent; |
41 class ScrollbarThemePaintParams; | 41 class ScrollbarThemePaintParams; |
42 | 42 |
43 class PLATFORM_EXPORT ScrollbarTheme { | 43 class PLATFORM_EXPORT ScrollbarTheme { |
44 WTF_MAKE_NONCOPYABLE(ScrollbarTheme); USING_FAST_MALLOC(ScrollbarTheme); | 44 WTF_MAKE_NONCOPYABLE(ScrollbarTheme); USING_FAST_MALLOC(ScrollbarTheme); |
45 public: | 45 public: |
46 ScrollbarTheme() { } | 46 ScrollbarTheme() { } |
47 virtual ~ScrollbarTheme() { } | 47 virtual ~ScrollbarTheme() { } |
48 | 48 |
49 // If true, then scrollbars with this theme will be painted every time | 49 // If true, then scrollbars with this theme will be painted every time |
50 // Scrollbar::setNeedsPaintInvalidation is called. If false, then only parts | 50 // Scrollbar::setNeedsPaintInvalidation is called. If false, then only parts |
51 // which are explicitly invalidated will be repainted. | 51 // which are explicitly invalidated will be repainted. |
52 virtual bool shouldRepaintAllPartsOnInvalidation() const { return true; } | 52 virtual bool shouldRepaintAllPartsOnInvalidation() const { return true; } |
53 | 53 |
54 virtual void updateEnabledState(const ScrollbarThemeClient&) { } | 54 virtual void updateEnabledState(const ScrollbarThemeClient&) { } |
55 | 55 |
56 virtual bool paint(const ScrollbarThemeClient&, GraphicsContext&, const Cull
Rect&); | 56 virtual bool paint(const Scrollbar&, GraphicsContext&, const CullRect&); |
57 | 57 |
58 virtual ScrollbarPart hitTest(const ScrollbarThemeClient&, const IntPoint&); | 58 virtual ScrollbarPart hitTest(const ScrollbarThemeClient&, const IntPoint&); |
59 | 59 |
60 virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) { re
turn 0; } | 60 virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) { re
turn 0; } |
61 virtual int scrollbarMargin() const { return 0; } | 61 virtual int scrollbarMargin() const { return 0; } |
62 | 62 |
63 virtual WebScrollbarButtonsPlacement buttonsPlacement() const { return WebSc
rollbarButtonsPlacementSingle; } | 63 virtual WebScrollbarButtonsPlacement buttonsPlacement() const { return WebSc
rollbarButtonsPlacementSingle; } |
64 | 64 |
65 virtual bool supportsControlTints() const { return false; } | 65 virtual bool supportsControlTints() const { return false; } |
66 virtual bool usesOverlayScrollbars() const { return false; } | 66 virtual bool usesOverlayScrollbars() const { return false; } |
67 virtual void updateScrollbarOverlayStyle(const ScrollbarThemeClient&) { } | 67 virtual void updateScrollbarOverlayStyle(const ScrollbarThemeClient&) { } |
68 | 68 |
69 virtual bool invalidateOnMouseEnterExit() { return false; } | 69 virtual bool invalidateOnMouseEnterExit() { return false; } |
70 virtual bool invalidateOnWindowActiveChange() const { return false; } | 70 virtual bool invalidateOnWindowActiveChange() const { return false; } |
71 | 71 |
72 // Returns parts of the scrollbar which must be repainted following a change | 72 // Returns parts of the scrollbar which must be repainted following a change |
73 // in the thumb position, given scroll positions before and after. | 73 // in the thumb position, given scroll positions before and after. |
74 virtual ScrollbarPart invalidateOnThumbPositionChange( | 74 virtual ScrollbarPart invalidateOnThumbPositionChange( |
75 const ScrollbarThemeClient&, float oldPosition, float newPosition) const | 75 const ScrollbarThemeClient&, float oldPosition, float newPosition) const |
76 { | 76 { |
77 return AllParts; | 77 return AllParts; |
78 } | 78 } |
79 | 79 |
80 virtual void paintScrollCorner(GraphicsContext&, const DisplayItemClient&, c
onst IntRect& cornerRect); | 80 virtual void paintScrollCorner(GraphicsContext&, const DisplayItemClient&, c
onst IntRect& cornerRect); |
81 virtual void paintTickmarks(GraphicsContext&, const ScrollbarThemeClient&, c
onst IntRect&) { } | 81 virtual void paintTickmarks(GraphicsContext&, const Scrollbar&, const IntRec
t&) { } |
82 | 82 |
83 virtual bool shouldCenterOnThumb(const ScrollbarThemeClient&, const Platform
MouseEvent&); | 83 virtual bool shouldCenterOnThumb(const ScrollbarThemeClient&, const Platform
MouseEvent&); |
84 virtual bool shouldSnapBackToDragOrigin(const ScrollbarThemeClient&, const P
latformMouseEvent&); | 84 virtual bool shouldSnapBackToDragOrigin(const ScrollbarThemeClient&, const P
latformMouseEvent&); |
85 virtual bool shouldDragDocumentInsteadOfThumb(const ScrollbarThemeClient&, c
onst PlatformMouseEvent&) { return false; } | 85 virtual bool shouldDragDocumentInsteadOfThumb(const ScrollbarThemeClient&, c
onst PlatformMouseEvent&) { return false; } |
86 | 86 |
87 // The position of the thumb relative to the track. | 87 // The position of the thumb relative to the track. |
88 int thumbPosition(const ScrollbarThemeClient& scrollbar) { return thumbPosit
ion(scrollbar, scrollbar.currentPos()); } | 88 int thumbPosition(const ScrollbarThemeClient& scrollbar) { return thumbPosit
ion(scrollbar, scrollbar.currentPos()); } |
89 // The position the thumb would have, relative to the track, at the specifie
d scroll position. | 89 // The position the thumb would have, relative to the track, at the specifie
d scroll position. |
90 virtual int thumbPosition(const ScrollbarThemeClient&, float scrollPosition)
; | 90 virtual int thumbPosition(const ScrollbarThemeClient&, float scrollPosition)
; |
91 // The length of the thumb along the axis of the scrollbar. | 91 // The length of the thumb along the axis of the scrollbar. |
(...skipping 11 matching lines...) Expand all Loading... |
103 virtual IntRect backButtonRect(const ScrollbarThemeClient&, ScrollbarPart, b
ool painting = false) = 0; | 103 virtual IntRect backButtonRect(const ScrollbarThemeClient&, ScrollbarPart, b
ool painting = false) = 0; |
104 virtual IntRect forwardButtonRect(const ScrollbarThemeClient&, ScrollbarPart
, bool painting = false) = 0; | 104 virtual IntRect forwardButtonRect(const ScrollbarThemeClient&, ScrollbarPart
, bool painting = false) = 0; |
105 virtual IntRect trackRect(const ScrollbarThemeClient&, bool painting = false
) = 0; | 105 virtual IntRect trackRect(const ScrollbarThemeClient&, bool painting = false
) = 0; |
106 virtual IntRect thumbRect(const ScrollbarThemeClient&); | 106 virtual IntRect thumbRect(const ScrollbarThemeClient&); |
107 virtual int thumbThickness(const ScrollbarThemeClient&); | 107 virtual int thumbThickness(const ScrollbarThemeClient&); |
108 | 108 |
109 virtual int minimumThumbLength(const ScrollbarThemeClient&); | 109 virtual int minimumThumbLength(const ScrollbarThemeClient&); |
110 | 110 |
111 virtual void splitTrack(const ScrollbarThemeClient&, const IntRect& track, I
ntRect& startTrack, IntRect& thumb, IntRect& endTrack); | 111 virtual void splitTrack(const ScrollbarThemeClient&, const IntRect& track, I
ntRect& startTrack, IntRect& thumb, IntRect& endTrack); |
112 | 112 |
113 virtual void paintScrollbarBackground(GraphicsContext&, const ScrollbarTheme
Client&) { } | 113 virtual void paintScrollbarBackground(GraphicsContext&, const Scrollbar&) {
} |
114 virtual void paintTrackBackground(GraphicsContext&, const ScrollbarThemeClie
nt&, const IntRect&) { } | 114 virtual void paintTrackBackground(GraphicsContext&, const Scrollbar&, const
IntRect&) { } |
115 virtual void paintTrackPiece(GraphicsContext&, const ScrollbarThemeClient&,
const IntRect&, ScrollbarPart) { } | 115 virtual void paintTrackPiece(GraphicsContext&, const Scrollbar&, const IntRe
ct&, ScrollbarPart) { } |
116 virtual void paintButton(GraphicsContext&, const ScrollbarThemeClient&, cons
t IntRect&, ScrollbarPart) { } | 116 virtual void paintButton(GraphicsContext&, const Scrollbar&, const IntRect&,
ScrollbarPart) { } |
117 virtual void paintThumb(GraphicsContext&, const ScrollbarThemeClient&, const
IntRect&) { } | 117 virtual void paintThumb(GraphicsContext&, const Scrollbar&, const IntRect&)
{ } |
118 | 118 |
119 virtual int maxOverlapBetweenPages() { return std::numeric_limits<int>::max(
); } | 119 virtual int maxOverlapBetweenPages() { return std::numeric_limits<int>::max(
); } |
120 | 120 |
121 virtual double initialAutoscrollTimerDelay() { return 0.25; } | 121 virtual double initialAutoscrollTimerDelay() { return 0.25; } |
122 virtual double autoscrollTimerDelay() { return 0.05; } | 122 virtual double autoscrollTimerDelay() { return 0.05; } |
123 | 123 |
124 virtual IntRect constrainTrackRectToTrackPieces(const ScrollbarThemeClient&,
const IntRect& rect) { return rect; } | 124 virtual IntRect constrainTrackRectToTrackPieces(const ScrollbarThemeClient&,
const IntRect& rect) { return rect; } |
125 | 125 |
126 virtual void registerScrollbar(ScrollbarThemeClient&) { } | 126 virtual void registerScrollbar(ScrollbarThemeClient&) { } |
127 virtual void unregisterScrollbar(ScrollbarThemeClient&) { } | 127 virtual void unregisterScrollbar(ScrollbarThemeClient&) { } |
128 | 128 |
129 virtual bool isMockTheme() const { return false; } | 129 virtual bool isMockTheme() const { return false; } |
130 | 130 |
131 static ScrollbarTheme& theme(); | 131 static ScrollbarTheme& theme(); |
132 | 132 |
133 static void setMockScrollbarsEnabled(bool flag); | 133 static void setMockScrollbarsEnabled(bool flag); |
134 static bool mockScrollbarsEnabled(); | 134 static bool mockScrollbarsEnabled(); |
135 | 135 |
136 protected: | 136 protected: |
137 static DisplayItem::Type buttonPartToDisplayItemType(ScrollbarPart); | 137 static DisplayItem::Type buttonPartToDisplayItemType(ScrollbarPart); |
138 static DisplayItem::Type trackPiecePartToDisplayItemType(ScrollbarPart); | 138 static DisplayItem::Type trackPiecePartToDisplayItemType(ScrollbarPart); |
139 | 139 |
140 private: | 140 private: |
141 static ScrollbarTheme& nativeTheme(); // Must be implemented to return the c
orrect theme subclass. | 141 static ScrollbarTheme& nativeTheme(); // Must be implemented to return the c
orrect theme subclass. |
142 static bool gMockScrollbarsEnabled; | 142 static bool gMockScrollbarsEnabled; |
143 }; | 143 }; |
144 | 144 |
145 } // namespace blink | 145 } // namespace blink |
146 #endif | 146 #endif |
OLD | NEW |