#ifndef RenderTheme_h
#define RenderTheme_h
#if USE(NEW_THEME)
#include "platform/Theme.h"
#else
#include "platform/ThemeTypes.h"
#endif
#include "core/rendering/RenderObject.h"
#include "core/rendering/style/CachedUAStyle.h"
#include "platform/scroll/ScrollTypes.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class CSSStyleSheet;
class Element;
class FileList;
class HTMLInputElement;
class PopupMenu;
class RenderMenuList;
class RenderMeter;
class RenderProgress;
class RenderTheme : public RefCounted<RenderTheme> {
protected:
RenderTheme();
public:
virtual ~RenderTheme() { }
static RenderTheme& theme();
static void setSizeIfAuto(RenderStyle*, const IntSize&);
void adjustStyle(RenderStyle*, Element*, const CachedUAStyle&);
bool paint(RenderObject*, const PaintInfo&, const IntRect&);
bool paintBorderOnly(RenderObject*, const PaintInfo&, const IntRect&);
bool paintDecorations(RenderObject*, const PaintInfo&, const IntRect&);
virtual String extraDefaultStyleSheet();
virtual String extraQuirksStyleSheet() { return String(); }
virtual String extraMediaControlsStyleSheet() { return String(); }
virtual String extraFullScreenStyleSheet() { return String(); }
virtual int baselinePosition(const RenderObject*) const;
bool isControlContainer(ControlPart) const;
virtual bool controlSupportsTints(const RenderObject*) const { return false; }
virtual bool isControlStyled(const RenderStyle*, const CachedUAStyle&) const;
virtual bool supportsControlTints() const { return false; }
virtual void adjustRepaintRect(const RenderObject*, IntRect&);
virtual bool stateChanged(RenderObject*, ControlState) const;
bool shouldDrawDefaultFocusRing(RenderObject*) const;
virtual bool supportsHover(const RenderStyle*) const { return false; }
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
virtual bool supportsCalendarPicker(const AtomicString&) const;
#endif
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;
Color focusRingColor() const;
virtual Color platformFocusRingColor() const { return Color(0, 0, 0); }
void setCustomFocusRingColor(const Color&);
static Color tapHighlightColor();
virtual Color platformTapHighlightColor() const { return RenderTheme::defaultTapHighlightColor; }
virtual void platformColorsDidChange();
virtual double caretBlinkInterval() const { return 0.5; }
virtual void systemFont(CSSValueID, FontDescription&) const = 0;
virtual Color systemColor(CSSValueID) const;
virtual int minimumMenuListSize(RenderStyle*) const { return 0; }
virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
virtual int popupInternalPaddingLeft(RenderStyle*) const { return 0; }
virtual int popupInternalPaddingRight(RenderStyle*) const { return 0; }
virtual int popupInternalPaddingTop(RenderStyle*) const { return 0; }
virtual int popupInternalPaddingBottom(RenderStyle*) const { return 0; }
virtual bool popupOptionSupportsTextIndent() const { return false; }
virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return RegularScrollbar; }
virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&) { return 0; };
virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const;
virtual double animationDurationForProgressBar(RenderProgress*) const;
virtual String formatMediaControlsTime(float time) const;
virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const;
virtual bool supportsMeter(ControlPart) const;
virtual IntSize sliderTickSize() const = 0;
virtual int sliderTickOffsetFromTrackCenter() const = 0;
void paintSliderTicks(RenderObject*, const PaintInfo&, const IntRect&);
virtual bool shouldShowPlaceholderWhenFocused() const { return false; }
virtual bool shouldHaveSpinButton(HTMLInputElement*) const;
virtual bool delegatesMenuListRendering() const { return false; }
virtual bool popsMenuByArrowKeys() const { return false; }
virtual bool popsMenuBySpaceOrReturn() const { return false; }
virtual String fileListNameForWidth(Locale&, const FileList*, const Font&, int width) const;
virtual bool shouldOpenPickerWithF4Key() const;
virtual bool supportsSelectionForegroundColors() const { return true; }
protected:
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 supportsFocusRing(const RenderStyle*) const;
#if !USE(NEW_THEME)
virtual void adjustCheckboxStyle(RenderStyle*, Element*) const;
virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void setCheckboxSize(RenderStyle*) const { }
virtual void adjustRadioStyle(RenderStyle*, Element*) const;
virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void setRadioSize(RenderStyle*) const { }
virtual void adjustButtonStyle(RenderStyle*, Element*) const;
virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustInnerSpinButtonStyle(RenderStyle*, Element*) const;
virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
#endif
virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustMenuListStyle(RenderStyle*, Element*) const;
virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustMenuListButtonStyle(RenderStyle*, Element*) const;
virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&);
virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
#if ENABLE(INPUT_SPEECH)
virtual void adjustInputFieldSpeechButtonStyle(RenderStyle*, Element*) const;
virtual bool paintInputFieldSpeechButton(RenderObject*, const PaintInfo&, const IntRect&);
#endif
virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSliderThumbStyle(RenderStyle*, Element*) const;
virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldStyle(RenderStyle*, Element*) const;
virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldCancelButtonStyle(RenderStyle*, Element*) const;
virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldDecorationStyle(RenderStyle*, Element*) const;
virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual void adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element*) const;
virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaOverlayPlayButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaTimeRemaining(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaFullScreenVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool paintMediaFullScreenVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
virtual bool shouldUseFallbackTheme(RenderStyle*) const;
void adjustStyleUsingFallbackTheme(RenderStyle*, Element*);
bool paintUsingFallbackTheme(RenderObject*, const PaintInfo&, const IntRect&);
void adjustCheckboxStyleUsingFallbackTheme(RenderStyle*, Element*) const;
bool paintCheckboxUsingFallbackTheme(RenderObject*, const PaintInfo&, const IntRect&);
void adjustRadioStyleUsingFallbackTheme(RenderStyle*, Element*) const;
bool paintRadioUsingFallbackTheme(RenderObject*, const PaintInfo&, const IntRect&);
public:
ControlStates controlStatesForRenderer(const RenderObject* o) 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;
private:
Color m_customFocusRingColor;
bool m_hasCustomFocusRingColor;
static const RGBA32 defaultTapHighlightColor = 0x66000000;
#if USE(NEW_THEME)
Theme* m_platformTheme;
#endif
};
}
#endif