LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2006 02:07:40 +0000 (02:07 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2006 02:07:40 +0000 (02:07 +0000)
        Reviewed by harrison

        Added to test changes:
        * editing/pasteboard/merge-end-1-expected.checksum: Added.
        * editing/pasteboard/merge-end-1-expected.png: Added.
        * editing/pasteboard/merge-end-1-expected.txt: Added.
        * editing/pasteboard/merge-end-1.html: Added.
        * editing/pasteboard/merge-end-2-expected.checksum: Added.
        * editing/pasteboard/merge-end-2-expected.png: Added.
        * editing/pasteboard/merge-end-2-expected.txt: Added.
        * editing/pasteboard/merge-end-2.html: Added.

        Use the editing library so the test can be run in slow motion.
        * editing/deleting/merge-unrendered-space.html:

        Merges after pasted content no longer happen unnecessary.  These
        tests used to do unnecessary merges that happened to move nodes
        that served as selection endpoints, which cleared the selection.
        So, you'll see changes to the selection change delegate calls.
        * editing/pasteboard/8145-2-expected.txt:
        * editing/pasteboard/paste-line-endings-010-expected.txt:
        * editing/pasteboard/paste-text-008-expected.txt:
        * editing/pasteboard/paste-text-009-expected.txt:

WebCore:

        Reviewed by harrison

        Fixes more instances of:
        <rdar://problem/3950559>
        CrashTracer: 2116 crashes in Mail at com.apple.WebCore: khtml::CompositeEditCommand::insertNodeAfter + 32

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply): Do paragraph merging using moveParagraphs.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/8145-2-expected.txt
LayoutTests/editing/pasteboard/merge-end-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-1-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-1.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-2-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-2-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/merge-end-2.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-line-endings-010-expected.txt
LayoutTests/editing/pasteboard/paste-text-008-expected.txt
LayoutTests/editing/pasteboard/paste-text-009-expected.txt
WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp

index 3c868a4..e16174c 100644 (file)
@@ -2,6 +2,32 @@
 
         Reviewed by harrison
 
+        Added to test changes:
+        * editing/pasteboard/merge-end-1-expected.checksum: Added.
+        * editing/pasteboard/merge-end-1-expected.png: Added.
+        * editing/pasteboard/merge-end-1-expected.txt: Added.
+        * editing/pasteboard/merge-end-1.html: Added.
+        * editing/pasteboard/merge-end-2-expected.checksum: Added.
+        * editing/pasteboard/merge-end-2-expected.png: Added.
+        * editing/pasteboard/merge-end-2-expected.txt: Added.
+        * editing/pasteboard/merge-end-2.html: Added.
+        
+        Use the editing library so the test can be run in slow motion.
+        * editing/deleting/merge-unrendered-space.html:
+        
+        Merges after pasted content no longer happen unnecessary.  These
+        tests used to do unnecessary merges that happened to move nodes
+        that served as selection endpoints, which cleared the selection.
+        So, you'll see changes to the selection change delegate calls.
+        * editing/pasteboard/8145-2-expected.txt:
+        * editing/pasteboard/paste-line-endings-010-expected.txt:
+        * editing/pasteboard/paste-text-008-expected.txt:
+        * editing/pasteboard/paste-text-009-expected.txt:
+
+2006-04-11  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+
         * editing/deleting/merge-unrendered-space-expected.checksum: Added.
         * editing/deleting/merge-unrendered-space-expected.png: Added.
         * editing/deleting/merge-unrendered-space-expected.txt: Added.
