Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / rendering / RenderThemeMac.h
1 /*
2  * This file is part of the theme implementation for form controls in WebCore.
3  *
4  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Computer, Inc.
5  *
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.
10  *
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.
15  *
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.
20  *
21  */
22
23 #ifndef RenderThemeMac_h
24 #define RenderThemeMac_h
25
26 #import "RenderTheme.h"
27 #import <wtf/HashMap.h>
28 #import <wtf/RetainPtr.h>
29
30
31 OBJC_CLASS WebCoreRenderThemeNotificationObserver;
32
33 namespace WebCore {
34
35 class RenderProgress;
36 class RenderStyle;
37
38 class RenderThemeMac : public RenderTheme {
39 public:
40     static PassRefPtr<RenderTheme> create();
41
42     // A method asking if the control changes its tint when the window has focus or not.
43     virtual bool controlSupportsTints(const RenderObject*) const;
44
45     // A general method asking if any control tinting is supported at all.
46     virtual bool supportsControlTints() const { return true; }
47
48     virtual void adjustRepaintRect(const RenderObject*, IntRect&) OVERRIDE;
49
50     virtual bool isControlStyled(const RenderStyle*, const BorderData&,
51                                  const FillLayer&, const Color& backgroundColor) const;
52
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;
60
61     virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return SmallScrollbar; }
62     
63     virtual void platformColorsDidChange();
64
65     // System fonts.
66     virtual void systemFont(int cssValueId, FontDescription&) const;
67
68     virtual int minimumMenuListSize(RenderStyle*) const;
69
70     virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
71
72 #if ENABLE(DATALIST_ELEMENT)
73     virtual IntSize sliderTickSize() const OVERRIDE;
74     virtual int sliderTickOffsetFromTrackCenter() const OVERRIDE;
75 #endif
76
77     virtual int popupInternalPaddingLeft(RenderStyle*) const;
78     virtual int popupInternalPaddingRight(RenderStyle*) const;
79     virtual int popupInternalPaddingTop(RenderStyle*) const;
80     virtual int popupInternalPaddingBottom(RenderStyle*) const;
81     
82     virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
83
84     virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; }
85
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;
90 #endif
91
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;
97 #endif
98
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;
104 protected:
105     RenderThemeMac();
106     virtual ~RenderThemeMac();
107
108     virtual bool supportsSelectionForegroundColors() const { return false; }
109
110     virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
111     virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
112
113     virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
114     virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const;
115
116     virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
117     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const;
118
119     virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
120     virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
121
122 #if ENABLE(PROGRESS_ELEMENT)
123     virtual void adjustProgressBarStyle(StyleResolver*, RenderStyle*, Element*) const;
124     virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
125 #endif
126
127     virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
128     virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const;
129
130     virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
131     virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const;
132
133     virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
134     virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
135
136     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
137     virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
138
139     virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
140     virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&);
141
142     virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
143     virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
144
145     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
146     virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
147
148 #if ENABLE(VIDEO)
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;
167
168     // Media controls
169     virtual String extraMediaControlsStyleSheet();
170 #if ENABLE(FULLSCREEN_API)
171     virtual String extraFullScreenStyleSheet();
172 #endif
173
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;
180 #endif
181     
182     virtual bool shouldShowPlaceholderWhenFocused() const;
183
184 private:
185     virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const OVERRIDE;
186
187     IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const;
188
189     FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const;
190     
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;
199
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*) {}
206
207     // Helpers for adjusting appearance and for painting
208
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;
215
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;
221     
222     NSPopUpButtonCell* popupButton() const;
223     NSSearchFieldCell* search() const;
224     NSMenu* searchMenuTemplate() const;
225     NSSliderCell* sliderThumbHorizontal() const;
226     NSSliderCell* sliderThumbVertical() const;
227     NSTextFieldCell* textField() const;
228
229 #if ENABLE(METER_ELEMENT)
230     NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const;
231     NSLevelIndicatorCell* levelIndicatorFor(const RenderMeter*) const;
232 #endif
233
234 #if ENABLE(PROGRESS_ELEMENT)
235     int minimumProgressBarHeight(RenderStyle*) const;
236     const IntSize* progressBarSizes() const;
237     const int* progressBarMargins(NSControlSize) const;
238 #endif
239
240 private:
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;
248
249     bool m_isSliderThumbHorizontalPressed;
250     bool m_isSliderThumbVerticalPressed;
251
252     mutable HashMap<int, RGBA32> m_systemColorCache;
253
254     RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
255 };
256
257 } // namespace WebCore
258
259 #endif // RenderThemeMac_h