Title: [87204] trunk
Revision
87204
Author
rn...@webkit.org
Date
2011-05-24 14:22:27 -0700 (Tue, 24 May 2011)

Log Message

2011-05-24  Ryosuke Niwa  <rn...@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  <rn...@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):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87203 => 87204)


--- trunk/LayoutTests/ChangeLog	2011-05-24 21:12:02 UTC (rev 87203)
+++ trunk/LayoutTests/ChangeLog	2011-05-24 21:22:27 UTC (rev 87204)
@@ -1,3 +1,15 @@
+2011-05-24  Ryosuke Niwa  <rn...@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  <ad...@chromium.org>
 
         Unreviewed. Updating Chromium test expectations.

Added: trunk/LayoutTests/editing/undo/undo-after-setting-value-expected.txt (0 => 87204)


--- trunk/LayoutTests/editing/undo/undo-after-setting-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/undo/undo-after-setting-value-expected.txt	2011-05-24 21:22:27 UTC (rev 87204)
@@ -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

Added: trunk/LayoutTests/editing/undo/undo-after-setting-value.html (0 => 87204)


--- trunk/LayoutTests/editing/undo/undo-after-setting-value.html	                        (rev 0)
+++ trunk/LayoutTests/editing/undo/undo-after-setting-value.html	2011-05-24 21:22:27 UTC (rev 87204)
@@ -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>

Modified: trunk/Source/WebCore/ChangeLog (87203 => 87204)


--- trunk/Source/WebCore/ChangeLog	2011-05-24 21:12:02 UTC (rev 87203)
+++ trunk/Source/WebCore/ChangeLog	2011-05-24 21:22:27 UTC (rev 87204)
@@ -1,3 +1,22 @@
+2011-05-24  Ryosuke Niwa  <rn...@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  <m...@apple.com>
 
         Reviewed by Dave Hyatt.

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (87203 => 87204)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2011-05-24 21:12:02 UTC (rev 87203)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2011-05-24 21:22:27 UTC (rev 87204)
@@ -147,14 +147,8 @@
 {
     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);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to