Changeset 48959 in webkit
- Timestamp:
- Sep 30, 2009 10:49:39 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r48953 r48959 1 2009-09-30 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Add ValidityState.tooLong support for <input> and <textarea>. 6 https://bugs.webkit.org/show_bug.cgi?id=27454 7 8 * fast/forms/ValidityState-tooLong-input-expected.txt: Added. 9 * fast/forms/ValidityState-tooLong-input.html: Added. 10 * fast/forms/ValidityState-tooLong-textarea-expected.txt: Added. 11 * fast/forms/ValidityState-tooLong-textarea.html: Added. 12 * fast/forms/script-tests/ValidityState-tooLong-input.js: Added. 13 * fast/forms/script-tests/ValidityState-tooLong-textarea.js: Added. 14 1 15 2009-09-30 Maciej Stachowiak <mjs@apple.com> 2 16 -
trunk/WebCore/ChangeLog
r48958 r48959 1 2009-09-30 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Adds ValidityState.tooLong support for <input> and <textarea>. 6 7 Introduces tooLong() in HTMLFormControlElement and it always returns false. 8 HTMLInputElement and HTMLTextAreaElement overrides it and checks the text 9 length and maxLength. tooLong() should work only for `dirty' values. 10 So, introduces m_isDirty flag for HTMLTextAreaElement, and 11 !m_data.value().isNull() works as a dirty flag for HTMLInputElement. 12 13 Renames parameter names of setMaxLength(). 14 15 https://bugs.webkit.org/show_bug.cgi?id=27454 16 17 Tests: fast/forms/ValidityState-tooLong-input.html 18 fast/forms/ValidityState-tooLong-textarea.html 19 20 * html/HTMLFormControlElement.h: 21 (WebCore::HTMLFormControlElement::tooLong): 22 * html/HTMLInputElement.cpp: 23 (WebCore::HTMLInputElement::tooLong): 24 (WebCore::HTMLInputElement::setMaxLength): 25 * html/HTMLInputElement.h: 26 * html/HTMLTextAreaElement.cpp: 27 (WebCore::HTMLTextAreaElement::HTMLTextAreaElement): 28 (WebCore::HTMLTextAreaElement::reset): 29 (WebCore::HTMLTextAreaElement::updateValue): 30 (WebCore::HTMLTextAreaElement::setMaxLength): 31 (WebCore::HTMLTextAreaElement::tooLong): 32 * html/HTMLTextAreaElement.h: 33 * html/ValidityState.h: 34 (WebCore::ValidityState::tooLong): 35 1 36 2009-09-30 Adam Barth <abarth@webkit.org> 2 37 -
trunk/WebCore/html/HTMLFormControlElement.h
r48792 r48959 111 111 virtual bool valueMissing() const { return false; } 112 112 virtual bool patternMismatch() const { return false; } 113 virtual bool tooLong() const { return false; } 113 114 114 115 void formDestroyed() { m_form = 0; } -
trunk/WebCore/html/HTMLInputElement.cpp
r48903 r48959 193 193 } 194 194 195 ASSERT_NOT_REACHED(); 196 return false; 197 } 198 199 bool HTMLInputElement::tooLong() const 200 { 201 switch (inputType()) { 202 case EMAIL: 203 case PASSWORD: 204 case SEARCH: 205 case TELEPHONE: 206 case TEXT: 207 case URL: { 208 int max = maxLength(); 209 if (max < 0) 210 return false; 211 // Return false for the default value even if it is longer than maxLength. 212 bool userEdited = !m_data.value().isNull(); 213 if (!userEdited) 214 return false; 215 return value().length() > static_cast<unsigned>(max); 216 } 217 case BUTTON: 218 case CHECKBOX: 219 case COLOR: 220 case FILE: 221 case HIDDEN: 222 case IMAGE: 223 case ISINDEX: 224 case NUMBER: 225 case RADIO: 226 case RANGE: 227 case RESET: 228 case SUBMIT: 229 return false; 230 } 195 231 ASSERT_NOT_REACHED(); 196 232 return false; … … 1611 1647 } 1612 1648 1613 void HTMLInputElement::setMaxLength(int _maxLength, ExceptionCode& exceptionCode)1614 { 1615 if ( _maxLength < 0)1616 e xceptionCode= INDEX_SIZE_ERR;1649 void HTMLInputElement::setMaxLength(int maxLength, ExceptionCode& ec) 1650 { 1651 if (maxLength < 0) 1652 ec = INDEX_SIZE_ERR; 1617 1653 else 1618 setAttribute(maxlengthAttr, String::number( _maxLength));1654 setAttribute(maxlengthAttr, String::number(maxLength)); 1619 1655 } 1620 1656 -
trunk/WebCore/html/HTMLInputElement.h
r48903 r48959 94 94 virtual bool valueMissing() const; 95 95 virtual bool patternMismatch() const; 96 virtual bool tooLong() const; 96 97 97 98 bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; } -
trunk/WebCore/html/HTMLTextAreaElement.cpp
r48903 r48959 71 71 , m_cachedSelectionStart(-1) 72 72 , m_cachedSelectionEnd(-1) 73 , m_isDirty(false) 73 74 { 74 75 ASSERT(hasTagName(textareaTag)); … … 232 233 { 233 234 setValue(defaultValue()); 235 m_isDirty = false; 234 236 } 235 237 … … 317 319 const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true); 318 320 notifyFormStateChanged(this); 321 m_isDirty = true; 319 322 } 320 323 … … 410 413 } 411 414 412 void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& e xceptionCode)415 void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& ec) 413 416 { 414 417 if (newValue < 0) 415 e xceptionCode= INDEX_SIZE_ERR;418 ec = INDEX_SIZE_ERR; 416 419 else 417 420 setAttribute(maxlengthAttr, String::number(newValue)); 421 } 422 423 bool HTMLTextAreaElement::tooLong() const 424 { 425 // Return false for the default value even if it is longer than maxLength. 426 if (!m_isDirty) 427 return false; 428 429 int max = maxLength(); 430 if (max < 0) 431 return false; 432 return value().length() > static_cast<unsigned>(max); 418 433 } 419 434 -
trunk/WebCore/html/HTMLTextAreaElement.h
r48903 r48959 82 82 int maxLength() const; 83 83 void setMaxLength(int, ExceptionCode&); 84 virtual bool tooLong() const; 84 85 85 86 void rendererWillBeDestroyed(); … … 117 118 int m_cachedSelectionStart; 118 119 int m_cachedSelectionEnd; 120 mutable bool m_isDirty; 119 121 }; 120 122 -
trunk/WebCore/html/ValidityState.h
r48043 r48959 44 44 bool typeMismatch(); 45 45 bool patternMismatch() { return control()->patternMismatch(); } 46 bool tooLong() { return false; }46 bool tooLong() { return control()->tooLong(); } 47 47 bool rangeUnderflow() { return false; } 48 48 bool rangeOverflow() { return false; }
Note: See TracChangeset
for help on using the changeset viewer.