Title: [170072] trunk
Revision
170072
Author
mmaxfi...@apple.com
Date
2014-06-17 14:28:40 -0700 (Tue, 17 Jun 2014)

Log Message

[iOS] Input type=time elements styled with SVG fonts have 0 width
https://bugs.webkit.org/show_bug.cgi?id=133524

Reviewed by Simon Fraser.

Source/WebCore:
Refactor how the LocalizedDateCache returns maximum widths for input elements. Currently,
measuring the width of an SVG font requires a RenderObject for context, which the
LocalizedDateCache can't know about (it would be a platform violation). Instead, the
LocalizedDateCache can return the strings that it would use to measure the width, and the
caller can actually run the width computation.

Test: fast/forms/time-input-svg-font.html

* platform/text/PlatformLocale.h:
* platform/text/ios/LocalizedDateCache.h:
* platform/text/ios/LocalizedDateCache.mm:
(WebCore::LocalizedDateCache::maximumWidthForDateType): Take a delegate which can
measure text
(WebCore::LocalizedDateCache::calculateMaximumWidth): Perform maximum width
computation using delegate.
* platform/text/mac/LocaleMac.h:
* platform/text/mac/LocaleMac.mm:
(WebCore::LocaleMac::formatDateTime):
(WebCore::LocaleMac::maximumWidthForDateType): Deleted. Short-circuit this and go
directly to the LocalizedDateCache. This makes sense because we have to explicitly
insert computed values back into the cache in this new model.
* rendering/RenderThemeIOS.mm:
(WebCore::adjustInputElementButtonStyle): Create a delegate and pass it to the
LocalizedDateCache

LayoutTests:
Simply render a variety of input elements with SVG fonts, and make sure they have sane widths. Note that this
test is not platform-specific, even though the bug is.

* fast/forms/time-input-svg-font-expected.txt: Added.
* fast/forms/time-input-svg-font.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (170071 => 170072)


--- trunk/LayoutTests/ChangeLog	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/LayoutTests/ChangeLog	2014-06-17 21:28:40 UTC (rev 170072)
@@ -1,3 +1,16 @@
+2014-06-17  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [iOS] Input type=time elements styled with SVG fonts have 0 width
+        https://bugs.webkit.org/show_bug.cgi?id=133524
+
+        Reviewed by Simon Fraser.
+
+        Simply render a variety of input elements with SVG fonts, and make sure they have sane widths. Note that this
+        test is not platform-specific, even though the bug is.
+
+        * fast/forms/time-input-svg-font-expected.txt: Added.
+        * fast/forms/time-input-svg-font.html: Added.
+
 2014-06-17  Simon Fraser  <simon.fra...@apple.com>
 
         [UI-side compositing] fix reflections on composited layers

Added: trunk/LayoutTests/fast/forms/time-input-svg-font-expected.txt (0 => 170072)


--- trunk/LayoutTests/fast/forms/time-input-svg-font-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/time-input-svg-font-expected.txt	2014-06-17 21:28:40 UTC (rev 170072)
@@ -0,0 +1,3 @@
+This test makes sure that input elements get rendered with a sane width. You should see five time input elements, followed by five "PASS"es.
+    
+Pass Pass Pass Pass Pass

Added: trunk/LayoutTests/fast/forms/time-input-svg-font.html (0 => 170072)


