Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderTheme.cpp
index 0a3bfb2..f07705b 100644 (file)
@@ -32,6 +32,7 @@
 #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"
@@ -98,7 +99,7 @@ void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl
     else if (style->display() == LIST_ITEM || style->display() == TABLE)
         style->setDisplay(BLOCK);
 
-    if (uaStyle && uaStyle->hasAppearance && isControlStyled(style, uaStyle)) {
+    if (uaStyle && isControlStyled(style, uaStyle)) {
         if (part == MenulistPart) {
             style->setAppearance(MenulistButtonPart);
             part = MenulistButtonPart;
@@ -310,6 +311,10 @@ bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe
         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:
@@ -405,16 +410,8 @@ bool RenderTheme::paintDecorations(RenderObject* o, const PaintInfo& paintInfo,
 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()) {
+    if (RuntimeEnabledFeatures::contextMenuEnabled())
         runtimeCSS.appendLiteral("menu[type=\"popup\" i] { display: none; }");
-    }
-
     return runtimeCSS.toString();
 }
 
@@ -593,7 +590,7 @@ bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle*
     }
 }
 
-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());
@@ -604,11 +601,11 @@ bool RenderTheme::shouldDrawDefaultFocusRing(RenderObject* renderer) const
 {
     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())
@@ -631,8 +628,7 @@ bool RenderTheme::stateChanged(RenderObject* o, ControlState state) const
     if (state == PressedControlState && !isEnabled(o))
         return false;
 
-    // Repaint the control.
-    o->paintInvalidationForWholeRenderer();
+    o->setShouldDoFullPaintInvalidation();
     return true;
 }
 
@@ -824,7 +820,7 @@ void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo,
         return;
 
     HTMLInputElement* input = toHTMLInputElement(node);
-    if (!input->isRangeControl())
+    if (input->type() != InputTypeNames::range)
         return;
 
     HTMLDataListElement* dataList = input->dataList();
@@ -878,13 +874,9 @@ void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo,
         tickRegionSideMargin = trackBounds.y() + (thumbSize.width() - tickSize.width() * zoomFactor) / 2.0;
         tickRegionWidth = trackBounds.height() - thumbSize.width();
     }
-    RefPtrWillBeRawPtr<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));
@@ -895,7 +887,7 @@ void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo,
             tickRect.setX(tickPosition);
         else
             tickRect.setY(tickPosition);
-        paintInfo.context->fillRect(tickRect);
+        paintInfo.context->fillRect(tickRect, o->resolveColor(CSSPropertyColor));
     }
 }
 
@@ -911,7 +903,7 @@ double RenderTheme::animationDurationForProgressBar(RenderProgress*) const
 
 bool RenderTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const
 {
-    return inputElement->isSteppable() && !inputElement->isRangeControl();
+    return inputElement->isSteppable() && inputElement->type() != InputTypeNames::range;
 }
 
 void RenderTheme::adjustMenuListButtonStyle(RenderStyle*, Element*) const
@@ -948,6 +940,64 @@ void RenderTheme::platformColorsDidChange()
     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) {