Changeset 86832 in webkit
- Timestamp:
- May 19, 2011 2:50:07 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r86831 r86832 1 2011-05-19 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Hajime Morita. 4 5 tooLong validity should not be true for a value set by a script 6 https://bugs.webkit.org/show_bug.cgi?id=60948 7 8 Update existing tests for the new behavior. 9 10 * fast/forms/ValidityState-tooLong-input-expected.txt: 11 * fast/forms/ValidityState-tooLong-textarea-expected.txt: 12 * fast/forms/resources/textarea-live-pseudo-selectors.js: 13 * fast/forms/script-tests/ValidityState-tooLong-input.js: 14 * fast/forms/script-tests/ValidityState-tooLong-textarea.js: 15 1 16 2011-05-19 Yuzo Fujishima <yuzo@google.com> 2 17 -
trunk/LayoutTests/fast/forms/ValidityState-tooLong-input-expected.txt
r73999 r86832 19 19 20 20 Sets a value via DOM property 21 PASS input.validity.tooLong is true21 PASS input.validity.tooLong is false 22 22 23 23 Disabled … … 29 29 Change the type with a too long value 30 30 PASS input.validity.tooLong is true 31 PASS input. validity.tooLong is false31 PASS input.type = "number"; input.validity.tooLong is false 32 32 PASS successfullyParsed is true 33 33 -
trunk/LayoutTests/fast/forms/ValidityState-tooLong-textarea-expected.txt
r82913 r86832 19 19 20 20 Sets a value via DOM property 21 PASS textarea.validity.tooLong is true21 PASS textarea.validity.tooLong is false 22 22 23 23 Disabled … … 27 27 PASS textarea.validity.tooLong is false 28 28 29 A value set by resetting a form or by a child node changedoesn't make tooLong true.29 A value set by resetting a form doesn't make tooLong true. 30 30 PASS textarea.validity.tooLong is true 31 PASS textarea.value is "abc "31 PASS textarea.value is "abcdef" 32 32 PASS textarea.validity.tooLong is false 33 PASS textarea.validity.tooLong is true 34 PASS textarea.value is "def" 35 PASS textarea.validity.tooLong is true 33 34 A value set by a child node change doesn't make tooLong true. 35 PASS textarea.validity.tooLong is false 36 PASS textarea.value is "abcdef" 37 PASS textarea.validity.tooLong is false 36 38 PASS successfullyParsed is true 37 39 -
trunk/LayoutTests/fast/forms/resources/textarea-live-pseudo-selectors.js
r61153 r86832 97 97 el.focus(); 98 98 el.setSelectionRange(10, 10); 99 document.execCommand(' \x08');99 document.execCommand('delete'); 100 100 el.maxLength = 5; 101 101 shouldBe(elBackground, 'invalidColor'); -
trunk/LayoutTests/fast/forms/script-tests/ValidityState-tooLong-input.js
r73999 r86832 37 37 input.maxLength = 3; 38 38 input.value = 'abcde'; 39 shouldBe True('input.validity.tooLong');39 shouldBeFalse('input.validity.tooLong'); 40 40 41 41 debug(''); … … 62 62 input.value = 'abcde'; 63 63 input.type = 'search'; 64 input.focus(); 65 input.setSelectionRange(5, 5); 66 document.execCommand('delete'); 64 67 shouldBeTrue('input.validity.tooLong'); 65 66 input.type = 'number'; 67 shouldBeFalse('input.validity.tooLong'); 68 shouldBeFalse('input.type = "number"; input.validity.tooLong'); 68 69 69 70 var successfullyParsed = true; -
trunk/LayoutTests/fast/forms/script-tests/ValidityState-tooLong-textarea.js
r82913 r86832 39 39 textarea.maxLength = 3; 40 40 textarea.value = 'abcde'; 41 shouldBe True('textarea.validity.tooLong');41 shouldBeFalse('textarea.validity.tooLong'); 42 42 43 43 debug(''); … … 60 60 61 61 debug(''); 62 debug('A value set by resetting a form or by a child node changedoesn\'t make tooLong true.');62 debug('A value set by resetting a form doesn\'t make tooLong true.'); 63 63 // Make a dirty textarea. 64 64 var parent = document.createElement('div'); 65 65 document.body.appendChild(parent); 66 parent.innerHTML = '<form><textarea maxlength=2>abc </textarea></form>';66 parent.innerHTML = '<form><textarea maxlength=2>abcdef</textarea></form>'; 67 67 textarea = parent.firstChild.firstChild; 68 textarea.value = 'def'; 68 textarea.focus(); 69 textarea.setSelectionRange(6, 6); 70 document.execCommand('delete'); 69 71 shouldBeTrue('textarea.validity.tooLong'); 70 72 parent.firstChild.reset(); 71 shouldBe('textarea.value', '"abc "');73 shouldBe('textarea.value', '"abcdef"'); 72 74 shouldBeFalse('textarea.validity.tooLong'); 73 75 76 debug(''); 77 debug('A value set by a child node change doesn\'t make tooLong true.'); 74 78 parent.innerHTML = '<textarea maxlength=2>abc</textarea>'; 75 79 textarea = parent.firstChild; 76 textarea.value = 'def'; 77 shouldBeTrue('textarea.validity.tooLong'); 80 shouldBeFalse('textarea.validity.tooLong'); 78 81 parent.firstChild.innerHTML = 'abcdef'; 79 shouldBe('textarea.value', '" def"');80 shouldBe True('textarea.validity.tooLong');82 shouldBe('textarea.value', '"abcdef"'); 83 shouldBeFalse('textarea.validity.tooLong'); 81 84 82 85 var successfullyParsed = true; -
trunk/Source/WebCore/ChangeLog
r86830 r86832 1 2011-05-19 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Hajime Morita. 4 5 tooLong validity should not be true for a value set by a script 6 https://bugs.webkit.org/show_bug.cgi?id=60948 7 8 The specification has been updated so that tooLong should be true only 9 for user-edit values. 10 11 Introduce m_wasModifiedByUser flag to HTMLInputElement and 12 HTMLTextAreaElemnt. It is set to true when a renderer updates the 13 value, and is cleared when the value is updated by others. 14 15 * html/HTMLInputElement.cpp: 16 (WebCore::HTMLInputElement::HTMLInputElement): 17 Initialize m_wasModifiedByUser. 18 (WebCore::HTMLInputElement::tooLong): 19 Skip the check if m_wasModifiedByUser is false. 20 (WebCore::HTMLInputElement::updateType): Clear m_wasModifiedByUser. 21 (WebCore::HTMLInputElement::copyNonAttributeProperties): 22 (WebCore::HTMLInputElement::setValue): If sendChange is true, 23 m_wasModifiedByUser should be true because sendChange is set in a case 24 of form auto-fill. We assume a value set by form auto-fill is a kind 25 of user-edit. 26 (WebCore::HTMLInputElement::setValueFromRenderer): 27 m_wasModifiedByUser should be true for the update by a renderer. 28 * html/HTMLInputElement.h: Declare m_wasModifiedByUser. 29 * html/HTMLTextAreaElement.cpp: 30 (WebCore::HTMLTextAreaElement::HTMLTextAreaElement): 31 Initialize m_wasModifiedByUser. 32 (WebCore::HTMLTextAreaElement::updateValue): 33 m_wasModifiedByUser should be true for the update by a renderer. 34 (WebCore::HTMLTextAreaElement::setValueCommon): Clear m_wasModifiedByUser. 35 (WebCore::HTMLTextAreaElement::tooLong): 36 Skip the check if m_wasModifiedByUser is false. 37 * html/HTMLTextAreaElement.h: Declare m_wasModifiedByUser. 38 1 39 2011-05-19 David Barr <davidbarr@chromium.org> 2 40 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r86654 r86832 94 94 , m_stateRestored(false) 95 95 , m_parsingInProgress(createdByParser) 96 , m_wasModifiedByUser(false) 96 97 , m_inputType(InputType::createText(this)) 97 98 { … … 219 220 return false; 220 221 if (check == CheckDirtyFlag) { 221 // Return false for the default value even if it is longer than maxLength. 222 bool userEdited = !m_value.isNull(); 223 if (!userEdited) 222 // Return false for the default value or a value set by a script even if 223 // it is longer than maxLength. 224 bool dirty = !m_value.isNull(); 225 if (!dirty || !m_wasModifiedByUser) 224 226 return false; 225 227 } … … 519 521 else 520 522 updateValueIfNeeded(); 523 m_wasModifiedByUser = false; 521 524 522 525 if (neededActivationCallback) … … 862 865 863 866 m_value = sourceElement->m_value; 867 m_wasModifiedByUser = false; 864 868 setChecked(sourceElement->m_isChecked); 865 869 m_reflectsCheckedAttribute = sourceElement->m_reflectsCheckedAttribute; … … 929 933 else { 930 934 m_value = sanitizeValue(value); 935 m_wasModifiedByUser = sendChangeEvent; 931 936 if (isTextField()) 932 937 updatePlaceholderVisibility(false); … … 1018 1023 1019 1024 setFormControlValueMatchesRenderer(true); 1025 m_wasModifiedByUser = true; 1020 1026 1021 1027 // Input event is fired by the Node::defaultEventHandler for editable controls. -
trunk/Source/WebCore/html/HTMLInputElement.h
r85998 r86832 340 340 bool m_stateRestored : 1; 341 341 bool m_parsingInProgress : 1; 342 bool m_wasModifiedByUser : 1; 342 343 OwnPtr<InputType> m_inputType; 343 344 }; -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r85998 r86832 72 72 , m_cachedSelectionEnd(-1) 73 73 , m_isDirty(false) 74 , m_wasModifiedByUser(false) 74 75 { 75 76 ASSERT(hasTagName(textareaTag)); … … 278 279 notifyFormStateChanged(this); 279 280 m_isDirty = true; 281 const_cast<HTMLTextAreaElement*>(this)->m_wasModifiedByUser = true; 280 282 const_cast<HTMLTextAreaElement*>(this)->updatePlaceholderVisibility(false); 281 283 } … … 305 307 void HTMLTextAreaElement::setValueCommon(const String& value) 306 308 { 309 m_wasModifiedByUser = false; 307 310 // Code elsewhere normalizes line endings added by the user via the keyboard or pasting. 308 311 // We normalize line endings coming from JavaScript here. … … 385 388 bool HTMLTextAreaElement::tooLong(const String& value, NeedsToCheckDirtyFlag check) const 386 389 { 387 // Return false for the default value even if it is longer than maxLength. 388 if (check == CheckDirtyFlag && !m_isDirty) 390 // Return false for the default value or value set by script even if it is 391 // longer than maxLength. 392 if (check == CheckDirtyFlag && !m_wasModifiedByUser) 389 393 return false; 390 394 -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r82925 r86832 111 111 int m_cachedSelectionEnd; 112 112 mutable bool m_isDirty; 113 bool m_wasModifiedByUser; 113 114 }; 114 115
Note: See TracChangeset
for help on using the changeset viewer.