1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
/*
* This file is part of the theme implementation for form controls in WebCore.
*
* Copyright (C) 2005 Apple Computer, Inc.
* Copyright (C) 2008, 2009 Google, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef LayoutThemeMac_h
#define LayoutThemeMac_h
#import "core/layout/LayoutTheme.h"
#import "core/paint/ThemePainterMac.h"
#import "wtf/HashMap.h"
#import "wtf/RetainPtr.h"
OBJC_CLASS BlinkLayoutThemeNotificationObserver;
namespace blink {
class LayoutThemeMac final : public LayoutTheme {
public:
static PassRefPtr<LayoutTheme> create();
void addVisualOverflow(const LayoutObject&, IntRect& borderBox) override;
bool isControlStyled(const ComputedStyle&) const override;
Color platformActiveSelectionBackgroundColor() const override;
Color platformInactiveSelectionBackgroundColor() const override;
Color platformActiveSelectionForegroundColor() const override;
Color platformActiveListBoxSelectionBackgroundColor() const override;
Color platformActiveListBoxSelectionForegroundColor() const override;
Color platformInactiveListBoxSelectionBackgroundColor() const override;
Color platformInactiveListBoxSelectionForegroundColor() const override;
Color platformFocusRingColor() const override;
ScrollbarControlSize scrollbarControlSizeForPart(ControlPart part) override {
return part == ListboxPart ? SmallScrollbar : RegularScrollbar;
}
void platformColorsDidChange() override;
// System fonts.
void systemFont(CSSValueID systemFontID,
FontStyle&,
FontWeight&,
float& fontSize,
AtomicString& fontFamily) const override;
bool needsHackForTextControlWithFontFamily(
const AtomicString& family) const override;
int minimumMenuListSize(const ComputedStyle&) const override;
void adjustSliderThumbSize(ComputedStyle&) const override;
IntSize sliderTickSize() const override;
int sliderTickOffsetFromTrackCenter() const override;
int popupInternalPaddingStart(const ComputedStyle&) const override;
int popupInternalPaddingEnd(const HostWindow*,
const ComputedStyle&) const override;
int popupInternalPaddingTop(const ComputedStyle&) const override;
int popupInternalPaddingBottom(const ComputedStyle&) const override;
bool popsMenuByArrowKeys() const override { return true; }
bool popsMenuBySpaceKey() const final { return true; }
// Returns the repeat interval of the animation for the progress bar.
double animationRepeatIntervalForProgressBar() const override;
// Returns the duration of the animation for the progress bar.
double animationDurationForProgressBar() const override;
Color systemColor(CSSValueID) const override;
bool supportsSelectionForegroundColors() const override { return false; }
virtual bool isModalColorChooser() const { return false; }
protected:
LayoutThemeMac();
~LayoutThemeMac() override;
void adjustMenuListStyle(ComputedStyle&, Element*) const override;
void adjustMenuListButtonStyle(ComputedStyle&, Element*) const override;
void adjustSearchFieldStyle(ComputedStyle&) const override;
void adjustSearchFieldCancelButtonStyle(ComputedStyle&) const override;
public:
// Constants and methods shared with ThemePainterMac
// Get the control size based off the font. Used by some of the controls (like
// buttons).
NSControlSize controlSizeForFont(const ComputedStyle&) const;
NSControlSize controlSizeForSystemFont(const ComputedStyle&) const;
void setControlSize(NSCell*,
const IntSize* sizes,
const IntSize& minSize,
float zoomLevel = 1.0f);
void setSizeFromFont(ComputedStyle&, const IntSize* sizes) const;
IntSize sizeForFont(const ComputedStyle&, const IntSize* sizes) const;
IntSize sizeForSystemFont(const ComputedStyle&, const IntSize* sizes) const;
void setFontFromControlSize(ComputedStyle&, NSControlSize) const;
void updateCheckedState(NSCell*, const LayoutObject&);
void updateEnabledState(NSCell*, const LayoutObject&);
void updateFocusedState(NSCell*, const LayoutObject&);
void updatePressedState(NSCell*, const LayoutObject&);
// Helpers for adjusting appearance and for painting
void setPopupButtonCellState(const LayoutObject&, const IntRect&);
const IntSize* popupButtonSizes() const;
const int* popupButtonMargins() const;
const int* popupButtonPadding(NSControlSize) const;
const IntSize* menuListSizes() const;
const IntSize* searchFieldSizes() const;
const IntSize* cancelButtonSizes() const;
void setSearchCellState(const LayoutObject&, const IntRect&);
void setSearchFieldSize(ComputedStyle&) const;
NSPopUpButtonCell* popupButton() const;
NSSearchFieldCell* search() const;
NSTextFieldCell* textField() const;
// A view associated to the contained document. Subclasses may not have such a
// view and return a fake.
NSView* documentViewFor(const LayoutObject&) const;
void updateActiveState(NSCell*, const LayoutObject&);
// We estimate the animation rate of a Mac OS X progress bar is 33 fps.
// Hard code the value here because we haven't found API for it.
static constexpr double progressAnimationFrameRate = 0.033;
// Mac OS X progress bar animation seems to have 256 frames.
static constexpr double progressAnimationNumFrames = 256;
static constexpr float baseFontSize = 11.0f;
static constexpr float menuListBaseArrowHeight = 4.0f;
static constexpr float menuListBaseArrowWidth = 5.0f;
static constexpr float menuListBaseSpaceBetweenArrows = 2.0f;
static const int menuListArrowPaddingStart = 4;
static const int menuListArrowPaddingEnd = 4;
static const int sliderThumbWidth = 15;
static const int sliderThumbHeight = 15;
static const int sliderThumbShadowBlur = 1;
static const int sliderThumbBorderWidth = 1;
static const int sliderTrackWidth = 5;
static const int sliderTrackBorderWidth = 1;
protected:
void adjustMediaSliderThumbSize(ComputedStyle&) const;
String extraFullscreenStyleSheet() override;
// Controls color values returned from platformFocusRingColor(). systemColor()
// will be used when false.
bool usesTestModeFocusRingColor() const;
bool shouldUseFallbackTheme(const ComputedStyle&) const override;
void adjustProgressBarBounds(ComputedStyle&) const override;
private:
const int* progressBarHeights() const;
const int* progressBarMargins(NSControlSize) const;
String fileListNameForWidth(Locale&,
const FileList*,
const Font&,
int width) const override;
String extraDefaultStyleSheet() override;
bool themeDrawsFocusRing(const ComputedStyle&) const override;
ThemePainter& painter() override { return m_painter; }
mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
mutable RetainPtr<NSSearchFieldCell> m_search;
mutable RetainPtr<NSMenu> m_searchMenuTemplate;
mutable RetainPtr<NSLevelIndicatorCell> m_levelIndicator;
mutable RetainPtr<NSTextFieldCell> m_textField;
mutable HashMap<int, RGBA32> m_systemColorCache;
RetainPtr<BlinkLayoutThemeNotificationObserver> m_notificationObserver;
ThemePainterMac m_painter;
};
} // namespace blink
#endif // LayoutThemeMac_h
|