2 * This file is part of the theme implementation for form controls in WebCore.
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef RenderThemeMac_h
24 #define RenderThemeMac_h
26 #import "RenderTheme.h"
27 #import <wtf/HashMap.h>
28 #import <wtf/RetainPtr.h>
33 @class WebCoreRenderThemeNotificationObserver;
35 class WebCoreRenderThemeNotificationObserver;
42 class RenderThemeMac : public RenderTheme {
44 static PassRefPtr<RenderTheme> create();
46 // A method asking if the control changes its tint when the window has focus or not.
47 virtual bool controlSupportsTints(const RenderObject*) const;
49 // A general method asking if any control tinting is supported at all.
50 virtual bool supportsControlTints() const { return true; }
52 virtual void adjustRepaintRect(const RenderObject*, IntRect&);
54 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
55 const FillLayer&, const Color& backgroundColor) const;
57 virtual Color platformActiveSelectionBackgroundColor() const;
58 virtual Color platformInactiveSelectionBackgroundColor() const;
59 virtual Color platformActiveListBoxSelectionBackgroundColor() const;
60 virtual Color platformActiveListBoxSelectionForegroundColor() const;
61 virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
62 virtual Color platformInactiveListBoxSelectionForegroundColor() const;
63 virtual Color platformFocusRingColor() const;
65 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return SmallScrollbar; }
67 virtual void platformColorsDidChange();
70 virtual void systemFont(int cssValueId, FontDescription&) const;
72 virtual int minimumMenuListSize(RenderStyle*) const;
74 virtual void adjustSliderThumbSize(RenderObject*) const;
76 virtual int popupInternalPaddingLeft(RenderStyle*) const;
77 virtual int popupInternalPaddingRight(RenderStyle*) const;
78 virtual int popupInternalPaddingTop(RenderStyle*) const;
79 virtual int popupInternalPaddingBottom(RenderStyle*) const;
81 virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&);
84 virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const;
85 virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&);
86 virtual bool supportsMeter(ControlPart, bool isHorizontal) const;
89 #if ENABLE(PROGRESS_TAG)
90 // Returns the repeat interval of the animation for the progress bar.
91 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const;
92 // Returns the duration of the animation for the progress bar.
93 virtual double animationDurationForProgressBar(RenderProgress*) const;
96 virtual Color systemColor(int cssValueId) const;
97 // Controls color values returned from platformFocusRingColor(). systemColor() will be used when false.
98 virtual bool usesTestModeFocusRingColor() const;
99 // A view associated to the contained document. Subclasses may not have such a view and return a fake.
100 virtual NSView* documentViewFor(RenderObject*) const;
103 virtual ~RenderThemeMac();
105 virtual bool supportsSelectionForegroundColors() const { return false; }
107 virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
108 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
110 virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
111 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
113 virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
114 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
116 virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
117 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
119 #if ENABLE(PROGRESS_TAG)
120 virtual void adjustProgressBarStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
121 virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
124 virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
125 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
127 virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
128 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
130 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
131 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
133 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
134 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
136 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
137 virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&);
139 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
140 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
142 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
143 virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
146 virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
147 virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
148 virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
149 virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
150 virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
151 virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
152 virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
153 virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&);
154 virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const PaintInfo&, const IntRect&);
155 virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&);
156 virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
157 virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&);
158 virtual bool paintMediaTimeRemaining(RenderObject*, const PaintInfo&, const IntRect&);
159 virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
160 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
161 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
164 virtual String extraMediaControlsStyleSheet();
166 virtual bool shouldRenderMediaControlPart(ControlPart, Element*);
167 virtual bool usesMediaControlStatusDisplay();
168 virtual void adjustMediaSliderThumbSize(RenderObject*) const;
169 virtual IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&) const;
172 virtual bool shouldShowPlaceholderWhenFocused() const;
176 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const;
178 FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const;
180 // Get the control size based off the font. Used by some of the controls (like buttons).
181 NSControlSize controlSizeForFont(RenderStyle*) const;
182 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
183 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f);
184 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
185 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
186 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
187 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
189 void updateCheckedState(NSCell*, const RenderObject*);
190 void updateEnabledState(NSCell*, const RenderObject*);
191 void updateFocusedState(NSCell*, const RenderObject*);
192 void updatePressedState(NSCell*, const RenderObject*);
193 // An optional hook for subclasses to update the control tint of NSCell.
194 virtual void updateActiveState(NSCell*, const RenderObject*) {}
196 // Helpers for adjusting appearance and for painting
198 void setPopupButtonCellState(const RenderObject*, const IntRect&);
199 const IntSize* popupButtonSizes() const;
200 const int* popupButtonMargins() const;
201 const int* popupButtonPadding(NSControlSize) const;
202 void paintMenuListButtonGradients(RenderObject*, const PaintInfo&, const IntRect&);
203 const IntSize* menuListSizes() const;
205 const IntSize* searchFieldSizes() const;
206 const IntSize* cancelButtonSizes() const;
207 const IntSize* resultsButtonSizes() const;
208 void setSearchCellState(RenderObject*, const IntRect&);
209 void setSearchFieldSize(RenderStyle*) const;
211 NSPopUpButtonCell* popupButton() const;
212 NSSearchFieldCell* search() const;
213 NSMenu* searchMenuTemplate() const;
214 NSSliderCell* sliderThumbHorizontal() const;
215 NSSliderCell* sliderThumbVertical() const;
217 #if ENABLE(METER_TAG)
218 NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const;
219 NSLevelIndicatorCell* levelIndicatorFor(const RenderMeter*) const;
223 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
224 mutable RetainPtr<NSSearchFieldCell> m_search;
225 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
226 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
227 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
228 mutable RetainPtr<NSLevelIndicatorCell> m_levelIndicator;
230 bool m_isSliderThumbHorizontalPressed;
231 bool m_isSliderThumbVerticalPressed;
233 mutable HashMap<int, RGBA32> m_systemColorCache;
235 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
238 } // namespace WebCore
240 #endif // RenderThemeMac_h