This source file includes following definitions.
- extraDefaultStyleSheet
- extraQuirksStyleSheet
- supportsHover
- supportsFocusRing
- platformActiveSelectionBackgroundColor
- platformInactiveSelectionBackgroundColor
- platformActiveSelectionForegroundColor
- platformInactiveSelectionForegroundColor
- platformFocusRingColor
- caretBlinkInterval
- systemFont
- minimumMenuListSize
- center
- setCheckboxSize
- setRadioSize
- adjustButtonStyle
- paintTextArea
- adjustSearchFieldStyle
- paintSearchField
- adjustSearchFieldCancelButtonStyle
- convertToPaintingRect
- paintSearchFieldCancelButton
- adjustSearchFieldDecorationStyle
- adjustSearchFieldResultsDecorationStyle
- paintSearchFieldResultsDecoration
- paintMediaSliderTrack
- paintMediaVolumeSliderTrack
- adjustSliderThumbSize
- paintMediaSliderThumb
- paintMediaToggleClosedCaptionsButton
- paintMediaVolumeSliderThumb
- paintMediaPlayButton
- paintMediaMuteButton
- formatMediaControlsTime
- formatMediaControlsCurrentTime
- paintMediaFullscreenButton
- adjustMenuListStyle
- adjustMenuListButtonStyle
- paintMenuListButton
- popupInternalPaddingLeft
- popupInternalPaddingRight
- popupInternalPaddingTop
- popupInternalPaddingBottom
- setDefaultFontSize
- caretBlinkIntervalInternal
- menuListArrowPadding
- menuListInternalPadding
- shouldShowPlaceholderWhenFocused
- determinateProgressValueRectFor
- indeterminateProgressValueRectFor
- animationRepeatIntervalForProgressBar
- animationDurationForProgressBar
- progressValueRectFor
- m_paintInfo
#include "config.h"
#include "core/rendering/RenderThemeChromiumSkia.h"
#include "UserAgentStyleSheets.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderBox.h"
#include "core/rendering/RenderMediaControls.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderProgress.h"
#include "core/rendering/RenderThemeChromiumFontProvider.h"
#include "platform/LayoutTestSupport.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/Image.h"
#include "platform/scroll/ScrollbarTheme.h"
#include "wtf/CurrentTime.h"
#include "wtf/StdLibExtras.h"
namespace WebCore {
enum PaddingType {
TopPadding,
RightPadding,
BottomPadding,
LeftPadding
};
static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
static const float defaultControlFontPixelSize = 13;
static const float defaultCancelButtonSize = 9;
static const float minCancelButtonSize = 5;
static const float maxCancelButtonSize = 21;
static const float defaultSearchFieldResultsDecorationSize = 13;
static const float minSearchFieldResultsDecorationSize = 9;
static const float maxSearchFieldResultsDecorationSize = 30;
RenderThemeChromiumSkia::RenderThemeChromiumSkia()
{
}
RenderThemeChromiumSkia::~RenderThemeChromiumSkia()
{
}
String RenderThemeChromiumSkia::extraDefaultStyleSheet()
{
return RenderTheme::extraDefaultStyleSheet() +
String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet)) +
String(themeChromiumSkiaUserAgentStyleSheet, sizeof(themeChromiumSkiaUserAgentStyleSheet)) +
String(themeChromiumUserAgentStyleSheet, sizeof(themeChromiumUserAgentStyleSheet));
}
String RenderThemeChromiumSkia::extraQuirksStyleSheet()
{
return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet));
}
bool RenderThemeChromiumSkia::supportsHover(const RenderStyle* style) const
{
return true;
}
bool RenderThemeChromiumSkia::supportsFocusRing(const RenderStyle* style) const
{
return false;
}
Color RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor() const
{
return Color(0x1e, 0x90, 0xff);
}
Color RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor() const
{
return Color(0xc8, 0xc8, 0xc8);
}
Color RenderThemeChromiumSkia::platformActiveSelectionForegroundColor() const
{
return Color::black;
}
Color RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor() const
{
return Color(0x32, 0x32, 0x32);
}
Color RenderThemeChromiumSkia::platformFocusRingColor() const
{
static Color focusRingColor(229, 151, 0, 255);
return focusRingColor;
}
double RenderThemeChromiumSkia::caretBlinkInterval() const
{
if (isRunningLayoutTest())
return 0;
return caretBlinkIntervalInternal();
}
void RenderThemeChromiumSkia::systemFont(CSSValueID valueID, FontDescription& fontDescription) const
{
RenderThemeChromiumFontProvider::systemFont(valueID, fontDescription);
}
int RenderThemeChromiumSkia::minimumMenuListSize(RenderStyle* style) const
{
return 0;
}
static const int widgetStandardWidth = 13;
static const int widgetStandardHeight = 13;
IntRect center(const IntRect& original, int width, int height)
{
width = std::min(original.width(), width);
height = std::min(original.height(), height);
int x = original.x() + (original.width() - width) / 2;
int y = original.y() + (original.height() - height) / 2;
return IntRect(x, y, width, height);
}
void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const
{
if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
return;
const IntSize size(widgetStandardWidth, widgetStandardHeight);
setSizeIfAuto(style, size);
}
void RenderThemeChromiumSkia::setRadioSize(RenderStyle* style) const
{
setCheckboxSize(style);
}
void RenderThemeChromiumSkia::adjustButtonStyle(RenderStyle* style, Element*) const
{
if (style->appearance() == PushButtonPart) {
style->setLineHeight(RenderStyle::initialLineHeight());
}
}
bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
return paintTextField(o, i, r);
}
void RenderThemeChromiumSkia::adjustSearchFieldStyle(RenderStyle* style, Element*) const
{
style->setLineHeight(RenderStyle::initialLineHeight());
}
bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
return paintTextField(o, i, r);
}
void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(RenderStyle* style, Element*) const
{
float fontScale = style->fontSize() / defaultControlFontPixelSize;
int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
style->setWidth(Length(cancelButtonSize, Fixed));
style->setHeight(Length(cancelButtonSize, Fixed));
}
IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const
{
LayoutSize offsetFromInputRenderer = -partRenderer->offsetFromAncestorContainer(inputRenderer);
partRect.move(offsetFromInputRenderer);
partRect.move(localOffset.x(), localOffset.y());
return pixelSnappedIntRect(partRect);
}
bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r)
{
if (!cancelButtonObject->node())
return false;
Node* input = cancelButtonObject->node()->shadowHost();
RenderObject* baseRenderer = input ? input->renderer() : cancelButtonObject;
if (!baseRenderer->isBox())
return false;
RenderBox* inputRenderBox = toRenderBox(baseRenderer);
LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height()));
LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
cancelButtonSize, cancelButtonSize);
IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r);
DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCancel")));
DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("searchCancelPressed")));
paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage, paintingRect);
return false;
}
void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(RenderStyle* style, Element*) const
{
IntSize emptySize(1, 11);
style->setWidth(Length(emptySize.width(), Fixed));
style->setHeight(Length(emptySize.height(), Fixed));
}
void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(RenderStyle* style, Element*) const
{
float fontScale = style->fontSize() / defaultControlFontPixelSize;
int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
maxSearchFieldResultsDecorationSize));
style->setWidth(Length(magnifierSize, Fixed));
style->setHeight(Length(magnifierSize, Fixed));
}
bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* magnifierObject, const PaintInfo& paintInfo, const IntRect& r)
{
if (!magnifierObject->node())
return false;
Node* input = magnifierObject->node()->shadowHost();
RenderObject* baseRenderer = input ? input->renderer() : magnifierObject;
if (!baseRenderer->isBox())
return false;
RenderBox* inputRenderBox = toRenderBox(baseRenderer);
LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height()));
LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
magnifierSize, magnifierSize);
IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searchMagnifier")));
paintInfo.context->drawImage(magnifierImage, paintingRect);
return false;
}
bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaSlider, object, paintInfo, rect);
}
bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect);
}
void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderStyle* style, Element*) const
{
RenderMediaControls::adjustMediaSliderThumbSize(style);
}
bool RenderThemeChromiumSkia::paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect);
}
bool RenderThemeChromiumSkia::paintMediaToggleClosedCaptionsButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
return RenderMediaControls::paintMediaControlsPart(MediaShowClosedCaptionsButton, o, paintInfo, r);
}
bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect);
}
bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect);
}
bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect);
}
String RenderThemeChromiumSkia::formatMediaControlsTime(float time) const
{
return RenderMediaControls::formatMediaControlsTime(time);
}
String RenderThemeChromiumSkia::formatMediaControlsCurrentTime(float currentTime, float duration) const
{
return RenderMediaControls::formatMediaControlsCurrentTime(currentTime, duration);
}
bool RenderThemeChromiumSkia::paintMediaFullscreenButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaEnterFullscreenButton, object, paintInfo, rect);
}
void RenderThemeChromiumSkia::adjustMenuListStyle(RenderStyle* style, WebCore::Element*) const
{
style->setLineHeight(RenderStyle::initialLineHeight());
}
void RenderThemeChromiumSkia::adjustMenuListButtonStyle(RenderStyle* style, Element* e) const
{
adjustMenuListStyle(style, e);
}
bool RenderThemeChromiumSkia::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& rect)
{
return paintMenuList(o, i, rect);
}
int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const
{
return menuListInternalPadding(style, LeftPadding);
}
int RenderThemeChromiumSkia::popupInternalPaddingRight(RenderStyle* style) const
{
return menuListInternalPadding(style, RightPadding);
}
int RenderThemeChromiumSkia::popupInternalPaddingTop(RenderStyle* style) const
{
return menuListInternalPadding(style, TopPadding);
}
int RenderThemeChromiumSkia::popupInternalPaddingBottom(RenderStyle* style) const
{
return menuListInternalPadding(style, BottomPadding);
}
void RenderThemeChromiumSkia::setDefaultFontSize(int fontSize)
{
RenderThemeChromiumFontProvider::setDefaultFontSize(fontSize);
}
double RenderThemeChromiumSkia::caretBlinkIntervalInternal() const
{
return RenderTheme::caretBlinkInterval();
}
int RenderThemeChromiumSkia::menuListArrowPadding() const
{
return ScrollbarTheme::theme()->scrollbarThickness();
}
int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int paddingType) const
{
int padding = styledMenuListInternalPadding[paddingType];
const int barType = style->direction() == LTR ? RightPadding : LeftPadding;
if (paddingType == barType && style->appearance() != NoControlPart)
padding += menuListArrowPadding();
return padding;
}
bool RenderThemeChromiumSkia::shouldShowPlaceholderWhenFocused() const
{
return true;
}
static const int progressActivityBlocks = 5;
static const int progressAnimationFrames = 10;
static const double progressAnimationInterval = 0.125;
IntRect RenderThemeChromiumSkia::determinateProgressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const
{
int dx = rect.width() * renderProgress->position();
return IntRect(rect.x(), rect.y(), dx, rect.height());
}
IntRect RenderThemeChromiumSkia::indeterminateProgressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const
{
int valueWidth = rect.width() / progressActivityBlocks;
int movableWidth = rect.width() - valueWidth;
if (movableWidth <= 0)
return IntRect();
double progress = renderProgress->animationProgress();
if (progress < 0.5)
return IntRect(rect.x() + progress * 2 * movableWidth, rect.y(), valueWidth, rect.height());
return IntRect(rect.x() + (1.0 - progress) * 2 * movableWidth, rect.y(), valueWidth, rect.height());
}
double RenderThemeChromiumSkia::animationRepeatIntervalForProgressBar(RenderProgress*) const
{
return progressAnimationInterval;
}
double RenderThemeChromiumSkia::animationDurationForProgressBar(RenderProgress* renderProgress) const
{
return progressAnimationInterval * progressAnimationFrames * 2;
}
IntRect RenderThemeChromiumSkia::progressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const
{
return renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect);
}
RenderThemeChromiumSkia::DirectionFlippingScope::DirectionFlippingScope(RenderObject* renderer, const PaintInfo& paintInfo, const IntRect& rect)
: m_needsFlipping(!renderer->style()->isLeftToRightDirection())
, m_paintInfo(paintInfo)
{
if (!m_needsFlipping)
return;
m_paintInfo.context->save();
m_paintInfo.context->translate(2 * rect.x() + rect.width(), 0);
m_paintInfo.context->scale(FloatSize(-1, 1));
}
RenderThemeChromiumSkia::DirectionFlippingScope::~DirectionFlippingScope()
{
if (!m_needsFlipping)
return;
m_paintInfo.context->restore();
}
}