Changeset 135836 in webkit
- Timestamp:
- Nov 27, 2012 1:09:15 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 1 deleted
- 25 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r135835 r135836 1 2012-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 1 25 2012-11-27 Alexander Pavlov <apavlov@chromium.org> 2 26 -
trunk/LayoutTests/fast/forms/number/number-validity-badinput.html
-
Property
svn:eol-style
set to
LF
r135835 r135836 17 17 </div> 18 18 <script> 19 description('A number input fields with a n unacceptable string should have :invalid style.');19 description('A number input fields with a bad input string should make validity.badInput true and have :invalid style.'); 20 20 21 21 function colorOf(el) { … … 28 28 debug('Initial state. The elment has no value.'); 29 29 shouldBeTrue('colorOf(number) != invalidStyleColor'); 30 shouldBeFalse('number.validity.badInput'); 30 31 31 debug("Type '-'. The renderer value becomes unacceptable.");32 debug("Type '-'. The element becomes badInput."); 32 33 document.execCommand('InsertText', false, '-'); 33 34 shouldBe('colorOf(number)', 'invalidStyleColor'); 34 shouldBeTrue('number.validity.valid'); 35 shouldBeFalse('number.validity.valid'); 36 shouldBeTrue('number.validity.badInput'); 35 37 shouldBeEqualToString('number.value', ''); 36 38 37 debug("Type '1' additionally. The renderer value becomes acceptable.");39 debug("Type '1' additionally. The element becomes valid."); 38 40 document.execCommand('InsertText', false, '1'); 39 41 shouldBeTrue('colorOf(number) != invalidStyleColor'); 42 shouldBeFalse('number.validity.badInput'); 40 43 shouldBeEqualToString('number.value', '-1'); 41 44 42 debug("Type 'a' additionally. The renderer value becomes unacceptableagain.");45 debug("Type 'a' additionally. The element becomes badInput again."); 43 46 document.execCommand('InsertText', false, 'a'); 44 47 shouldBe('colorOf(number)', 'invalidStyleColor'); 48 shouldBeTrue('number.validity.badInput'); 45 49 shouldBeEqualToString('number.value', ''); 46 50 47 debug("The element losts focus. The unacceptable value should be purged and the style should be normal.");51 debug("The element losts focus. The element state should not be changed."); 48 52 document.getElementById('another').focus(); 49 shouldBeTrue('colorOf(number) != invalidStyleColor'); 50 // Visiblue value is not '-1a'. 53 shouldBe('colorOf(number)', 'invalidStyleColor'); 54 shouldBeTrue('number.validity.badInput'); 55 // Visible value is '-1a'. 51 56 number.focus(); 52 57 document.execCommand('SelectAll'); 53 shouldBeEqualToString('document.getSelection().toString()', ' ');58 shouldBeEqualToString('document.getSelection().toString()', '-1a'); 54 59 shouldBeEqualToString('number.value', ''); 60 61 debug("The element losts a renderer. The element state should not be changed."); 62 shouldBeTrue('number.style.display = "none"; number.validity.badInput'); 55 63 56 64 document.getElementById('parent').innerHTML = ''; -
Property
svn:eol-style
set to
-
trunk/Source/WebCore/ChangeLog
r135833 r135836 1 2012-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 1 112 2012-11-27 Hajime Morrita <morrita@google.com> 2 113 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r135829 r135836 1069 1069 return false; 1070 1070 element->document()->setContainsValidityStyleRules(); 1071 return (element->willValidate() && !element->isValidFormControlElement()) || element->hasUnacceptableValue();1071 return element->willValidate() && !element->isValidFormControlElement(); 1072 1072 case CSSSelector::PseudoChecked: 1073 1073 { -
trunk/Source/WebCore/dom/Element.h
r135816 r135836 384 384 virtual bool willValidate() const { return false; } 385 385 virtual bool isValidFormControlElement() { return false; } 386 virtual bool hasUnacceptableValue() const { return false; }387 386 virtual bool isInRange() const { return false; } 388 387 virtual bool isOutOfRange() const { return false; } -
trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp
r135510 r135836 42 42 #include "HTMLOptionElement.h" 43 43 #include "KeyboardEvent.h" 44 #include "LocalizedStrings.h" 44 45 #include "Page.h" 45 46 #include "PickerIndicatorElement.h" … … 167 168 if (m_pickerIndicatorElement) 168 169 m_pickerIndicatorElement->removePickerIndicatorOwner(); 170 } 171 172 String BaseMultipleFieldsDateAndTimeInputType::badInputText() const 173 { 174 return validationMessageBadInputForDateTimeText(); 169 175 } 170 176 … … 274 280 } 275 281 282 bool BaseMultipleFieldsDateAndTimeInputType::hasBadInput() const 283 { 284 return element()->value().isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->anyEditableFieldsHaveValues(); 285 } 286 276 287 bool BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable(KeyboardEvent*) const 277 288 { … … 326 337 { 327 338 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())) { 329 340 updateInnerTextValue(); 341 element()->setNeedsValidityCheck(); 342 } 330 343 } 331 344 -
trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h
r134206 r135836 74 74 75 75 // InputType functions 76 virtual String badInputText() const OVERRIDE; 76 77 virtual void blur() OVERRIDE FINAL; 77 78 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE FINAL; … … 82 83 virtual void forwardEvent(Event*) OVERRIDE FINAL; 83 84 virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL; 85 virtual bool hasBadInput() const OVERRIDE; 84 86 virtual bool hasCustomFocusLogic() const OVERRIDE FINAL; 85 87 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE FINAL; -
trunk/Source/WebCore/html/FormAssociatedElement.cpp
r128572 r135836 190 190 } 191 191 192 bool FormAssociatedElement::hasBadInput() const 193 { 194 return false; 195 } 196 192 197 bool FormAssociatedElement::patternMismatch() const 193 198 { … … 223 228 { 224 229 bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow() 225 || tooLong() || patternMismatch() || valueMissing() || customError();230 || tooLong() || patternMismatch() || valueMissing() || hasBadInput() || customError(); 226 231 return !someError; 227 232 } -
trunk/Source/WebCore/html/FormAssociatedElement.h
r127752 r135836 78 78 // Override functions for patterMismatch, rangeOverflow, rangerUnderflow, 79 79 // stepMismatch, tooLong and valueMissing must call willValidate method. 80 virtual bool hasBadInput() const; 80 81 virtual bool patternMismatch() const; 81 82 virtual bool rangeOverflow() const; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r135829 r135836 265 265 { 266 266 return willValidate() && m_inputType->valueMissing(value()); 267 } 268 269 bool HTMLInputElement::hasBadInput() const 270 { 271 return willValidate() && m_inputType->hasBadInput(); 267 272 } 268 273 … … 1392 1397 } 1393 1398 1394 bool HTMLInputElement::hasUnacceptableValue() const1395 {1396 return m_inputType->hasUnacceptableValue();1397 }1398 1399 1399 bool HTMLInputElement::isInRange() const 1400 1400 { -
trunk/Source/WebCore/html/HTMLInputElement.h
r135829 r135836 56 56 57 57 // For ValidityState 58 virtual bool hasBadInput() const OVERRIDE; 58 59 virtual bool patternMismatch() const OVERRIDE; 59 60 virtual bool rangeUnderflow() const OVERRIDE; … … 357 358 358 359 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 359 360 virtual bool hasUnacceptableValue() const;361 360 362 361 virtual bool isInRange() const; -
trunk/Source/WebCore/html/InputType.cpp
r135829 r135836 259 259 } 260 260 261 bool InputType::hasBadInput() const 262 { 263 return false; 264 } 265 261 266 bool InputType::patternMismatch(const String&) const 262 267 { … … 345 350 346 351 return createStepRange(RejectAny).stepMismatch(numericValue); 352 } 353 354 String InputType::badInputText() const 355 { 356 ASSERT_NOT_REACHED(); 357 return validationMessageTypeMismatchText(); 347 358 } 348 359 … … 368 379 if (typeMismatch()) 369 380 return typeMismatchText(); 381 382 if (hasBadInput()) 383 return badInputText(); 370 384 371 385 if (patternMismatch(value)) … … 688 702 { 689 703 return proposedValue; 690 }691 692 bool InputType::hasUnacceptableValue()693 {694 return false;695 704 } 696 705 -
trunk/Source/WebCore/html/InputType.h
r135829 r135836 157 157 virtual bool supportsRequired() const; 158 158 virtual bool valueMissing(const String&) const; 159 virtual bool hasBadInput() const; 159 160 virtual bool patternMismatch(const String&) const; 160 161 bool rangeUnderflow(const String&) const; … … 171 172 virtual void stepUp(int, ExceptionCode&); 172 173 virtual void stepUpFromRenderer(int); 174 virtual String badInputText() const; 173 175 virtual String typeMismatchText() const; 174 176 virtual String valueMissingText() const; … … 179 181 // This function must be called only by HTMLInputElement::sanitizeValue(). 180 182 virtual String sanitizeValue(const String&) const; 181 virtual bool hasUnacceptableValue();182 183 183 184 // Event handlers -
trunk/Source/WebCore/html/NumberInputType.cpp
r135598 r135836 40 40 #include "InputTypeNames.h" 41 41 #include "KeyboardEvent.h" 42 #include "LocalizedStrings.h" 42 43 #include "PlatformLocale.h" 43 44 #include "RenderTextControl.h" … … 214 215 } 215 216 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 unacceptable222 // renderer value should be purged before style calculation.223 updateInnerTextValue();224 }225 226 217 static bool isE(UChar ch) 227 218 { … … 261 252 } 262 253 263 bool NumberInputType::hasUnacceptableValue() 264 { 265 if (!element()->renderer()) 266 return false; 254 bool NumberInputType::hasBadInput() const 255 { 267 256 String standardValue = convertFromVisibleValue(element()->innerTextValue()); 268 257 return !standardValue.isEmpty() && !isfinite(parseToDoubleForNumberType(standardValue)); 269 258 } 270 259 260 String NumberInputType::badInputText() const 261 { 262 return validationMessageBadInputForNumberText(); 263 } 264 271 265 bool NumberInputType::shouldRespectSpeechAttribute() 272 266 { -
trunk/Source/WebCore/html/NumberInputType.h
r135598 r135836 54 54 virtual Decimal parseToNumber(const String&, const Decimal&) const OVERRIDE; 55 55 virtual String serialize(const Decimal&) const OVERRIDE; 56 virtual void handleBlurEvent() OVERRIDE;57 56 virtual String localizeValue(const String&) const OVERRIDE; 58 57 virtual String visibleValue() const OVERRIDE; 59 58 virtual String convertFromVisibleValue(const String&) const OVERRIDE; 60 59 virtual String sanitizeValue(const String&) const OVERRIDE; 61 virtual bool hasUnacceptableValue() OVERRIDE; 60 virtual bool hasBadInput() const OVERRIDE; 61 virtual String badInputText() const OVERRIDE; 62 62 virtual bool shouldRespectSpeechAttribute() OVERRIDE; 63 63 virtual bool supportsPlaceholder() const OVERRIDE; -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r135829 r135836 464 464 element()->setValueFromRenderer(sanitizeValue(convertFromVisibleValue(element()->innerTextValue()))); 465 465 element()->updatePlaceholderVisibility(false); 466 // Recalc for :invalid and hasUnacceptableValue()change.466 // Recalc for :invalid change. 467 467 element()->setNeedsStyleRecalc(); 468 468 -
trunk/Source/WebCore/html/ValidityState.cpp
r116915 r135836 77 77 } 78 78 79 bool ValidityState::badInput() const 80 { 81 return m_control->hasBadInput(); 82 } 83 79 84 bool ValidityState::customError() const 80 85 { -
trunk/Source/WebCore/html/ValidityState.h
r135058 r135836 53 53 bool rangeOverflow() const; 54 54 bool stepMismatch() const; 55 bool badInput() const; 55 56 bool customError() const; 56 57 bool valid() const; -
trunk/Source/WebCore/html/ValidityState.idl
r131172 r135836 31 31 readonly attribute boolean rangeOverflow; 32 32 readonly attribute boolean stepMismatch; 33 readonly attribute boolean badInput; 33 34 readonly attribute boolean customError; 34 35 readonly attribute boolean valid; -
trunk/Source/WebCore/platform/LocalizedStrings.cpp
r134465 r135836 993 993 } 994 994 995 String validationMessageBadInputForNumberText() 996 { 997 notImplemented(); 998 return validationMessageTypeMismatchText(); 999 } 1000 995 1001 } // namespace WebCore -
trunk/Source/WebCore/platform/LocalizedStrings.h
r134465 r135836 253 253 String validationMessageRangeOverflowText(const String& maximum); 254 254 String validationMessageStepMismatchText(const String& base, const String& step); 255 String validationMessageBadInputForNumberText(); 256 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 257 String validationMessageBadInputForDateTimeText(); 258 #endif 255 259 #if USE(SOUP) 256 260 String unacceptableTLSCertificate(); -
trunk/Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp
r133338 r135836 525 525 } 526 526 527 String validationMessageBadInputForNumberText() 528 { 529 notImplemented(); 530 return validationMessageTypeMismatchText(); 531 } 532 527 533 String localizedMediaControlElementString(const String&) 528 534 { -
trunk/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
r133338 r135836 536 536 } 537 537 538 String validationMessageBadInputForNumberText() 539 { 540 notImplemented(); 541 return validationMessageTypeMismatchText(); 542 } 543 538 544 String missingPluginText() 539 545 { -
trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp
r133763 r135836 712 712 } 713 713 714 String validationMessageBadInputForNumberText() 715 { 716 notImplemented(); 717 return validationMessageTypeMismatchText(); 718 } 719 714 720 String localizedString(const char* key) 715 721 { -
trunk/Source/WebKit/chromium/ChangeLog
r135815 r135836 1 2012-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 1 14 2012-11-26 Sheriff Bot <webkit.review.bot@gmail.com> 2 15 -
trunk/Source/WebKit/chromium/src/LocalizedStrings.cpp
r133338 r135836 505 505 } 506 506 507 String validationMessageBadInputForNumberText() 508 { 509 notImplemented(); 510 return String("Bad number"); 511 } 512 513 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 514 String validationMessageBadInputForDateTimeText() 515 { 516 notImplemented(); 517 return String("Bad date"); 518 } 519 #endif 520 507 521 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.