Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: Source/core/layout/LayoutTheme.h

Issue 1102353008: Split ThemePainter out of LayoutTheme (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Android build Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutTextControlSingleLine.cpp ('k') | Source/core/layout/LayoutTheme.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the theme implementation for form controls in WebCore. 2 * This file is part of the theme implementation for form controls in WebCore.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 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 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, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef LayoutTheme_h 23 #ifndef LayoutTheme_h
24 #define LayoutTheme_h 24 #define LayoutTheme_h
25 25
26 #include "core/CoreExport.h" 26 #include "core/CoreExport.h"
27 #include "core/layout/LayoutObject.h" 27 #include "core/layout/LayoutObject.h"
28 #if USE(NEW_THEME)
29 #include "platform/Theme.h"
30 #else
31 #include "platform/ThemeTypes.h" 28 #include "platform/ThemeTypes.h"
32 #endif
33 #include "platform/scroll/ScrollTypes.h" 29 #include "platform/scroll/ScrollTypes.h"
34 #include "wtf/PassRefPtr.h" 30 #include "wtf/PassRefPtr.h"
35 #include "wtf/RefCounted.h" 31 #include "wtf/RefCounted.h"
36 #include "wtf/text/WTFString.h" 32 #include "wtf/text/WTFString.h"
37 33
38 namespace blink { 34 namespace blink {
39 35
40 class AuthorStyleInfo; 36 class AuthorStyleInfo;
37 class ComputedStyle;
41 class Element; 38 class Element;
42 class FileList; 39 class FileList;
43 class HTMLInputElement; 40 class HTMLInputElement;
44 class LayoutMeter; 41 class LayoutMeter;
45 class LayoutProgress; 42 class Theme;
46 43 class ThemePainter;
47 44
48 class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> { 45 class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> {
49 protected: 46 protected:
50 LayoutTheme(); 47 LayoutTheme();
51 48
52 public: 49 public:
53 virtual ~LayoutTheme() { } 50 virtual ~LayoutTheme() { }
54 51
55 // This function is to be implemented in your platform-specific theme implem entation to hand back the 52 // This function is to be implemented in your platform-specific theme implem entation to hand back the
56 // appropriate platform theme. 53 // appropriate platform theme.
57 static LayoutTheme& theme(); 54 static LayoutTheme& theme();
58 55
56 virtual ThemePainter& painter() = 0;
57 static ThemePainter& themePainter() { return theme().painter(); }
chrishtr 2015/04/30 20:16:16 I'd say get rid of themePainter(), it doesn't seem
Xianzhu 2015/04/30 21:08:42 Done.
58
59 static void setSizeIfAuto(ComputedStyle&, const IntSize&); 59 static void setSizeIfAuto(ComputedStyle&, const IntSize&);
60 60
61 // This method is called whenever style has been computed for an element and the appearance 61 // This method is called whenever style has been computed for an element and the appearance
62 // property has been set to a value other than "none". The theme should map in all of the appropriate 62 // property has been set to a value other than "none". The theme should map in all of the appropriate
63 // metrics and defaults given the contents of the style. This includes soph isticated operations like 63 // metrics and defaults given the contents of the style. This includes soph isticated operations like
64 // selection of control size based off the font, the disabling of appearance when certain other properties like 64 // selection of control size based off the font, the disabling of appearance when certain other properties like
65 // "border" are set, or if the appearance is not supported by the theme. 65 // "border" are set, or if the appearance is not supported by the theme.
66 void adjustStyle(ComputedStyle&, Element*, const AuthorStyleInfo&); 66 void adjustStyle(ComputedStyle&, Element*, const AuthorStyleInfo&);
67 67
68 // This method is called to paint the widget as a background of the LayoutOb ject. A widget's foreground, e.g., the
69 // text of a button, is always laid out by the engine itself. The boolean r eturn value indicates
70 // whether the CSS border/background should also be painted.
71 bool paint(LayoutObject*, const PaintInfo&, const IntRect&);
72 bool paintBorderOnly(LayoutObject*, const PaintInfo&, const IntRect&);
73 bool paintDecorations(LayoutObject*, const PaintInfo&, const IntRect&);
74
75 // The remaining methods should be implemented by the platform-specific port ion of the theme, e.g., 68 // The remaining methods should be implemented by the platform-specific port ion of the theme, e.g.,
76 // LayoutThemeMac.cpp for Mac OS X. 69 // LayoutThemeMac.cpp for Mac OS X.
77 70
78 // These methods return the theme's extra style sheets rules, to let each pl atform 71 // These methods return the theme's extra style sheets rules, to let each pl atform
79 // adjust the default CSS rules in html.css, quirks.css or mediaControls.css . 72 // adjust the default CSS rules in html.css, quirks.css or mediaControls.css .
80 virtual String extraDefaultStyleSheet(); 73 virtual String extraDefaultStyleSheet();
81 virtual String extraQuirksStyleSheet() { return String(); } 74 virtual String extraQuirksStyleSheet() { return String(); }
82 virtual String extraMediaControlsStyleSheet() { return String(); } 75 virtual String extraMediaControlsStyleSheet() { return String(); }
83 virtual String extraFullScreenStyleSheet() { return String(); } 76 virtual String extraFullScreenStyleSheet() { return String(); }
84 77
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 virtual void adjustSliderThumbSize(ComputedStyle&, Element*) const; 141 virtual void adjustSliderThumbSize(ComputedStyle&, Element*) const;
149 142
150 virtual int popupInternalPaddingLeft(const ComputedStyle&) const { return 0; } 143 virtual int popupInternalPaddingLeft(const ComputedStyle&) const { return 0; }
151 virtual int popupInternalPaddingRight(const ComputedStyle&) const { return 0 ; } 144 virtual int popupInternalPaddingRight(const ComputedStyle&) const { return 0 ; }
152 virtual int popupInternalPaddingTop(const ComputedStyle&) const { return 0; } 145 virtual int popupInternalPaddingTop(const ComputedStyle&) const { return 0; }
153 virtual int popupInternalPaddingBottom(const ComputedStyle&) const { return 0; } 146 virtual int popupInternalPaddingBottom(const ComputedStyle&) const { return 0; }
154 virtual bool popupOptionSupportsTextIndent() const { return false; } 147 virtual bool popupOptionSupportsTextIndent() const { return false; }
155 148
156 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { retu rn RegularScrollbar; } 149 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { retu rn RegularScrollbar; }
157 150
158 // Method for painting the caps lock indicator
159 virtual bool paintCapsLockIndicator(LayoutObject*, const PaintInfo&, const I ntRect&) { return 0; };
160
161 // Returns the repeat interval of the animation for the progress bar. 151 // Returns the repeat interval of the animation for the progress bar.
162 virtual double animationRepeatIntervalForProgressBar() const; 152 virtual double animationRepeatIntervalForProgressBar() const;
163 // Returns the duration of the animation for the progress bar. 153 // Returns the duration of the animation for the progress bar.
164 virtual double animationDurationForProgressBar() const; 154 virtual double animationDurationForProgressBar() const;
165 155
166 // Media controls 156 // Media controls
167 virtual String formatMediaControlsTime(float time) const; 157 String formatMediaControlsTime(float time) const;
168 virtual String formatMediaControlsCurrentTime(float currentTime, float durat ion) const; 158 String formatMediaControlsCurrentTime(float currentTime, float duration) con st;
169 159
170 virtual IntSize meterSizeForBounds(const LayoutMeter*, const IntRect&) const ; 160 virtual IntSize meterSizeForBounds(const LayoutMeter*, const IntRect&) const ;
171 virtual bool supportsMeter(ControlPart) const; 161 virtual bool supportsMeter(ControlPart) const;
172 162
173 // Returns size of one slider tick mark for a horizontal track. 163 // Returns size of one slider tick mark for a horizontal track.
174 // For vertical tracks we rotate it and use it. i.e. Width is always length along the track. 164 // For vertical tracks we rotate it and use it. i.e. Width is always length along the track.
175 virtual IntSize sliderTickSize() const = 0; 165 virtual IntSize sliderTickSize() const = 0;
176 // Returns the distance of slider tick origin from the slider track center. 166 // Returns the distance of slider tick origin from the slider track center.
177 virtual int sliderTickOffsetFromTrackCenter() const = 0; 167 virtual int sliderTickOffsetFromTrackCenter() const = 0;
178 void paintSliderTicks(LayoutObject*, const PaintInfo&, const IntRect&);
179 168
180 virtual bool shouldShowPlaceholderWhenFocused() const { return false; } 169 virtual bool shouldShowPlaceholderWhenFocused() const { return false; }
181 virtual bool shouldHaveSpinButton(HTMLInputElement*) const; 170 virtual bool shouldHaveSpinButton(HTMLInputElement*) const;
182 171
183 // Functions for <select> elements. 172 // Functions for <select> elements.
184 virtual bool delegatesMenuListRendering() const { return false; } 173 virtual bool delegatesMenuListRendering() const { return false; }
185 virtual bool popsMenuByArrowKeys() const { return false; } 174 virtual bool popsMenuByArrowKeys() const { return false; }
186 virtual bool popsMenuBySpaceKey() const { return false; } 175 virtual bool popsMenuBySpaceKey() const { return false; }
187 virtual bool popsMenuByReturnKey() const { return false; } 176 virtual bool popsMenuByReturnKey() const { return false; }
188 virtual bool popsMenuByAltDownUpOrF4Key() const { return false; } 177 virtual bool popsMenuByAltDownUpOrF4Key() const { return false; }
189 178
190 virtual String fileListNameForWidth(Locale&, const FileList*, const Font&, i nt width) const; 179 virtual String fileListNameForWidth(Locale&, const FileList*, const Font&, i nt width) const;
191 180
192 virtual bool shouldOpenPickerWithF4Key() const; 181 virtual bool shouldOpenPickerWithF4Key() const;
193 182
194 virtual bool supportsSelectionForegroundColors() const { return true; } 183 virtual bool supportsSelectionForegroundColors() const { return true; }
195 184
196 virtual bool isModalColorChooser() const { return true; } 185 virtual bool isModalColorChooser() const { return true; }
197 186
187 virtual bool shouldUseFallbackTheme(const ComputedStyle&) const;
188
198 protected: 189 protected:
199 // The platform selection color. 190 // The platform selection color.
200 virtual Color platformActiveSelectionBackgroundColor() const; 191 virtual Color platformActiveSelectionBackgroundColor() const;
201 virtual Color platformInactiveSelectionBackgroundColor() const; 192 virtual Color platformInactiveSelectionBackgroundColor() const;
202 virtual Color platformActiveSelectionForegroundColor() const; 193 virtual Color platformActiveSelectionForegroundColor() const;
203 virtual Color platformInactiveSelectionForegroundColor() const; 194 virtual Color platformInactiveSelectionForegroundColor() const;
204 195
205 virtual Color platformActiveListBoxSelectionBackgroundColor() const; 196 virtual Color platformActiveListBoxSelectionBackgroundColor() const;
206 virtual Color platformInactiveListBoxSelectionBackgroundColor() const; 197 virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
207 virtual Color platformActiveListBoxSelectionForegroundColor() const; 198 virtual Color platformActiveListBoxSelectionForegroundColor() const;
208 virtual Color platformInactiveListBoxSelectionForegroundColor() const; 199 virtual Color platformInactiveListBoxSelectionForegroundColor() const;
209 200
210 // A method asking if the theme is able to draw the focus ring. 201 // A method asking if the theme is able to draw the focus ring.
211 virtual bool supportsFocusRing(const ComputedStyle&) const; 202 virtual bool supportsFocusRing(const ComputedStyle&) const;
212 203
213 #if !USE(NEW_THEME) 204 #if !USE(NEW_THEME)
214 // Methods for each appearance value. 205 // Methods for each appearance value.
215 virtual void adjustCheckboxStyle(ComputedStyle&, Element*) const; 206 virtual void adjustCheckboxStyle(ComputedStyle&, Element*) const;
216 virtual bool paintCheckbox(LayoutObject*, const PaintInfo&, const IntRect&) { return true; }
217 virtual void setCheckboxSize(ComputedStyle&) const { } 207 virtual void setCheckboxSize(ComputedStyle&) const { }
218 208
219 virtual void adjustRadioStyle(ComputedStyle&, Element*) const; 209 virtual void adjustRadioStyle(ComputedStyle&, Element*) const;
220 virtual bool paintRadio(LayoutObject*, const PaintInfo&, const IntRect&) { r eturn true; }
221 virtual void setRadioSize(ComputedStyle&) const { } 210 virtual void setRadioSize(ComputedStyle&) const { }
222 211
223 virtual void adjustButtonStyle(ComputedStyle&, Element*) const; 212 virtual void adjustButtonStyle(ComputedStyle&, Element*) const;
224 virtual bool paintButton(LayoutObject*, const PaintInfo&, const IntRect&) { return true; }
225
226 virtual void adjustInnerSpinButtonStyle(ComputedStyle&, Element*) const; 213 virtual void adjustInnerSpinButtonStyle(ComputedStyle&, Element*) const;
227 virtual bool paintInnerSpinButton(LayoutObject*, const PaintInfo&, const Int Rect&) { return true; }
228 #endif 214 #endif
229 215
230 virtual bool paintTextField(LayoutObject*, const PaintInfo&, const IntRect&) { return true; }
231
232 virtual bool paintTextArea(LayoutObject*, const PaintInfo&, const IntRect&) { return true; }
233
234 virtual void adjustMenuListStyle(ComputedStyle&, Element*) const; 216 virtual void adjustMenuListStyle(ComputedStyle&, Element*) const;
235 virtual bool paintMenuList(LayoutObject*, const PaintInfo&, const IntRect&) { return true; }
236
237 virtual void adjustMenuListButtonStyle(ComputedStyle&, Element*) const; 217 virtual void adjustMenuListButtonStyle(ComputedStyle&, Element*) const;
238 virtual bool paintMenuListButton(LayoutObject*, const PaintInfo&, const IntR ect&) { return true; }
239
240 virtual bool paintMeter(LayoutObject*, const PaintInfo&, const IntRect&);
241
242 virtual bool paintProgressBar(LayoutObject*, const PaintInfo&, const IntRect &) { return true; }
243
244 virtual bool paintSliderTrack(LayoutObject*, const PaintInfo&, const IntRect &) { return true; }
245
246 virtual void adjustSliderThumbStyle(ComputedStyle&, Element*) const; 218 virtual void adjustSliderThumbStyle(ComputedStyle&, Element*) const;
247 virtual bool paintSliderThumb(LayoutObject*, const PaintInfo&, const IntRect &) { return true; }
248
249 virtual void adjustSearchFieldStyle(ComputedStyle&, Element*) const; 219 virtual void adjustSearchFieldStyle(ComputedStyle&, Element*) const;
250 virtual bool paintSearchField(LayoutObject*, const PaintInfo&, const IntRect &) { return true; }
251
252 virtual void adjustSearchFieldCancelButtonStyle(ComputedStyle&, Element*) co nst; 220 virtual void adjustSearchFieldCancelButtonStyle(ComputedStyle&, Element*) co nst;
253 virtual bool paintSearchFieldCancelButton(LayoutObject*, const PaintInfo&, c onst IntRect&) { return true; }
254
255 virtual void adjustSearchFieldDecorationStyle(ComputedStyle&, Element*) cons t; 221 virtual void adjustSearchFieldDecorationStyle(ComputedStyle&, Element*) cons t;
256 virtual bool paintSearchFieldDecoration(LayoutObject*, const PaintInfo&, con st IntRect&) { return true; }
257
258 virtual void adjustSearchFieldResultsDecorationStyle(ComputedStyle&, Element *) const; 222 virtual void adjustSearchFieldResultsDecorationStyle(ComputedStyle&, Element *) const;
259 virtual bool paintSearchFieldResultsDecoration(LayoutObject*, const PaintInf o&, const IntRect&) { return true; }
260
261 virtual bool paintMediaFullscreenButton(LayoutObject*, const PaintInfo&, con st IntRect&) { return true; }
262 virtual bool paintMediaPlayButton(LayoutObject*, const PaintInfo&, const Int Rect&) { return true; }
263 virtual bool paintMediaOverlayPlayButton(LayoutObject*, const PaintInfo&, co nst IntRect&) { return true; }
264 virtual bool paintMediaMuteButton(LayoutObject*, const PaintInfo&, const Int Rect&) { return true; }
265 virtual bool paintMediaSliderTrack(LayoutObject*, const PaintInfo&, const In tRect&) { return true; }
266 virtual bool paintMediaSliderThumb(LayoutObject*, const PaintInfo&, const In tRect&) { return true; }
267 virtual bool paintMediaVolumeSliderContainer(LayoutObject*, const PaintInfo& , const IntRect&) { return true; }
268 virtual bool paintMediaVolumeSliderTrack(LayoutObject*, const PaintInfo&, co nst IntRect&) { return true; }
269 virtual bool paintMediaVolumeSliderThumb(LayoutObject*, const PaintInfo&, co nst IntRect&) { return true; }
270 virtual bool paintMediaToggleClosedCaptionsButton(LayoutObject*, const Paint Info&, const IntRect&) { return true; }
271 virtual bool paintMediaCastButton(LayoutObject*, const PaintInfo&, const Int Rect&) { return true; };
272 virtual bool paintMediaControlsBackground(LayoutObject*, const PaintInfo&, c onst IntRect&) { return true; }
273 virtual bool paintMediaCurrentTime(LayoutObject*, const PaintInfo&, const In tRect&) { return true; }
274 virtual bool paintMediaTimeRemaining(LayoutObject*, const PaintInfo&, const IntRect&) { return true; }
275 virtual bool paintMediaFullScreenVolumeSliderTrack(LayoutObject*, const Pain tInfo&, const IntRect&) { return true; }
276 virtual bool paintMediaFullScreenVolumeSliderThumb(LayoutObject*, const Pain tInfo&, const IntRect&) { return true; }
277
278 virtual bool shouldUseFallbackTheme(const ComputedStyle&) const;
279 void adjustStyleUsingFallbackTheme(ComputedStyle&, Element*); 223 void adjustStyleUsingFallbackTheme(ComputedStyle&, Element*);
280 bool paintUsingFallbackTheme(LayoutObject*, const PaintInfo&, const IntRect& );
281 void adjustCheckboxStyleUsingFallbackTheme(ComputedStyle&, Element*) const; 224 void adjustCheckboxStyleUsingFallbackTheme(ComputedStyle&, Element*) const;
282 bool paintCheckboxUsingFallbackTheme(LayoutObject*, const PaintInfo&, const IntRect&);
283 void adjustRadioStyleUsingFallbackTheme(ComputedStyle&, Element*) const; 225 void adjustRadioStyleUsingFallbackTheme(ComputedStyle&, Element*) const;
284 bool paintRadioUsingFallbackTheme(LayoutObject*, const PaintInfo&, const Int Rect&);
285 226
286 public: 227 public:
287 // Methods for state querying 228 // Methods for state querying
288 ControlStates controlStatesForLayoutObject(const LayoutObject*) const; 229 static ControlStates controlStatesForLayoutObject(const LayoutObject*);
289 bool isActive(const LayoutObject*) const; 230 static bool isActive(const LayoutObject*);
290 bool isChecked(const LayoutObject*) const; 231 static bool isChecked(const LayoutObject*);
291 bool isIndeterminate(const LayoutObject*) const; 232 static bool isIndeterminate(const LayoutObject*);
292 bool isEnabled(const LayoutObject*) const; 233 static bool isEnabled(const LayoutObject*);
293 bool isFocused(const LayoutObject*) const; 234 static bool isFocused(const LayoutObject*);
294 bool isPressed(const LayoutObject*) const; 235 static bool isPressed(const LayoutObject*);
295 bool isSpinUpButtonPartPressed(const LayoutObject*) const; 236 static bool isSpinUpButtonPartPressed(const LayoutObject*);
296 bool isHovered(const LayoutObject*) const; 237 static bool isHovered(const LayoutObject*);
297 bool isSpinUpButtonPartHovered(const LayoutObject*) const; 238 static bool isSpinUpButtonPartHovered(const LayoutObject*);
298 bool isReadOnlyControl(const LayoutObject*) const; 239 static bool isReadOnlyControl(const LayoutObject*);
299 240
300 private: 241 private:
301 Color m_customFocusRingColor; 242 Color m_customFocusRingColor;
302 bool m_hasCustomFocusRingColor; 243 bool m_hasCustomFocusRingColor;
303 244
304 // This color is expected to be drawn on a semi-transparent overlay, 245 // This color is expected to be drawn on a semi-transparent overlay,
305 // making it more transparent than its alpha value indicates. 246 // making it more transparent than its alpha value indicates.
306 static const RGBA32 defaultTapHighlightColor = 0x66000000; 247 static const RGBA32 defaultTapHighlightColor = 0x66000000;
307 248
308 static const RGBA32 defaultCompositionBackgroundColor = 0xFFFFDD55; 249 static const RGBA32 defaultCompositionBackgroundColor = 0xFFFFDD55;
309 250
310 #if USE(NEW_THEME) 251 #if USE(NEW_THEME)
311 Theme* m_platformTheme; // The platform-specific theme. 252 Theme* m_platformTheme; // The platform-specific theme.
312 #endif 253 #endif
313 }; 254 };
314 255
315 } // namespace blink 256 } // namespace blink
316 257
317 #endif // LayoutTheme_h 258 #endif // LayoutTheme_h
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutTextControlSingleLine.cpp ('k') | Source/core/layout/LayoutTheme.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698