LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2006 00:45:37 +0000 (00:45 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2006 00:45:37 +0000 (00:45 +0000)
        Reviewed by Darin.

        <rdar://problem/4523976> REGRESSION (NativeTextField): Crash occurs when choosing "Undo Typing" after typing and setting the value

        * fast/forms/text-field-setvalue-crash-expected.txt: Added.
        * fast/forms/text-field-setvalue-crash.html: Added.

WebCore:

        Reviewed by Darin.

        <rdar://problem/4523976> REGRESSION (NativeTextField): Crash occurs when choosing "Undo Typing" after typing and setting the value

        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::updateFromElement): Clear the undo
        chain when the text control contents have been set
        programmatically.
        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::clearUndoRedoOperations): Before clearing undo
        stack, close all open undo groups and then open an equal number,
        since otherwise NSUndoManager ends up in an inconsistent state
        leading to uncaught ObjC exceptions.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/text-field-setvalue-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/text-field-setvalue-crash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bridge/mac/FrameMac.mm
WebCore/rendering/RenderTextControl.cpp

index 41dd5fb131fcfe41e0b725111532acc041bfc112..09f1b5f6bfad8302659586d8e064c4335fc51c36 100644 (file)
@@ -1,3 +1,12 @@
+2006-07-21  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+        <rdar://problem/4523976> REGRESSION (NativeTextField): Crash occurs when choosing "Undo Typing" after typing and setting the value
+        
+        * fast/forms/text-field-setvalue-crash-expected.txt: Added.
+        * fast/forms/text-field-setvalue-crash.html: Added.
+
 2006-07-21  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
diff --git a/LayoutTests/fast/forms/text-field-setvalue-crash-expected.txt b/LayoutTests/fast/forms/text-field-setvalue-crash-expected.txt
new file mode 100644 (file)
index 0000000..9d4c462
--- /dev/null
@@ -0,0 +1,14 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV to 0 of DIV toDOMRange:range from 3 of #text > DIV to 3 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV to 0 of DIV toDOMRange:range from 3 of #text > DIV to 3 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV to 0 of DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+This test checks that undoing across a programmatic change to a text field's value doesn't cause crashes or assertion failures. If this test does not crash, it has passed.
+
+
diff --git a/LayoutTests/fast/forms/text-field-setvalue-crash.html b/LayoutTests/fast/forms/text-field-setvalue-crash.html
new file mode 100644 (file)
index 0000000..74edc0f
--- /dev/null
@@ -0,0 +1,28 @@
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function test()
+{
+       var emailID=document.apply.EmailAdd;
+       emailID.focus();
+       document.execCommand("InsertText", false, "aaa")
+       emailID.value="";
+       document.execCommand("InsertText", false, "aaa")
+       document.execCommand("Undo");
+       document.execCommand("Undo");
+}
+
+</script>
+
+<BODY onload="test()">
+<p>This test checks that undoing across a programmatic change to a
+text field's value doesn't cause crashes or assertion failures. If
+this test does not crash, it has passed.</p>
+
+<form name="apply"> 
+<input name="EmailAdd" type="text" onBlur="javascript:ValidateForm();">
+</form>
+
+</body>
+</html>
index 7b7582345d39f2b1b02b5be85fa11aa75d539c5f..219992c33066c2ef42cee766cbbfeae96467c059 100644 (file)
@@ -1,3 +1,19 @@
+2006-07-21  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+        <rdar://problem/4523976> REGRESSION (NativeTextField): Crash occurs when choosing "Undo Typing" after typing and setting the value
+
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::updateFromElement): Clear the undo
+        chain when the text control contents have been set
+        programmatically.
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::clearUndoRedoOperations): Before clearing undo
+        stack, close all open undo groups and then open an equal number,
+        since otherwise NSUndoManager ends up in an inconsistent state
+        leading to uncaught ObjC exceptions.
+
 2006-07-21  Beth Dakin  <bdakin@apple.com>
         
         Reviewed by Darin.
@@ -33,6 +49,7 @@
 
 === Safari-521.20 ===
 
+>>>>>>> .r15564
 2006-07-21  Tim Omernick  <timo@apple.com>
 
         Reviewed by Beth Dakin & John Sullivan.
index 291a0016c713566cea1a8e0ffd30668747c428c6..da0a8e64a1fd9a503b0e0907e1455d5b2ec67424 100644 (file)
@@ -3045,7 +3045,19 @@ void FrameMac::registerCommandForRedo(const EditCommandPtr &cmd)
 void FrameMac::clearUndoRedoOperations()
 {
     if (_haveUndoRedoOperations) {
-        [[_bridge undoManager] removeAllActionsWithTarget:_bridge];
+        // workaround for <rdar://problem/4645507> NSUndoManager dies
+        // with uncaught exception when undo items cleared while
+        // groups are open
+        NSUndoManager *undoManager = [_bridge undoManager];
+        int groupingLevel = [undoManager groupingLevel];
+        for (int i = 0; i < groupingLevel; ++i)
+            [undoManager endUndoGrouping];
+        
+        [undoManager removeAllActionsWithTarget:_bridge];
+
+        for (int i = 0; i < groupingLevel; ++i)
+            [undoManager beginUndoGrouping];
+
         _haveUndoRedoOperations = NO;
     }
 }
index 8df9d8b0b6799a718cc0cb2302364e491682d749..d0fae9c787360f95bd71c8f4792bdc3abf34fec3 100644 (file)
@@ -156,6 +156,8 @@ void RenderTextControl::updateFromElement()
         if (value != oldText || !m_div->hasChildNodes()) {
             ExceptionCode ec = 0;
             m_div->setInnerText(value, ec);
+            if (document()->frame())
+                document()->frame()->clearUndoRedoOperations();
             setEdited(false);
         }
         element->setValueMatchesRenderer();