--- trunk/LayoutTests/fast/forms/time-input-svg-font.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/time-input-svg-font.html	2014-06-17 21:28:40 UTC (rev 170072)
@@ -0,0 +1,40 @@
+<style>
+@font-face {
+    font-family: 'SVGraffiti';
+    src: url("../../svg/custom/resources/graffiti.svg") format(svg)
+}
+</style>
+<div>
+This test makes sure that input elements get rendered with
+a sane width. You should see five time input elements, followed by five "PASS"es.
+</div>
+<div style="font-family: SVGraffiti;">
+<input id="i" type="time">
+<input id="d" type="date">
+<input id="dt" type="datetime">
+<input id="dtl" type="datetime-local">
+<input id="m" type="month">
+</div>
+<div id="console"></div>
+<script>
+function test(inputId) {
+    if (document.getElementById("i").offsetWidth > 50)
+        return "Pass"
+    else
+        return "Fail"
+}
+
+window.setTimeout((function() {
+    document.getElementById("console").textContent += test("i") + " ";
+    document.getElementById("console").textContent += test("d") + " ";
+    document.getElementById("console").textContent += test("dt") + " ";
+    document.getElementById("console").textContent += test("dtl") + " ";
+    document.getElementById("console").textContent += test("m");
+    if (window.testRunner)
+        testRunner.notifyDone();
+}), 0);
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+</script>

Modified: trunk/Source/WebCore/ChangeLog (170071 => 170072)


--- trunk/Source/WebCore/ChangeLog	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/ChangeLog	2014-06-17 21:28:40 UTC (rev 170072)
@@ -1,3 +1,35 @@
+2014-06-17  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [iOS] Input type=time elements styled with SVG fonts have 0 width
+        https://bugs.webkit.org/show_bug.cgi?id=133524
+
+        Reviewed by Simon Fraser.
+
+        Refactor how the LocalizedDateCache returns maximum widths for input elements. Currently,
+        measuring the width of an SVG font requires a RenderObject for context, which the
+        LocalizedDateCache can't know about (it would be a platform violation). Instead, the
+        LocalizedDateCache can return the strings that it would use to measure the width, and the
+        caller can actually run the width computation.
+
+        Test: fast/forms/time-input-svg-font.html
+
+        * platform/text/PlatformLocale.h:
+        * platform/text/ios/LocalizedDateCache.h:
+        * platform/text/ios/LocalizedDateCache.mm:
+        (WebCore::LocalizedDateCache::maximumWidthForDateType): Take a delegate which can
+        measure text
+        (WebCore::LocalizedDateCache::calculateMaximumWidth): Perform maximum width
+        computation using delegate.
+        * platform/text/mac/LocaleMac.h:
+        * platform/text/mac/LocaleMac.mm:
+        (WebCore::LocaleMac::formatDateTime):
+        (WebCore::LocaleMac::maximumWidthForDateType): Deleted. Short-circuit this and go
+        directly to the LocalizedDateCache. This makes sense because we have to explicitly
+        insert computed values back into the cache in this new model.
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::adjustInputElementButtonStyle): Create a delegate and pass it to the
+        LocalizedDateCache
+
 2014-06-17  Simon Fraser  <simon.fra...@apple.com>
 
         [UI-side compositing] fix reflections on composited layers

Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp (170071 => 170072)


--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2014-06-17 21:28:40 UTC (rev 170072)
@@ -847,20 +847,20 @@
     return paintThemePart(object, ComboBox, info, IntRect(rect));
 }
 
-void RenderThemeEfl::adjustMenuListButtonStyle(StyleResolver* styleResolver, RenderStyle* style, Element* element) const
+void RenderThemeEfl::adjustMenuListButtonStyle(StyleResolver& styleResolver, RenderStyle& style, Element& element) const
 {
     // Height is locked to auto if height is not specified.
-    style->setHeight(Length(Auto));
+    style.setHeight(Length(Auto));
 
     // The <select> box must be at least 12px high for the button to render the text inside the box without clipping.
     const int dropDownBoxMinHeight = 12;
 
     // Calculate min-height of the <select> element.
-    int minHeight = style->fontMetrics().height();
+    int minHeight = style.fontMetrics().height();
     minHeight = std::max(minHeight, dropDownBoxMinHeight);
-    style->setMinHeight(Length(minHeight, Fixed));
+    style.setMinHeight(Length(minHeight, Fixed));
 
-    adjustMenuListStyle(styleResolver, style, element);
+    adjustMenuListStyle(&styleResolver, &style, &element);
 }
 
 bool RenderThemeEfl::paintMenuListButtonDecorations(const RenderObject& object, const PaintInfo& info, const FloatRect& rect)

Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.h (170071 => 170072)


