1/* 2 * Copyright (C) 2007, 2008, 2013, 2014 Apple Inc. 3 * Copyright (C) 2009 Kenneth Rohde Christiansen 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 * 20 */ 21 22#ifndef RenderThemeSafari_h 23#define RenderThemeSafari_h 24 25#if USE(SAFARI_THEME) 26 27#include "RenderTheme.h" 28 29// If you have an empty placeholder SafariThemeConstants.h, then include SafariTheme.h 30// This is a workaround until a version of WebKitSupportLibrary is released with an updated SafariThemeConstants.h 31#include <SafariTheme/SafariThemeConstants.h> 32#ifndef SafariThemeConstants_h 33#include <SafariTheme/SafariTheme.h> 34#endif 35 36#if PLATFORM(WIN) 37typedef void* HANDLE; 38typedef struct HINSTANCE__* HINSTANCE; 39typedef HINSTANCE HMODULE; 40#endif 41 42namespace WebCore { 43 44using namespace SafariTheme; 45 46class RenderStyle; 47 48class RenderThemeSafari : public RenderTheme { 49public: 50 static PassRefPtr<RenderTheme> create(); 51 52 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline 53 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of 54 // controls that need to do this. 55 virtual int baselinePosition(const RenderObject&) const; 56 57 // A method asking if the control changes its tint when the window has focus or not. 58 virtual bool controlSupportsTints(const RenderObject&) const; 59 60 // A general method asking if any control tinting is supported at all. 61 virtual bool supportsControlTints() const { return true; } 62 63 virtual void adjustRepaintRect(const RenderObject&, IntRect&); 64 65 virtual bool isControlStyled(const RenderStyle&, const BorderData&, 66 const FillLayer&, const Color& backgroundColor) const; 67 68 virtual Color platformActiveSelectionBackgroundColor() const; 69 virtual Color platformInactiveSelectionBackgroundColor() const; 70 virtual Color activeListBoxSelectionBackgroundColor() const; 71 72 virtual Color platformFocusRingColor() const; 73 74 // System fonts. 75 virtual void systemFont(CSSValueID, FontDescription&) const; 76 77 virtual int minimumMenuListSize(RenderStyle&) const; 78 79 virtual void adjustSliderThumbSize(RenderStyle&, Element&) const; 80 virtual void adjustSliderThumbStyle(StyleResolver&, RenderStyle&, Element&) const; 81 82 virtual int popupInternalPaddingLeft(RenderStyle&) const; 83 virtual int popupInternalPaddingRight(RenderStyle&) const; 84 virtual int popupInternalPaddingTop(RenderStyle&) const; 85 virtual int popupInternalPaddingBottom(RenderStyle&) const; 86 87protected: 88 // Methods for each appearance value. 89 virtual bool paintCheckbox(const RenderObject&, const PaintInfo&, const IntRect&); 90 virtual void setCheckboxSize(RenderStyle&) const; 91 92 virtual bool paintRadio(const RenderObject&, const PaintInfo&, const IntRect&); 93 virtual void setRadioSize(RenderStyle&) const; 94 95 virtual void adjustButtonStyle(StyleResolver&, RenderStyle&, WebCore::Element&) const; 96 virtual bool paintButton(const RenderObject&, const PaintInfo&, const IntRect&); 97 virtual void setButtonSize(RenderStyle&) const; 98 99 virtual bool paintTextField(const RenderObject&, const PaintInfo&, const IntRect&); 100 virtual void adjustTextFieldStyle(StyleResolver&, RenderStyle&, Element&) const; 101 102 virtual bool paintTextArea(const RenderObject&, const PaintInfo&, const IntRect&); 103 virtual void adjustTextAreaStyle(StyleResolver&, RenderStyle&, Element&) const; 104 105 virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const IntRect&); 106 virtual void adjustMenuListStyle(StyleResolver&, RenderStyle&, Element&) const; 107 108 virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&); 109 virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const; 110 111 virtual bool paintSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&); 112 virtual bool paintSliderThumb(const RenderObject&, const PaintInfo&, const IntRect&); 113 114 virtual bool paintSearchField(const RenderObject&, const PaintInfo&, const IntRect&); 115 virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, Element&) const; 116 117 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, Element&) const; 118 virtual bool paintSearchFieldCancelButton(const RenderObject&, const PaintInfo&, const IntRect&); 119 120 virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, Element&) const; 121 virtual bool paintSearchFieldDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&); 122 123 virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, Element&) const; 124 virtual bool paintSearchFieldResultsDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&); 125 126 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, Element&) const; 127 virtual bool paintSearchFieldResultsButton(const RenderObject&, const PaintInfo&, const IntRect&); 128 129 virtual bool paintCapsLockIndicator(const RenderObject&, const PaintInfo&, const IntRect&); 130 131#if ENABLE(VIDEO) 132 virtual String mediaControlsStyleSheet() override; 133 virtual String mediaControlsScript() override; 134#endif 135 136#if ENABLE(METER_ELEMENT) 137 virtual IntSize meterSizeForBounds(const RenderMeter&, const IntRect&) const override; 138 virtual bool supportsMeter(ControlPart) const override; 139 virtual void adjustMeterStyle(StyleResolver&, RenderStyle&, Element&) const override; 140 virtual bool paintMeter(const RenderObject&, const PaintInfo&, const IntRect&) override; 141#endif 142 143 virtual bool shouldShowPlaceholderWhenFocused() const { return true; } 144 145private: 146 RenderThemeSafari(); 147 virtual ~RenderThemeSafari(); 148 149 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const; 150 151 // Get the control size based off the font. Used by some of the controls (like buttons). 152 153 NSControlSize controlSizeForFont(RenderStyle&) const; 154 NSControlSize controlSizeForSystemFont(RenderStyle&) const; 155 //void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize); 156 void setSizeFromFont(RenderStyle&, const IntSize* sizes) const; 157 IntSize sizeForFont(RenderStyle&, const IntSize* sizes) const; 158 IntSize sizeForSystemFont(RenderStyle&, const IntSize* sizes) const; 159 void setFontFromControlSize(StyleResolver&, RenderStyle&, NSControlSize) const; 160 161 // Helpers for adjusting appearance and for painting 162 const IntSize* checkboxSizes() const; 163 const int* checkboxMargins(NSControlSize) const; 164 165 const IntSize* radioSizes() const; 166 const int* radioMargins(NSControlSize) const; 167 168 void setButtonPaddingFromControlSize(RenderStyle&, NSControlSize) const; 169 const IntSize* buttonSizes() const; 170 const int* buttonMargins(NSControlSize) const; 171 172 const IntSize* popupButtonSizes() const; 173 const int* popupButtonMargins(NSControlSize) const; 174 const int* popupButtonPadding(NSControlSize) const; 175 void paintMenuListButtonGradients(const RenderObject&, const PaintInfo&, const IntRect&); 176 const IntSize* menuListSizes() const; 177 178 const IntSize* searchFieldSizes() const; 179 const IntSize* cancelButtonSizes() const; 180 const IntSize* resultsButtonSizes() const; 181 void setSearchFieldSize(RenderStyle&) const; 182 183 ThemeControlState determineState(const RenderObject&) const; 184 185 String m_mediaControlsScript; 186 String m_mediaControlsStyleSheet; 187}; 188 189} // namespace WebCore 190 191#endif // #if USE(SAFARI_THEME) 192 193#endif // RenderThemeSafari_h 194