2 * This file is part of the theme implementation for form controls in WebCore.
4 * Copyright (C) 2005 Apple Computer, Inc.
5 * Copyright (C) 2008, 2009 Google, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef RenderThemeChromiumMac_h
25 #define RenderThemeChromiumMac_h
27 #import "RenderTheme.h"
28 #import <wtf/HashMap.h>
29 #import <wtf/RetainPtr.h>
32 @
class WebCoreRenderThemeNotificationObserver
;
34 class WebCoreRenderThemeNotificationObserver
;
41 class RenderThemeChromiumMac
: public RenderTheme
{
43 RenderThemeChromiumMac();
44 virtual ~RenderThemeChromiumMac();
46 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
47 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
48 // controls that need to do this.
49 virtual int baselinePosition(const RenderObject
*) const;
51 // A method asking if the control changes its tint when the window has focus or not.
52 virtual bool controlSupportsTints(const RenderObject
*) const;
54 // A general method asking if any control tinting is supported at all.
55 virtual bool supportsControlTints() const { return true; }
57 virtual void adjustRepaintRect(const RenderObject
*, IntRect
&);
59 virtual bool isControlStyled(const RenderStyle
*, const BorderData
&,
60 const FillLayer
&, const Color
& backgroundColor
) const;
62 virtual Color
platformActiveSelectionBackgroundColor() const;
63 virtual Color
platformInactiveSelectionBackgroundColor() const;
64 virtual Color
activeListBoxSelectionBackgroundColor() const;
66 virtual void platformColorsDidChange();
69 virtual void systemFont(int cssValueId
, Document
*, FontDescription
&) const;
71 virtual int minimumMenuListSize(RenderStyle
*) const;
73 virtual void adjustSliderThumbSize(RenderObject
*) const;
75 virtual int popupInternalPaddingLeft(RenderStyle
*) const;
76 virtual int popupInternalPaddingRight(RenderStyle
*) const;
77 virtual int popupInternalPaddingTop(RenderStyle
*) const;
78 virtual int popupInternalPaddingBottom(RenderStyle
*) const;
80 virtual bool paintCapsLockIndicator(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
82 virtual Color
systemColor(int cssValueId
) const;
85 // Methods for each appearance value.
86 virtual bool paintCheckbox(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
87 virtual void setCheckboxSize(RenderStyle
*) const;
89 virtual bool paintRadio(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
90 virtual void setRadioSize(RenderStyle
*) const;
92 virtual void adjustButtonStyle(CSSStyleSelector
*, RenderStyle
*, WebCore::Element
*) const;
93 virtual bool paintButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
94 virtual void setButtonSize(RenderStyle
*) const;
96 virtual bool paintTextField(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
97 virtual void adjustTextFieldStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
99 virtual bool paintTextArea(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
100 virtual void adjustTextAreaStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
102 virtual bool paintMenuList(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
103 virtual void adjustMenuListStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
105 virtual bool paintMenuListButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
106 virtual void adjustMenuListButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
108 virtual bool paintSliderTrack(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
109 virtual void adjustSliderTrackStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
111 virtual bool paintSliderThumb(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
112 virtual void adjustSliderThumbStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
114 virtual bool paintSearchField(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
115 virtual void adjustSearchFieldStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
117 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
118 virtual bool paintSearchFieldCancelButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
120 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
121 virtual bool paintSearchFieldDecoration(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
123 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
124 virtual bool paintSearchFieldResultsDecoration(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
126 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector
*, RenderStyle
*, Element
*) const;
127 virtual bool paintSearchFieldResultsButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
129 virtual bool paintMediaFullscreenButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
130 virtual bool paintMediaPlayButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
131 virtual bool paintMediaMuteButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
132 virtual bool paintMediaSeekBackButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
133 virtual bool paintMediaSeekForwardButton(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
134 virtual bool paintMediaSliderTrack(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
135 virtual bool paintMediaSliderThumb(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
138 IntRect
inflateRect(const IntRect
&, const IntSize
&, const int* margins
, float zoomLevel
= 1.0f
) const;
140 // Get the control size based off the font. Used by some of the controls (like buttons).
141 NSControlSize
controlSizeForFont(RenderStyle
*) const;
142 NSControlSize
controlSizeForSystemFont(RenderStyle
*) const;
143 void setControlSize(NSCell
*, const IntSize
* sizes
, const IntSize
& minSize
, float zoomLevel
= 1.0f
);
144 void setSizeFromFont(RenderStyle
*, const IntSize
* sizes
) const;
145 IntSize
sizeForFont(RenderStyle
*, const IntSize
* sizes
) const;
146 IntSize
sizeForSystemFont(RenderStyle
*, const IntSize
* sizes
) const;
147 void setFontFromControlSize(CSSStyleSelector
*, RenderStyle
*, NSControlSize
) const;
149 void updateCheckedState(NSCell
*, const RenderObject
*);
150 void updateEnabledState(NSCell
*, const RenderObject
*);
151 void updateFocusedState(NSCell
*, const RenderObject
*);
152 void updatePressedState(NSCell
*, const RenderObject
*);
154 // Helpers for adjusting appearance and for painting
155 const IntSize
* checkboxSizes() const;
156 const int* checkboxMargins() const;
157 void setCheckboxCellState(const RenderObject
*, const IntRect
&);
159 const IntSize
* radioSizes() const;
160 const int* radioMargins() const;
161 void setRadioCellState(const RenderObject
*, const IntRect
&);
163 void setButtonPaddingFromControlSize(RenderStyle
*, NSControlSize
) const;
164 const IntSize
* buttonSizes() const;
165 const int* buttonMargins() const;
166 void setButtonCellState(const RenderObject
*, const IntRect
&);
168 void setPopupButtonCellState(const RenderObject
*, const IntRect
&);
169 const IntSize
* popupButtonSizes() const;
170 const int* popupButtonMargins() const;
171 const int* popupButtonPadding(NSControlSize
) const;
172 void paintMenuListButtonGradients(RenderObject
*, const RenderObject::PaintInfo
&, const IntRect
&);
173 const IntSize
* menuListSizes() const;
175 const IntSize
* searchFieldSizes() const;
176 const IntSize
* cancelButtonSizes() const;
177 const IntSize
* resultsButtonSizes() const;
178 void setSearchCellState(RenderObject
*, const IntRect
&);
179 void setSearchFieldSize(RenderStyle
*) const;
181 NSButtonCell
* checkbox() const;
182 NSButtonCell
* radio() const;
183 NSButtonCell
* button() const;
184 NSPopUpButtonCell
* popupButton() const;
185 NSSearchFieldCell
* search() const;
186 NSMenu
* searchMenuTemplate() const;
187 NSSliderCell
* sliderThumbHorizontal() const;
188 NSSliderCell
* sliderThumbVertical() const;
191 mutable RetainPtr
<NSButtonCell
> m_checkbox
;
192 mutable RetainPtr
<NSButtonCell
> m_radio
;
193 mutable RetainPtr
<NSButtonCell
> m_button
;
194 mutable RetainPtr
<NSPopUpButtonCell
> m_popupButton
;
195 mutable RetainPtr
<NSSearchFieldCell
> m_search
;
196 mutable RetainPtr
<NSMenu
> m_searchMenuTemplate
;
197 mutable RetainPtr
<NSSliderCell
> m_sliderThumbHorizontal
;
198 mutable RetainPtr
<NSSliderCell
> m_sliderThumbVertical
;
200 bool m_isSliderThumbHorizontalPressed
;
201 bool m_isSliderThumbVerticalPressed
;
203 mutable HashMap
<int, RGBA32
> m_systemColorCache
;
205 RetainPtr
<WebCoreRenderThemeNotificationObserver
> m_notificationObserver
;
208 } // namespace WebCore