Changeset 48903 in webkit
- Timestamp:
- Sep 29, 2009 2:25:54 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r48896 r48903 1 2009-09-29 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Update for .maxLength behavior change. 6 https://bugs.webkit.org/show_bug.cgi?id=29796 7 8 * fast/forms/input-maxlength-expected.txt: 9 * fast/forms/input-maxlength.html: 10 * fast/forms/script-tests/textarea-maxlength.js: 11 * fast/forms/textarea-maxlength-expected.txt: 12 1 13 2009-09-29 Dirk Schulze <krit@webkit.org> 2 14 -
trunk/LayoutTests/fast/forms/input-maxlength-expected.txt
r48449 r48903 73 73 Attempting to insert 530000 characters with maxLength = 600000. 74 74 PASS 75 Some tests for .maxLength property. 76 PASS input.maxLength is implicitMaxLength 77 PASS input.maxLength = -1 threw exception Error: INDEX_SIZE_ERR: DOM Exception 1. 78 PASS input.getAttribute('maxlength') is '100' 75 79 PASS successfullyParsed is true 76 80 -
trunk/LayoutTests/fast/forms/input-maxlength.html
r48449 r48903 45 45 } 46 46 47 debug('Some tests for .maxLength property.'); 48 input = document.createElement("input"); 49 shouldBe("input.maxLength", "implicitMaxLength"); 50 shouldThrow("input.maxLength = -1", "'Error: INDEX_SIZE_ERR: DOM Exception 1'"); 51 input.maxLength = 100; 52 shouldBe("input.getAttribute('maxlength')", "'100'"); 53 47 54 var successfullyParsed = true; 48 55 </script> -
trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js
r48698 r48903 5 5 6 6 // No maxlength attribute 7 shouldBe('textArea.maxLength', ' 0');7 shouldBe('textArea.maxLength', '-1'); 8 8 9 9 // Invalid maxlength attributes 10 10 textArea.setAttribute('maxlength', '-3'); 11 shouldBe('textArea.maxLength', ' 0');11 shouldBe('textArea.maxLength', '-1'); 12 12 textArea.setAttribute('maxlength', 'xyz'); 13 shouldBe('textArea.maxLength', ' 0');13 shouldBe('textArea.maxLength', '-1'); 14 14 15 15 // Valid maxlength attributes … … 23 23 shouldBe('textArea.getAttribute("maxlength")', '"13"'); 24 24 25 textArea.maxLength = -1; 26 shouldBe('textArea.maxLength', '4294967295'); 27 shouldBe('textArea.getAttribute("maxlength")', '"4294967295"'); 25 shouldThrow('textArea.maxLength = -1', '"Error: INDEX_SIZE_ERR: DOM Exception 1"'); 26 shouldBe('textArea.getAttribute("maxlength")', '"13"'); // Not changed 27 28 textArea.maxLength = null; 29 shouldBe('textArea.maxLength', '0'); 30 shouldBe('textArea.getAttribute("maxlength")', '"0"'); 28 31 29 32 // maxLength doesn't truncate the default value. -
trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt
r48698 r48903 4 4 5 5 6 PASS textArea.maxLength is 07 PASS textArea.maxLength is 08 PASS textArea.maxLength is 06 PASS textArea.maxLength is -1 7 PASS textArea.maxLength is -1 8 PASS textArea.maxLength is -1 9 9 PASS textArea.maxLength is 1 10 10 PASS textArea.maxLength is 256 11 11 PASS textArea.getAttribute("maxlength") is "13" 12 PASS textArea.maxLength is 4294967295 13 PASS textArea.getAttribute("maxlength") is "4294967295" 12 PASS textArea.maxLength = -1 threw exception Error: INDEX_SIZE_ERR: DOM Exception 1. 13 PASS textArea.getAttribute("maxlength") is "13" 14 PASS textArea.maxLength is 0 15 PASS textArea.getAttribute("maxlength") is "0" 14 16 PASS textArea.value is "abcd" 15 17 PASS textArea.value is "abcde" -
trunk/WebCore/ChangeLog
r48902 r48903 1 2009-09-29 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Follows HTML5's maxLength change in September 2009. 6 - Change HTMLTextAreaElement.maxLength type to signed. 7 - HTMLTextAreaElement.maxLength returns -1 if maxlength= attribute is missing. 8 - HTMLTextAreaElement.maxLength and HTMLInputElement.maxLength 9 throw INDEX_SIZE_ERR for setting negative values. 10 https://bugs.webkit.org/show_bug.cgi?id=29796 11 12 * html/HTMLInputElement.cpp: 13 (WebCore::HTMLInputElement::setMaxLength): 14 * html/HTMLInputElement.h: 15 * html/HTMLInputElement.idl: 16 * html/HTMLTextAreaElement.cpp: 17 (WebCore::HTMLTextAreaElement::handleBeforeTextInsertedEvent): 18 (WebCore::HTMLTextAreaElement::maxLength): 19 (WebCore::HTMLTextAreaElement::setMaxLength): 20 * html/HTMLTextAreaElement.h: 21 * html/HTMLTextAreaElement.idl: 22 1 23 2009-09-29 Dimitri Glazkov <dglazkov@chromium.org> 2 24 -
trunk/WebCore/html/HTMLInputElement.cpp
r48792 r48903 35 35 #include "EventHandler.h" 36 36 #include "EventNames.h" 37 #include "ExceptionCode.h" 37 38 #include "File.h" 38 39 #include "FileList.h" … … 1610 1611 } 1611 1612 1612 void HTMLInputElement::setMaxLength(int _maxLength) 1613 { 1614 setAttribute(maxlengthAttr, String::number(_maxLength)); 1613 void HTMLInputElement::setMaxLength(int _maxLength, ExceptionCode& exceptionCode) 1614 { 1615 if (_maxLength < 0) 1616 exceptionCode = INDEX_SIZE_ERR; 1617 else 1618 setAttribute(maxlengthAttr, String::number(_maxLength)); 1615 1619 } 1616 1620 -
trunk/WebCore/html/HTMLInputElement.h
r48792 r48903 202 202 203 203 int maxLength() const; 204 void setMaxLength(int );204 void setMaxLength(int, ExceptionCode&); 205 205 206 206 bool multiple() const; -
trunk/WebCore/html/HTMLInputElement.idl
r47889 r48903 43 43 readonly attribute HTMLElement list; 44 44 #endif 45 attribute long maxLength; 45 attribute long maxLength 46 setter raises(DOMException); 46 47 attribute boolean multiple; 47 48 attribute [ConvertNullToNullString] DOMString name; -
trunk/WebCore/html/HTMLTextAreaElement.cpp
r48792 r48903 33 33 #include "Event.h" 34 34 #include "EventNames.h" 35 #include "ExceptionCode.h" 35 36 #include "FocusController.h" 36 37 #include "FormDataList.h" … … 284 285 ASSERT(event); 285 286 ASSERT(renderer()); 286 bool ok; 287 unsigned maxLength = getAttribute(maxlengthAttr).string().toUInt(&ok); 288 if (!ok) 287 int signedMaxLength = maxLength(); 288 if (signedMaxLength < 0) 289 289 return; 290 unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength); 290 291 291 292 unsigned currentLength = toRenderTextControl(renderer())->text().numGraphemeClusters(); … … 293 294 ASSERT(currentLength >= selectionLength); 294 295 unsigned baseLength = currentLength - selectionLength; 295 unsigned appendableLength = maxLength > baseLength ? maxLength - baseLength : 0;296 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLength - baseLength : 0; 296 297 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); 297 298 } … … 402 403 } 403 404 404 unsigned HTMLTextAreaElement::maxLength() const 405 { 406 return getAttribute(maxlengthAttr).string().toUInt(); 407 } 408 409 void HTMLTextAreaElement::setMaxLength(unsigned newValue) 410 { 411 setAttribute(maxlengthAttr, String::number(newValue)); 405 int HTMLTextAreaElement::maxLength() const 406 { 407 bool ok; 408 int value = getAttribute(maxlengthAttr).string().toInt(&ok); 409 return ok && value >= 0 ? value : -1; 410 } 411 412 void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& exceptionCode) 413 { 414 if (newValue < 0) 415 exceptionCode = INDEX_SIZE_ERR; 416 else 417 setAttribute(maxlengthAttr, String::number(newValue)); 412 418 } 413 419 -
trunk/WebCore/html/HTMLTextAreaElement.h
r48792 r48903 80 80 void setDefaultValue(const String&); 81 81 int textLength() const { return value().length(); } 82 unsignedmaxLength() const;83 void setMaxLength( unsigned);82 int maxLength() const; 83 void setMaxLength(int, ExceptionCode&); 84 84 85 85 void rendererWillBeDestroyed(); -
trunk/WebCore/html/HTMLTextAreaElement.idl
r48698 r48903 35 35 attribute boolean disabled; 36 36 attribute boolean autofocus; 37 attribute unsigned long maxLength; 37 attribute long maxLength 38 setter raises(DOMException); 38 39 attribute [ConvertNullToNullString] DOMString name; 39 40 attribute [ConvertNullToNullString, Reflect] DOMString placeholder;
Note: See TracChangeset
for help on using the changeset viewer.