Changeset 135836 in webkit


Ignore:
Timestamp:
Nov 27, 2012 1:09:15 AM (11 years ago)
Author:
tkent@chromium.org
Message:

Implement ValidityState::badInput
https://bugs.webkit.org/show_bug.cgi?id=102861

Reviewed by Hajime Morita.

Source/WebCore:

Add ValidityState::badInput, add hasBadInput, which always returns
false, to FormAssociatedElement, HTMLInputElement, and InputType.

For NumberInputType, we had hasUnacceptableValue, which was a hack to
make an input element match to :invalid if the element had non-number
strings. We don't need the hack any more because badInput affects :invalid
style. hasUnacceptableValue is re-used for hasBadInput implementation.
We cleared invalid numbers when elements lost focus to tell users that
the element had invalid numbers. We don't need this behavior because the
interactive validation tells it.

For date/time input types, we should make an input badInput when the
input has empty value but its sub-fields have values. It covers both of
partial input cases such as 12/--/2012 and invalid dates such as
02/31/2012.

For other types, ValidityState::badInput always returns false.

This patch doesn't contain tests for badInput validation messages. They
will be added later.

Tests: fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput.html

fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput.html
fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput.html
fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput.html
fast/forms/number/number-validity-badinput.html
fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput.html
fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput.html

  • html/ValidityState.idl: Add badInput IDL attribute.
  • html/ValidityState.h:

(ValidityState): Add badInput.

  • html/ValidityState.cpp:

(WebCore::ValidityState::badInput):
Added. Calls FormAssociatedElement::hasBadInput.

  • html/FormAssociatedElement.h:

(FormAssociatedElement): Add hasBadInput.

  • html/FormAssociatedElement.cpp:

(WebCore::FormAssociatedElement::hasBadInput):
Added. It always returns false.
(WebCore::FormAssociatedElement::valid): Takes account of hasBadInput().

  • html/HTMLInputElement.h:

(HTMLInputElement):
Remove hasUnacceptableValue, and add hasBadInput override.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::hasBadInput):
Added. Delegate to InputType::hasBadInput.
(WebCore): Remove hasUnacceptableValue.

  • html/InputType.h:

(InputType): Add hasBadInput and badInputText, and remove
hasUnacceptableValue.

  • html/InputType.cpp:

(WebCore::InputType::hasBadInput): Added. Returns false.
(WebCore::InputType::badInputText):
Added. This function should not be called because hasBadInput always
returns false.
(WebCore::InputType::validationMessage):
Supports badInput. This returns badInputText if hasBadInput is true.

  • html/NumberInputType.h:

(NumberInputType): Add hasBadInput and badInputTest. Remove
handleBlurEvent and hasUnacceptableValue.

  • html/NumberInputType.cpp:

Remove handleBlurEvent, which cleared invalid number strings.
(WebCore::NumberInputType::hasBadInput):
Added. We don't need to check existence of a renderer. The standard form
validation feature doesn't care of it.
(WebCore::NumberInputType::badInputText): Returns
validationMessageBadInputForNumberText defined in LocalizedStrings.h.

  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::checkOneSelector):
Remove a hack for hasUnacceptableValue. isValidFormControlElement takes
account of badInput.

  • dom/Element.h: Remove hasUnacceptableValue.
  • html/BaseMultipleFieldsDateAndTimeInputType.h:

(BaseMultipleFieldsDateAndTimeInputType): Add hasBadInput and badInputText.

  • html/BaseMultipleFieldsDateAndTimeInputType.cpp:

(WebCore::BaseMultipleFieldsDateAndTimeInputType::badInputText):
Returns validationMessageBadInputForDateTimeText defined in LocalizedStrings.h.
(WebCore::BaseMultipleFieldsDateAndTimeInputType::hasBadInput):
Added.
(WebCore::BaseMultipleFieldsDateAndTimeInputType::setValue):
Add setNeedsValidityCheck call. It is needed because
updateInnerTextValue can modify subfields empty state.

  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::subtreeHasChanged): Update a comment.

  • platform/LocalizedStrings.h:

