Changeset 118677 in webkit


Ignore:
Timestamp:
May 28, 2012 5:50:01 AM (12 years ago)
Author:
keishi@webkit.org
Message:

Expose value localization function of HTMLInputElement
https://bugs.webkit.org/show_bug.cgi?id=84356

Reviewed by Kent Tamura.

Source/WebCore:

No new tests.

We want to localize the values that are defined in the datalist element.
This adds HTMLInputElement::localizeValue() which will localize a given
value.

  • html/BaseDateAndTimeInputType.cpp:

(WebCore::BaseDateAndTimeInputType::localizeValue):
(WebCore):
(WebCore::BaseDateAndTimeInputType::visibleValue):

  • html/BaseDateAndTimeInputType.h:

(BaseDateAndTimeInputType):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::localizeValue):
(WebCore):

  • html/HTMLInputElement.h:

(HTMLInputElement):

  • html/InputType.cpp:

(WebCore::InputType::localizeValue):
(WebCore):

  • html/InputType.h:

(InputType):

  • html/NumberInputType.cpp:

(WebCore::NumberInputType::localizeValue):
(WebCore):
(WebCore::NumberInputType::visibleValue):

  • html/NumberInputType.h:

(NumberInputType):

Source/WebKit/chromium:

  • public/WebInputElement.h:

(WebInputElement):

  • src/WebInputElement.cpp:

