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

Side by Side Diff: rendering/RenderThemeChromiumMac.h

Issue 174242: Bring the Mac Chromium render theme up to date and easier to keep merged. DO ... (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « platform/graphics/IntRect.h ('k') | rendering/RenderThemeChromiumMac.mm » ('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 Apple Computer, Inc. 4 * Copyright (C) 2005 Apple Computer, Inc.
5 * Copyright (C) 2008, 2009 Google, Inc. 5 * Copyright (C) 2008, 2009 Google, Inc.
6 * Copyright (C) 2009 Kenneth Rohde Christiansen
7 * 6 *
8 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
12 * 11 *
13 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 15 * Library General Public License for more details.
17 * 16 *
18 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
22 * 21 *
23 */ 22 */
24 23
25 #ifndef RenderThemeChromiumMac_h 24 #ifndef RenderThemeChromiumMac_h
26 #define RenderThemeChromiumMac_h 25 #define RenderThemeChromiumMac_h
27 26
28 #import "RenderTheme.h" 27 #import "RenderTheme.h"
29 #import <AppKit/AppKit.h>
30 #import <wtf/HashMap.h> 28 #import <wtf/HashMap.h>
31 #import <wtf/RetainPtr.h> 29 #import <wtf/RetainPtr.h>
32 30
33 #ifdef __OBJC__ 31 #ifdef __OBJC__
34 @class WebCoreRenderThemeNotificationObserver; 32 @class WebCoreRenderThemeNotificationObserver;
35 #else 33 #else
36 class WebCoreRenderThemeNotificationObserver; 34 class WebCoreRenderThemeNotificationObserver;
37 #endif 35 #endif
38 36
37 // This file (and its associated .mm file) is a clone of RenderThemeMac.h. See
38 // the .mm file for details.
39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class RenderStyle; 42 class RenderStyle;
42 43
43 class RenderThemeChromiumMac : public RenderTheme { 44 class RenderThemeChromiumMac : public RenderTheme {
44 public: 45 public:
45 static PassRefPtr<RenderTheme> create(); 46 static PassRefPtr<RenderTheme> create();
46 47
47 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline 48 // A method asking if the control changes its tint when the window has focus or not.
48 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of 49 virtual bool controlSupportsTints(const RenderObject*) const;
49 // controls that need to do this.
50 virtual int baselinePosition(const RenderObject*) const;
51 50
52 // A method asking if the control changes its tint when the window has f ocus or not. 51 // A general method asking if any control tinting is supported at all.
53 virtual bool controlSupportsTints(const RenderObject*) const; 52 virtual bool supportsControlTints() const { return true; }
54 53
55 // A general method asking if any control tinting is supported at all. 54 virtual void adjustRepaintRect(const RenderObject*, IntRect&);
56 virtual bool supportsControlTints() const { return true; }
57 55
58 virtual void adjustRepaintRect(const RenderObject*, IntRect&); 56 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
57 const FillLayer&, const Color& backgroundColor) const;
59 58
60 virtual bool isControlStyled(const RenderStyle*, const BorderData&, 59 virtual Color platformActiveSelectionBackgroundColor() const;
61 const FillLayer&, const Color& backgroundCo lor) const; 60 virtual Color platformInactiveSelectionBackgroundColor() const;
61 virtual Color platformActiveListBoxSelectionBackgroundColor() const;
62 virtual Color platformActiveListBoxSelectionForegroundColor() const;
63 virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
64 virtual Color platformInactiveListBoxSelectionForegroundColor() const;
65 virtual Color platformFocusRingColor() const;
62 66
63 virtual Color platformActiveSelectionBackgroundColor() const; 67 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { retu rn SmallScrollbar; }
64 virtual Color platformInactiveSelectionBackgroundColor() const; 68
65 virtual Color platformActiveListBoxSelectionBackgroundColor() const; 69 virtual void platformColorsDidChange();
66 70
67 virtual Color platformFocusRingColor() const; 71 // System fonts.
68 72 virtual void systemFont(int cssValueId, FontDescription&) const;
69 virtual void platformColorsDidChange();
70 73
71 // System fonts. 74 virtual int minimumMenuListSize(RenderStyle*) const;
72 virtual void systemFont(int cssValueId, FontDescription&) const;
73 75
74 virtual int minimumMenuListSize(RenderStyle*) const; 76 virtual void adjustSliderThumbSize(RenderObject*) const;
77
78 virtual int popupInternalPaddingLeft(RenderStyle*) const;
79 virtual int popupInternalPaddingRight(RenderStyle*) const;
80 virtual int popupInternalPaddingTop(RenderStyle*) const;
81 virtual int popupInternalPaddingBottom(RenderStyle*) const;
82
83 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::Paint Info&, const IntRect&);
75 84
76 virtual void adjustSliderThumbSize(RenderObject*) const; 85 virtual Color systemColor(int cssValueId) const;
77 86
78 virtual int popupInternalPaddingLeft(RenderStyle*) const; 87 protected:
79 virtual int popupInternalPaddingRight(RenderStyle*) const; 88 virtual bool supportsSelectionForegroundColors() const { return false; }
80 virtual int popupInternalPaddingTop(RenderStyle*) const; 89
81 virtual int popupInternalPaddingBottom(RenderStyle*) const; 90 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, c onst IntRect&);
82 91 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
83 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return SmallScrollbar; } 92
93 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, co nst IntRect&);
94 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
95
96 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, co nst IntRect&);
97 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
98
99 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInf o&, const IntRect&);
100 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Elem ent*) const;
101
102 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
103 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element *) const;
104
105 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
106 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element *) const;
107
108 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
109 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element *) const;
110
111 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderSty le*, Element*) const;
112 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject: :PaintInfo&, const IntRect&);
113
114 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle *, Element*) const;
115 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::P aintInfo&, const IntRect&);
116
117 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, Rend erStyle*, Element*) const;
118 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderOb ject::PaintInfo&, const IntRect&);
119
120 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderSt yle*, Element*) const;
121 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject ::PaintInfo&, const IntRect&);
122
123 #if ENABLE(VIDEO)
124 virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::P aintInfo&, const IntRect&);
125 virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintIn fo&, const IntRect&);
126 virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintIn fo&, const IntRect&);
127 virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::Pai ntInfo&, const IntRect&);
128 virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject:: PaintInfo&, const IntRect&);
129 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintI nfo&, const IntRect&);
130 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintI nfo&, const IntRect&);
131 virtual bool paintMediaRewindButton(RenderObject*, const RenderObject::Paint Info&, const IntRect&);
132 virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const RenderObj ect::PaintInfo&, const IntRect&);
133 virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject: :PaintInfo&, const IntRect&);
134 virtual bool paintMediaCurrentTime(RenderObject*, const RenderObject::PaintI nfo&, const IntRect&);
135 virtual bool paintMediaTimeRemaining(RenderObject*, const RenderObject::Pain tInfo&, const IntRect&);
136
137 // Media controls
138 virtual String extraMediaControlsStyleSheet();
139 #endif
140
141 private:
142 RenderThemeChromiumMac();
143 virtual ~RenderThemeChromiumMac();
144
145 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, floa t zoomLevel = 1.0f) const;
146
147 FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const Ren derObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const;
84 148
85 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::P aintInfo&, const IntRect&); 149 // Get the control size based off the font. Used by some of the controls (l ike buttons).
150 NSControlSize controlSizeForFont(RenderStyle*) const;
151 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
152 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, f loat zoomLevel = 1.0f);
153 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
154 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
155 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
156 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
86 157
87 virtual Color systemColor(int cssValueId) const; 158 void updateActiveState(NSCell*, const RenderObject*);
159 void updateCheckedState(NSCell*, const RenderObject*);
160 void updateEnabledState(NSCell*, const RenderObject*);
161 void updateFocusedState(NSCell*, const RenderObject*);
162 void updatePressedState(NSCell*, const RenderObject*);
88 163
89 protected: 164 // Helpers for adjusting appearance and for painting
90 virtual bool supportsSelectionForegroundColors() const { return false; }
91 165
92 // Methods for each appearance value. 166 void setPopupButtonCellState(const RenderObject*, const IntRect&);
93 virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo& , const IntRect&); 167 const IntSize* popupButtonSizes() const;
94 virtual void setCheckboxSize(RenderStyle*) const; 168 const int* popupButtonMargins() const;
169 const int* popupButtonPadding(NSControlSize) const;
170 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintIn fo&, const IntRect&);
171 const IntSize* menuListSizes() const;
95 172
96 virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, c onst IntRect&); 173 const IntSize* searchFieldSizes() const;
97 virtual void setRadioSize(RenderStyle*) const; 174 const IntSize* cancelButtonSizes() const;
175 const IntSize* resultsButtonSizes() const;
176 void setSearchCellState(RenderObject*, const IntRect&);
177 void setSearchFieldSize(RenderStyle*) const;
178
179 NSPopUpButtonCell* popupButton() const;
180 NSSearchFieldCell* search() const;
181 NSMenu* searchMenuTemplate() const;
182 NSSliderCell* sliderThumbHorizontal() const;
183 NSSliderCell* sliderThumbVertical() const;
98 184
99 virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, WebCore: :Element*) const; 185 private:
100 virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 186 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
101 virtual void setButtonSize(RenderStyle*) const; 187 mutable RetainPtr<NSSearchFieldCell> m_search;
188 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
189 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
190 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
102 191
103 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo &, const IntRect&); 192 bool m_isSliderThumbHorizontalPressed;
104 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Eleme nt*) const; 193 bool m_isSliderThumbVerticalPressed;
105 194
106 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo& , const IntRect&); 195 mutable HashMap<int, RGBA32> m_systemColorCache;
107 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Elemen t*) const;
108 196
109 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo& , const IntRect&); 197 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
110 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Elemen t*) const; 198 };
111
112 virtual bool paintMenuListButton(RenderObject*, const RenderObject::Pain tInfo&, const IntRect&);
113 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
114
115 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintIn fo&, const IntRect&);
116 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Ele ment*) const;
117
118 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintIn fo&, const IntRect&);
119 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Ele ment*) const;
120
121 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintIn fo&, const IntRect&);
122 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Ele ment*) const;
123
124 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, Rende rStyle*, Element*) const;
125 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObj ect::PaintInfo&, const IntRect&);
126
127 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderS tyle*, Element*) const;
128 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObjec t::PaintInfo&, const IntRect&);
129
130 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
131 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const Rend erObject::PaintInfo&, const IntRect&);
132
133 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, Rend erStyle*, Element*) const;
134 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderOb ject::PaintInfo&, const IntRect&);
135
136 virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObjec t::PaintInfo&, const IntRect&);
137 virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::Pai ntInfo&, const IntRect&);
138 virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::Pai ntInfo&, const IntRect&);
139 virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject: :PaintInfo&, const IntRect&);
140 virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObje ct::PaintInfo&, const IntRect&);
141 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::Pa intInfo&, const IntRect&);
142 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::Pa intInfo&, const IntRect&);
143
144 private:
145 RenderThemeChromiumMac();
146 virtual ~RenderThemeChromiumMac();
147
148 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const;
149
150 // Get the control size based off the font. Used by some of the control s (like buttons).
151 NSControlSize controlSizeForFont(RenderStyle*) const;
152 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
153 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSiz e, float zoomLevel = 1.0f);
154 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
155 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
156 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
157 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSi ze) const;
158
159 void updateActiveState(NSCell*, const RenderObject*);
160 void updateCheckedState(NSCell*, const RenderObject*);
161 void updateEnabledState(NSCell*, const RenderObject*);
162 void updateFocusedState(NSCell*, const RenderObject*);
163 void updatePressedState(NSCell*, const RenderObject*);
164
165 // Helpers for adjusting appearance and for painting
166 const IntSize* checkboxSizes() const;
167 const int* checkboxMargins() const;
168 void setCheckboxCellState(const RenderObject*, const IntRect&);
169
170 const IntSize* radioSizes() const;
171 const int* radioMargins() const;
172 void setRadioCellState(const RenderObject*, const IntRect&);
173
174 void setButtonPaddingFromControlSize(RenderStyle*, NSControlSize) const;
175 const IntSize* buttonSizes() const;
176 const int* buttonMargins() const;
177 void setButtonCellState(const RenderObject*, const IntRect&);
178
179 void setPopupButtonCellState(const RenderObject*, const IntRect&);
180 const IntSize* popupButtonSizes() const;
181 const int* popupButtonMargins() const;
182 const int* popupButtonPadding(NSControlSize) const;
183 void paintMenuListButtonGradients(RenderObject*, const RenderObject::Pai ntInfo&, const IntRect&);
184 const IntSize* menuListSizes() const;
185
186 const IntSize* searchFieldSizes() const;
187 const IntSize* cancelButtonSizes() const;
188 const IntSize* resultsButtonSizes() const;
189 void setSearchCellState(RenderObject*, const IntRect&);
190 void setSearchFieldSize(RenderStyle*) const;
191
192 NSButtonCell* checkbox() const;
193 NSButtonCell* radio() const;
194 NSButtonCell* button() const;
195 NSPopUpButtonCell* popupButton() const;
196 NSSearchFieldCell* search() const;
197 NSMenu* searchMenuTemplate() const;
198 NSSliderCell* sliderThumbHorizontal() const;
199 NSSliderCell* sliderThumbVertical() const;
200
201 private:
202 mutable RetainPtr<NSButtonCell> m_checkbox;
203 mutable RetainPtr<NSButtonCell> m_radio;
204 mutable RetainPtr<NSButtonCell> m_button;
205 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
206 mutable RetainPtr<NSSearchFieldCell> m_search;
207 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
208 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
209 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
210
211 bool m_isSliderThumbHorizontalPressed;
212 bool m_isSliderThumbVerticalPressed;
213
214 mutable HashMap<int, RGBA32> m_systemColorCache;
215
216 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver ;
217 };
218 199
219 } // namespace WebCore 200 } // namespace WebCore
220 201
221 #endif 202 #endif // RenderThemeChromiumMac_h
OLDNEW
« no previous file with comments | « platform/graphics/IntRect.h ('k') | rendering/RenderThemeChromiumMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698