[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 11:27:37 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit dbe05e8ce8771e687c15f4a22b1914c283820ec6
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 26 08:19:12 2010 +0000

    WebCore: Redo fails after text node is split by SplitTextNodeCommand
    https://bugs.webkit.org/show_bug.cgi?id=42941
    
    Reviewed by Darin Adler.
    
    The bug was caused by SplitTextNodeCommand not implementing doReapply.
    Implemented doReapply and added insertText1AndTrimText2 to share the code between doApply and doReapply.
    
    Test: editing/undo/redo-split-text-node.html
          editing/undo/redo-split-text-node-with-removal.html
    
    * editing/SplitTextNodeCommand.cpp:
    (WebCore::SplitTextNodeCommand::doApply): Calls executeApply.
    (WebCore::SplitTextNodeCommand::doUnapply): Don't delete m_text1, which is later used in doReapply.
    (WebCore::SplitTextNodeCommand::doReapply): Added.
    (WebCore::SplitTextNodeCommand::insertText1AndTrimText2): Added.
    * editing/SplitTextNodeCommand.h:
    
    LayoutTests: Added a test that splits a text node by inserting a paragraph and applies inline style.
    The test then ensures that the style is preserved after undos and redos.
    
    Reviewed by Darin Adler.
    
    Also added a test in which the text node is removed by the script after undo.
    
    Redo fails after text node is split by SplitTextNodeCommand
    https://bugs.webkit.org/show_bug.cgi?id=42941
    
    * editing/undo/redo-split-text-node-expected.txt: Added.
    * editing/undo/redo-split-text-node.html: Added.
    * editing/undo/redo-split-text-with-removal-expected.txt: Added.
    * editing/undo/redo-split-text-with-removal.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64034 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f24be96..bedab0b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2010-07-25  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Added a test that splits a text node by inserting a paragraph and applies inline style.
+        The test then ensures that the style is preserved after undos and redos.
+
+        Also added a test in which the text node is removed by the script after undo.
+
+        Redo fails after text node is split by SplitTextNodeCommand
+        https://bugs.webkit.org/show_bug.cgi?id=42941
+
+        * editing/undo/redo-split-text-node-expected.txt: Added.
+        * editing/undo/redo-split-text-node.html: Added.
+        * editing/undo/redo-split-text-with-removal-expected.txt: Added.
+        * editing/undo/redo-split-text-with-removal.html: Added.
+
 2010-07-25  Darin Adler  <darin at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/LayoutTests/editing/undo/redo-split-text-node-expected.txt b/LayoutTests/editing/undo/redo-split-text-node-expected.txt
new file mode 100644
index 0000000..73a7bfb
--- /dev/null
+++ b/LayoutTests/editing/undo/redo-split-text-node-expected.txt
@@ -0,0 +1,27 @@
+This test splits a text node by inserting a new paragraph and bolds the the first half.
+If splitTextNode correctly reapplied the split, undo and redo should preserve the style. (See bug 42941).
+
+before undo:
+<DIV id="test" contentEditable="">
+<B>
+<#text><selection-anchor>he<selection-focus></#text>
+</B>
+<DIV>
+<#text>llo</#text>
+</DIV>
+</DIV>
+
+after undo:
+<DIV id="test" contentEditable="">
+<#text>he<selection-caret>llo</#text>
+</DIV>
+
+after redo:
+<DIV id="test" contentEditable="">
+<B>
+<#text><selection-anchor>he<selection-focus></#text>
+</B>
+<DIV>
+<#text>llo</#text>
+</DIV>
+</DIV>
diff --git a/LayoutTests/editing/undo/redo-split-text-node.html b/LayoutTests/editing/undo/redo-split-text-node.html
new file mode 100644
index 0000000..8aa9aa6
--- /dev/null
+++ b/LayoutTests/editing/undo/redo-split-text-node.html
@@ -0,0 +1,22 @@
+<script src="../../resources/dump-as-markup.js" type="text/javascript"></script>
+<body>
+<div id="test" contenteditable>hello</div>
+<script>
+
+var div = document.getElementById('test');
+window.getSelection().setBaseAndExtent(div.firstChild, 2, div.firstChild, 2);
+document.execCommand('InsertParagraph', true, null);
+window.getSelection().setBaseAndExtent(div.firstChild, 0, div.firstChild, 2);
+document.execCommand('bold', false, null);
+
+Markup.description("This test splits a text node by inserting a new paragraph and bolds the the first half.\nIf splitTextNode correctly reapplied the split, undo and redo should preserve the style. (See bug 42941).")
+Markup.dump(div, "before undo");
+document.execCommand('undo', false, null);
+document.execCommand('undo', false, null);
+Markup.dump(div, "after undo");
+document.execCommand('redo', false, null);
+document.execCommand('redo', false, null);
+Markup.dump(div, "after redo");
+
+</script>
+</body>
diff --git a/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt b/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt
new file mode 100644
index 0000000..96c4164
--- /dev/null
+++ b/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt
@@ -0,0 +1,28 @@
+This test splits a text node by inserting a new paragraph and bolds the the first half.
+After undoing these two steps, it removes the text node, and then redo. The test should not crash. (See bug 42941).
+
+before undo:
+<DIV id="test" contentEditable="">
+<B>
+<#text><selection-anchor>he<selection-focus></#text>
+</B>
+<DIV>
+<#text>llo</#text>
+</DIV>
+</DIV>
+
+after undo:
+<DIV id="test" contentEditable="">
+<#text>he<selection-caret>llo</#text>
+</DIV>
+
+after node removal:
+<DIV id="test" contentEditable="">
+</DIV>
+
+after redo:
+<DIV id="test" contentEditable="">
+<DIV>
+<#text>hello</#text>
+</DIV>
+</DIV>
diff --git a/LayoutTests/editing/undo/redo-split-text-with-removal.html b/LayoutTests/editing/undo/redo-split-text-with-removal.html
new file mode 100644
index 0000000..7837178
--- /dev/null
+++ b/LayoutTests/editing/undo/redo-split-text-with-removal.html
@@ -0,0 +1,27 @@
+<script src="../../resources/dump-as-markup.js" type="text/javascript"></script>
+<body>
+<div id="test" contenteditable>hello</div>
+<script>
+
+var div = document.getElementById('test');
+
+window.getSelection().setBaseAndExtent(div.firstChild, 2, div.firstChild, 2);
+document.execCommand('InsertParagraph', true, null);
+window.getSelection().setBaseAndExtent(div.firstChild, 0, div.firstChild, 2);
+document.execCommand('bold', false, null);
+
+Markup.description("This test splits a text node by inserting a new paragraph and bolds the the first half.\nAfter undoing these two steps, it removes the text node, and then redo. The test should not crash. (See bug 42941).")
+Markup.dump(div, "before undo");
+document.execCommand('undo', false, null);
+document.execCommand('undo', false, null);
+
+Markup.dump(div, "after undo");
+div.removeChild(div.firstChild);
+Markup.dump(div, "after node removal");
+
+document.execCommand('redo', false, null);
+document.execCommand('redo', false, null);
+Markup.dump(div, "after redo");
+
+</script>
+</body>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8d71de1..719c682 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-07-25  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Redo fails after text node is split by SplitTextNodeCommand
+        https://bugs.webkit.org/show_bug.cgi?id=42941
+
+        The bug was caused by SplitTextNodeCommand not implementing doReapply.
+        Implemented doReapply and added insertText1AndTrimText2 to share the code between doApply and doReapply.
+
+        Test: editing/undo/redo-split-text-node.html
+              editing/undo/redo-split-text-node-with-removal.html
+
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::doApply): Calls executeApply.
+        (WebCore::SplitTextNodeCommand::doUnapply): Don't delete m_text1, which is later used in doReapply.
+        (WebCore::SplitTextNodeCommand::doReapply): Added.
+        (WebCore::SplitTextNodeCommand::insertText1AndTrimText2): Added.
+        * editing/SplitTextNodeCommand.h:
+
 2010-07-23  Philippe Normand  <pnormand at igalia.com>
 
         Reviewed by Eric Carlson.
