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 <Eina.h> 39#include <cairo.h> 40#include <wtf/efl/RefPtrEfl.h> 41 42namespace WebCore { 43 44enum FormType { // KEEP IN SYNC WITH edjeGroupFromFormType() 45 Button, 46 RadioButton, 47 TextField, 48 CheckBox, 49 ComboBox, 50#if ENABLE(PROGRESS_ELEMENT) 51 ProgressBar, 52#endif 53 SearchField, 54 SearchFieldDecoration, 55 SearchFieldResultsButton, 56 SearchFieldResultsDecoration, 57 SearchFieldCancelButton, 58 SliderVertical, 59 SliderHorizontal, 60 SliderThumbVertical, 61 SliderThumbHorizontal, 62#if ENABLE(VIDEO) 63 PlayPauseButton, 64 MuteUnMuteButton, 65 SeekForwardButton, 66 SeekBackwardButton, 67 FullScreenButton, 68#endif 69#if ENABLE(VIDEO_TRACK) 70 ToggleCaptionsButton, 71#endif 72 Spinner, 73 FormTypeLast 74}; 75 76class RenderThemeEfl : public RenderTheme { 77private: 78 explicit RenderThemeEfl(Page*); 79 ~RenderThemeEfl(); 80 81public: 82 static PassRefPtr<RenderTheme> create(Page*); 83 84 // A method asking if the theme's controls actually care about redrawing when hovered. 85 virtual bool supportsHover(const RenderStyle*) const { return true; } 86 87 // A method asking if the theme is able to draw the focus ring. 88 virtual bool supportsFocusRing(const RenderStyle*) const; 89 90 // A method asking if the control changes its tint when the window has focus or not. 91 virtual bool controlSupportsTints(const RenderObject*) const; 92 93 // A general method asking if any control tinting is supported at all. 94 virtual bool supportsControlTints() const { return true; } 95 96 // A general method asking if foreground colors of selection are supported. 97 virtual bool supportsSelectionForegroundColors() const; 98 99 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline 100 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of 101 // controls that need to do this. 102 virtual int baselinePosition(const RenderObject*) const; 103 104 virtual Color platformActiveSelectionBackgroundColor() const; 105 virtual Color platformInactiveSelectionBackgroundColor() const; 106 virtual Color platformActiveSelectionForegroundColor() const; 107 virtual Color platformInactiveSelectionForegroundColor() const; 108 virtual Color platformFocusRingColor() const; 109 110 // Set platform colors; remember to call platformColorDidChange after. 111 void setColorFromThemeClass(const char* colorClass); 112 113 void setButtonTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA); 114 void setComboTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA); 115 void setEntryTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA); 116 void setSearchTextColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA); 117 118 void adjustSizeConstraints(RenderStyle*, FormType) const; 119 120 // System fonts. 121 virtual void systemFont(int propId, FontDescription&) const; 122 123 virtual void adjustCheckboxStyle(StyleResolver*, RenderStyle*, Element*) const; 124 virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&); 125 126 virtual void adjustRadioStyle(StyleResolver*, RenderStyle*, Element*) const; 127 virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&); 128 129 virtual void adjustButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 130 virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); 131 132 virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle*, Element*) const; 133 virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); 134 135 virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const; 136 virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); 137 138 virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const; 139 virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); 140 141 virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 142 virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); 143 144 virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const; 145 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&); 146 147 virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const; 148 virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&); 149 150 virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const; 151 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); 152 153 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 154 virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&); 155 156 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 157 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&); 158 159 virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const; 160 virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 161 162 virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const; 163 164 virtual void adjustSliderThumbSize(RenderStyle*, Element*) const; 165 166#if ENABLE(DATALIST_ELEMENT) 167 virtual IntSize sliderTickSize() const OVERRIDE; 168 virtual int sliderTickOffsetFromTrackCenter() const OVERRIDE; 169 virtual LayoutUnit sliderTickSnappingThreshold() const OVERRIDE; 170#endif 171 172 virtual bool supportsDataListUI(const AtomicString&) const OVERRIDE; 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 virtual String extraFullScreenStyleSheet(); 192#endif 193 virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const; 194 virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const; 195 196 virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&); 197 virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&); 198 virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&); 199 virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&); 200 virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&); 201 virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 202 virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 203 virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&); 204 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 205 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 206 virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&); 207#endif 208#if ENABLE(VIDEO_TRACK) 209 virtual bool supportsClosedCaptioning() const OVERRIDE; 210 virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 211#endif 212 virtual bool shouldShowPlaceholderWhenFocused() const OVERRIDE { return true; } 213 214 void setThemePath(const String&); 215 String themePath() const; 216 217protected: 218 static float defaultFontSize; 219 220private: 221 bool loadTheme(); 222 ALWAYS_INLINE bool loadThemeIfNeeded() const 223 { 224 return m_edje || (!m_themePath.isEmpty() && const_cast<RenderThemeEfl*>(this)->loadTheme()); 225 } 226 227 ALWAYS_INLINE Ecore_Evas* canvas() const { return m_canvas.get(); } 228 ALWAYS_INLINE Evas_Object* edje() const { return m_edje.get(); } 229 230 void applyPartDescriptionsFrom(const String& themePath); 231 232 void applyEdjeStateFromForm(Evas_Object*, ControlStates); 233 void applyEdjeRTLState(Evas_Object*, RenderObject*, FormType, const IntRect&); 234 bool paintThemePart(RenderObject*, FormType, const PaintInfo&, const IntRect&); 235 236#if ENABLE(VIDEO) 237 bool emitMediaButtonSignal(FormType, MediaControlElementType, const IntRect&); 238#endif 239 240 Page* m_page; 241 Color m_activeSelectionBackgroundColor; 242 Color m_activeSelectionForegroundColor; 243 Color m_inactiveSelectionBackgroundColor; 244 Color m_inactiveSelectionForegroundColor; 245 Color m_focusRingColor; 246 Color m_sliderThumbColor; 247 248#if ENABLE(VIDEO) 249 Color m_mediaPanelColor; 250 Color m_mediaSliderColor; 251#endif 252 253 String m_themePath; 254 // Order so that the canvas gets destroyed at last. 255 OwnPtr<Ecore_Evas> m_canvas; 256 RefPtr<Evas_Object> m_edje; 257 258 bool m_supportsSelectionForegroundColor; 259 260 struct ThemePartDesc { 261 FormType type; 262 LengthSize min; 263 LengthSize max; 264 LengthBox padding; 265 }; 266 void applyPartDescriptionFallback(struct ThemePartDesc*); 267 void applyPartDescription(Evas_Object*, struct ThemePartDesc*); 268 269 struct ThemePartCacheEntry { 270 static PassOwnPtr<RenderThemeEfl::ThemePartCacheEntry> create(const String& themePath, FormType, const IntSize&); 271 void reuse(const String& themePath, FormType, const IntSize&); 272 273 ALWAYS_INLINE Ecore_Evas* canvas() { return m_canvas.get(); } 274 ALWAYS_INLINE Evas_Object* edje() { return m_edje.get(); } 275 ALWAYS_INLINE cairo_surface_t* surface() { return m_surface.get(); } 276 277 FormType type; 278 IntSize size; 279 280 private: 281 // Order so that the canvas gets destroyed at last. 282 OwnPtr<Ecore_Evas> m_canvas; 283 RefPtr<Evas_Object> m_edje; 284 RefPtr<cairo_surface_t> m_surface; 285 }; 286 287 struct ThemePartDesc m_partDescs[FormTypeLast]; 288 289 // List of ThemePartCacheEntry* sorted so that the most recently 290 // used entries come first. We use a list for efficient moving 291 // of items within the container. 292 Eina_List* m_partCache; 293 294 ThemePartCacheEntry* getThemePartFromCache(FormType, const IntSize&); 295 void clearThemePartCache(); 296}; 297} 298 299#endif // RenderThemeEfl_h 300