(WebCore): Add validationMessageBadInputForNumberText and
validationMessageBadInputForDateTimeText.

  • platform/LocalizedStrings.cpp:

(WebCore::validationMessageBadInputForNumberText):
Added a placeholder implementation. This should be fixed later.

  • platform/blackberry/LocalizedStringsBlackBerry.cpp:

(WebCore::validationMessageBadInputForNumberText): Ditto.

  • platform/efl/LocalizedStringsEfl.cpp:

(WebCore::validationMessageBadInputForNumberText): Ditto.

  • platform/qt/LocalizedStringsQt.cpp:

(WebCore::validationMessageBadInputForNumberText): Ditto.

Source/WebKit/chromium:

  • src/LocalizedStrings.cpp:

Add placeholder implementations for new localized string functions.
We'll update them in another patch.
(WebCore::validationMessageBadInputForNumberText):
(WebCore::validationMessageBadInputForDateTimeText):

LayoutTests:

  • fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput-expected.txt: Added.
  • fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput.html: Added.
  • fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput-expected.txt: Added.
  • fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput.html: Added.
  • fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput-expected.txt: Added.
  • fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput.html: Added.
  • fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput-expected.txt: Added.
  • fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput.html: Added.
  • fast/forms/number/number-unacceptable-style-expected.txt: Removed.
  • fast/forms/number/number-validity-badinput-expected.txt: Added.
  • fast/forms/number/number-validity-badinput.html: Renamed from LayoutTests/fast/forms/number/number-unacceptable-style.html.
  • fast/forms/resources/multiple-fields-validity-badinput.js: Added.
  • fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput-expected.txt: Added.
  • fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput.html: Added.
  • fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput-expected.txt: Added.
  • fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput.html: Added.
