Skip to content
Permalink
Browse files
2011-05-24 Ryosuke Niwa <rniwa@webkit.org>
        Reviewed by Darin Adler.

        Undo gets broken in contenteditable area when a text field's value is set by script
        https://bugs.webkit.org/show_bug.cgi?id=61340

        Added a test to ensure WebKit does not clear undo stack when setting the value of input or textarea.

        * editing/undo/undo-after-setting-value-expected.txt: Added.
        * editing/undo/undo-after-setting-value.html: Added.
2011-05-24  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Darin Adler.

        Undo gets broken in contenteditable area when a text field's value is set by script
        https://bugs.webkit.org/show_bug.cgi?id=61340

        The bug was caused by RenderTextControl::setInnerTextValue's clearing undo stack by
        calling clearUndoRedoOperations whenever script sets new value to input or textarea.

        Fixed the bug by removing the offending call to clearUndoRedoOperations. While this call
        was added by r15565 to fix a crash, SimpleEditCommands have since become much more robust
        and the test added by r15565 (fast/forms/text-field-setvalue-crash.html) still passes.

        Test: editing/undo/undo-after-setting-value.html

        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::setInnerTextValue):


Canonical link: https://commits.webkit.org/76779@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed May 24, 2011
1 parent 53a7395 commit f150ee6b1954760fbe8b7150112ab8f1e293075b
@@ -1,3 +1,15 @@
2011-05-24 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

Undo gets broken in contenteditable area when a text field's value is set by script
https://bugs.webkit.org/show_bug.cgi?id=61340

Added a test to ensure WebKit does not clear undo stack when setting the value of input or textarea.

* editing/undo/undo-after-setting-value-expected.txt: Added.
* editing/undo/undo-after-setting-value.html: Added.

2011-05-24 Adam Klein <adamk@chromium.org>

Unreviewed. Updating Chromium test expectations.
@@ -0,0 +1,4 @@
This test ensures WebKit does not clear undo stack in a contenteditable element when setting the value of input or textarea element.


PASS
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<body>
<p>This test ensures WebKit does not clear undo stack in a contenteditable element when setting the value of input or textarea element.</p>
<input type="text">
<textarea></textarea>
<div contenteditable>PASS</div>
<script>

document.getElementsByTagName('div')[0].focus();
document.execCommand('SelectAll', false, null);
document.execCommand('InsertText', false, 'FAIL');
document.getElementsByTagName('input')[0].value = 'hello';
document.getElementsByTagName('textarea')[0].value = 'world';
document.execCommand('Undo', false, null);

if (window.layoutTestController)
layoutTestController.dumpAsText();

</script>
</body>
</html>
@@ -1,3 +1,22 @@
2011-05-24 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

Undo gets broken in contenteditable area when a text field's value is set by script
https://bugs.webkit.org/show_bug.cgi?id=61340

The bug was caused by RenderTextControl::setInnerTextValue's clearing undo stack by
calling clearUndoRedoOperations whenever script sets new value to input or textarea.

Fixed the bug by removing the offending call to clearUndoRedoOperations. While this call
was added by r15565 to fix a crash, SimpleEditCommands have since become much more robust
and the test added by r15565 (fast/forms/text-field-setvalue-crash.html) still passes.

Test: editing/undo/undo-after-setting-value.html

* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::setInnerTextValue):

2011-05-24 Dan Bernstein <mitz@apple.com>

Reviewed by Dave Hyatt.
@@ -147,14 +147,8 @@ void RenderTextControl::setInnerTextValue(const String& innerTextValue)
{
String value = innerTextValue;
if (value != text() || !innerTextElement()->hasChildNodes()) {
if (value != text()) {
if (Frame* frame = this->frame()) {
frame->editor()->clearUndoRedoOperations();

if (AXObjectCache::accessibilityEnabled())
document()->axObjectCache()->postNotification(this, AXObjectCache::AXValueChanged, false);
}
}
if (value != text() && document() && AXObjectCache::accessibilityEnabled())
document()->axObjectCache()->postNotification(this, AXObjectCache::AXValueChanged, false);

ExceptionCode ec = 0;
innerTextElement()->setInnerText(value, ec);

0 comments on commit f150ee6

Please sign in to comment.