WebCore:
authorjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2008 21:51:13 +0000 (21:51 +0000)
committerjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2008 21:51:13 +0000 (21:51 +0000)
        Reviewed by Alice Liu.

        <rdar://problem/5658727> Undo/redo for pasted or typed text in yahoo mail becomes disabled after one round of being selected

        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::updateFromElement): If value == text() and
        m_innerText is empty, then value and text() are "". In that case both DOM
        mutations are no-ops and there is no reason to clear the Undo stack.

LayoutTests:

        Reviewed by Alice Liu.

        <rdar://problem/5658727> Undo/redo for pasted or typed text in yahoo mail becomes disabled after one round of being selected

        * editing/undo/5658727-expected.txt: Added.
        * editing/undo/5658727.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29748 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/undo/5658727-expected.txt [new file with mode: 0644]
LayoutTests/editing/undo/5658727.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderTextControl.cpp

index aef61b5..edfccb8 100644 (file)
@@ -1,3 +1,12 @@
+2008-01-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Alice Liu.
+        
+        <rdar://problem/5658727> Undo/redo for pasted or typed text in yahoo mail becomes disabled after one round of being selected
+
+        * editing/undo/5658727-expected.txt: Added.
+        * editing/undo/5658727.html: Added.
+
 2008-01-23  Adam Roben  <aroben@apple.com>
 
         Add a test for <rdar://5700620> REGRESSION (r28190): "Open frame in
diff --git a/LayoutTests/editing/undo/5658727-expected.txt b/LayoutTests/editing/undo/5658727-expected.txt
new file mode 100644 (file)
index 0000000..7e26410
--- /dev/null
@@ -0,0 +1,3 @@
+This tests for a bug where changing focus away from a textarea that has been emptied out by the Undo operation would clear the Undo stack. You should see a textarea with "foo" inside it below.
+
+ Success: Redo worked after the textarea lost focus.
diff --git a/LayoutTests/editing/undo/5658727.html b/LayoutTests/editing/undo/5658727.html
new file mode 100644 (file)
index 0000000..18f643b
--- /dev/null
@@ -0,0 +1,18 @@
+<p>This tests for a bug where changing focus away from a textarea that has been emptied out by the Undo operation would clear the Undo stack. You should see a textarea with "foo" inside it below.</p>
+<textarea id="textarea"></textarea>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+textarea = document.getElementById("textarea");
+textarea.focus();
+document.execCommand("InsertText", false, "foo");
+document.execCommand("Undo");
+textarea.blur();
+document.execCommand("Redo");
+if (textarea.value == "foo")
+    document.write("Success: Redo worked after the textarea lost focus.");
+else
+    document.write("Failure: Redo didn't work after the textarea lost focus.");
+</script>
index 75db72e..6bf4cf1 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-22  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Alice Liu.
+
+        <rdar://problem/5658727> Undo/redo for pasted or typed text in yahoo mail becomes disabled after one round of being selected
+
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::updateFromElement): If value == text() and
+        m_innerText is empty, then value and text() are "". In that case both DOM 
+        mutations are no-ops and there is no reason to clear the Undo stack.
+
 2008-01-23  Steve Falkenburg  <sfalken@apple.com>
 
         <rdar://problem/5699509> Allow file upload dialog to be localized.
index f33bef2..18a9fac 100644 (file)
@@ -397,12 +397,14 @@ void RenderTextControl::updateFromElement()
         else
             value = value.replace('\\', backslashAsCurrencySymbol());
         if (value != text() || !m_innerText->hasChildNodes()) {
+            if (value != text()) {
+                if (Frame* frame = document()->frame())
+                    frame->editor()->clearUndoRedoOperations();
+            }
             ExceptionCode ec = 0;
             m_innerText->setInnerText(value, ec);
             if (value.endsWith("\n") || value.endsWith("\r"))
                 m_innerText->appendChild(new HTMLBRElement(document()), ec);
-            if (Frame* frame = document()->frame())
-                frame->editor()->clearUndoRedoOperations();
             m_dirty = false;
             m_userEdited = false;
         }