(WebKit::WebInputElement::localizeValue):
(WebKit):

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118674 r118677  
     12012-05-28  Keishi Hattori  <keishi@webkit.org>
     2
     3        Expose value localization function of HTMLInputElement
     4        https://bugs.webkit.org/show_bug.cgi?id=84356
     5
     6        Reviewed by Kent Tamura.
     7
     8        No new tests.
     9
     10        We want to localize the values that are defined in the datalist element.
     11        This adds HTMLInputElement::localizeValue() which will localize a given
     12        value.
     13
     14        * html/BaseDateAndTimeInputType.cpp:
     15        (WebCore::BaseDateAndTimeInputType::localizeValue):
     16        (WebCore):
     17        (WebCore::BaseDateAndTimeInputType::visibleValue):
     18        * html/BaseDateAndTimeInputType.h:
     19        (BaseDateAndTimeInputType):
     20        * html/HTMLInputElement.cpp:
     21        (WebCore::HTMLInputElement::localizeValue):
     22        (WebCore):
     23        * html/HTMLInputElement.h:
     24        (HTMLInputElement):
     25        * html/InputType.cpp:
     26        (WebCore::InputType::localizeValue):
     27        (WebCore):
     28        * html/InputType.h:
     29        (InputType):
     30        * html/NumberInputType.cpp:
     31        (WebCore::NumberInputType::localizeValue):
     32        (WebCore):
     33        (WebCore::NumberInputType::visibleValue):
     34        * html/NumberInputType.h:
     35        (NumberInputType):
     36
    1372012-05-28  Yury Semikhatsky  <yurys@chromium.org>
    238
  • trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp

    r117738 r118677  
    156156}
    157157
     158String BaseDateAndTimeInputType::localizeValue(const String& proposedValue) const
     159{
     160    DateComponents date;
     161    if (!parseToDateComponents(proposedValue, &date))
     162        return proposedValue;
     163
     164    String localized = formatLocalizedDate(date);
     165    return localized.isEmpty() ? proposedValue : localized;
     166}
     167
    158168String BaseDateAndTimeInputType::visibleValue() const
    159169{
    160     String currentValue = element()->value();
    161     DateComponents date;
    162     if (!parseToDateComponents(currentValue, &date))
    163         return currentValue;
    164 
    165     String localized = formatLocalizedDate(date);
    166     return localized.isEmpty() ? currentValue : localized;
     170    return localizeValue(element()->value());
    167171}
    168172
  • trunk/Source/WebCore/html/BaseDateAndTimeInputType.h

    r117738 r118677  
    6262    virtual String serialize(double) const OVERRIDE;
    6363    virtual String serializeWithMilliseconds(double) const;
     64    virtual String localizeValue(const String&) const OVERRIDE;
    6465    virtual String visibleValue() const OVERRIDE;
    6566    virtual String convertFromVisibleValue(const String&) const OVERRIDE;
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r118192 r118677  
    12671267}
    12681268
     1269String HTMLInputElement::localizeValue(const String& proposedValue) const
     1270{
     1271    if (proposedValue.isNull())
     1272        return proposedValue;
     1273    return m_inputType->localizeValue(proposedValue);
     1274}
     1275
    12691276bool HTMLInputElement::hasUnacceptableValue() const
    12701277{
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r118192 r118677  
    148148    String sanitizeValue(const String&) const;
    149149
     150    String localizeValue(const String&) const;
     151
    150152    void updateInnerTextValue();
    151153
  • trunk/Source/WebCore/html/InputType.cpp

    r117738 r118677  
    630630}
    631631
     632String InputType::localizeValue(const String& proposedValue) const
     633{
     634    return proposedValue;
     635}
     636
    632637String InputType::visibleValue() const
    633638{
  • trunk/Source/WebCore/html/InputType.h

    r117738 r118677  
    168168    virtual String valueMissingText() const;
    169169    virtual bool canSetStringValue() const;
     170    virtual String localizeValue(const String&) const;
    170171    virtual String visibleValue() const;
    171172    virtual String convertFromVisibleValue(const String&) const;
  • trunk/Source/WebCore/html/NumberInputType.cpp

    r117929 r118677  
    219219}
    220220
    221 String NumberInputType::visibleValue() const
    222 {
    223     String currentValue = element()->value();
    224     if (currentValue.isEmpty())
    225         return currentValue;
     221String NumberInputType::localizeValue(const String& proposedValue) const
     222{
     223    if (proposedValue.isEmpty())
     224        return proposedValue;
    226225    // We don't localize scientific notations.
    227     if (currentValue.find(isE) != notFound)
    228         return currentValue;
     226    if (proposedValue.find(isE) != notFound)
     227        return proposedValue;
    229228    // FIXME: The following three lines should be removed when we
    230229    // remove the second argument of convertToLocalizedNumber().
     
    232231    // if currentValue isn't valid floating pointer number.
    233232    unsigned decimalPlace;
    234     parseToDoubleForNumberTypeWithDecimalPlaces(currentValue, &decimalPlace);
    235     return convertToLocalizedNumber(currentValue, decimalPlace);
     233    parseToDoubleForNumberTypeWithDecimalPlaces(proposedValue, &decimalPlace);
     234    return convertToLocalizedNumber(proposedValue, decimalPlace);
     235}
     236
     237String NumberInputType::visibleValue() const
     238{
     239    return localizeValue(element()->value());
    236240}
    237241
  • trunk/Source/WebCore/html/NumberInputType.h

    r117738 r118677  
    5656    virtual String serialize(double) const OVERRIDE;
    5757    virtual void handleBlurEvent() OVERRIDE;
     58    virtual String localizeValue(const String&) const OVERRIDE;
    5859    virtual String visibleValue() const OVERRIDE;
    5960    virtual String convertFromVisibleValue(const String&) const OVERRIDE;
  • trunk/Source/WebKit/chromium/ChangeLog

    r118660 r118677  
     12012-05-28  Keishi Hattori  <keishi@webkit.org>
     2
     3        Expose value localization function of HTMLInputElement
     4        https://bugs.webkit.org/show_bug.cgi?id=84356
     5
     6        Reviewed by Kent Tamura.
     7
     8        * public/WebInputElement.h:
     9        (WebInputElement):
     10        * src/WebInputElement.cpp:
     11        (WebKit::WebInputElement::localizeValue):
     12        (WebKit):
     13
    1142012-05-28  MORITA Hajime <morrita@google.com>
    215
  • trunk/Source/WebKit/chromium/public/WebInputElement.h

    r118601 r118677  
    9797        WEBKIT_EXPORT WebNodeCollection dataListOptions() const;
    9898
     99        // Return the localized value for this input type.
     100        WEBKIT_EXPORT WebString localizeValue(const WebString&) const;
     101
    99102        WEBKIT_EXPORT bool isSpeechInputEnabled() const;
    100103        WEBKIT_EXPORT SpeechInputState getSpeechInputState() const;
  • trunk/Source/WebKit/chromium/src/WebInputElement.cpp

    r118601 r118677  
    184184}
    185185
     186WebString WebInputElement::localizeValue(const WebString& proposedValue) const
     187{
     188    return constUnwrap<HTMLInputElement>()->localizeValue(proposedValue);
     189}
     190
    186191bool WebInputElement::isSpeechInputEnabled() const
    187192{
Note: See TracChangeset for help on using the changeset viewer.