--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -128,7 +128,7 @@
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const override;
     virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
-    virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const override;
+    virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const override;
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustSearchFieldResultsDecorationPartStyle(StyleResolver*, RenderStyle*, Element*) const override;

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp (170071 => 170072)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2014-06-17 21:28:40 UTC (rev 170072)
@@ -236,9 +236,9 @@
     style->resetBorderRadius();
 }
 
-void RenderThemeGtk::adjustMenuListButtonStyle(StyleResolver* styleResolver, RenderStyle* style, Element* e) const
+void RenderThemeGtk::adjustMenuListButtonStyle(StyleResolver& styleResolver, RenderStyle& style, Element& e) const
 {
-    adjustMenuListStyle(styleResolver, style, e);
+    adjustMenuListStyle(&styleResolver, &style, &e);
 }
 
 bool RenderThemeGtk::paintMenuListButtonDecorations(const RenderObject& object, const PaintInfo& info, const FloatRect& rect)

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h (170071 => 170072)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -136,7 +136,7 @@
     // Aqua themed controls whenever possible. We always want to use GTK+ theming, so
     // we don't maintain this differentiation.
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const override;
-    virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const override;
+    virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const override;
     virtual bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) override;
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 

Modified: trunk/Source/WebCore/platform/text/PlatformLocale.h (170071 => 170072)


--- trunk/Source/WebCore/platform/text/PlatformLocale.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/text/PlatformLocale.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -124,12 +124,6 @@
 #endif // !PLATFORM(IOS)
 #endif
 
-#if PLATFORM(IOS)
-    // FIXME: This code should be merged with Open Source in a way that is future compatible.
-    // Maximum width for a formatted date string with a specified font.
-    virtual float maximumWidthForDateType(DateComponents::Type, const Font&) = 0;
-#endif
-
     virtual ~Locale();
 
 protected:

Modified: trunk/Source/WebCore/platform/text/ios/LocalizedDateCache.h (170071 => 170072)