index e941da5..db93938 100644 (file)
@@ -3,7 +3,7 @@ EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
diff --git a/LayoutTests/editing/pasteboard/merge-end-1-expected.checksum b/LayoutTests/editing/pasteboard/merge-end-1-expected.checksum
new file mode 100644 (file)
index 0000000..ff502e8
--- /dev/null
@@ -0,0 +1 @@
+e45accfe2f4a6c9c48faac6a0e2e3fd3
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/merge-end-1-expected.png b/LayoutTests/editing/pasteboard/merge-end-1-expected.png
new file mode 100644 (file)
index 0000000..3c47998
Binary files /dev/null and b/LayoutTests/editing/pasteboard/merge-end-1-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/merge-end-1-expected.txt b/LayoutTests/editing/pasteboard/merge-end-1-expected.txt
new file mode 100644 (file)
index 0000000..7eb0b1f
--- /dev/null
@@ -0,0 +1,32 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 3 of #text > SPAN > DIV > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {TEXT} at (0,0) size 766x36
+          text run at (0,0) width 766: "This tests one of the cases where it is necessary for paste to merge the last paragraph in the fragment being pasted with the"
+          text run at (0,18) width 328: "content after the position where the paste will occur."
+      RenderBlock {DIV} at (0,52) size 784x36
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderInline {SPAN} at (0,0) size 25x18
+            RenderText {TEXT} at (0,0) size 5x18
+              text run at (0,0) width 5: "f"
+            RenderText {TEXT} at (5,0) size 20x18
+              text run at (5,0) width 20: "bar"
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderInline {SPAN} at (0,0) size 38x18
+            RenderText {TEXT} at (0,0) size 22x18
+              text run at (0,0) width 22: "baz"
+            RenderText {TEXT} at (22,0) size 16x18
+              text run at (22,0) width 16: "oo"
+caret: position 3 of child 0 {TEXT} of child 0 {SPAN} of child 1 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/merge-end-1.html b/LayoutTests/editing/pasteboard/merge-end-1.html
new file mode 100644 (file)
index 0000000..3041fdc
--- /dev/null
@@ -0,0 +1,13 @@
+<p>This tests one of the cases where it is necessary for paste to merge the last paragraph in the fragment being pasted with the content after the position where the paste will occur.</p>
+<div id="test" contenteditable="true"><span>foo</span></div>
+
+<script type="text/javascript" src="../editing.js"></script>
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+
+e.focus();
+s.setPosition(e, 0);
+moveSelectionForwardByCharacterCommand();
+insertHTMLCommand("<div>bar</div>baz");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/merge-end-2-expected.checksum b/LayoutTests/editing/pasteboard/merge-end-2-expected.checksum
new file mode 100644 (file)
index 0000000..c94eb49
--- /dev/null
@@ -0,0 +1 @@
+6cac15233d2aa377bc36e3133e4cbf61
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/merge-end-2-expected.png b/LayoutTests/editing/pasteboard/merge-end-2-expected.png
new file mode 100644 (file)
index 0000000..390e57b
Binary files /dev/null and b/LayoutTests/editing/pasteboard/merge-end-2-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/merge-end-2-expected.txt b/LayoutTests/editing/pasteboard/merge-end-2-expected.txt
new file mode 100644 (file)
index 0000000..88a42a8
--- /dev/null
@@ -0,0 +1,34 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 3 of #text > SPAN > DIV > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {TEXT} at (0,0) size 766x36
+          text run at (0,0) width 766: "This tests one of the cases where it is necessary for paste to merge the last paragraph in the fragment being pasted with the"
+          text run at (0,18) width 328: "content after the position where the paste will occur."
+      RenderBlock {DIV} at (0,52) size 784x36
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderInline {SPAN} at (0,0) size 25x18
+            RenderText {TEXT} at (0,0) size 5x18
+              text run at (0,0) width 5: "f"
+            RenderText {TEXT} at (5,0) size 20x18
+              text run at (5,0) width 20: "bar"
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderInline {SPAN} at (0,0) size 38x18
+            RenderText {TEXT} at (0,0) size 22x18
+              text run at (0,0) width 22: "baz"
+            RenderText {TEXT} at (22,0) size 16x18
+              text run at (22,0) width 16: "oo"
+          RenderText {TEXT} at (38,0) size 20x18
+            text run at (38,0) width 20: "bar"
+caret: position 3 of child 0 {TEXT} of child 0 {SPAN} of child 1 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/merge-end-2.html b/LayoutTests/editing/pasteboard/merge-end-2.html
new file mode 100644 (file)
index 0000000..25252e2
--- /dev/null
@@ -0,0 +1,13 @@
+<p>This tests one of the cases where it is necessary for paste to merge the last paragraph in the fragment being pasted with the content after the position where the paste will occur.</p>
+<div id="test" contenteditable="true"><span>foo</span>bar</div>
+
+<script type="text/javascript" src="../editing.js"></script>
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+
+e.focus();
+s.setPosition(e, 0);
+moveSelectionForwardByCharacterCommand();
+insertHTMLCommand("<div>bar</div>baz");
+</script>
\ No newline at end of file
index b2dc248..0499ae7 100644 (file)
@@ -12,7 +12,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
index 1e45749..8aef920 100644 (file)
@@ -99,7 +99,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 12 of #text > DIV > DIV > BODY > HTML > #document to 20 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 20 of #text > DIV > BODY > HTML > #document to 20 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 19 of #text > DIV > BODY > HTML > #document toDOMRange:range from 20 of #text > DIV > BODY > HTML > #document to 20 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 20 of #text > DIV > BODY > HTML > #document to 20 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
index 44f0259..d7d3646 100644 (file)
@@ -80,7 +80,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 37 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 37 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
index d206e1a..686f5f3 100644 (file)
@@ -2,6 +2,17 @@
 
         Reviewed by harrison
         
+        Fixes more instances of:
+        <rdar://problem/3950559>
+        CrashTracer: 2116 crashes in Mail at com.apple.WebCore: khtml::CompositeEditCommand::insertNodeAfter + 32
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::doApply): Do paragraph merging using moveParagraphs.
+
+2006-04-11  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
         Some setup for work on paste performance.
 
         * editing/CompositeEditCommand.cpp:
index b5db444..1d3f97d 100644 (file)
@@ -797,33 +797,12 @@ void ReplaceSelectionCommand::doApply()
                 }
             }
         }
-
-        // FIXME: This is a bad way to move a paragraph.  This could share code with DeleteSelectionCommand::mergeParagraphs().
+        
         if (beyondEndNode) {
-            updateLayout();
-            RenderingInfoMap renderingInfo;
-            NodeVector nodes;
-            Node* node = beyondEndNode->enclosingInlineElement();
-            Node* refNode = m_lastNodeInserted.get();
-            
-            while (node) {
-                if (node->isBlockFlowOrBlockTable())
-                    break;
-                    
-                Node *next = node->nextSibling();
-                nodes.append(node);
-                renderingInfo.add(node, new RenderingInfo(styleForNode(node)));
-                removeNodeAndPruneAncestors(node);
-                // No need to update inserted node variables.
-                insertNodeAfter(node, refNode);
-                refNode = node;
-                // We want to move the first BR we see, so check for that here.
-                if (node->hasTagName(brTag))
-                    break;
-                node = next;
-            }
-
-            fixupNodeStyles(nodes, renderingInfo);
+            VisiblePosition startOfParagraphToMove(Position(beyondEndNode, 0));
+            VisiblePosition endOfParagraphToMove = endOfParagraph(startOfParagraphToMove);
+            VisiblePosition destination(Position(m_lastNodeInserted->parentNode(), m_lastNodeInserted->nodeIndex() + 1));
+            moveParagraph(startOfParagraphToMove, endOfParagraphToMove, destination);
         }
     }