1/* 2 * This file is part of the theme implementation for form controls in WebCore. 3 * 4 * Copyright (C) 2005 Apple Computer, Inc. 5 * Copyright (C) 2008, 2009 Google, Inc. 6 * 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. 11 * 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. 16 * 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. 21 * 22 */ 23 24#ifndef RenderThemeChromiumMac_h 25#define RenderThemeChromiumMac_h 26 27#import "RenderTheme.h" 28#import <wtf/HashMap.h> 29#import <wtf/RetainPtr.h> 30 31#ifdef __OBJC__ 32@class WebCoreRenderThemeNotificationObserver; 33#else 34class WebCoreRenderThemeNotificationObserver; 35#endif 36 37// This file (and its associated .mm file) is a clone of RenderThemeMac.h. See 38// the .mm file for details. 39 40namespace WebCore { 41 42class RenderStyle; 43 44class RenderThemeChromiumMac : public RenderTheme { 45public: 46 static PassRefPtr<RenderTheme> create(); 47 48 // A method asking if the control changes its tint when the window has focus or not. 49 virtual bool controlSupportsTints(const RenderObject*) const; 50 51 // A general method asking if any control tinting is supported at all. 52 virtual bool supportsControlTints() const { return true; } 53 54 virtual void adjustRepaintRect(const RenderObject*, IntRect&); 55 56 virtual bool isControlStyled(const RenderStyle*, const BorderData&, 57 const FillLayer&, const Color& backgroundColor) const; 58 59 virtual Color platformActiveSelectionBackgroundColor() 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; 66 67 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return SmallScrollbar; } 68 69 virtual void platformColorsDidChange(); 70 71 // System fonts. 72 virtual void systemFont(int cssValueId, FontDescription&) const; 73 74 virtual int minimumMenuListSize(RenderStyle*) const; 75 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::PaintInfo&, const IntRect&); 84 85 virtual Color systemColor(int cssValueId) const; 86 87protected: 88 virtual bool supportsSelectionForegroundColors() const { return false; } 89 90 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 91 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 92 93 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 94 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 95 96 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 97 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 98 99 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 100 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) 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*, RenderStyle*, 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::PaintInfo&, const IntRect&); 116 117 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 118 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 119 120 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 121 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 122 123#if ENABLE(VIDEO) 124 virtual bool shouldRenderMediaControlPart(ControlPart, Element*); 125 virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 126 virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 127 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 128 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 129 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 130 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 131 virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 132 133 // Media controls 134 virtual String extraMediaControlsStyleSheet(); 135#endif 136 137private: 138 RenderThemeChromiumMac(); 139 virtual ~RenderThemeChromiumMac(); 140 141 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const; 142 143 FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const; 144 145 // Get the control size based off the font. Used by some of the controls (like buttons). 146 NSControlSize controlSizeForFont(RenderStyle*) const; 147 NSControlSize controlSizeForSystemFont(RenderStyle*) const; 148 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f); 149 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const; 150 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const; 151 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const; 152 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const; 153 154 void updateActiveState(NSCell*, const RenderObject*); 155 void updateCheckedState(NSCell*, const RenderObject*); 156 void updateEnabledState(NSCell*, const RenderObject*); 157 void updateFocusedState(NSCell*, const RenderObject*); 158 void updatePressedState(NSCell*, const RenderObject*); 159 160 // Helpers for adjusting appearance and for painting 161 162 void setPopupButtonCellState(const RenderObject*, const IntRect&); 163 const IntSize* popupButtonSizes() const; 164 const int* popupButtonMargins() const; 165 const int* popupButtonPadding(NSControlSize) const; 166 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 167 const IntSize* menuListSizes() const; 168 169 const IntSize* searchFieldSizes() const; 170 const IntSize* cancelButtonSizes() const; 171 const IntSize* resultsButtonSizes() const; 172 void setSearchCellState(RenderObject*, const IntRect&); 173 void setSearchFieldSize(RenderStyle*) const; 174 175 NSPopUpButtonCell* popupButton() const; 176 NSSearchFieldCell* search() const; 177 NSMenu* searchMenuTemplate() const; 178 NSSliderCell* sliderThumbHorizontal() const; 179 NSSliderCell* sliderThumbVertical() const; 180 181private: 182 mutable RetainPtr<NSPopUpButtonCell> m_popupButton; 183 mutable RetainPtr<NSSearchFieldCell> m_search; 184 mutable RetainPtr<NSMenu> m_searchMenuTemplate; 185 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal; 186 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical; 187 188 bool m_isSliderThumbHorizontalPressed; 189 bool m_isSliderThumbVerticalPressed; 190 191 mutable HashMap<int, RGBA32> m_systemColorCache; 192 193 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; 194}; 195 196} // namespace WebCore 197 198#endif // RenderThemeChromiumMac_h 199