Implement ValidityState::badInput
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2012 09:09:15 +0000 (09:09 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2012 09:09:15 +0000 (09:09 +0000)
commit8d40961c28f8d8442cf5a43e1ec5a8ed70af8b36
tree469cd1ab7c3be07f3d874ca61dddf2a3d6e8d052
parentaea056bed61019ac79e05ece350b4ae259e43b34
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-validity-badinput.html [new file with mode: 0644]
LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-validity-badinput.html [new file with mode: 0644]
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-validity-badinput.html [new file with mode: 0644]
LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-validity-badinput.html [new file with mode: 0644]
LayoutTests/fast/forms/number/number-unacceptable-style-expected.txt [deleted file]
LayoutTests/fast/forms/number/number-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/number/number-validity-badinput.html [moved from LayoutTests/fast/forms/number/number-unacceptable-style.html with 59% similarity]
LayoutTests/fast/forms/resources/multiple-fields-validity-badinput.js [new file with mode: 0644]
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-validity-badinput.html [new file with mode: 0644]
LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-validity-badinput.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/dom/Element.h
Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp
Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h
Source/WebCore/html/FormAssociatedElement.cpp
Source/WebCore/html/FormAssociatedElement.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/NumberInputType.cpp
Source/WebCore/html/NumberInputType.h
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/ValidityState.cpp
Source/WebCore/html/ValidityState.h
Source/WebCore/html/ValidityState.idl
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp
Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
Source/WebCore/platform/qt/LocalizedStringsQt.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/LocalizedStrings.cpp