Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / scroll / ScrollbarTheme.h
blobadeb08cc06b8495681c6340701b03e3a65040fd6
1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ScrollbarTheme_h
27 #define ScrollbarTheme_h
29 #include "platform/PlatformExport.h"
30 #include "platform/geometry/IntRect.h"
31 #include "platform/graphics/paint/DisplayItem.h"
32 #include "platform/scroll/ScrollTypes.h"
33 #include "public/platform/mac/MacScrollTypes.h"
35 namespace blink {
37 class GraphicsContext;
38 class PlatformMouseEvent;
39 class ScrollbarThemeClient;
41 class PLATFORM_EXPORT ScrollbarTheme {
42 WTF_MAKE_NONCOPYABLE(ScrollbarTheme); WTF_MAKE_FAST_ALLOCATED(ScrollbarTheme);
43 public:
44 ScrollbarTheme() { }
45 virtual ~ScrollbarTheme() { }
47 virtual void updateEnabledState(ScrollbarThemeClient*) { }
49 virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& damageRect);
51 virtual ScrollbarPart hitTest(ScrollbarThemeClient*, const IntPoint&);
53 virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) { return 0; }
54 virtual int scrollbarMargin() const { return 0; }
56 virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarButtonsPlacementSingle; }
58 virtual bool supportsControlTints() const { return false; }
59 virtual bool usesOverlayScrollbars() const { return false; }
60 virtual void updateScrollbarOverlayStyle(ScrollbarThemeClient*) { }
62 virtual bool invalidateOnMouseEnterExit() { return false; }
64 void invalidateParts(ScrollbarThemeClient* scrollbar, ScrollbarControlPartMask mask)
66 if (mask & BackButtonStartPart)
67 invalidatePart(scrollbar, BackButtonStartPart);
68 if (mask & ForwardButtonStartPart)
69 invalidatePart(scrollbar, ForwardButtonStartPart);
70 if (mask & BackTrackPart)
71 invalidatePart(scrollbar, BackTrackPart);
72 if (mask & ThumbPart)
73 invalidatePart(scrollbar, ThumbPart);
74 if (mask & ForwardTrackPart)
75 invalidatePart(scrollbar, ForwardTrackPart);
76 if (mask & BackButtonEndPart)
77 invalidatePart(scrollbar, BackButtonEndPart);
78 if (mask & ForwardButtonEndPart)
79 invalidatePart(scrollbar, ForwardButtonEndPart);
82 virtual void invalidatePart(ScrollbarThemeClient*, ScrollbarPart);
84 virtual void paintScrollCorner(GraphicsContext*, const DisplayItemClientWrapper&, const IntRect& cornerRect);
85 virtual void paintTickmarks(GraphicsContext*, ScrollbarThemeClient*, const IntRect&) { }
87 virtual bool shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent&);
88 virtual bool shouldSnapBackToDragOrigin(ScrollbarThemeClient*, const PlatformMouseEvent&);
89 virtual bool shouldDragDocumentInsteadOfThumb(ScrollbarThemeClient*, const PlatformMouseEvent&) { return false; }
91 // The position of the thumb relative to the track.
92 virtual int thumbPosition(ScrollbarThemeClient*);
93 // The length of the thumb along the axis of the scrollbar.
94 virtual int thumbLength(ScrollbarThemeClient*);
95 // The position of the track relative to the scrollbar.
96 virtual int trackPosition(ScrollbarThemeClient*);
97 // The length of the track along the axis of the scrollbar.
98 virtual int trackLength(ScrollbarThemeClient*);
100 virtual bool hasButtons(ScrollbarThemeClient*) = 0;
101 virtual bool hasThumb(ScrollbarThemeClient*) = 0;
103 virtual IntRect backButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false) = 0;
104 virtual IntRect forwardButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false) = 0;
105 virtual IntRect trackRect(ScrollbarThemeClient*, bool painting = false) = 0;
106 virtual IntRect thumbRect(ScrollbarThemeClient*);
107 virtual int thumbThickness(ScrollbarThemeClient*);
109 virtual int minimumThumbLength(ScrollbarThemeClient*);
111 virtual void splitTrack(ScrollbarThemeClient*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack);
113 virtual void paintScrollbarBackground(GraphicsContext*, ScrollbarThemeClient*) { }
114 virtual void paintTrackBackground(GraphicsContext*, ScrollbarThemeClient*, const IntRect&) { }
115 virtual void paintTrackPiece(GraphicsContext*, ScrollbarThemeClient*, const IntRect&, ScrollbarPart) { }
116 virtual void paintButton(GraphicsContext*, ScrollbarThemeClient*, const IntRect&, ScrollbarPart) { }
117 virtual void paintThumb(GraphicsContext*, ScrollbarThemeClient*, const IntRect&) { }
119 virtual int maxOverlapBetweenPages() { return std::numeric_limits<int>::max(); }
121 virtual double initialAutoscrollTimerDelay() { return 0.25; }
122 virtual double autoscrollTimerDelay() { return 0.05; }
124 virtual IntRect constrainTrackRectToTrackPieces(ScrollbarThemeClient*, const IntRect& rect) { return rect; }
126 virtual void registerScrollbar(ScrollbarThemeClient*) { }
127 virtual void unregisterScrollbar(ScrollbarThemeClient*) { }
129 virtual bool isMockTheme() const { return false; }
131 static ScrollbarTheme* theme();
133 static void setMockScrollbarsEnabled(bool flag);
134 static bool mockScrollbarsEnabled();
136 protected:
137 static DisplayItem::Type buttonPartToDisplayItemType(ScrollbarPart);
138 static DisplayItem::Type trackPiecePartToDisplayItemType(ScrollbarPart);
140 private:
141 static ScrollbarTheme* nativeTheme(); // Must be implemented to return the correct theme subclass.
142 static bool gMockScrollbarsEnabled;
146 #endif