--- trunk/Source/WebCore/platform/text/ios/LocalizedDateCache.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/text/ios/LocalizedDateCache.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -36,11 +36,17 @@
 #if PLATFORM(IOS)
 
 namespace WebCore {
+    
+class MeasureTextClient {
+public:
+    virtual float measureText(const String&) const = 0;
+    virtual ~MeasureTextClient() { }
+};
 
 class LocalizedDateCache {
 public:
     NSDateFormatter *formatterForDateType(DateComponents::Type);
-    float maximumWidthForDateType(DateComponents::Type, const Font&);
+    float maximumWidthForDateType(DateComponents::Type, const Font&, const MeasureTextClient&);
     void localeChanged();
 
 private:
@@ -48,7 +54,7 @@
     ~LocalizedDateCache();
 
     NSDateFormatter *createFormatterForType(DateComponents::Type);
-    float calculateMaximumWidth(DateComponents::Type, const Font&);
+    float calculateMaximumWidth(DateComponents::Type, const MeasureTextClient&);
 
     // Using int instead of DateComponents::Type for the key because the enum
     // does not have a default hash and hash traits. Usage of the maps

Modified: trunk/Source/WebCore/platform/text/ios/LocalizedDateCache.mm (170071 => 170072)


--- trunk/Source/WebCore/platform/text/ios/LocalizedDateCache.mm	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/text/ios/LocalizedDateCache.mm	2014-06-17 21:28:40 UTC (rev 170072)
@@ -84,7 +84,7 @@
     return dateFormatter;
 }
 
-float LocalizedDateCache::maximumWidthForDateType(DateComponents::Type type, const Font& font)
+float LocalizedDateCache::maximumWidthForDateType(DateComponents::Type type, const Font& font, const MeasureTextClient& measurer)
 {
     int key = static_cast<int>(type);
     if (m_font == font) {
@@ -95,7 +95,7 @@
         m_maxWidthMap.clear();
     }
 
-    float calculatedMaximum = calculateMaximumWidth(type, font);
+    float calculatedMaximum = calculateMaximumWidth(type, measurer);
     m_maxWidthMap.set(key, calculatedMaximum);
     return calculatedMaximum;
 }
@@ -144,7 +144,7 @@
 
 // NOTE: This does not check for the widest day of the week.
 // We assume no formatter option shows that information.
-float LocalizedDateCache::calculateMaximumWidth(DateComponents::Type type, const Font& font)
+float LocalizedDateCache::calculateMaximumWidth(DateComponents::Type type, const MeasureTextClient& measurer)
 {
     float maximumWidth = 0;
 
@@ -182,8 +182,7 @@
         [components.get() setMonth:(i + 1)];
         NSDate *date = [gregorian.get() dateFromComponents:components.get()];
         NSString *formattedDate = [dateFormatter stringFromDate:date];
-        String str = String(formattedDate);
-        maximumWidth = max(maximumWidth, font.width(str));
+        maximumWidth = max(maximumWidth, measurer.measureText(String(formattedDate)));
     }
 
     return maximumWidth;

Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.h (170071 => 170072)


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -51,7 +51,6 @@
     ~LocaleMac();
 
 #if PLATFORM(IOS)
-    virtual float maximumWidthForDateType(DateComponents::Type, const Font&) override;
     virtual String formatDateTime(const DateComponents&, FormatType = FormatTypeUnspecified) override;
 #endif
 

Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.mm (170071 => 170072)


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2014-06-17 21:28:40 UTC (rev 170072)
@@ -133,14 +133,6 @@
     NSDateFormatter *dateFormatter = localizedDateCache().formatterForDateType(type);
     return [dateFormatter stringFromDate:date];
 }
-
-float LocaleMac::maximumWidthForDateType(DateComponents::Type type, const Font& font)
-{
-    ASSERT(type != DateComponents::Invalid);
-    ASSERT(type != DateComponents::Week);
-
-    return localizedDateCache().maximumWidthForDateType(type, font);
-}
 #endif
 
 #if ENABLE(DATE_AND_TIME_INPUT_TYPES)

Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (170071 => 170072)


--- trunk/Source/WebCore/rendering/RenderTheme.cpp	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp	2014-06-17 21:28:40 UTC (rev 170072)
@@ -210,7 +210,7 @@
     case MenulistPart:
         return adjustMenuListStyle(&styleResolver, &style, e);
     case MenulistButtonPart:
-        return adjustMenuListButtonStyle(&styleResolver, &style, e);
+        return adjustMenuListButtonStyle(styleResolver, style, *e);
     case MediaPlayButtonPart:
     case MediaCurrentTimePart:
     case MediaTimeRemainingPart:
@@ -1119,7 +1119,7 @@
     return inputElement->isSteppable() && !inputElement->isRangeControl();
 }
 
-void RenderTheme::adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const
+void RenderTheme::adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const
 {
 }
 

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (170071 => 170072)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -302,7 +302,7 @@
     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*, Element*) const;
+    virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const;
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
 
     virtual bool paintPushButtonDecorations(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (170071 => 170072)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -71,7 +71,7 @@
     virtual bool paintTextFieldDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
     virtual bool paintTextAreaDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
-    virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const override;
+    virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const override;
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
 
     virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const override;

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (170071 => 170072)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2014-06-17 21:28:40 UTC (rev 170072)
@@ -44,6 +44,7 @@
 #import "HTMLNames.h"
 #import "HTMLSelectElement.h"
 #import "Icon.h"
+#import "LocalizedDateCache.h"
 #import "NodeRenderStyle.h"
 #import "Page.h"
 #import "PlatformLocale.h"
@@ -536,67 +537,91 @@
     style.setBorderRadius(LengthSize(radiusWidth, radiusHeight));
 }
 
