2 * This file is part of the theme implementation for form controls in WebCore.
4 * Copyright (C) 2005, 2006, 2007, 2008 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.
26 #include "RenderObject.h"
30 #include "ThemeTypes.h"
43 virtual ~RenderTheme() { }
45 // This method is called whenever style has been computed for an element and the appearance
46 // property has been set to a value other than "none". The theme should map in all of the appropriate
47 // metrics and defaults given the contents of the style. This includes sophisticated operations like
48 // selection of control size based off the font, the disabling of appearance when certain other properties like
49 // "border" are set, or if the appearance is not supported by the theme.
50 void adjustStyle(CSSStyleSelector
*, RenderStyle
*, Element
*, bool UAHasAppearance
,
51 const BorderData
&, const FillLayer
&, const Color
& backgroundColor
);
53 // This method is called to paint the widget as a background of the RenderObject. A widget's foreground, e.g., the
54 // text of a button, is always rendered by the engine itself. The boolean return value indicates
55 // whether the CSS border/background should also be painted.
56 bool paint(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
57 bool paintBorderOnly(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
58 bool paintDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
60 // The remaining methods should be implemented by the platform-specific portion of the theme, e.g.,
61 // RenderThemeMac.cpp for Mac OS X.
63 // These methods return the theme's extra style sheets rules, to let each platform
64 // adjust the default CSS rules in html4.css, quirks.css, or mediaControls.css
65 virtual String
extraDefaultStyleSheet() { return String(); }
66 virtual String
extraQuirksStyleSheet() { return String(); }
68 virtual String
extraMediaControlsStyleSheet() { return String(); };
71 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
72 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
73 // controls that need to do this.
74 virtual int baselinePosition(const RenderObject
*) const;
76 // A method for asking if a control is a container or not. Leaf controls have to have some special behavior (like
77 // the baseline position API above).
78 bool isControlContainer(ControlPart
) const;
80 // A method asking if the control changes its tint when the window has focus or not.
81 virtual bool controlSupportsTints(const RenderObject
*) const { return false; }
83 // Whether or not the control has been styled enough by the author to disable the native appearance.
84 virtual bool isControlStyled(const RenderStyle
*, const BorderData
&, const FillLayer
&, const Color
& backgroundColor
) const;
86 // A general method asking if any control tinting is supported at all.
87 virtual bool supportsControlTints() const { return false; }
89 // Some controls may spill out of their containers (e.g., the check on an OS X checkbox). When these controls repaint,
90 // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
91 virtual void adjustRepaintRect(const RenderObject
*, IntRect
&);
93 // This method is called whenever a relevant state changes on a particular themed object, e.g., the mouse becomes pressed
94 // or a control becomes disabled.
95 virtual bool stateChanged(RenderObject
*, ControlState
) const;
97 // This method is called whenever the theme changes on the system in order to flush cached resources from the
99 virtual void themeChanged() { }
101 // A method asking if the theme is able to draw the focus ring.
102 virtual bool supportsFocusRing(const RenderStyle
*) const;
104 // A method asking if the theme's controls actually care about redrawing when hovered.
105 virtual bool supportsHover(const RenderStyle
*) const { return false; }
107 // Text selection colors.
108 Color
activeSelectionBackgroundColor() const;
109 Color
inactiveSelectionBackgroundColor() const;
110 Color
activeSelectionForegroundColor() const;
111 Color
inactiveSelectionForegroundColor() const;
113 // List box selection colors
114 Color
activeListBoxSelectionBackgroundColor() const;
115 Color
activeListBoxSelectionForegroundColor() const;
116 Color
inactiveListBoxSelectionBackgroundColor() const;
117 Color
inactiveListBoxSelectionForegroundColor() const;
119 virtual Color
platformTextSearchHighlightColor() const;
121 virtual void platformColorsDidChange();
123 virtual double caretBlinkInterval() const { return 0.5; }
125 // System fonts and colors for CSS.
126 virtual Color
systemColor(int cssValueId
) const;
128 virtual int minimumMenuListSize(RenderStyle
*) const { return 0; }
130 virtual void adjustButtonInnerStyle(RenderStyle
*) const;
131 virtual void adjustSliderThumbSize(RenderObject
*) const;
133 virtual int popupInternalPaddingLeft(RenderStyle
*) const { return 0; }
134 virtual int popupInternalPaddingRight(RenderStyle
*) const { return 0; }
135 virtual int popupInternalPaddingTop(RenderStyle
*) const { return 0; }
136 virtual int popupInternalPaddingBottom(RenderStyle
*) const { return 0; }
138 // Method for painting the caps lock indicator
139 virtual bool paintCapsLockIndicator(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return 0; };
141 virtual bool paintCheckboxDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
142 virtual bool paintRadioDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
143 virtual bool paintButtonDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
144 virtual bool paintPushButtonDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
145 virtual bool paintSquareButtonDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
146 virtual bool paintTextFieldDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
147 virtual bool paintTextAreaDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
148 virtual bool paintMenuListDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
149 virtual bool paintMenuListButtonDecorations(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
153 virtual bool hitTestMediaControlPart(RenderObject
*, const IntPoint
& absPoint
);
157 // The platform selection color.
158 virtual Color
platformActiveSelectionBackgroundColor() const;
159 virtual Color
platformInactiveSelectionBackgroundColor() const;
160 virtual Color
platformActiveSelectionForegroundColor() const;
161 virtual Color
platformInactiveSelectionForegroundColor() const;
163 virtual Color
platformActiveListBoxSelectionBackgroundColor() const;
164 virtual Color
platformInactiveListBoxSelectionBackgroundColor() const;
165 virtual Color
platformActiveListBoxSelectionForegroundColor() const;
166 virtual Color
platformInactiveListBoxSelectionForegroundColor() const;
168 virtual bool supportsSelectionForegroundColors() const { return true; }
169 virtual bool supportsListBoxSelectionForegroundColors() const { return true; }
172 // Methods for each appearance value.
173 virtual void adjustCheckboxStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
174 virtual bool paintCheckbox(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
175 virtual void setCheckboxSize(RenderStyle
*) const { }
177 virtual void adjustRadioStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
178 virtual bool paintRadio(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
179 virtual void setRadioSize(RenderStyle
*) const { }
181 virtual void adjustButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
182 virtual bool paintButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
183 virtual void setButtonSize(RenderStyle
*) const { }
186 virtual void adjustTextFieldStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
187 virtual bool paintTextField(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
189 virtual void adjustTextAreaStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
190 virtual bool paintTextArea(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
192 virtual void adjustMenuListStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
193 virtual bool paintMenuList(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
195 virtual void adjustMenuListButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
196 virtual bool paintMenuListButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
198 virtual void adjustSliderTrackStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
199 virtual bool paintSliderTrack(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
201 virtual void adjustSliderThumbStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
202 virtual bool paintSliderThumb(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
204 virtual void adjustSearchFieldStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
205 virtual bool paintSearchField(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
207 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
208 virtual bool paintSearchFieldCancelButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
210 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
211 virtual bool paintSearchFieldDecoration(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
213 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
214 virtual bool paintSearchFieldResultsDecoration(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
216 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
217 virtual bool paintSearchFieldResultsButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
219 virtual bool paintMediaFullscreenButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
220 virtual bool paintMediaPlayButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
221 virtual bool paintMediaMuteButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
222 virtual bool paintMediaSeekBackButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
223 virtual bool paintMediaSeekForwardButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
224 virtual bool paintMediaSliderTrack(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
225 virtual bool paintMediaSliderThumb(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
226 virtual bool paintMediaTimelineContainer(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
227 virtual bool paintMediaCurrentTime(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
228 virtual bool paintMediaTimeRemaining(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&) { return true; }
231 // Methods for state querying
232 ControlStates
controlStatesForRenderer(const RenderObject
* o
) const;
233 bool isActive(const RenderObject
*) const;
234 bool isChecked(const RenderObject
*) const;
235 bool isIndeterminate(const RenderObject
*) const;
236 bool isEnabled(const RenderObject
*) const;
237 bool isFocused(const RenderObject
*) const;
238 bool isPressed(const RenderObject
*) const;
239 bool isHovered(const RenderObject
*) const;
240 bool isReadOnlyControl(const RenderObject
*) const;
241 bool isDefault(const RenderObject
*) const;
244 mutable Color m_activeSelectionBackgroundColor
;
245 mutable Color m_inactiveSelectionBackgroundColor
;
246 mutable Color m_activeSelectionForegroundColor
;
247 mutable Color m_inactiveSelectionForegroundColor
;
249 mutable Color m_activeListBoxSelectionBackgroundColor
;
250 mutable Color m_inactiveListBoxSelectionBackgroundColor
;
251 mutable Color m_activeListBoxSelectionForegroundColor
;
252 mutable Color m_inactiveListBoxSelectionForegroundColor
;
255 Theme
* m_theme
; // The platform-specific theme.
259 // Function to obtain the theme. This is implemented in your platform-specific theme implementation to hand
260 // back the appropriate platform theme.
261 RenderTheme
* theme();
263 } // namespace WebCore
265 #endif // RenderTheme_h