- Revision
- 87008
- Author
- [email protected]
- Date
- 2011-05-20 18:15:40 -0700 (Fri, 20 May 2011)
Log Message
2011-05-20 Alexey Proskuryakov <[email protected]>
Reviewed by Kent Tamura.
Special characters can be inserted in text field having reached maxlength
https://bugs.webkit.org/show_bug.cgi?id=19479
<rdar://problem/7828739>
* platform/mac/editing/input/maxlength-expected.txt: Added.
* platform/mac/editing/input/maxlength.html: Added.
* fast/forms/input-number-commit-valid-only-expected.txt:
* fast/forms/script-tests/input-number-commit-valid-only.js:
The user can make a number field empty by deleting its content, so there is no reason why
execCommand shouldn't be able to make it empty.
2011-05-20 Alexey Proskuryakov <[email protected]>
Reviewed by Kent Tamura.
Special characters can be inserted in text field having reached maxlength
https://bugs.webkit.org/show_bug.cgi?id=19479
<rdar://problem/7828739>
Test: platform/mac/editing/input/maxlength.html
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::insertTextIntoNode):
(WebCore::CompositeEditCommand::replaceTextInNode):
Avoid hitting an assertion below, now that we can get here with empty text.
* editing/TypingCommand.cpp: (WebCore::TypingCommand::insertText): There is still work to do
even if beforetextinput removed all text from the event. At the very least, we should delete
the current selection.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (87007 => 87008)
--- trunk/LayoutTests/ChangeLog 2011-05-21 01:07:16 UTC (rev 87007)
+++ trunk/LayoutTests/ChangeLog 2011-05-21 01:15:40 UTC (rev 87008)
@@ -1,3 +1,19 @@
+2011-05-20 Alexey Proskuryakov <[email protected]>
+
+ Reviewed by Kent Tamura.
+
+ Special characters can be inserted in text field having reached maxlength
+ https://bugs.webkit.org/show_bug.cgi?id=19479
+ <rdar://problem/7828739>
+
+ * platform/mac/editing/input/maxlength-expected.txt: Added.
+ * platform/mac/editing/input/maxlength.html: Added.
+
+ * fast/forms/input-number-commit-valid-only-expected.txt:
+ * fast/forms/script-tests/input-number-commit-valid-only.js:
+ The user can make a number field empty by deleting its content, so there is no reason why
+ execCommand shouldn't be able to make it empty.
+
2011-05-20 Andy Estes <[email protected]>
Reviewed by Darin Adler.
Modified: trunk/LayoutTests/fast/forms/input-number-commit-valid-only-expected.txt (87007 => 87008)
--- trunk/LayoutTests/fast/forms/input-number-commit-valid-only-expected.txt 2011-05-21 01:07:16 UTC (rev 87007)
+++ trunk/LayoutTests/fast/forms/input-number-commit-valid-only-expected.txt 2011-05-21 01:15:40 UTC (rev 87008)
@@ -5,7 +5,7 @@
PASS input.value is "512"
PASS input.value is "512"
-PASS input.value is "512"
+PASS input.value is ""
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/forms/script-tests/input-number-commit-valid-only.js (87007 => 87008)
--- trunk/LayoutTests/fast/forms/script-tests/input-number-commit-valid-only.js 2011-05-21 01:07:16 UTC (rev 87007)
+++ trunk/LayoutTests/fast/forms/script-tests/input-number-commit-valid-only.js 2011-05-21 01:15:40 UTC (rev 87008)
@@ -19,6 +19,6 @@
document.execCommand('SelectAll', false, null);
document.execCommand('InsertText', false, '');
input.blur();
-shouldBe('input.value', '"512"');
+shouldBe('input.value', '""');
var successfullyParsed = true;
Added: trunk/LayoutTests/platform/mac/editing/input/maxlength-expected.txt (0 => 87008)
--- trunk/LayoutTests/platform/mac/editing/input/maxlength-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/input/maxlength-expected.txt 2011-05-21 01:15:40 UTC (rev 87008)
@@ -0,0 +1,9 @@
+Test for bug 19479: Special characters can be inserted in text field having reached maxlength.
+
+
+PASS testElement.value is "12345678"
+PASS testElement.value is "12345678"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/mac/editing/input/maxlength.html (0 => 87008)
--- trunk/LayoutTests/platform/mac/editing/input/maxlength.html (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/input/maxlength.html 2011-05-21 01:15:40 UTC (rev 87008)
@@ -0,0 +1,45 @@
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p>Test for <a href="" 19479</a>:
+Special characters can be inserted in text field having reached maxlength.</p>
+<p id="description"></p>
+<input id="test" maxlength=8>
+<div id="console"></div>
+<script>
+
+ var testInput = document.getElementById("test");
+ testInput.focus();
+
+ if (window.layoutTestController) {
+
+ try {
+ var testElement = document.getElementById("test");
+
+ textInputController.setMarkedText("1234567890", 10, 0);
+ textInputController.unmarkText();
+ shouldBe('testElement.value', '"12345678"');
+
+ textInputController.setMarkedText("FAIL", 14, 0);
+ textInputController.unmarkText();
+ shouldBe('testElement.value', '"12345678"');
+
+ } catch (ex) {
+ testFailed("Exception: " + ex.description);
+ }
+ } else {
+ document.write("<p>To test this manually:<ol>");
+ document.write("<li>Type something long using inline input (e.g. Kotoeri Hiragana IM)");
+ document.write("<li>The text should be truncated to 8 characters when confirmed");
+ document.write("<li>Type some more text");
+ document.write("<li>The text should disappear when confirmed");
+ }
+
+ var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (87007 => 87008)
--- trunk/Source/WebCore/ChangeLog 2011-05-21 01:07:16 UTC (rev 87007)
+++ trunk/Source/WebCore/ChangeLog 2011-05-21 01:15:40 UTC (rev 87008)
@@ -1,3 +1,22 @@
+2011-05-20 Alexey Proskuryakov <[email protected]>
+
+ Reviewed by Kent Tamura.
+
+ Special characters can be inserted in text field having reached maxlength
+ https://bugs.webkit.org/show_bug.cgi?id=19479
+ <rdar://problem/7828739>
+
+ Test: platform/mac/editing/input/maxlength.html
+
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::insertTextIntoNode):
+ (WebCore::CompositeEditCommand::replaceTextInNode):
+ Avoid hitting an assertion below, now that we can get here with empty text.
+
+ * editing/TypingCommand.cpp: (WebCore::TypingCommand::insertText): There is still work to do
+ even if beforetextinput removed all text from the event. At the very least, we should delete
+ the current selection.
+
2011-05-20 Andy Estes <[email protected]>
Reviewed by Darin Adler.
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (87007 => 87008)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2011-05-21 01:07:16 UTC (rev 87007)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2011-05-21 01:15:40 UTC (rev 87008)
@@ -321,7 +321,8 @@
void CompositeEditCommand::insertTextIntoNode(PassRefPtr<Text> node, unsigned offset, const String& text)
{
- applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, text));
+ if (!text.isEmpty())
+ applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, text));
}
void CompositeEditCommand::deleteTextFromNode(PassRefPtr<Text> node, unsigned offset, unsigned count)
@@ -332,7 +333,8 @@
void CompositeEditCommand::replaceTextInNode(PassRefPtr<Text> node, unsigned offset, unsigned count, const String& replacementText)
{
applyCommandToComposite(DeleteFromTextNodeCommand::create(node.get(), offset, count));
- applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, replacementText));
+ if (!replacementText.isEmpty())
+ applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, replacementText));
}
void CompositeEditCommand::replaceTextInNodePreservingMarkers(PassRefPtr<Text> prpNode, unsigned offset, unsigned count, const String& replacementText)
Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (87007 => 87008)
--- trunk/Source/WebCore/editing/TypingCommand.cpp 2011-05-21 01:07:16 UTC (rev 87007)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp 2011-05-21 01:15:40 UTC (rev 87008)
@@ -182,9 +182,6 @@
}
}
- if (newText.isEmpty())
- return;
-
// Set the starting and ending selection appropriately if we are using a selection
// that is different from the current selection. In the future, we should change EditCommand
// to deal with custom selections in a general way that can be used by all of the commands.