Changed focus ring color
[framework/web/webkit-efl.git] / Source / WebCore / platform / efl / RenderThemeEfl.h
1 /*
2  * This file is part of the WebKit project.
3  *
4  * Copyright (C) 2006 Apple Computer, Inc.
5  * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
6  * Copyright (C) 2007 Holger Hans Peter Freyther
7  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
8  * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
9  * Copyright (C) 2009-2010 ProFUSION embedded systems
10  * Copyright (C) 2009-2010 Samsung Electronics
11  * All rights reserved.
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Library General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library General Public License
24  * along with this library; see the file COPYING.LIB.  If not, write to
25  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26  * Boston, MA 02110-1301, USA.
27  *
28  */
29
30 #ifndef RenderThemeEfl_h
31 #define RenderThemeEfl_h
32
33 #if ENABLE(VIDEO)
34 #include "MediaControlElements.h"
35 #endif
36 #include "RenderTheme.h"
37
38 #include <cairo.h>
39
40 typedef struct _Ecore_Evas Ecore_Evas;
41 typedef struct _Evas_Object Evas_Object;
42
43 namespace WebCore {
44
45 enum FormType { // KEEP IN SYNC WITH edjeGroupFromFormType()
46     Button,
47     RadioButton,
48     TextField,
49     CheckBox,
50     ComboBox,
51 #if ENABLE(PROGRESS_ELEMENT)
52     ProgressBar,
53 #endif
54     SearchField,
55     SearchFieldDecoration,
56     SearchFieldResultsButton,
57     SearchFieldResultsDecoration,
58     SearchFieldCancelButton,
59     SliderVertical,
60     SliderHorizontal,
61     SliderThumbVertical,
62     SliderThumbHorizontal,
63 #if ENABLE(VIDEO)
64     PlayPauseButton,
65     MuteUnMuteButton,
66     SeekForwardButton,
67     SeekBackwardButton,
68     FullScreenButton,
69     SliderThumb,
70 #endif
71     Spinner,
72     FormTypeLast
73 };
74
75 class RenderThemeEfl : public RenderTheme {
76 private:
77     RenderThemeEfl(Page*);
78     ~RenderThemeEfl();
79
80 public:
81     static PassRefPtr<RenderTheme> create(Page*);
82
83     // A method asking if the theme's controls actually care about redrawing when hovered.
84     virtual bool supportsHover(const RenderStyle*) const { return true; }
85
86     // A method asking if the theme is able to draw the focus ring.
87     virtual bool supportsFocusRing(const RenderStyle*) const;
88
89     // A method asking if the control changes its tint when the window has focus or not.
90     virtual bool controlSupportsTints(const RenderObject*) const;
91
92     // A general method asking if any control tinting is supported at all.
93     virtual bool supportsControlTints() const { return true; }
94
95     // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
96     // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
97     // controls that need to do this.
98     virtual LayoutUnit baselinePosition(const RenderObject*) const;
99
100     virtual Color platformActiveSelectionBackgroundColor() const { return m_activeSelectionBackgroundColor; }
101     virtual Color platformInactiveSelectionBackgroundColor() const { return m_inactiveSelectionBackgroundColor; }
102     virtual Color platformActiveSelectionForegroundColor() const { return m_activeSelectionForegroundColor; }
103     virtual Color platformInactiveSelectionForegroundColor() const { return m_inactiveSelectionForegroundColor; }
104     virtual Color platformFocusRingColor() const { return m_focusRingColor; }
105
106     virtual bool supportsSelectionForegroundColors() const { return m_supportsSelectionForegroundColors; }
107
108     virtual void themeChanged();
109
110     // Set platform colors and notify they changed
111     void setSelectionForegroundColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
112     void setSelectionBackgroundColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
113     void setFocusRingColor(int r, int g, int b, int a);
114
115     void setButtonTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
116     void setComboTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
117     void setEntryTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
118     void setSearchTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
119
120     void adjustSizeConstraints(RenderStyle*, FormType) const;
121
122
123     // System fonts.
124     virtual void systemFont(int propId, FontDescription&) const;
125
126     virtual void adjustCheckboxStyle(StyleResolver*, RenderStyle*, Element*) const;
127     virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&);
128
129     virtual void adjustRadioStyle(StyleResolver*, RenderStyle*, Element*) const;
130     virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&);
131
132     virtual void adjustButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
133     virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
134
135     virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
136     virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
137
138     virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const;
139     virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
140
141     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const;
142     virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
143
144     virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
145     virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
146
147     virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
148     virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
149
150     virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
151     virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&);
152
153     virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
154     virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
155
156     virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
157     virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
158
159     virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
160     virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
161
162     virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const;
163     virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
164
165     virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const;
166
167     virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
168
169 #if ENABLE(DATALIST_ELEMENT)
170     virtual IntSize sliderTickSize() const OVERRIDE;
171     virtual int sliderTickOffsetFromTrackCenter() const OVERRIDE;
172 #endif
173
174     virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
175
176     virtual void adjustInnerSpinButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
177     virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
178
179     static void setDefaultFontSize(int fontsize);
180
181 #if ENABLE(PROGRESS_ELEMENT)
182     virtual void adjustProgressBarStyle(StyleResolver*, RenderStyle*, Element*) const;
183     virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
184     virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const;
185     virtual double animationDurationForProgressBar(RenderProgress*) const;
186 #endif
187
188 #if ENABLE(VIDEO)
189     virtual String extraMediaControlsStyleSheet();
190 #if ENABLE(FULLSCREEN_API)
191 #if ENABLE(TIZEN_MEDIA_CONTROL_USER_AGENT_SHEET)
192     virtual String extraFullScreenHorizontalStyleSheet();
193     virtual String extraFullScreenVerticalStyleSheet();
194 #else
195     virtual String extraFullScreenStyleSheet();
196 #endif
197 #endif
198     virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
199     virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return true; }
200
201     virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
202     virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
203     virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
204     virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
205     virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
206     virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
207     virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
208     virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
209     virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
210     virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
211     virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&);
212 #if ENABLE(TIZEN_GSTREAMER_VIDEO)
213     virtual bool paintMediaTimeRemaining(RenderObject* object, const PaintInfo& info, const IntRect& rect);
214 #endif
215 #endif
216     virtual bool shouldShowPlaceholderWhenFocused() const OVERRIDE { return true; }
217
218 #if ENABLE(TIZEN_MULTIPLE_SELECT)
219     virtual bool delegatesMenuListRendering() const { return true; }
220 #endif
221     void setThemePath(const String&);
222     String themePath() { return m_themePath; }
223
224 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
225     virtual Color platformTapHighlightColor() const OVERRIDE
226     {
227         return RenderThemeEfl::defaultTapHighlightColor;
228     }
229 #endif
230
231 protected:
232     static float defaultFontSize;
233
234 private:
235     void createCanvas();
236     void createEdje();
237     void applyEdjeColors();
238     void applyPartDescriptions();
239     const char* edjeGroupFromFormType(FormType) const;
240     void applyEdjeStateFromForm(Evas_Object*, ControlStates);
241     bool paintThemePart(RenderObject*, FormType, const PaintInfo&, const IntRect&);
242     bool isFormElementTooLargeToDisplay(const IntSize&);
243 #if ENABLE(TIZEN_THEME_STYLE_WORKAROUND)
244     bool paintTransparentMenuList(RenderObject*, const PaintInfo&, const IntRect&);
245 #endif
246
247 #if ENABLE(VIDEO)
248     bool emitMediaButtonSignal(FormType, MediaControlElementType, const IntRect&);
249 #endif
250
251     Page* m_page;
252     Color m_activeSelectionBackgroundColor;
253     Color m_activeSelectionForegroundColor;
254     Color m_inactiveSelectionBackgroundColor;
255     Color m_inactiveSelectionForegroundColor;
256     Color m_focusRingColor;
257     Color m_sliderThumbColor;
258
259 #if ENABLE(VIDEO)
260     Color m_mediaPanelColor;
261     Color m_mediaSliderColor;
262 #if ENABLE(TIZEN_GSTREAMER_VIDEO)
263     Color m_mediaBufferingColor;
264     Color m_mediaPlayingColor;
265 #endif
266 #endif
267
268     String m_themePath;
269     Ecore_Evas* m_canvas;
270     Evas_Object* m_edje;
271
272     bool m_supportsSelectionForegroundColors;
273
274     struct ThemePartDesc {
275         FormType type;
276         LengthSize min;
277         LengthSize max;
278         LengthBox padding;
279     };
280     void applyPartDescriptionFallback(struct ThemePartDesc*);
281     void applyPartDescription(Evas_Object*, struct ThemePartDesc*);
282
283     struct ThemePartCacheEntry {
284         FormType type;
285         IntSize size;
286         Ecore_Evas* ee;
287         Evas_Object* o;
288         cairo_surface_t* surface;
289     };
290
291     struct ThemePartDesc m_partDescs[FormTypeLast];
292
293     // this should be small and not so frequently used,
294     // so use a vector and do linear searches
295     Vector<struct ThemePartCacheEntry *> m_partCache;
296
297     // get (use, create or replace) entry from cache
298     struct ThemePartCacheEntry* cacheThemePartGet(FormType, const IntSize&);
299     // flush cache, deleting all entries
300     void cacheThemePartFlush();
301
302     // internal, used by cacheThemePartGet()
303     bool themePartCacheEntryReset(struct ThemePartCacheEntry*, FormType);
304     bool themePartCacheEntrySurfaceCreate(struct ThemePartCacheEntry*);
305     struct ThemePartCacheEntry* cacheThemePartNew(FormType, const IntSize&);
306     struct ThemePartCacheEntry* cacheThemePartReset(FormType, struct ThemePartCacheEntry*);
307     struct ThemePartCacheEntry* cacheThemePartResizeAndReset(FormType, const IntSize&, struct ThemePartCacheEntry*);
308
309 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
310     static const RGBA32 defaultTapHighlightColor = 0x99ff8f25;
311 #endif
312
313 };
314 }
315
316 #endif // RenderThemeEfl_h