-static void applyCommonButtonPaddingToStyle(RenderStyle* style, Element* element)
+static void applyCommonButtonPaddingToStyle(RenderStyle& style, Element& element)
 {
-    Document& document = element->document();
+    Document& document = element.document();
     RefPtr<CSSPrimitiveValue> emSize = CSSPrimitiveValue::create(0.5, CSSPrimitiveValue::CSS_EMS);
-    int pixels = emSize->computeLength<int>(CSSToLengthConversionData(style, document.renderStyle(), document.renderView(), document.frame()->pageZoomFactor()));
-    style->setPaddingBox(LengthBox(0, pixels, 0, pixels));
+    int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, document.renderStyle(), document.renderView(), document.frame()->pageZoomFactor()));
+    style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
 }
 
-static void adjustSelectListButtonStyle(RenderStyle* style, Element* element)
+static void adjustSelectListButtonStyle(RenderStyle& style, Element& element)
 {
     // Enforce "padding: 0 0.5em".
     applyCommonButtonPaddingToStyle(style, element);
 
     // Enforce "line-height: normal".
-    style->setLineHeight(Length(-100.0, Percent));
+    style.setLineHeight(Length(-100.0, Percent));
 }
+    
+class RenderThemeMeasureTextClient : public MeasureTextClient {
+public:
+    RenderThemeMeasureTextClient(const Font& font, RenderObject& renderObject, const RenderStyle& style)
+        : m_font(font)
+        , m_renderObject(renderObject)
+        , m_style(style)
+    {
+    }
+    virtual float measureText(const String& string) const override
+    {
+        TextRun run = RenderBlock::constructTextRun(&m_renderObject, m_font, string, m_style, TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, DefaultTextRunFlags);
+        return m_font.width(run);
+    }
+private:
+    const Font& m_font;
+    RenderObject& m_renderObject;
+    const RenderStyle& m_style;
+};
 
-static void adjustInputElementButtonStyle(RenderStyle* style, HTMLInputElement* inputElement)
+static void adjustInputElementButtonStyle(RenderStyle& style, HTMLInputElement& inputElement)
 {
     // Always Enforce "padding: 0 0.5em".
     applyCommonButtonPaddingToStyle(style, inputElement);
 
     // Don't adjust the style if the width is specified.
-    if (style->width().isFixed() && style->width().value() > 0)
+    if (style.width().isFixed() && style.width().value() > 0)
         return;
 
     // Don't adjust for unsupported date input types.
-    DateComponents::Type dateType = inputElement->dateType();
+    DateComponents::Type dateType = inputElement.dateType();
     if (dateType == DateComponents::Invalid || dateType == DateComponents::Week)
         return;
 
     // Enforce the width and set the box-sizing to content-box to not conflict with the padding.
-    Font font = style->font();
+    Font font = style.font();
+    
+    RenderObject* renderer = inputElement.renderer();
+    if (font.isSVGFont() && !renderer)
+        return;
+    
     FontCachePurgePreventer fontCachePurgePreventer;
-    // FIXME: Choose an appropriate width for these elements when
-    // styled with SVG fonts (rather than simply 0).
-    // https://bugs.webkit.org/show_bug.cgi?id=133524
-    float maximumWidth = font.isSVGFont() ? 0 : inputElement->locale().maximumWidthForDateType(dateType, font);
+    float maximumWidth = localizedDateCache().maximumWidthForDateType(dateType, font, RenderThemeMeasureTextClient(font, *renderer, style));
+
+    ASSERT(maximumWidth >= 0);
+
     if (maximumWidth > 0) {    
         int width = static_cast<int>(maximumWidth + MenuListButtonPaddingRight);
-        style->setWidth(Length(width, Fixed));
-        style->setBoxSizing(CONTENT_BOX);
+        style.setWidth(Length(width, Fixed));
+        style.setBoxSizing(CONTENT_BOX);
     }
 }
 
