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 "core/rendering/RenderTheme.h" 28#import "wtf/HashMap.h" 29#import "wtf/RetainPtr.h" 30 31OBJC_CLASS WebCoreRenderThemeNotificationObserver; 32 33namespace blink { 34 35class RenderThemeChromiumMac FINAL : public RenderTheme { 36public: 37 static PassRefPtr<RenderTheme> create(); 38 39 virtual void adjustPaintInvalidationRect(const RenderObject*, IntRect&) OVERRIDE; 40 41 virtual bool isControlStyled(const RenderStyle*, const CachedUAStyle*) const OVERRIDE; 42 43 virtual Color platformActiveSelectionBackgroundColor() const OVERRIDE; 44 virtual Color platformInactiveSelectionBackgroundColor() const OVERRIDE; 45 virtual Color platformActiveSelectionForegroundColor() const OVERRIDE; 46 virtual Color platformActiveListBoxSelectionBackgroundColor() const OVERRIDE; 47 virtual Color platformActiveListBoxSelectionForegroundColor() const OVERRIDE; 48 virtual Color platformInactiveListBoxSelectionBackgroundColor() const OVERRIDE; 49 virtual Color platformInactiveListBoxSelectionForegroundColor() const OVERRIDE; 50 virtual Color platformFocusRingColor() const OVERRIDE; 51 52 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart part) OVERRIDE { return part == ListboxPart ? SmallScrollbar : RegularScrollbar; } 53 54 virtual void platformColorsDidChange() OVERRIDE; 55 56 // System fonts. 57 virtual void systemFont(CSSValueID, FontDescription&) const OVERRIDE; 58 59 virtual int minimumMenuListSize(RenderStyle*) const OVERRIDE; 60 61 virtual void adjustSliderThumbSize(RenderStyle*, Element*) const OVERRIDE; 62 63 virtual IntSize sliderTickSize() const OVERRIDE; 64 virtual int sliderTickOffsetFromTrackCenter() const OVERRIDE; 65 66 virtual int popupInternalPaddingLeft(RenderStyle*) const OVERRIDE; 67 virtual int popupInternalPaddingRight(RenderStyle*) const OVERRIDE; 68 virtual int popupInternalPaddingTop(RenderStyle*) const OVERRIDE; 69 virtual int popupInternalPaddingBottom(RenderStyle*) const OVERRIDE; 70 71 virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 72 73 virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; } 74 virtual bool popsMenuBySpaceKey() const OVERRIDE FINAL { return true; } 75 76 virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const OVERRIDE; 77 virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 78 virtual bool supportsMeter(ControlPart) const OVERRIDE; 79 80 // Returns the repeat interval of the animation for the progress bar. 81 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const OVERRIDE; 82 // Returns the duration of the animation for the progress bar. 83 virtual double animationDurationForProgressBar(RenderProgress*) const OVERRIDE; 84 85 virtual Color systemColor(CSSValueID) const OVERRIDE; 86 87 virtual bool supportsSelectionForegroundColors() const OVERRIDE { return false; } 88 89 virtual bool isModalColorChooser() const { return false; } 90 91protected: 92 RenderThemeChromiumMac(); 93 virtual ~RenderThemeChromiumMac(); 94 95 virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 96 97 virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 98 99 virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 100 virtual void adjustMenuListStyle(RenderStyle*, Element*) const OVERRIDE; 101 102 virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 103 virtual void adjustMenuListButtonStyle(RenderStyle*, Element*) const OVERRIDE; 104 105 virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 106 107 virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 108 109 virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 110 111 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 112 virtual void adjustSearchFieldStyle(RenderStyle*, Element*) const OVERRIDE; 113 114 virtual void adjustSearchFieldCancelButtonStyle(RenderStyle*, Element*) const OVERRIDE; 115 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 116 117 virtual void adjustSearchFieldDecorationStyle(RenderStyle*, Element*) const OVERRIDE; 118 virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 119 120 virtual void adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element*) const OVERRIDE; 121 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 122 123private: 124 virtual String fileListNameForWidth(Locale&, const FileList*, const Font&, int width) const OVERRIDE; 125 126 FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect&) const; 127 128 // Get the control size based off the font. Used by some of the controls (like buttons). 129 NSControlSize controlSizeForFont(RenderStyle*) const; 130 NSControlSize controlSizeForSystemFont(RenderStyle*) const; 131 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f); 132 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const; 133 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const; 134 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const; 135 void setFontFromControlSize(RenderStyle*, NSControlSize) const; 136 137 void updateCheckedState(NSCell*, const RenderObject*); 138 void updateEnabledState(NSCell*, const RenderObject*); 139 void updateFocusedState(NSCell*, const RenderObject*); 140 void updatePressedState(NSCell*, const RenderObject*); 141 142 // Helpers for adjusting appearance and for painting 143 144 void setPopupButtonCellState(const RenderObject*, const IntRect&); 145 const IntSize* popupButtonSizes() const; 146 const int* popupButtonMargins() const; 147 const int* popupButtonPadding(NSControlSize) const; 148 const IntSize* menuListSizes() const; 149 150 const IntSize* searchFieldSizes() const; 151 const IntSize* cancelButtonSizes() const; 152 const IntSize* resultsButtonSizes() const; 153 void setSearchCellState(RenderObject*, const IntRect&); 154 void setSearchFieldSize(RenderStyle*) const; 155 156 NSPopUpButtonCell* popupButton() const; 157 NSSearchFieldCell* search() const; 158 NSTextFieldCell* textField() const; 159 160 NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const; 161 NSLevelIndicatorCell* levelIndicatorFor(const RenderMeter*) const; 162 163 int minimumProgressBarHeight(RenderStyle*) const; 164 const IntSize* progressBarSizes() const; 165 const int* progressBarMargins(NSControlSize) const; 166 167protected: 168 virtual void adjustMediaSliderThumbSize(RenderStyle*) const; 169 virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 170 virtual bool paintMediaOverlayPlayButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 171 virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 172 virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 173 virtual String extraFullScreenStyleSheet() OVERRIDE; 174 175 virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 176 virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 177 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 178 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 179 virtual String formatMediaControlsTime(float time) const OVERRIDE; 180 virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const OVERRIDE; 181 virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 182 virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 183 184 // Controls color values returned from platformFocusRingColor(). systemColor() will be used when false. 185 bool usesTestModeFocusRingColor() const; 186 // A view associated to the contained document. Subclasses may not have such a view and return a fake. 187 NSView* documentViewFor(RenderObject*) const; 188 189 virtual bool shouldUseFallbackTheme(RenderStyle*) const OVERRIDE; 190 191private: 192 virtual void updateActiveState(NSCell*, const RenderObject*); 193 virtual String extraDefaultStyleSheet() OVERRIDE; 194 virtual bool shouldShowPlaceholderWhenFocused() const OVERRIDE; 195 196 mutable RetainPtr<NSPopUpButtonCell> m_popupButton; 197 mutable RetainPtr<NSSearchFieldCell> m_search; 198 mutable RetainPtr<NSMenu> m_searchMenuTemplate; 199 mutable RetainPtr<NSLevelIndicatorCell> m_levelIndicator; 200 mutable RetainPtr<NSTextFieldCell> m_textField; 201 202 mutable HashMap<int, RGBA32> m_systemColorCache; 203 204 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; 205}; 206 207} // namespace blink 208 209#endif // RenderThemeChromiumMac_h 210