2 * This file is part of the theme implementation for form controls in WebCore.
4 * Copyright (C) 2005 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"
46 virtual ~RenderTheme() { }
48 // This method is called whenever style has been computed for an element and the appearance
49 // property has been set to a value other than "none". The theme should map in all of the appropriate
50 // metrics and defaults given the contents of the style. This includes sophisticated operations like
51 // selection of control size based off the font, the disabling of appearance when certain other properties like
52 // "border" are set, or if the appearance is not supported by the theme.
53 void adjustStyle(CSSStyleSelector*, RenderStyle*, Element*, bool UAHasAppearance,
54 const BorderData&, const BackgroundLayer&, const Color& backgroundColor);
56 // This method is called to paint the widget as a background of the RenderObject. A widget's foreground, e.g., the
57 // text of a button, is always rendered by the engine itself. The boolean return value indicates
58 // whether the CSS border/background should also be painted.
59 bool paint(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
60 bool paintBorderOnly(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
61 bool paintDecorations(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
63 // The remaining methods should be implemented by the platform-specific portion of the theme, e.g.,
64 // RenderThemeMac.cpp for Mac OS X.
66 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
67 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
68 // controls that need to do this.
69 virtual short baselinePosition(const RenderObject*) const;
71 // A method for asking if a control is a container or not. Leaf controls have to have some special behavior (like
72 // the baseline position API above).
73 virtual bool isControlContainer(EAppearance) const;
75 // A method asking if the control changes its tint when the window has focus or not.
76 virtual bool controlSupportsTints(const RenderObject*) const { return false; }
78 // Whether or not the control has been styled enough by the author to disable the native appearance.
79 virtual bool isControlStyled(const RenderStyle*, const BorderData&, const BackgroundLayer&, const Color& backgroundColor) const;
81 // A general method asking if any control tinting is supported at all.
82 virtual bool supportsControlTints() const { return false; }
84 // Some controls may spill out of their containers (e.g., the check on an OS X checkbox). When these controls repaint,
85 // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
86 virtual void adjustRepaintRect(const RenderObject*, IntRect&) { }
88 // This method is called whenever a relevant state changes on a particular themed object, e.g., the mouse becomes pressed
89 // or a control becomes disabled.
90 virtual bool stateChanged(RenderObject*, ControlState) const;
92 // This method is called whenever the theme changes on the system in order to flush cached resources from the
94 virtual void themeChanged() { }
96 // A method asking if the theme is able to draw the focus ring.
97 virtual bool supportsFocusRing(const RenderStyle*) const;
99 // A method asking if the theme's controls actually care about redrawing when hovered.
100 virtual bool supportsHover(const RenderStyle*) const { return false; }
102 // The selection color.
103 Color activeSelectionBackgroundColor() const;
104 Color inactiveSelectionBackgroundColor() const;
106 virtual Color platformTextSearchHighlightColor() const;
108 // The platform selection color.
109 virtual Color platformActiveSelectionBackgroundColor() const;
110 virtual Color platformInactiveSelectionBackgroundColor() const;
111 virtual Color platformActiveSelectionForegroundColor() const;
112 virtual Color platformInactiveSelectionForegroundColor() const;
114 // List Box selection color
115 virtual Color activeListBoxSelectionBackgroundColor() const;
116 virtual Color activeListBoxSelectionForegroundColor() const;
117 virtual Color inactiveListBoxSelectionBackgroundColor() const;
118 virtual Color inactiveListBoxSelectionForegroundColor() const;
120 virtual void platformColorsDidChange();
122 virtual double caretBlinkFrequency() const { return 0.5; }
124 // System fonts and colors for CSS.
125 virtual void systemFont(int cssValueId, FontDescription&) const = 0;
126 virtual Color systemColor(int cssValueId) const;
128 virtual int minimumMenuListSize(RenderStyle*) const { return 0; }
130 virtual void adjustSliderThumbSize(RenderObject*) const;
132 // Methods for state querying
133 bool isChecked(const RenderObject*) const;
134 bool isIndeterminate(const RenderObject*) const;
135 bool isEnabled(const RenderObject*) const;
136 bool isFocused(const RenderObject*) const;
137 bool isPressed(const RenderObject*) const;
138 bool isHovered(const RenderObject*) const;
139 bool isReadOnlyControl(const RenderObject*) const;
141 virtual int popupInternalPaddingLeft(RenderStyle*) const { return 0; }
142 virtual int popupInternalPaddingRight(RenderStyle*) const { return 0; }
143 virtual int popupInternalPaddingTop(RenderStyle*) const { return 0; }
144 virtual int popupInternalPaddingBottom(RenderStyle*) const { return 0; }
146 // Method for painting the caps lock indicator
147 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return 0; };
150 // Methods for each appearance value.
151 virtual void adjustCheckboxStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
152 virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
153 virtual void setCheckboxSize(RenderStyle*) const { }
155 virtual void adjustRadioStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
156 virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
157 virtual void setRadioSize(RenderStyle*) const { }
159 virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
160 virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
161 virtual void setButtonSize(RenderStyle*) const { }
163 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
164 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
166 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
167 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
169 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
170 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
172 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
173 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
175 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
176 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
178 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
179 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
181 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
182 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
184 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
185 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
187 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
188 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
190 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
191 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
193 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
194 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; }
197 mutable Color m_activeSelectionColor;
198 mutable Color m_inactiveSelectionColor;
201 // Function to obtain the theme. This is implemented in your platform-specific theme implementation to hand
202 // back the appropriate platform theme.
203 RenderTheme* theme();
205 } // namespace WebCore
207 #endif // RenderTheme_h