| OLD | NEW |
| 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 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * 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. |
| 11 * | 11 * |
| 12 * 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, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * 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 |
| 18 * 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 |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #ifndef LayoutThemeMac_h | 24 #ifndef LayoutThemeMac_h |
| 25 #define LayoutThemeMac_h | 25 #define LayoutThemeMac_h |
| 26 | 26 |
| 27 #import "core/layout/LayoutTheme.h" | 27 #import "core/layout/LayoutTheme.h" |
| 28 #import "core/paint/ThemePainterMac.h" |
| 28 #import "wtf/HashMap.h" | 29 #import "wtf/HashMap.h" |
| 29 #import "wtf/RetainPtr.h" | 30 #import "wtf/RetainPtr.h" |
| 30 | 31 |
| 31 OBJC_CLASS LayoutThemeNotificationObserver; | 32 OBJC_CLASS LayoutThemeNotificationObserver; |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 class LayoutThemeMac final : public LayoutTheme { | 36 class LayoutThemeMac final : public LayoutTheme { |
| 36 public: | 37 public: |
| 37 static PassRefPtr<LayoutTheme> create(); | 38 static PassRefPtr<LayoutTheme> create(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 virtual void adjustSliderThumbSize(ComputedStyle&, Element*) const override; | 62 virtual void adjustSliderThumbSize(ComputedStyle&, Element*) const override; |
| 62 | 63 |
| 63 virtual IntSize sliderTickSize() const override; | 64 virtual IntSize sliderTickSize() const override; |
| 64 virtual int sliderTickOffsetFromTrackCenter() const override; | 65 virtual int sliderTickOffsetFromTrackCenter() const override; |
| 65 | 66 |
| 66 virtual int popupInternalPaddingLeft(const ComputedStyle&) const override; | 67 virtual int popupInternalPaddingLeft(const ComputedStyle&) const override; |
| 67 virtual int popupInternalPaddingRight(const ComputedStyle&) const override; | 68 virtual int popupInternalPaddingRight(const ComputedStyle&) const override; |
| 68 virtual int popupInternalPaddingTop(const ComputedStyle&) const override; | 69 virtual int popupInternalPaddingTop(const ComputedStyle&) const override; |
| 69 virtual int popupInternalPaddingBottom(const ComputedStyle&) const override; | 70 virtual int popupInternalPaddingBottom(const ComputedStyle&) const override; |
| 70 | 71 |
| 71 virtual bool paintCapsLockIndicator(LayoutObject*, const PaintInfo&, const I
ntRect&) override; | |
| 72 | |
| 73 virtual bool popsMenuByArrowKeys() const override { return true; } | 72 virtual bool popsMenuByArrowKeys() const override { return true; } |
| 74 virtual bool popsMenuBySpaceKey() const override final { return true; } | 73 virtual bool popsMenuBySpaceKey() const override final { return true; } |
| 75 | 74 |
| 76 virtual IntSize meterSizeForBounds(const LayoutMeter*, const IntRect&) const
override; | 75 virtual IntSize meterSizeForBounds(const LayoutMeter*, const IntRect&) const
override; |
| 77 virtual bool paintMeter(LayoutObject*, const PaintInfo&, const IntRect&) ove
rride; | |
| 78 virtual bool supportsMeter(ControlPart) const override; | 76 virtual bool supportsMeter(ControlPart) const override; |
| 79 | 77 |
| 80 // Returns the repeat interval of the animation for the progress bar. | 78 // Returns the repeat interval of the animation for the progress bar. |
| 81 virtual double animationRepeatIntervalForProgressBar() const override; | 79 virtual double animationRepeatIntervalForProgressBar() const override; |
| 82 // Returns the duration of the animation for the progress bar. | 80 // Returns the duration of the animation for the progress bar. |
| 83 virtual double animationDurationForProgressBar() const override; | 81 virtual double animationDurationForProgressBar() const override; |
| 84 | 82 |
| 85 virtual Color systemColor(CSSValueID) const override; | 83 virtual Color systemColor(CSSValueID) const override; |
| 86 | 84 |
| 87 virtual bool supportsSelectionForegroundColors() const override { return fal
se; } | 85 virtual bool supportsSelectionForegroundColors() const override { return fal
se; } |
| 88 | 86 |
| 89 virtual bool isModalColorChooser() const { return false; } | 87 virtual bool isModalColorChooser() const { return false; } |
| 90 | 88 |
| 91 protected: | 89 protected: |
| 92 LayoutThemeMac(); | 90 LayoutThemeMac(); |
| 93 virtual ~LayoutThemeMac(); | 91 virtual ~LayoutThemeMac(); |
| 94 | 92 |
| 95 virtual bool paintTextField(LayoutObject*, const PaintInfo&, const IntRect&)
override; | 93 virtual void adjustMenuListStyle(ComputedStyle&, Element*) const override; |
| 94 virtual void adjustMenuListButtonStyle(ComputedStyle&, Element*) const overr
ide; |
| 95 virtual void adjustSearchFieldStyle(ComputedStyle&, Element*) const override
; |
| 96 virtual void adjustSearchFieldCancelButtonStyle(ComputedStyle&, Element*) co
nst override; |
| 97 virtual void adjustSearchFieldDecorationStyle(ComputedStyle&, Element*) cons
t override; |
| 98 virtual void adjustSearchFieldResultsDecorationStyle(ComputedStyle&, Element
*) const override; |
| 96 | 99 |
| 97 virtual bool paintTextArea(LayoutObject*, const PaintInfo&, const IntRect&)
override; | 100 public: |
| 98 | 101 // Constants and methods shared with ThemePainterMac |
| 99 virtual bool paintMenuList(LayoutObject*, const PaintInfo&, const IntRect&)
override; | |
| 100 virtual void adjustMenuListStyle(ComputedStyle&, Element*) const override; | |
| 101 | |
| 102 virtual bool paintMenuListButton(LayoutObject*, const PaintInfo&, const IntR
ect&) override; | |
| 103 virtual void adjustMenuListButtonStyle(ComputedStyle&, Element*) const overr
ide; | |
| 104 | |
| 105 virtual bool paintProgressBar(LayoutObject*, const PaintInfo&, const IntRect
&) override; | |
| 106 | |
| 107 virtual bool paintSliderTrack(LayoutObject*, const PaintInfo&, const IntRect
&) override; | |
| 108 | |
| 109 virtual bool paintSliderThumb(LayoutObject*, const PaintInfo&, const IntRect
&) override; | |
| 110 | |
| 111 virtual bool paintSearchField(LayoutObject*, const PaintInfo&, const IntRect
&) override; | |
| 112 virtual void adjustSearchFieldStyle(ComputedStyle&, Element*) const override
; | |
| 113 | |
| 114 virtual void adjustSearchFieldCancelButtonStyle(ComputedStyle&, Element*) co
nst override; | |
| 115 virtual bool paintSearchFieldCancelButton(LayoutObject*, const PaintInfo&, c
onst IntRect&) override; | |
| 116 | |
| 117 virtual void adjustSearchFieldDecorationStyle(ComputedStyle&, Element*) cons
t override; | |
| 118 virtual bool paintSearchFieldDecoration(LayoutObject*, const PaintInfo&, con
st IntRect&) override; | |
| 119 | |
| 120 virtual void adjustSearchFieldResultsDecorationStyle(ComputedStyle&, Element
*) const override; | |
| 121 virtual bool paintSearchFieldResultsDecoration(LayoutObject*, const PaintInf
o&, const IntRect&) override; | |
| 122 | |
| 123 private: | |
| 124 virtual String fileListNameForWidth(Locale&, const FileList*, const Font&, i
nt width) const override; | |
| 125 | |
| 126 FloatRect convertToPaintingRect(const LayoutObject* inputRenderer, const Lay
outObject* partRenderer, const FloatRect& inputRect, const IntRect&) const; | |
| 127 | 102 |
| 128 // Get the control size based off the font. Used by some of the controls (li
ke buttons). | 103 // Get the control size based off the font. Used by some of the controls (li
ke buttons). |
| 129 NSControlSize controlSizeForFont(const ComputedStyle&) const; | 104 NSControlSize controlSizeForFont(const ComputedStyle&) const; |
| 130 NSControlSize controlSizeForSystemFont(const ComputedStyle&) const; | 105 NSControlSize controlSizeForSystemFont(const ComputedStyle&) const; |
| 131 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, f
loat zoomLevel = 1.0f); | 106 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, f
loat zoomLevel = 1.0f); |
| 132 void setSizeFromFont(ComputedStyle&, const IntSize* sizes) const; | 107 void setSizeFromFont(ComputedStyle&, const IntSize* sizes) const; |
| 133 IntSize sizeForFont(const ComputedStyle&, const IntSize* sizes) const; | 108 IntSize sizeForFont(const ComputedStyle&, const IntSize* sizes) const; |
| 134 IntSize sizeForSystemFont(const ComputedStyle&, const IntSize* sizes) const; | 109 IntSize sizeForSystemFont(const ComputedStyle&, const IntSize* sizes) const; |
| 135 void setFontFromControlSize(ComputedStyle&, NSControlSize) const; | 110 void setFontFromControlSize(ComputedStyle&, NSControlSize) const; |
| 136 | 111 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 153 void setSearchCellState(LayoutObject*, const IntRect&); | 128 void setSearchCellState(LayoutObject*, const IntRect&); |
| 154 void setSearchFieldSize(ComputedStyle&) const; | 129 void setSearchFieldSize(ComputedStyle&) const; |
| 155 | 130 |
| 156 NSPopUpButtonCell* popupButton() const; | 131 NSPopUpButtonCell* popupButton() const; |
| 157 NSSearchFieldCell* search() const; | 132 NSSearchFieldCell* search() const; |
| 158 NSTextFieldCell* textField() const; | 133 NSTextFieldCell* textField() const; |
| 159 | 134 |
| 160 NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const; | 135 NSLevelIndicatorStyle levelIndicatorStyleFor(ControlPart) const; |
| 161 NSLevelIndicatorCell* levelIndicatorFor(const LayoutMeter*) const; | 136 NSLevelIndicatorCell* levelIndicatorFor(const LayoutMeter*) const; |
| 162 | 137 |
| 138 // A view associated to the contained document. Subclasses may not have such
a view and return a fake. |
| 139 NSView* documentViewFor(LayoutObject*) const; |
| 140 |
| 163 int minimumProgressBarHeight(const ComputedStyle&) const; | 141 int minimumProgressBarHeight(const ComputedStyle&) const; |
| 164 const IntSize* progressBarSizes() const; | 142 const IntSize* progressBarSizes() const; |
| 165 const int* progressBarMargins(NSControlSize) const; | 143 const int* progressBarMargins(NSControlSize) const; |
| 166 | 144 |
| 145 void updateActiveState(NSCell*, const LayoutObject*); |
| 146 |
| 147 // We estimate the animation rate of a Mac OS X progress bar is 33 fps. |
| 148 // Hard code the value here because we haven't found API for it. |
| 149 static constexpr double progressAnimationFrameRate = 0.033; |
| 150 // Mac OS X progress bar animation seems to have 256 frames. |
| 151 static constexpr double progressAnimationNumFrames = 256; |
| 152 |
| 153 static constexpr float baseFontSize = 11.0f; |
| 154 static constexpr float menuListBaseArrowHeight = 4.0f; |
| 155 static constexpr float menuListBaseArrowWidth = 5.0f; |
| 156 static constexpr float menuListBaseSpaceBetweenArrows = 2.0f; |
| 157 static const int menuListArrowPaddingLeft = 6; |
| 158 static const int menuListArrowPaddingRight = 6; |
| 159 static const int sliderThumbWidth = 15; |
| 160 static const int sliderThumbHeight = 15; |
| 161 static const int sliderThumbShadowBlur = 1; |
| 162 static const int sliderThumbBorderWidth = 1; |
| 163 static const int sliderTrackWidth = 5; |
| 164 static const int sliderTrackBorderWidth = 1; |
| 165 |
| 167 protected: | 166 protected: |
| 168 virtual void adjustMediaSliderThumbSize(ComputedStyle&) const; | 167 void adjustMediaSliderThumbSize(ComputedStyle&) const; |
| 169 virtual bool paintMediaPlayButton(LayoutObject*, const PaintInfo&, const Int
Rect&) override; | |
| 170 virtual bool paintMediaOverlayPlayButton(LayoutObject*, const PaintInfo&, co
nst IntRect&) override; | |
| 171 virtual bool paintMediaMuteButton(LayoutObject*, const PaintInfo&, const Int
Rect&) override; | |
| 172 virtual bool paintMediaSliderTrack(LayoutObject*, const PaintInfo&, const In
tRect&) override; | |
| 173 virtual String extraFullScreenStyleSheet() override; | 168 virtual String extraFullScreenStyleSheet() override; |
| 174 | 169 |
| 175 virtual bool paintMediaSliderThumb(LayoutObject*, const PaintInfo&, const In
tRect&) override; | |
| 176 virtual bool paintMediaVolumeSliderContainer(LayoutObject*, const PaintInfo&
, const IntRect&) override; | |
| 177 virtual bool paintMediaVolumeSliderTrack(LayoutObject*, const PaintInfo&, co
nst IntRect&) override; | |
| 178 virtual bool paintMediaVolumeSliderThumb(LayoutObject*, const PaintInfo&, co
nst IntRect&) override; | |
| 179 virtual String formatMediaControlsTime(float time) const override; | |
| 180 virtual String formatMediaControlsCurrentTime(float currentTime, float durat
ion) const override; | |
| 181 virtual bool paintMediaFullscreenButton(LayoutObject*, const PaintInfo&, con
st IntRect&) override; | |
| 182 virtual bool paintMediaToggleClosedCaptionsButton(LayoutObject*, const Paint
Info&, const IntRect&) override; | |
| 183 | |
| 184 // Controls color values returned from platformFocusRingColor(). systemColor
() will be used when false. | 170 // Controls color values returned from platformFocusRingColor(). systemColor
() will be used when false. |
| 185 bool usesTestModeFocusRingColor() const; | 171 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(LayoutObject*) const; | |
| 188 | 172 |
| 189 virtual bool shouldUseFallbackTheme(const ComputedStyle&) const override; | 173 virtual bool shouldUseFallbackTheme(const ComputedStyle&) const override; |
| 190 | 174 |
| 191 private: | 175 private: |
| 192 virtual void updateActiveState(NSCell*, const LayoutObject*); | 176 virtual String fileListNameForWidth(Locale&, const FileList*, const Font&, i
nt width) const override; |
| 193 virtual String extraDefaultStyleSheet() override; | 177 virtual String extraDefaultStyleSheet() override; |
| 194 virtual bool shouldShowPlaceholderWhenFocused() const override; | 178 virtual bool shouldShowPlaceholderWhenFocused() const override; |
| 195 | 179 |
| 180 virtual ThemePainter& painter() override { return m_painter; } |
| 181 |
| 196 mutable RetainPtr<NSPopUpButtonCell> m_popupButton; | 182 mutable RetainPtr<NSPopUpButtonCell> m_popupButton; |
| 197 mutable RetainPtr<NSSearchFieldCell> m_search; | 183 mutable RetainPtr<NSSearchFieldCell> m_search; |
| 198 mutable RetainPtr<NSMenu> m_searchMenuTemplate; | 184 mutable RetainPtr<NSMenu> m_searchMenuTemplate; |
| 199 mutable RetainPtr<NSLevelIndicatorCell> m_levelIndicator; | 185 mutable RetainPtr<NSLevelIndicatorCell> m_levelIndicator; |
| 200 mutable RetainPtr<NSTextFieldCell> m_textField; | 186 mutable RetainPtr<NSTextFieldCell> m_textField; |
| 201 | 187 |
| 202 mutable HashMap<int, RGBA32> m_systemColorCache; | 188 mutable HashMap<int, RGBA32> m_systemColorCache; |
| 203 | 189 |
| 204 RetainPtr<LayoutThemeNotificationObserver> m_notificationObserver; | 190 RetainPtr<LayoutThemeNotificationObserver> m_notificationObserver; |
| 191 |
| 192 ThemePainterMac m_painter; |
| 205 }; | 193 }; |
| 206 | 194 |
| 207 } // namespace blink | 195 } // namespace blink |
| 208 | 196 |
| 209 #endif // LayoutThemeMac_h | 197 #endif // LayoutThemeMac_h |
| OLD | NEW |