Location:
trunk
Files:
14 added
1 deleted
25 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r135835 r135836  
     12012-11-27  Kent Tamura  <tkent@chromium.org>
     2
     3        Implement ValidityState::badInput
     4        https://bugs.webkit.org/show_bug.cgi?id=102861
     5
     6        Reviewed by Hajime Morita.
     7
     8        * fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput-expected.txt: Added.
     9        * fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput.html: Added.
     10        * fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput-expected.txt: Added.
     11        * fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput.html: Added.
     12        * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput-expected.txt: Added.
     13        * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput.html: Added.
     14        * fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput-expected.txt: Added.
     15        * fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput.html: Added.
     16        * fast/forms/number/number-unacceptable-style-expected.txt: Removed.
     17        * fast/forms/number/number-validity-badinput-expected.txt: Added.
     18        * fast/forms/number/number-validity-badinput.html: Renamed from LayoutTests/fast/forms/number/number-unacceptable-style.html.
     19        * fast/forms/resources/multiple-fields-validity-badinput.js: Added.
     20        * fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput-expected.txt: Added.
     21        * fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput.html: Added.
     22        * fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput-expected.txt: Added.
     23        * fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput.html: Added.
     24
    1252012-11-27  Alexander Pavlov  <apavlov@chromium.org>
    226
  • trunk/LayoutTests/fast/forms/number/number-validity-badinput.html

    • Property svn:eol-style set to LF
    r135835 r135836  
    1717</div>
    1818<script>
    19 description('A number input fields with an unacceptable string should have :invalid style.');
     19description('A number input fields with a bad input string should make validity.badInput true and have :invalid style.');
    2020
    2121function colorOf(el) {
     
    2828debug('Initial state. The elment has no value.');
    2929shouldBeTrue('colorOf(number) != invalidStyleColor');
     30shouldBeFalse('number.validity.badInput');
    3031
    31 debug("Type '-'. The renderer value becomes unacceptable.");
     32debug("Type '-'. The element becomes badInput.");
    3233document.execCommand('InsertText', false, '-');
    3334shouldBe('colorOf(number)', 'invalidStyleColor');
    34 shouldBeTrue('number.validity.valid');
     35shouldBeFalse('number.validity.valid');
     36shouldBeTrue('number.validity.badInput');
    3537shouldBeEqualToString('number.value', '');
    3638
    37 debug("Type '1' additionally. The renderer value becomes acceptable.");
     39debug("Type '1' additionally. The element becomes valid.");
    3840document.execCommand('InsertText', false, '1');
    3941shouldBeTrue('colorOf(number) != invalidStyleColor');
     42shouldBeFalse('number.validity.badInput');
    4043shouldBeEqualToString('number.value', '-1');
    4144
    42 debug("Type 'a' additionally. The renderer value becomes unacceptable again.");
     45debug("Type 'a' additionally. The element becomes badInput again.");
    4346document.execCommand('InsertText', false, 'a');
    4447shouldBe('colorOf(number)', 'invalidStyleColor');
     48shouldBeTrue('number.validity.badInput');
    4549shouldBeEqualToString('number.value', '');
    4650
    47 debug("The element losts focus. The unacceptable value should be purged and the style should be normal.");
     51debug("The element losts focus. The element state should not be changed.");
    4852document.getElementById('another').focus();
    49 shouldBeTrue('colorOf(number) != invalidStyleColor');
    50 // Visiblue value is not '-1a'.
     53shouldBe('colorOf(number)', 'invalidStyleColor');
     54shouldBeTrue('number.validity.badInput');
     55// Visible value is '-1a'.
    5156number.focus();
    5257document.execCommand('SelectAll');
    53 shouldBeEqualToString('document.getSelection().toString()', '');
     58shouldBeEqualToString('document.getSelection().toString()', '-1a');
    5459shouldBeEqualToString('number.value', '');
     60
     61debug("The element losts a renderer. The element state should not be changed.");
     62shouldBeTrue('number.style.display = "none"; number.validity.badInput');
    5563
    5664document.getElementById('parent').innerHTML = '';
  • trunk/Source/WebCore/ChangeLog

    r135833 r135836  
     12012-11-27  Kent Tamura  <tkent@chromium.org>
     2
     3        Implement ValidityState::badInput
     4        https://bugs.webkit.org/show_bug.cgi?id=102861
     5
     6        Reviewed by Hajime Morita.
     7
     8        Add ValidityState::badInput, add hasBadInput, which always returns
     9        false, to FormAssociatedElement, HTMLInputElement, and InputType.
     10
     11        For NumberInputType, we had hasUnacceptableValue, which was a hack to
     12        make an input element match to :invalid if the element had non-number
     13        strings. We don't need the hack any more because badInput affects :invalid
     14        style. hasUnacceptableValue is re-used for hasBadInput implementation.
     15        We cleared invalid numbers when elements lost focus to tell users that
     16        the element had invalid numbers. We don't need this behavior because the
     17        interactive validation tells it.
     18
     19        For date/time input types, we should make an input badInput when the
     20        input has empty value but its sub-fields have values. It covers both of
     21        partial input cases such as 12/--/2012 and invalid dates such as
     22        02/31/2012.
     23
     24        For other types, ValidityState::badInput always returns false.
     25
     26        This patch doesn't contain tests for badInput validation messages. They
     27        will be added later.
     28
     29        Tests: fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput.html
     30               fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput.html
     31               fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput.html
     32               fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput.html
     33               fast/forms/number/number-validity-badinput.html
     34               fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput.html
     35               fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput.html
     36
     37        * html/ValidityState.idl: Add badInput IDL attribute.
     38        * html/ValidityState.h:
     39        (ValidityState): Add badInput.
     40        * html/ValidityState.cpp:
     41        (WebCore::ValidityState::badInput):
     42        Added. Calls FormAssociatedElement::hasBadInput.
     43
     44        * html/FormAssociatedElement.h:
     45        (FormAssociatedElement): Add hasBadInput.
     46        * html/FormAssociatedElement.cpp:
     47        (WebCore::FormAssociatedElement::hasBadInput):
     48        Added. It always returns false.
     49        (WebCore::FormAssociatedElement::valid): Takes account of hasBadInput().
     50
     51        * html/HTMLInputElement.h:
     52        (HTMLInputElement):
     53        Remove hasUnacceptableValue, and add hasBadInput override.
     54        * html/HTMLInputElement.cpp:
     55        (WebCore::HTMLInputElement::hasBadInput):
     56        Added. Delegate to InputType::hasBadInput.
     57        (WebCore): Remove hasUnacceptableValue.
     58
     59        * html/InputType.h:
     60        (InputType): Add hasBadInput and badInputText, and remove
     61        hasUnacceptableValue.
     62        * html/InputType.cpp:
     63        (WebCore::InputType::hasBadInput): Added. Returns false.
     64        (WebCore::InputType::badInputText):
     65        Added. This function should not be called because hasBadInput always
     66        returns false.
     67        (WebCore::InputType::validationMessage):
     68        Supports badInput. This returns badInputText if hasBadInput is true.
     69
     70        * html/NumberInputType.h:
     71        (NumberInputType): Add hasBadInput and badInputTest. Remove
     72        handleBlurEvent and hasUnacceptableValue.
     73        * html/NumberInputType.cpp:
     74        Remove handleBlurEvent, which cleared invalid number strings.
     75        (WebCore::NumberInputType::hasBadInput):
     76        Added. We don't need to check existence of a renderer. The standard form
     77        validation feature doesn't care of it.
     78        (WebCore::NumberInputType::badInputText): Returns
     79        validationMessageBadInputForNumberText defined in LocalizedStrings.h.
     80        * css/SelectorChecker.cpp:
     81        (WebCore::SelectorChecker::checkOneSelector):
     82        Remove a hack for hasUnacceptableValue. isValidFormControlElement takes
     83        account of badInput.
     84        * dom/Element.h: Remove hasUnacceptableValue.
     85
     86        * html/BaseMultipleFieldsDateAndTimeInputType.h:
     87        (BaseMultipleFieldsDateAndTimeInputType): Add hasBadInput and badInputText.
     88        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
     89        (WebCore::BaseMultipleFieldsDateAndTimeInputType::badInputText):
     90        Returns validationMessageBadInputForDateTimeText defined in LocalizedStrings.h.
     91        (WebCore::BaseMultipleFieldsDateAndTimeInputType::hasBadInput):
     92        Added.
     93        (WebCore::BaseMultipleFieldsDateAndTimeInputType::setValue):
     94        Add setNeedsValidityCheck call. It is needed because
     95        updateInnerTextValue can modify subfields empty state.
     96
     97        * html/TextFieldInputType.cpp:
     98        (WebCore::TextFieldInputType::subtreeHasChanged): Update a comment.
     99        * platform/LocalizedStrings.h:
     100        (WebCore): Add validationMessageBadInputForNumberText and
     101        validationMessageBadInputForDateTimeText.
     102        * platform/LocalizedStrings.cpp:
     103        (WebCore::validationMessageBadInputForNumberText):
     104        Added a placeholder implementation. This should be fixed later.
     105        * platform/blackberry/LocalizedStringsBlackBerry.cpp:
     106        (WebCore::validationMessageBadInputForNumberText): Ditto.
     107        * platform/efl/LocalizedStringsEfl.cpp:
     108        (WebCore::validationMessageBadInputForNumberText): Ditto.
     109        * platform/qt/LocalizedStringsQt.cpp:
     110        (WebCore::validationMessageBadInputForNumberText): Ditto.
     111
    11122012-11-27  Hajime Morrita  <morrita@google.com>
    2113
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r135829 r135836  
    10691069                return false;
    10701070            element->document()->setContainsValidityStyleRules();
    1071             return (element->willValidate() && !element->isValidFormControlElement()) || element->hasUnacceptableValue();
     1071            return element->willValidate() && !element->isValidFormControlElement();
    10721072        case CSSSelector::PseudoChecked:
    10731073            {
  • trunk/Source/WebCore/dom/Element.h

    r135816 r135836  
    384384    virtual bool willValidate() const { return false; }
    385385    virtual bool isValidFormControlElement() { return false; }
    386     virtual bool hasUnacceptableValue() const { return false; }
    387386    virtual bool isInRange() const { return false; }
    388387    virtual bool isOutOfRange() const { return false; }
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp

    r135510 r135836  
    4242#include "HTMLOptionElement.h"
    4343#include "KeyboardEvent.h"
     44#include "LocalizedStrings.h"
    4445#include "Page.h"
    4546#include "PickerIndicatorElement.h"
     
    167168    if (m_pickerIndicatorElement)
    168169        m_pickerIndicatorElement->removePickerIndicatorOwner();
     170}
     171
     172String BaseMultipleFieldsDateAndTimeInputType::badInputText() const
     173{
     174    return validationMessageBadInputForDateTimeText();
    169175}
    170176
     
    274280}
    275281
     282bool BaseMultipleFieldsDateAndTimeInputType::hasBadInput() const
     283{
     284    return element()->value().isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->anyEditableFieldsHaveValues();
     285}
     286
    276287bool BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable(KeyboardEvent*) const
    277288{
     
    326337{
    327338    InputType::setValue(sanitizedValue, valueChanged, eventBehavior);
    328     if (valueChanged || (sanitizedValue.isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->anyEditableFieldsHaveValues()))
     339    if (valueChanged || (sanitizedValue.isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->anyEditableFieldsHaveValues())) {
    329340        updateInnerTextValue();
     341        element()->setNeedsValidityCheck();
     342    }
    330343}
    331344
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h

    r134206 r135836  
    7474
    7575    // InputType functions
     76    virtual String badInputText() const OVERRIDE;
    7677    virtual void blur() OVERRIDE FINAL;
    7778    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE FINAL;
     
    8283    virtual void forwardEvent(Event*) OVERRIDE FINAL;
    8384    virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL;
     85    virtual bool hasBadInput() const OVERRIDE;
    8486    virtual bool hasCustomFocusLogic() const OVERRIDE FINAL;
    8587    virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE FINAL;
  • trunk/Source/WebCore/html/FormAssociatedElement.cpp

    r128572 r135836  
    190190}
    191191
     192bool FormAssociatedElement::hasBadInput() const
     193{
     194    return false;
     195}
     196
    192197bool FormAssociatedElement::patternMismatch() const
    193198{
     
    223228{
    224229    bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow()
    225         || tooLong() || patternMismatch() || valueMissing() || customError();
     230        || tooLong() || patternMismatch() || valueMissing() || hasBadInput() || customError();
    226231    return !someError;
    227232}
  • trunk/Source/WebCore/html/FormAssociatedElement.h

    r127752 r135836  
    7878    // Override functions for patterMismatch, rangeOverflow, rangerUnderflow,
    7979    // stepMismatch, tooLong and valueMissing must call willValidate method.
     80    virtual bool hasBadInput() const;
    8081    virtual bool patternMismatch() const;
    8182    virtual bool rangeOverflow() const;
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r135829 r135836  
    265265{
    266266    return willValidate() && m_inputType->valueMissing(value());
     267}
     268
     269bool HTMLInputElement::hasBadInput() const
     270{
     271    return willValidate() && m_inputType->hasBadInput();
    267272}
    268273
     
    13921397}
    13931398
    1394 bool HTMLInputElement::hasUnacceptableValue() const
    1395 {
    1396     return m_inputType->hasUnacceptableValue();
    1397 }
    1398 
    13991399bool HTMLInputElement::isInRange() const
    14001400{
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r135829 r135836  
    5656
    5757    // For ValidityState
     58    virtual bool hasBadInput() const OVERRIDE;
    5859    virtual bool patternMismatch() const OVERRIDE;
    5960    virtual bool rangeUnderflow() const OVERRIDE;
     
    357358
    358359    virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
    359 
    360     virtual bool hasUnacceptableValue() const;
    361360
    362361    virtual bool isInRange() const;
  • trunk/Source/WebCore/html/InputType.cpp

    r135829 r135836  
    259259}
    260260
     261bool InputType::hasBadInput() const
     262{
     263    return false;
     264}
     265
    261266bool InputType::patternMismatch(const String&) const
    262267{
     
    345350
    346351    return createStepRange(RejectAny).stepMismatch(numericValue);
     352}
     353
     354String InputType::badInputText() const
     355{
     356    ASSERT_NOT_REACHED();
     357    return validationMessageTypeMismatchText();
    347358}
    348359
     
    368379    if (typeMismatch())
    369380        return typeMismatchText();
     381
     382    if (hasBadInput())
     383        return badInputText();
    370384
    371385    if (patternMismatch(value))
     
    688702{
    689703    return proposedValue;
    690 }
    691 
    692 bool InputType::hasUnacceptableValue()
    693 {
    694     return false;
    695704}
    696705
  • trunk/Source/WebCore/html/InputType.h

    r135829 r135836  
    157157    virtual bool supportsRequired() const;
    158158    virtual bool valueMissing(const String&) const;
     159    virtual bool hasBadInput() const;
    159160    virtual bool patternMismatch(const String&) const;
    160161    bool rangeUnderflow(const String&) const;
     
    171172    virtual void stepUp(int, ExceptionCode&);
    172173    virtual void stepUpFromRenderer(int);
     174    virtual String badInputText() const;
    173175    virtual String typeMismatchText() const;
    174176    virtual String valueMissingText() const;
     
    179181    // This function must be called only by HTMLInputElement::sanitizeValue().
    180182    virtual String sanitizeValue(const String&) const;
    181     virtual bool hasUnacceptableValue();
    182183
    183184    // Event handlers
  • trunk/Source/WebCore/html/NumberInputType.cpp

    r135598 r135836  
    4040#include "InputTypeNames.h"
    4141#include "KeyboardEvent.h"
     42#include "LocalizedStrings.h"
    4243#include "PlatformLocale.h"
    4344#include "RenderTextControl.h"
     
    214215}
    215216
    216 void NumberInputType::handleBlurEvent()
    217 {
    218     // Reset the renderer value, which might be unmatched with the element value.
    219     element()->setFormControlValueMatchesRenderer(false);
    220 
    221     // We need to reset the renderer value explicitly because an unacceptable
    222     // renderer value should be purged before style calculation.
    223     updateInnerTextValue();
    224 }
    225 
    226217static bool isE(UChar ch)
    227218{
     
    261252}
    262253
    263 bool NumberInputType::hasUnacceptableValue()
    264 {
    265     if (!element()->renderer())
    266         return false;
     254bool NumberInputType::hasBadInput() const
     255{
    267256    String standardValue = convertFromVisibleValue(element()->innerTextValue());
    268257    return !standardValue.isEmpty() && !isfinite(parseToDoubleForNumberType(standardValue));
    269258}
    270259
     260String NumberInputType::badInputText() const
     261{
     262    return validationMessageBadInputForNumberText();
     263}
     264
    271265bool NumberInputType::shouldRespectSpeechAttribute()
    272266{
  • trunk/Source/WebCore/html/NumberInputType.h

    r135598 r135836  
    5454    virtual Decimal parseToNumber(const String&, const Decimal&) const OVERRIDE;
    5555    virtual String serialize(const Decimal&) const OVERRIDE;
    56     virtual void handleBlurEvent() OVERRIDE;
    5756    virtual String localizeValue(const String&) const OVERRIDE;
    5857    virtual String visibleValue() const OVERRIDE;
    5958    virtual String convertFromVisibleValue(const String&) const OVERRIDE;
    6059    virtual String sanitizeValue(const String&) const OVERRIDE;
    61     virtual bool hasUnacceptableValue() OVERRIDE;
     60    virtual bool hasBadInput() const OVERRIDE;
     61    virtual String badInputText() const OVERRIDE;
    6262    virtual bool shouldRespectSpeechAttribute() OVERRIDE;
    6363    virtual bool supportsPlaceholder() const OVERRIDE;
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r135829 r135836  
    464464    element()->setValueFromRenderer(sanitizeValue(convertFromVisibleValue(element()->innerTextValue())));
    465465    element()->updatePlaceholderVisibility(false);
    466     // Recalc for :invalid and hasUnacceptableValue() change.
     466    // Recalc for :invalid change.
    467467    element()->setNeedsStyleRecalc();
    468468
  • trunk/Source/WebCore/html/ValidityState.cpp

    r116915 r135836  
    7777}
    7878
     79bool ValidityState::badInput() const
     80{
     81    return m_control->hasBadInput();
     82}
     83
    7984bool ValidityState::customError() const
    8085{
  • trunk/Source/WebCore/html/ValidityState.h

    r135058 r135836  
    5353    bool rangeOverflow() const;
    5454    bool stepMismatch() const;
     55    bool badInput() const;
    5556    bool customError() const;
    5657    bool valid() const;
  • trunk/Source/WebCore/html/ValidityState.idl

    r131172 r135836  
    3131    readonly attribute boolean         rangeOverflow;
    3232    readonly attribute boolean         stepMismatch;
     33    readonly attribute boolean         badInput;
    3334    readonly attribute boolean         customError;
    3435    readonly attribute boolean         valid;
  • trunk/Source/WebCore/platform/LocalizedStrings.cpp

    r134465 r135836  
    993993}
    994994
     995String validationMessageBadInputForNumberText()
     996{
     997    notImplemented();
     998    return validationMessageTypeMismatchText();
     999}
     1000
    9951001} // namespace WebCore
  • trunk/Source/WebCore/platform/LocalizedStrings.h

    r134465 r135836  
    253253    String validationMessageRangeOverflowText(const String& maximum);
    254254    String validationMessageStepMismatchText(const String& base, const String& step);
     255    String validationMessageBadInputForNumberText();
     256#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     257    String validationMessageBadInputForDateTimeText();
     258#endif
    255259#if USE(SOUP)
    256260    String unacceptableTLSCertificate();
  • trunk/Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp

    r133338 r135836  
    525525}
    526526
     527String validationMessageBadInputForNumberText()
     528{
     529    notImplemented();
     530    return validationMessageTypeMismatchText();
     531}
     532
    527533String localizedMediaControlElementString(const String&)
    528534{
  • trunk/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp

    r133338 r135836  
    536536}
    537537
     538String validationMessageBadInputForNumberText()
     539{
     540    notImplemented();
     541    return validationMessageTypeMismatchText();
     542}
     543
    538544String missingPluginText()
    539545{
  • trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp

    r133763 r135836  
    712712}
    713713
     714String validationMessageBadInputForNumberText()
     715{
     716    notImplemented();
     717    return validationMessageTypeMismatchText();
     718}
     719
    714720String localizedString(const char* key)
    715721{
  • trunk/Source/WebKit/chromium/ChangeLog

    r135815 r135836  
     12012-11-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Implement ValidityState::badInput
     4        https://bugs.webkit.org/show_bug.cgi?id=102861
     5
     6        Reviewed by Hajime Morita.
     7
     8        * src/LocalizedStrings.cpp:
     9        Add placeholder implementations for new localized string functions.
     10        We'll update them in another patch.
     11        (WebCore::validationMessageBadInputForNumberText):
     12        (WebCore::validationMessageBadInputForDateTimeText):
     13
    1142012-11-26  Sheriff Bot  <webkit.review.bot@gmail.com>
    215
  • trunk/Source/WebKit/chromium/src/LocalizedStrings.cpp

    r133338 r135836  
    505505}
    506506
     507String validationMessageBadInputForNumberText()
     508{
     509    notImplemented();
     510    return String("Bad number");
     511}
     512
     513#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     514String validationMessageBadInputForDateTimeText()
     515{
     516    notImplemented();
     517    return String("Bad date");
     518}
     519#endif
     520
    507521} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.