#include "config.h"
#include "core/rendering/RenderTheme.h"
-#include "CSSValueKeywords.h"
-#include "HTMLNames.h"
-#include "InputTypeNames.h"
-#include "RuntimeEnabledFeatures.h"
+#include "core/CSSValueKeywords.h"
+#include "core/HTMLNames.h"
+#include "core/InputTypeNames.h"
#include "core/dom/Document.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/editing/FrameSelection.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLDataListElement.h"
+#include "core/html/HTMLDataListOptionsCollection.h"
#include "core/html/HTMLFormControlElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLMeterElement.h"
#include "core/rendering/style/RenderStyle.h"
#include "platform/FileMetadata.h"
#include "platform/FloatConversion.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/fonts/FontSelector.h"
#include "platform/graphics/GraphicsContextStateSaver.h"
#include "platform/text/PlatformLocale.h"
#include "public/platform/WebRect.h"
#include "wtf/text/StringBuilder.h"
-#if ENABLE(INPUT_SPEECH)
-#include "core/rendering/RenderInputSpeech.h"
-#endif
-
// The methods in this file are shared by all themes on every platform.
-namespace WebCore {
+namespace blink {
using namespace HTMLNames;
-static blink::WebFallbackThemeEngine::State getWebFallbackThemeState(const RenderTheme* theme, const RenderObject* o)
+static WebFallbackThemeEngine::State getWebFallbackThemeState(const RenderTheme* theme, const RenderObject* o)
{
if (!theme->isEnabled(o))
- return blink::WebFallbackThemeEngine::StateDisabled;
+ return WebFallbackThemeEngine::StateDisabled;
if (theme->isPressed(o))
- return blink::WebFallbackThemeEngine::StatePressed;
+ return WebFallbackThemeEngine::StatePressed;
if (theme->isHovered(o))
- return blink::WebFallbackThemeEngine::StateHover;
+ return WebFallbackThemeEngine::StateHover;
- return blink::WebFallbackThemeEngine::StateNormal;
+ return WebFallbackThemeEngine::StateNormal;
}
RenderTheme::RenderTheme()
{
}
-void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyle& uaStyle)
+void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyle* uaStyle)
{
// Force inline and table display styles to be inline-block (except for table- which is block)
ControlPart part = style->appearance();
else if (style->display() == LIST_ITEM || style->display() == TABLE)
style->setDisplay(BLOCK);
- if (uaStyle.hasAppearance && isControlStyled(style, uaStyle)) {
+ if (uaStyle && isControlStyled(style, uaStyle)) {
if (part == MenulistPart) {
style->setAppearance(MenulistButtonPart);
part = MenulistButtonPart;
return adjustSearchFieldDecorationStyle(style, e);
case SearchFieldResultsDecorationPart:
return adjustSearchFieldResultsDecorationStyle(style, e);
-#if ENABLE(INPUT_SPEECH)
- case InputSpeechButtonPart:
- return adjustInputFieldSpeechButtonStyle(style, e);
-#endif
default:
break;
}
bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
- // If painting is disabled, but we aren't updating control tints, then just bail.
- // If we are updating control tints, just schedule a repaint if the theme supports tinting
- // for that control.
- if (paintInfo.context->updatingControlTints()) {
- if (controlSupportsTints(o))
- o->repaint();
- return false;
- }
- if (paintInfo.context->paintingDisabled())
- return false;
-
ControlPart part = o->style()->appearance();
if (shouldUseFallbackTheme(o->style()))
return paintMediaCurrentTime(o, paintInfo, r);
case MediaControlsBackgroundPart:
return paintMediaControlsBackground(o, paintInfo, r);
+ case MediaCastOffButtonPart:
+ return paintMediaCastButton(o, paintInfo, r);
+ case MediaOverlayCastOffButtonPart:
+ return paintMediaCastButton(o, paintInfo, r);
case MenulistButtonPart:
case TextFieldPart:
case TextAreaPart:
- case ListboxPart:
return true;
case SearchFieldPart:
return paintSearchField(o, paintInfo, r);
return paintSearchFieldDecoration(o, paintInfo, r);
case SearchFieldResultsDecorationPart:
return paintSearchFieldResultsDecoration(o, paintInfo, r);
-#if ENABLE(INPUT_SPEECH)
- case InputSpeechButtonPart:
- return paintInputFieldSpeechButton(o, paintInfo, r);
-#endif
default:
break;
}
bool RenderTheme::paintBorderOnly(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
- if (paintInfo.context->paintingDisabled())
- return false;
-
// Call the appropriate paint method based off the appearance value.
switch (o->style()->appearance()) {
case TextFieldPart:
return paintTextField(o, paintInfo, r);
- case ListboxPart:
case TextAreaPart:
return paintTextArea(o, paintInfo, r);
case MenulistButtonPart:
case SearchFieldPart:
+ case ListboxPart:
return true;
case CheckboxPart:
case RadioPart:
case SearchFieldCancelButtonPart:
case SearchFieldDecorationPart:
case SearchFieldResultsDecorationPart:
-#if ENABLE(INPUT_SPEECH)
- case InputSpeechButtonPart:
-#endif
default:
break;
}
bool RenderTheme::paintDecorations(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
- if (paintInfo.context->paintingDisabled())
- return false;
-
// Call the appropriate paint method based off the appearance value.
switch (o->style()->appearance()) {
case MenulistButtonPart:
return paintMenuListButton(o, paintInfo, r);
case TextFieldPart:
case TextAreaPart:
- case ListboxPart:
case CheckboxPart:
case RadioPart:
case PushButtonPart:
case SearchFieldCancelButtonPart:
case SearchFieldDecorationPart:
case SearchFieldResultsDecorationPart:
-#if ENABLE(INPUT_SPEECH)
- case InputSpeechButtonPart:
-#endif
default:
break;
}
String RenderTheme::extraDefaultStyleSheet()
{
StringBuilder runtimeCSS;
- if (RuntimeEnabledFeatures::dialogElementEnabled()) {
- runtimeCSS.appendLiteral("dialog:not([open]) { display: none; }");
- runtimeCSS.appendLiteral("dialog { position: absolute; left: 0; right: 0; width: -webkit-fit-content; height: -webkit-fit-content; margin: auto; border: solid; padding: 1em; background: white; color: black;}");
- runtimeCSS.appendLiteral("dialog::backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,0.1); }");
- }
-
+ if (RuntimeEnabledFeatures::contextMenuEnabled())
+ runtimeCSS.appendLiteral("menu[type=\"popup\" i] { display: none; }");
return runtimeCSS.toString();
}
{
// Code below excludes the background-repeat from comparison by resetting it
FillLayer backgroundCopy = uaStyle.backgroundLayers;
- FillLayer backgroundLayersCopy = *style.backgroundLayers();
+ FillLayer backgroundLayersCopy = style.backgroundLayers();
backgroundCopy.setRepeatX(NoRepeatFill);
backgroundCopy.setRepeatY(NoRepeatFill);
backgroundLayersCopy.setRepeatX(NoRepeatFill);
|| style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.backgroundColor;
}
-bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle& uaStyle) const
+bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle* uaStyle) const
{
+ ASSERT(uaStyle);
+
switch (style->appearance()) {
case PushButtonPart:
case SquareButtonPart:
case ContinuousCapacityLevelIndicatorPart:
case DiscreteCapacityLevelIndicatorPart:
case RatingLevelIndicatorPart:
- return isBackgroundOrBorderStyled(*style, uaStyle);
+ return isBackgroundOrBorderStyled(*style, *uaStyle);
- case ListboxPart:
case MenulistPart:
case SearchFieldPart:
case TextAreaPart:
case TextFieldPart:
- return isBackgroundOrBorderStyled(*style, uaStyle) || style->boxShadow();
+ return isBackgroundOrBorderStyled(*style, *uaStyle) || style->boxShadow();
case SliderHorizontalPart:
case SliderVerticalPart:
}
}
-void RenderTheme::adjustRepaintRect(const RenderObject* o, IntRect& r)
+void RenderTheme::adjustPaintInvalidationRect(const RenderObject* o, IntRect& r)
{
#if USE(NEW_THEME)
m_platformTheme->inflateControlPaintRect(o->style()->appearance(), controlStatesForRenderer(o), r, o->style()->effectiveZoom());
{
if (supportsFocusRing(renderer->style()))
return false;
- if (!renderer->style()->hasAppearance())
- return true;
Node* node = renderer->node();
if (!node)
return true;
+ if (!renderer->style()->hasAppearance() && !node->isLink())
+ return true;
// We can't use RenderTheme::isFocused because outline:auto might be
// specified to non-:focus rulesets.
if (node->focused() && !node->shouldHaveFocusAppearance())
bool RenderTheme::stateChanged(RenderObject* o, ControlState state) const
{
// Default implementation assumes the controls don't respond to changes in :hover state
- if (state == HoverState && !supportsHover(o->style()))
+ if (state == HoverControlState && !supportsHover(o->style()))
return false;
// Assume pressed state is only responded to if the control is enabled.
- if (state == PressedState && !isEnabled(o))
+ if (state == PressedControlState && !isEnabled(o))
return false;
- // Repaint the control.
- o->repaint();
+ o->setShouldDoFullPaintInvalidation();
return true;
}
{
ControlStates result = 0;
if (isHovered(o)) {
- result |= HoverState;
+ result |= HoverControlState;
if (isSpinUpButtonPartHovered(o))
- result |= SpinUpState;
+ result |= SpinUpControlState;
}
if (isPressed(o)) {
- result |= PressedState;
+ result |= PressedControlState;
if (isSpinUpButtonPartPressed(o))
- result |= SpinUpState;
+ result |= SpinUpControlState;
}
if (isFocused(o) && o->style()->outlineStyleIsAuto())
- result |= FocusState;
+ result |= FocusControlState;
if (isEnabled(o))
- result |= EnabledState;
+ result |= EnabledControlState;
if (isChecked(o))
- result |= CheckedState;
+ result |= CheckedControlState;
if (isReadOnlyControl(o))
- result |= ReadOnlyState;
+ result |= ReadOnlyControlState;
if (!isActive(o))
- result |= WindowInactiveState;
+ result |= WindowInactiveControlState;
if (isIndeterminate(o))
- result |= IndeterminateState;
+ result |= IndeterminateControlState;
return result;
}
node = node->focusDelegate();
Document& document = node->document();
LocalFrame* frame = document.frame();
- return node == document.focusedElement() && node->shouldHaveFocusAppearance() && frame && frame->selection().isFocusedAndActive();
+ return node == document.focusedElement() && node->focused() && node->shouldHaveFocusAppearance() && frame && frame->selection().isFocusedAndActive();
}
bool RenderTheme::isPressed(const RenderObject* o) const
{
}
-#if ENABLE(INPUT_SPEECH)
-void RenderTheme::adjustInputFieldSpeechButtonStyle(RenderStyle* style, Element* element) const
-{
- RenderInputSpeech::adjustInputFieldSpeechButtonStyle(style, element);
-}
-
-bool RenderTheme::paintInputFieldSpeechButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
-{
- return RenderInputSpeech::paintInputFieldSpeechButton(object, paintInfo, rect);
-}
-#endif
-
IntSize RenderTheme::meterSizeForBounds(const RenderMeter*, const IntRect& bounds) const
{
return bounds.size();
return;
HTMLInputElement* input = toHTMLInputElement(node);
- if (!input->isRangeControl())
+ if (input->type() != InputTypeNames::range)
return;
HTMLDataListElement* dataList = input->dataList();
tickRegionSideMargin = trackBounds.y() + (thumbSize.width() - tickSize.width() * zoomFactor) / 2.0;
tickRegionWidth = trackBounds.height() - thumbSize.width();
}
- RefPtr<HTMLCollection> options = dataList->options();
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
- paintInfo.context->setFillColor(o->resolveColor(CSSPropertyColor));
- for (unsigned i = 0; Element* element = options->item(i); i++) {
- ASSERT(isHTMLOptionElement(*element));
- HTMLOptionElement& optionElement = toHTMLOptionElement(*element);
- String value = optionElement.value();
+ RefPtrWillBeRawPtr<HTMLDataListOptionsCollection> options = dataList->options();
+ for (unsigned i = 0; HTMLOptionElement* optionElement = options->item(i); i++) {
+ String value = optionElement->value();
if (!input->isValidValue(value))
continue;
double parsedValue = parseToDoubleForNumberType(input->sanitizeValue(value));
tickRect.setX(tickPosition);
else
tickRect.setY(tickPosition);
- paintInfo.context->fillRect(tickRect);
+ paintInfo.context->fillRect(tickRect, o->resolveColor(CSSPropertyColor));
}
}
bool RenderTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const
{
- return inputElement->isSteppable() && !inputElement->isRangeControl();
+ return inputElement->isSteppable() && inputElement->type() != InputTypeNames::range;
}
void RenderTheme::adjustMenuListButtonStyle(RenderStyle*, Element*) const
Page::scheduleForcedStyleRecalcForAllPages();
}
+static FontDescription& getCachedFontDescription(CSSValueID systemFontID)
+{
+ DEFINE_STATIC_LOCAL(FontDescription, caption, ());
+ DEFINE_STATIC_LOCAL(FontDescription, icon, ());
+ DEFINE_STATIC_LOCAL(FontDescription, menu, ());
+ DEFINE_STATIC_LOCAL(FontDescription, messageBox, ());
+ DEFINE_STATIC_LOCAL(FontDescription, smallCaption, ());
+ DEFINE_STATIC_LOCAL(FontDescription, statusBar, ());
+ DEFINE_STATIC_LOCAL(FontDescription, webkitMiniControl, ());
+ DEFINE_STATIC_LOCAL(FontDescription, webkitSmallControl, ());
+ DEFINE_STATIC_LOCAL(FontDescription, webkitControl, ());
+ DEFINE_STATIC_LOCAL(FontDescription, defaultDescription, ());
+ switch (systemFontID) {
+ case CSSValueCaption:
+ return caption;
+ case CSSValueIcon:
+ return icon;
+ case CSSValueMenu:
+ return menu;
+ case CSSValueMessageBox:
+ return messageBox;
+ case CSSValueSmallCaption:
+ return smallCaption;
+ case CSSValueStatusBar:
+ return statusBar;
+ case CSSValueWebkitMiniControl:
+ return webkitMiniControl;
+ case CSSValueWebkitSmallControl:
+ return webkitSmallControl;
+ case CSSValueWebkitControl:
+ return webkitControl;
+ case CSSValueNone:
+ return defaultDescription;
+ default:
+ ASSERT_NOT_REACHED();
+ return defaultDescription;
+ }
+}
+
+void RenderTheme::systemFont(CSSValueID systemFontID, FontDescription& fontDescription)
+{
+ fontDescription = getCachedFontDescription(systemFontID);
+ if (fontDescription.isAbsoluteSize())
+ return;
+
+ FontStyle fontStyle = FontStyleNormal;
+ FontWeight fontWeight = FontWeightNormal;
+ float fontSize = 0;
+ AtomicString fontFamily;
+ systemFont(systemFontID, fontStyle, fontWeight, fontSize, fontFamily);
+ fontDescription.setStyle(fontStyle);
+ fontDescription.setWeight(fontWeight);
+ fontDescription.setSpecifiedSize(fontSize);
+ fontDescription.setIsAbsoluteSize(true);
+ fontDescription.firstFamily().setFamily(fontFamily);
+ fontDescription.setGenericFamily(FontDescription::NoFamily);
+}
+
Color RenderTheme::systemColor(CSSValueID cssValueId) const
{
switch (cssValueId) {
String string;
if (fileList->isEmpty()) {
- string = locale.queryString(blink::WebLocalizedString::FileButtonNoFileSelectedLabel);
+ string = locale.queryString(WebLocalizedString::FileButtonNoFileSelectedLabel);
} else if (fileList->length() == 1) {
string = fileList->item(0)->name();
} else {
// FIXME: Localization of fileList->length().
- return StringTruncator::rightTruncate(locale.queryString(blink::WebLocalizedString::MultipleFileUploadText, String::number(fileList->length())), width, font, StringTruncator::EnableRoundingHacks);
+ return StringTruncator::rightTruncate(locale.queryString(WebLocalizedString::MultipleFileUploadText, String::number(fileList->length())), width, font);
}
- return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
+ return StringTruncator::centerTruncate(string, width, font);
}
bool RenderTheme::shouldOpenPickerWithF4Key() const
bool RenderTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
- blink::WebFallbackThemeEngine::ExtraParams extraParams;
- blink::WebCanvas* canvas = i.context->canvas();
+ WebFallbackThemeEngine::ExtraParams extraParams;
+ WebCanvas* canvas = i.context->canvas();
extraParams.button.checked = isChecked(o);
extraParams.button.indeterminate = isIndeterminate(o);
unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
i.context->translate(unzoomedRect.x(), unzoomedRect.y());
- i.context->scale(FloatSize(zoomLevel, zoomLevel));
+ i.context->scale(zoomLevel, zoomLevel);
i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
- blink::Platform::current()->fallbackThemeEngine()->paint(canvas, blink::WebFallbackThemeEngine::PartCheckbox, getWebFallbackThemeState(this, o), blink::WebRect(unzoomedRect), &extraParams);
+ Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEngine::PartCheckbox, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &extraParams);
return false;
}
if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
return;
- IntSize size = blink::Platform::current()->fallbackThemeEngine()->getSize(blink::WebFallbackThemeEngine::PartCheckbox);
+ IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallbackThemeEngine::PartCheckbox);
float zoomLevel = style->effectiveZoom();
size.setWidth(size.width() * zoomLevel);
size.setHeight(size.height() * zoomLevel);
bool RenderTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
- blink::WebFallbackThemeEngine::ExtraParams extraParams;
- blink::WebCanvas* canvas = i.context->canvas();
+ WebFallbackThemeEngine::ExtraParams extraParams;
+ WebCanvas* canvas = i.context->canvas();
extraParams.button.checked = isChecked(o);
extraParams.button.indeterminate = isIndeterminate(o);
unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
i.context->translate(unzoomedRect.x(), unzoomedRect.y());
- i.context->scale(FloatSize(zoomLevel, zoomLevel));
+ i.context->scale(zoomLevel, zoomLevel);
i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
- blink::Platform::current()->fallbackThemeEngine()->paint(canvas, blink::WebFallbackThemeEngine::PartRadio, getWebFallbackThemeState(this, o), blink::WebRect(unzoomedRect), &extraParams);
+ Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEngine::PartRadio, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &extraParams);
return false;
}
if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
return;
- IntSize size = blink::Platform::current()->fallbackThemeEngine()->getSize(blink::WebFallbackThemeEngine::PartRadio);
+ IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallbackThemeEngine::PartRadio);
float zoomLevel = style->effectiveZoom();
size.setWidth(size.width() * zoomLevel);
size.setHeight(size.height() * zoomLevel);
style->resetBorder();
}
-} // namespace WebCore
+} // namespace blink