-void RenderThemeIOS::adjustMenuListButtonStyle(StyleResolver*, RenderStyle* style, Element* element) const
+void RenderThemeIOS::adjustMenuListButtonStyle(StyleResolver&, RenderStyle& style, Element& element) const
 {
     // Set the min-height to be at least MenuListMinHeight.
-    if (style->height().isAuto())
-        style->setMinHeight(Length(std::max(MenuListMinHeight, static_cast<int>(MenuListBaseHeight / MenuListBaseFontSize * style->fontDescription().computedSize())), Fixed));
+    if (style.height().isAuto())
+        style.setMinHeight(Length(std::max(MenuListMinHeight, static_cast<int>(MenuListBaseHeight / MenuListBaseFontSize * style.fontDescription().computedSize())), Fixed));
     else
-        style->setMinHeight(Length(MenuListMinHeight, Fixed));
+        style.setMinHeight(Length(MenuListMinHeight, Fixed));
 
     // Enforce some default styles in the case that this is a non-multiple <select> element,
     // or a date input. We don't force these if this is just an element with
     // "-webkit-appearance: menulist-button".
-    if (element->hasTagName(HTMLNames::selectTag) && !element->hasAttribute(HTMLNames::multipleAttr))
+    if (element.hasTagName(HTMLNames::selectTag) && !element.hasAttribute(HTMLNames::multipleAttr))
         adjustSelectListButtonStyle(style, element);
-    else if (element->hasTagName(HTMLNames::inputTag)) {
-        HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
-        adjustInputElementButtonStyle(style, inputElement);
+    else if (element.hasTagName(HTMLNames::inputTag)) {
+        HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(&element);
+        adjustInputElementButtonStyle(style, *inputElement);
     }
 }
 
@@ -1046,7 +1071,7 @@
 
     return false;
 }
-    
+
 Color RenderThemeIOS::platformActiveSelectionBackgroundColor() const
 {
     return Color::transparent;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (170071 => 170072)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2014-06-17 21:28:40 UTC (rev 170072)
@@ -134,7 +134,7 @@
     virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const override;
 
     virtual bool paintMenuListButtonDecorations(const RenderObject&, const PaintInfo&, const FloatRect&) override;
-    virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const override;
+    virtual void adjustMenuListButtonStyle(StyleResolver&, RenderStyle&, Element&) const override;
 
 #if ENABLE(PROGRESS_ELEMENT)
     virtual void adjustProgressBarStyle(StyleResolver*, RenderStyle*, Element*) const override;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (170071 => 170072)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2014-06-17 21:06:12 UTC (rev 170071)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2014-06-17 21:28:40 UTC (rev 170072)
@@ -1420,17 +1420,17 @@
     }
 }
 
-void RenderThemeMac::adjustMenuListButtonStyle(StyleResolver*, RenderStyle* style, Element*) const
+void RenderThemeMac::adjustMenuListButtonStyle(StyleResolver&, RenderStyle& style, Element&) const
 {
-    float fontScale = style->fontSize() / baseFontSize;
+    float fontScale = style.fontSize() / baseFontSize;
 
-    style->resetPadding();
-    style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up?
+    style.resetPadding();
+    style.setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up?
 
     const int minHeight = 15;
-    style->setMinHeight(Length(minHeight, Fixed));
+    style.setMinHeight(Length(minHeight, Fixed));
 
-    style->setLineHeight(RenderStyle::initialLineHeight());
+    style.setLineHeight(RenderStyle::initialLineHeight());
 }
 
 void RenderThemeMac::setPopupButtonCellState(const RenderObject& o, const IntSize& buttonSize)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to