[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

adele at apple.com adele at apple.com
Thu Oct 29 20:38:22 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit c407ca34c7b018e8410f270487aa6fc52cf9ff66
Author: adele at apple.com <adele at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 2 21:34:03 2009 +0000

    WebCore: Assertion failure in CompositeEditCommand::moveParagraphs() and crash in Node::nodeIndex() when pasting.
    <rdar://problem/7148712>
    https://bugs.webkit.org/show_bug.cgi?id=28992
    
    Patch by Enrica Casucci <enrica at apple.com> on 2009-10-02
    Reviewed by Adele Peterson.
    
    Test: editing/selection/replace-selection-crash.html
    
    * editing/ReplaceSelectionCommand.cpp:
    (WebCore::ReplaceSelectionCommand::mergeEndIfNeeded): Handle properly the case of
    the destination position matching the end of the paragraph to move.
    
    LayoutTests: Added test case.
    <rdar://problem/7148712> Assertion failure in CompositeEditCommand::moveParagraphs() and crash in Node::nodeIndex() when pasting.
    https://bugs.webkit.org/show_bug.cgi?id=28992
    
    Patch by Enrica Casucci <enrica at apple.com> on 2009-10-02
    Reviewed by Adele Peterson.
    
    * editing/selection/replace-selection-crash-expected.txt: Added.
    * editing/selection/replace-selection-crash.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49041 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a0c1cf2..2b72ef9 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-02  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Added test case.
+        <rdar://problem/7148712> Assertion failure in CompositeEditCommand::moveParagraphs() and crash in Node::nodeIndex() when pasting.
+        https://bugs.webkit.org/show_bug.cgi?id=28992
+
+        * editing/selection/replace-selection-crash-expected.txt: Added.
+        * editing/selection/replace-selection-crash.html: Added.
+
 2009-10-02  Jeremy Orlow  <jorlow at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/LayoutTests/editing/selection/replace-selection-crash-expected.txt b/LayoutTests/editing/selection/replace-selection-crash-expected.txt
new file mode 100644
index 0000000..91911fd
--- /dev/null
+++ b/LayoutTests/editing/selection/replace-selection-crash-expected.txt
@@ -0,0 +1,7 @@
+
+        <div contenteditable="">
+            <p><span class="Apple-tab-span" style="white-space:pre">    <br></span>No crash!&nbsp;</p>
+        </div>
+    
+
+
diff --git a/LayoutTests/editing/selection/replace-selection-crash.html b/LayoutTests/editing/selection/replace-selection-crash.html
new file mode 100644
index 0000000..27f23d8
--- /dev/null
+++ b/LayoutTests/editing/selection/replace-selection-crash.html
@@ -0,0 +1,25 @@
+<html>
+    <head>
+        <script>
+            function test()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+
+                document.getElementsByTagName("div")[0].focus();
+
+                var sel = window.getSelection();
+                var paragraph = document.getElementsByTagName("p")[0];
+                sel.setBaseAndExtent(paragraph, 1, paragraph.lastChild, 6);
+                document.execCommand("InsertHTML", false, '<p>No crash!</p>');
+
+                document.write("<xmp>" + document.body.innerHTML + "</xmp>");
+            }
+        </script>
+    </head>
+    <body onload="test()">
+        <div contenteditable>
+            <p><span class="Apple-tab-span" style="white-space:pre">    </span>select&nbsp;</p>
+        </div>
+    </body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c235644..70a9a9b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-02  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Assertion failure in CompositeEditCommand::moveParagraphs() and crash in Node::nodeIndex() when pasting.
+        <rdar://problem/7148712>
+        https://bugs.webkit.org/show_bug.cgi?id=28992
+
+        Test: editing/selection/replace-selection-crash.html
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::mergeEndIfNeeded): Handle properly the case of
+        the destination position matching the end of the paragraph to move.
+
 2009-10-02  Jeremy Orlow  <jorlow at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/editing/ReplaceSelectionCommand.cpp b/WebCore/editing/ReplaceSelectionCommand.cpp
index a3a43b3..b40dab2 100644
--- a/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -695,8 +695,17 @@ void ReplaceSelectionCommand::mergeEndIfNeeded()
     
     VisiblePosition destination = mergeForward ? endOfInsertedContent.next() : endOfInsertedContent;
     VisiblePosition startOfParagraphToMove = mergeForward ? startOfParagraph(endOfInsertedContent) : endOfInsertedContent.next();
+   
+    // Merging forward could result in deleting the destination anchor node.
+    // To avoid this, we add a placeholder node before the start of the paragraph.
+    if (endOfParagraph(startOfParagraphToMove) == destination) {
+        RefPtr<Node> placeholder = createBreakElement(document());
+        insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().node());
+        destination = VisiblePosition(Position(placeholder.get(), 0));
+    }
 
     moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToMove), destination);
+    
     // Merging forward will remove m_lastLeafInserted from the document.
     // FIXME: Maintain positions for the start and end of inserted content instead of keeping nodes.  The nodes are
     // only ever used to create positions where inserted content starts/ends.  Also, we sometimes insert content
@@ -705,6 +714,10 @@ void ReplaceSelectionCommand::mergeEndIfNeeded()
         m_lastLeafInserted = destination.previous().deepEquivalent().node();
         if (!m_firstNodeInserted->inDocument())
             m_firstNodeInserted = endingSelection().visibleStart().deepEquivalent().node();
+        // If we merged text nodes, m_lastLeafInserted could be null. If this is the case,
+        // we use m_firstNodeInserted.
+        if (!m_lastLeafInserted)
+            m_lastLeafInserted = m_firstNodeInserted;
     }
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list