#pragma once
#include "BorderData.h"
#include "ControlStates.h"
#include "FillLayer.h"
#if USE(NEW_THEME)
#include "Theme.h"
#else
#include "ThemeTypes.h"
#endif
#include "PaintInfo.h"
#include "PopupMenuStyle.h"
#include "ScrollTypes.h"
#include <wtf/RefCounted.h>
namespace WebCore {
class CSSStyleSheet;
class Element;
class FileList;
class HTMLInputElement;
class Icon;
class Page;
class PopupMenu;
class RenderAttachment;
class RenderBox;
class RenderMenuList;
class RenderMeter;
class RenderObject;
class RenderProgress;
class RenderSnapshottedPlugIn;
class StyleResolver;
class RenderTheme : public RefCounted<RenderTheme> {
protected:
RenderTheme();
public:
virtual ~RenderTheme() { }
WEBCORE_EXPORT static RenderTheme& singleton();
virtual void purgeCaches() { }
void adjustStyle(StyleResolver&, RenderStyle&, const Element*, bool UAHasAppearance, const BorderData&, const FillLayer&, const Color& backgroundColor);
bool paint(const RenderBox&, ControlStates&, const PaintInfo&, const LayoutRect&);
bool paintBorderOnly(const RenderBox&, const PaintInfo&, const LayoutRect&);
bool paintDecorations(const RenderBox&, const PaintInfo&, const LayoutRect&);
virtual String extraDefaultStyleSheet() { return String(); }
virtual String extraQuirksStyleSheet() { return String(); }
virtual String extraPlugInsStyleSheet() { return String(); }
#if ENABLE(VIDEO)
virtual String mediaControlsStyleSheet() { return String(); }
virtual String modernMediaControlsStyleSheet() { return String(); }
virtual String extraMediaControlsStyleSheet() { return String(); }
virtual String mediaControlsScript() { return String(); }
virtual String mediaControlsBase64StringForIconNameAndType(const String&, const String&) { return String(); }
virtual String mediaControlsFormattedStringForDuration(double) { return String(); }
#endif
#if ENABLE(FULLSCREEN_API)
virtual String extraFullScreenStyleSheet() { return String(); }
#endif
#if ENABLE(SERVICE_CONTROLS)
virtual String imageControlsStyleSheet() const { return String(); }
#endif
virtual int baselinePosition(const RenderBox&) const;
bool isControlContainer(ControlPart) const;
virtual bool controlSupportsTints(const RenderObject&) const { return false; }
virtual bool isControlStyled(const RenderStyle&, const BorderData&, const FillLayer&, const Color& backgroundColor) const;
virtual bool supportsControlTints() const { return false; }
virtual void adjustRepaintRect(const RenderObject&, FloatRect&);
virtual bool stateChanged(const RenderObject&, ControlStates::States) const;
virtual void themeChanged() { }
virtual bool supportsFocusRing(const RenderStyle&) const;
virtual bool supportsHover(const RenderStyle&) const { return false; }
virtual bool supportsDataListUI(const AtomicString&) const { return false; }
Color activeSelectionBackgroundColor() const;
Color inactiveSelectionBackgroundColor() const;
Color activeSelectionForegroundColor() const;
Color inactiveSelectionForegroundColor() const;
Color activeListBoxSelectionBackgroundColor() const;
Color activeListBoxSelectionForegroundColor() const;
Color inactiveListBoxSelectionBackgroundColor() const;
Color inactiveListBoxSelectionForegroundColor() const;
virtual Color platformActiveTextSearchHighlightColor() const;
virtual Color platformInactiveTextSearchHighlightColor() const;
virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
static Color focusRingColor();
virtual Color platformFocusRingColor() const { return Color(0, 0, 0); }
static void setCustomFocusRingColor(const Color&);
static float platformFocusRingWidth() { return 3; }
static float platformFocusRingOffset(float outlineWidth) { return std::max<float>(outlineWidth - platformFocusRingWidth(), 0); }
#if ENABLE(TOUCH_EVENTS)
static Color tapHighlightColor();
virtual Color platformTapHighlightColor() const;
#endif
virtual void platformColorsDidChange();
virtual Seconds caretBlinkInterval() const { return 500_ms; }
void systemFont(CSSValueID, FontCascadeDescription&) const;
virtual Color systemColor(CSSValueID) const;
virtual int minimumMenuListSize(const RenderStyle&) const { return 0; }
virtual void adjustSliderThumbSize(RenderStyle&, const Element*) const;
virtual LengthBox popupInternalPaddingBox(const RenderStyle&) const { return { 0, 0, 0, 0 }; }
virtual bool popupOptionSupportsTextIndent() const { return false; }
virtual PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle&, IntRect&) const { return PopupMenuStyle::PopupMenuSizeNormal; }
virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return RegularScrollbar; }
virtual Seconds animationRepeatIntervalForProgressBar(RenderProgress&) const;
virtual double animationDurationForProgressBar(RenderProgress&) const;
virtual IntRect progressBarRectForBounds(const RenderObject&, const IntRect&) const;
#if ENABLE(VIDEO)
virtual bool supportsClosedCaptioning() const { return false; }
virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return false; }
virtual bool usesMediaControlStatusDisplay() { return false; }
virtual bool usesMediaControlVolumeSlider() const { return true; }
virtual bool usesVerticalVolumeSlider() const { return true; }
virtual double mediaControlsFadeInDuration() { return 0.1; }
virtual Seconds mediaControlsFadeOutDuration() { return 300_ms; }
virtual String formatMediaControlsTime(float time) const;
virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const;
virtual LayoutPoint volumeSliderOffsetFromMuteButton(const RenderBox&, const LayoutSize&) const;
#endif
#if ENABLE(METER_ELEMENT)
virtual IntSize meterSizeForBounds(const RenderMeter&, const IntRect&) const;
virtual bool supportsMeter(ControlPart) const;
#endif
#if ENABLE(DATALIST_ELEMENT)
virtual LayoutUnit sliderTickSnappingThreshold() const;
virtual IntSize sliderTickSize() const = 0;
virtual int sliderTickOffsetFromTrackCenter() const = 0;
void paintSliderTicks(const RenderObject&, const PaintInfo&, const IntRect&);
#endif
virtual bool shouldHaveSpinButton(const HTMLInputElement&) const;
virtual bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const;
virtual bool delegatesMenuListRendering() const { return false; }
virtual bool popsMenuByArrowKeys() const { return false; }
virtual bool popsMenuBySpaceOrReturn() const { return false; }
virtual String fileListDefaultLabel(bool multipleFilesAllowed) const;
virtual String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const;
enum FileUploadDecorations { SingleFile, MultipleFiles };
virtual bool paintFileUploadIconDecorations(const RenderObject& , const RenderObject& , const PaintInfo&, const IntRect&, Icon*, FileUploadDecorations) { return true; }
#if ENABLE(SERVICE_CONTROLS)
virtual IntSize imageControlsButtonSize(const RenderObject&) const { return IntSize(); }
virtual IntSize imageControlsButtonPositionOffset() const { return IntSize(); }
#endif
#if ENABLE(ATTACHMENT_ELEMENT)
virtual LayoutSize attachmentIntrinsicSize(const RenderAttachment&) const { return LayoutSize(); }
virtual int attachmentBaseline(const RenderAttachment&) const { return -1; }
#endif
enum class InnerSpinButtonLayout { Vertical, HorizontalUpLeft, HorizontalUpRight };
virtual InnerSpinButtonLayout innerSpinButtonLayout(const RenderObject&) const { return InnerSpinButtonLayout::Vertical; }
virtual bool shouldMockBoldSystemFontForAccessibility() const { return false; }
virtual void setShouldMockBoldSystemFontForAccessibility(bool) { }
protected:
virtual FontCascadeDescription& cachedSystemFontDescription(CSSValueID systemFontID) const;
virtual void updateCachedSystemFontDescription(CSSValueID systemFontID, FontCascadeDescription&) const = 0;
virtual Color platformActiveSelectionBackgroundColor() const;
virtual Color platformInactiveSelectionBackgroundColor() const;
virtual Color platformActiveSelectionForegroundColor() const;
virtual Color platformInactiveSelectionForegroundColor() const;
virtual Color platformActiveListBoxSelectionBackgroundColor() const;
virtual Color platformInactiveListBoxSelectionBackgroundColor() const;
virtual Color platformActiveListBoxSelectionForegroundColor() const;
virtual Color platformInactiveListBoxSelectionForegroundColor() const;
virtual bool supportsSelectionForegroundColors() const { return true; }
virtual bool supportsListBoxSelectionForegroundColors() const { return true; }
#if !USE(NEW_THEME)
virtual void adjustCheckboxStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintCheckbox(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void setCheckboxSize(RenderStyle&) const { }
virtual void adjustRadioStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintRadio(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void setRadioSize(RenderStyle&) const { }
virtual void adjustButtonStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void setButtonSize(RenderStyle&) const { }
virtual void adjustInnerSpinButtonStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintInnerSpinButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
#endif
virtual bool paintCheckboxDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintRadioDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintButtonDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustTextFieldStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintTextField(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
virtual bool paintTextFieldDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
virtual void adjustTextAreaStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
virtual bool paintTextAreaDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
virtual void adjustMenuListStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
virtual bool paintMenuListDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintMenuListButtonDecorations(const RenderBox&, const PaintInfo&, const FloatRect&) { return true; }
virtual bool paintPushButtonDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintSquareButtonDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
#if ENABLE(METER_ELEMENT)
virtual void adjustMeterStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintMeter(const RenderObject&, const PaintInfo&, const IntRect&);
#endif
virtual void adjustCapsLockIndicatorStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintCapsLockIndicator(const RenderObject&, const PaintInfo&, const IntRect&);
#if ENABLE(APPLE_PAY)
virtual void adjustApplePayButtonStyle(StyleResolver&, RenderStyle&, const Element*) const { }
virtual bool paintApplePayButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
#endif
#if ENABLE(ATTACHMENT_ELEMENT)
virtual void adjustAttachmentStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&);
#endif
virtual void adjustProgressBarStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintProgressBar(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSliderTrackStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSliderThumbStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSliderThumb(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintSliderThumbDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSearchField(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintSearchFieldDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldCancelButtonStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldDecorationPartStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSearchFieldDecorationPart(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSearchFieldResultsDecorationPart(const RenderBox&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintSearchFieldResultsButton(const RenderBox&, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustMediaControlStyle(StyleResolver&, RenderStyle&, const Element*) const;
virtual bool paintMediaFullscreenButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaPlayButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaOverlayPlayButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaMuteButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaSeekBackButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaSeekForwardButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaSliderThumb(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaVolumeSliderContainer(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaVolumeSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaVolumeSliderThumb(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaRewindButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaReturnToRealtimeButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaToggleClosedCaptionsButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaControlsBackground(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaCurrentTime(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaTimeRemaining(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaFullScreenVolumeSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaFullScreenVolumeSliderThumb(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintSnapshottedPluginOverlay(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
#if ENABLE(SERVICE_CONTROLS)
virtual bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
#endif
public:
void updateControlStatesForRenderer(const RenderBox&, ControlStates&) const;
ControlStates::States extractControlStatesForRenderer(const RenderObject&) const;
bool isActive(const RenderObject&) const;
bool isChecked(const RenderObject&) const;
bool isIndeterminate(const RenderObject&) const;
bool isEnabled(const RenderObject&) const;
bool isFocused(const RenderObject&) const;
bool isPressed(const RenderObject&) const;
bool isSpinUpButtonPartPressed(const RenderObject&) const;
bool isHovered(const RenderObject&) const;
bool isSpinUpButtonPartHovered(const RenderObject&) const;
bool isReadOnlyControl(const RenderObject&) const;
bool isDefault(const RenderObject&) const;
private:
mutable Color m_activeSelectionBackgroundColor;
mutable Color m_inactiveSelectionBackgroundColor;
mutable Color m_activeSelectionForegroundColor;
mutable Color m_inactiveSelectionForegroundColor;
mutable Color m_activeListBoxSelectionBackgroundColor;
mutable Color m_inactiveListBoxSelectionBackgroundColor;
mutable Color m_activeListBoxSelectionForegroundColor;
mutable Color m_inactiveListBoxSelectionForegroundColor;
#if USE(NEW_THEME)
Theme* m_theme; #endif
};
}