2 * This file is part of the theme implementation for form controls in WebCore.
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 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>
31 OBJC_CLASS WebCoreRenderThemeNotificationObserver;
38 class RenderThemeMac : public RenderTheme {
40 static PassRefPtr<RenderTheme> create();
42 // A method asking if the control changes its tint when the window has focus or not.
43 virtual bool controlSupportsTints(const RenderObject*) const;
45 // A general method asking if any control tinting is supported at all.
46 virtual bool supportsControlTints() const { return true; }
48 virtual void adjustRepaintRect(const RenderObject*, IntRect&) OVERRIDE;
50 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
51 const FillLayer&, const Color& backgroundColor) const;
53 virtual Color platformActiveSelectionBackgroundColor() const;
54 virtual Color platformInactiveSelectionBackgroundColor() const;
55 virtual Color platformActiveListBoxSelectionBackgroundColor() const;
56 virtual Color platformActiveListBoxSelectionForegroundColor() const;
57 virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
58 virtual Color platformInactiveListBoxSelectionForegroundColor() const;
59 virtual Color platformFocusRingColor() const;
61 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return SmallScrollbar; }
63 virtual void platformColorsDidChange();
66 virtual void systemFont(int cssValueId, FontDescription&) const;
68 virtual int minimumMenuListSize(RenderStyle*) const;
70 virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
72 #if ENABLE(DATALIST_ELEMENT)
73 virtual IntSize sliderTickSize() const OVERRIDE;
74 virtual int sliderTickOffsetFromTrackCenter() const OVERRIDE;
77 virtual int popupInternalPaddingLeft(RenderStyle*) const;
78 virtual int popupInternalPaddingRight(RenderStyle*) const;
79 virtual int popupInternalPaddingTop(RenderStyle*) const;
80 virtual int popupInternalPaddingBottom(RenderStyle*) const;
82 virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
84 virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; }
86 #if ENABLE(METER_ELEMENT)
87 virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const OVERRIDE;
88 virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&);
89 virtual bool supportsMeter(ControlPart) const;
92 #if ENABLE(PROGRESS_ELEMENT)
93 // Returns the repeat interval of the animation for the progress bar.
94 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const;
95 // Returns the duration of the animation for the progress bar.
96 virtual double animationDurationForProgressBar(RenderProgress*) const;
99 virtual Color systemColor(int cssValueId) const;
100 // Controls color values returned from platformFocusRingColor(). systemColor() will be used when false.
101 virtual bool usesTestModeFocusRingColor() const;
102 // A view associated to the contained document. Subclasses may not have such a view and return a fake.
103 virtual NSView* documentViewFor(RenderObject*) const;
106 virtual ~RenderThemeMac();
108 virtual bool supportsSelectionForegroundColors() const { return false; }
110 virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
111 virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
113 virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
114 virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const;
116 virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
117 virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const;
119 virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
120 virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
122 #if ENABLE(PROGRESS_ELEMENT)
123 virtual void adjustProgressBarStyle(StyleResolver*, RenderStyle*, Element*) const;
124 virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
127 virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
128 virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const;
130 virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
131 virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const;
133 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
134 virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
136 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
137 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
139 virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
140 virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&);
142 virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
143 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
145 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
146 virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
149 virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
150 virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
151 virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
152 virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
153 virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
154 virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
155 virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
156 virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&);
157 virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const PaintInfo&, const IntRect&);
158 virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&);
159 virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
160 virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&);
161 virtual bool paintMediaTimeRemaining(RenderObject*, const PaintInfo&, const IntRect&);
162 virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
163 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
164 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
165 virtual bool paintMediaFullScreenVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
166 virtual bool paintMediaFullScreenVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
169 virtual String extraMediaControlsStyleSheet();
170 #if ENABLE(FULLSCREEN_API)
171 virtual String extraFullScreenStyleSheet();
174 virtual bool supportsClosedCaptioning() const { return true; }
175 virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const;
176 virtual bool usesMediaControlStatusDisplay();
177 virtual bool usesMediaControlVolumeSlider() const;
178 virtual void adjustMediaSliderThumbSize(RenderStyle*) const;
179 virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const OVERRIDE;
182 virtual bool shouldShowPlaceholderWhenFocused() const;
185 virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const OVERRIDE;
187 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const;
189 FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const;
191 // Get the control size based off the font. Used by some of the controls (like buttons).
192 NSControlSize controlSizeForFont(RenderStyle*) const;
193 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
194 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f);
195 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
196 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
197 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
198 void setFontFromControlSize(StyleResolver*, RenderStyle*, NSControlSize) const;
200 void updateCheckedState(NSCell*, const RenderObject*);
201 void updateEnabledState(NSCell*, const RenderObject*);
202 void updateFocusedState(NSCell*, const RenderObject*);
203 void updatePressedState(NSCell*, const RenderObject*);
204 // An optional hook for subclasses to update the control tint of NSCell.
205 virtual void updateActiveState(NSCell*, const RenderObject*) {}
207 // Helpers for adjusting appearance and for painting
209 void setPopupButtonCellState(const RenderObject*, const IntRect&);
210 const IntSize* popupButtonSizes() const;
211 const int* popupButtonMargins() const;
212 const int* popupButtonPadding(NSControlSize) const;
213 void paintMenuListButtonGradients(RenderObject*, const PaintInfo&, const IntRect&);
214 const IntSize* menuListSizes() const;
216 const IntSize* searchFieldSizes() const;
217 const IntSize* cancelButtonSizes() const;
218 const IntSize* resultsButtonSizes() const;
219 void setSearchCellState(RenderObject*, const IntRect&);
220 void setSearchFieldSize(RenderStyle*) const;
222 NSPopUpButtonCell* popupButton() const;
223 NSSearchFieldCell* search() const;
224 NSMenu* searchMenuTemplate() const;
225 NSSliderCell* sliderThumbHorizontal() const;
226 NSSliderCell* sliderThumbVertical() const;
227 NSTextFieldCell* textField() const;
229 #if ENABLE(METER_ELEMENT)
230 NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const;
231 NSLevelIndicatorCell* levelIndicatorFor(const RenderMeter*) const;
234 #if ENABLE(PROGRESS_ELEMENT)
235 int minimumProgressBarHeight(RenderStyle*) const;
236 const IntSize* progressBarSizes() const;
237 const int* progressBarMargins(NSControlSize) const;
241 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
242 mutable RetainPtr<NSSearchFieldCell> m_search;
243 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
244 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
245 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
246 mutable RetainPtr<NSLevelIndicatorCell> m_levelIndicator;
247 mutable RetainPtr<NSTextFieldCell> m_textField;
249 bool m_isSliderThumbHorizontalPressed;
250 bool m_isSliderThumbVerticalPressed;
252 mutable HashMap<int, RGBA32> m_systemColorCache;
254 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
257 } // namespace WebCore
259 #endif // RenderThemeMac_h