diff --git a/WebCore/editing/SplitTextNodeCommand.cpp b/WebCore/editing/SplitTextNodeCommand.cpp
index 15daa49..9a7e3b3 100644
--- a/WebCore/editing/SplitTextNodeCommand.cpp
+++ b/WebCore/editing/SplitTextNodeCommand.cpp
@@ -54,21 +54,15 @@ void SplitTextNodeCommand::doApply()
         return;
 
     ExceptionCode ec = 0;
-
     String prefixText = m_text2->substringData(0, m_offset, ec);
     if (prefixText.isEmpty())
         return;
 
-    RefPtr<Text> prefixTextNode = Text::create(document(), prefixText);
-    ASSERT(prefixTextNode);
-    document()->copyMarkers(m_text2.get(), 0, m_offset, prefixTextNode.get(), 0);
+    m_text1 = Text::create(document(), prefixText);
+    ASSERT(m_text1);
+    document()->copyMarkers(m_text2.get(), 0, m_offset, m_text1.get(), 0);
 
-    parent->insertBefore(prefixTextNode.get(), m_text2.get(), ec);
-    if (ec)
-        return;
-
-    m_text2->deleteData(0, m_offset, ec);
-    m_text1 = prefixTextNode.release();
+    insertText1AndTrimText2();
 }
 
 void SplitTextNodeCommand::doUnapply()
@@ -78,16 +72,35 @@ void SplitTextNodeCommand::doUnapply()
 
     ASSERT(m_text1->document() == document());
 
-    RefPtr<Text> prefixTextNode = m_text1.release();
-    String prefixText = prefixTextNode->data();
+    String prefixText = m_text1->data();
 
     ExceptionCode ec = 0;
     m_text2->insertData(0, prefixText, ec);
-    if (ec)
+    ASSERT(!ec);
+
+    document()->copyMarkers(m_text1.get(), 0, prefixText.length(), m_text2.get(), 0);
+    m_text1->remove(ec);
+}
+
+void SplitTextNodeCommand::doReapply()
+{
+    if (!m_text1 || !m_text2)
         return;
 
-    document()->copyMarkers(prefixTextNode.get(), 0, prefixText.length(), m_text2.get(), 0);
-    prefixTextNode->remove(ec);
+    Node* parent = m_text2->parentNode();
+    if (!parent || !parent->isContentEditable())
+        return;
+
+    insertText1AndTrimText2();
 }
 
+void SplitTextNodeCommand::insertText1AndTrimText2()
+{
+    ExceptionCode ec = 0;
+    m_text2->parentNode()->insertBefore(m_text1.get(), m_text2.get(), ec);
+    if (ec)
+        return;
+    m_text2->deleteData(0, m_offset, ec);
+}
+    
 } // namespace WebCore
diff --git a/WebCore/editing/SplitTextNodeCommand.h b/WebCore/editing/SplitTextNodeCommand.h
index 48d444c..8d67d82 100644
--- a/WebCore/editing/SplitTextNodeCommand.h
+++ b/WebCore/editing/SplitTextNodeCommand.h
@@ -44,6 +44,8 @@ private:
 
     virtual void doApply();
     virtual void doUnapply();
+    virtual void doReapply();
+    void insertText1AndTrimText2();
 
     RefPtr<Text> m_text1;
     RefPtr<Text> m_text2;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list