[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

enrica at apple.com enrica at apple.com
Thu Apr 8 00:14:49 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit d19cb889d6850c399b9ac5045ecaa411fadc09ae
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 3 19:18:42 2009 +0000

    WebCore: Multiple Undos removes the last posted comment and/or the ones before it.
    <rdar://problem/6557066>
    https://bugs.webkit.org/show_bug.cgi?id=32079
    
    Reviewed by Adele Peterson.
    
    The fix consists in preventing Undos and Redos to be applied to elements that
    are no longer editable. We do not attempt to remove the commands from the queue.
    It is a relatively simple fix that comes with a little extra overhead for the apply
    and unapply methods where we are now performing the editability check.
    
    Test: editing/undo/undo-indent-noneditable.html
    
    * editing/AppendNodeCommand.cpp:
    (WebCore::AppendNodeCommand::doApply):
    (WebCore::AppendNodeCommand::doUnapply):
    * editing/DeleteFromTextNodeCommand.cpp:
    (WebCore::DeleteFromTextNodeCommand::doApply):
    (WebCore::DeleteFromTextNodeCommand::doUnapply):
    * editing/InsertIntoTextNodeCommand.cpp:
    (WebCore::InsertIntoTextNodeCommand::doApply):
    (WebCore::InsertIntoTextNodeCommand::doUnapply):
    * editing/InsertNodeBeforeCommand.cpp:
    (WebCore::InsertNodeBeforeCommand::doApply):
    (WebCore::InsertNodeBeforeCommand::doUnapply):
    * editing/JoinTextNodesCommand.cpp:
    (WebCore::JoinTextNodesCommand::doApply):
    (WebCore::JoinTextNodesCommand::doUnapply):
    * editing/MergeIdenticalElementsCommand.cpp:
    (WebCore::MergeIdenticalElementsCommand::doApply):
    (WebCore::MergeIdenticalElementsCommand::doUnapply):
    * editing/RemoveNodeCommand.cpp:
    (WebCore::RemoveNodeCommand::doApply):
    (WebCore::RemoveNodeCommand::doUnapply):
    * editing/SplitElementCommand.cpp:
    (WebCore::SplitElementCommand::executeApply):
    (WebCore::SplitElementCommand::doUnapply):
    * editing/SplitTextNodeCommand.cpp:
    (WebCore::SplitTextNodeCommand::doApply):
    (WebCore::SplitTextNodeCommand::doUnapply):
    * editing/WrapContentsInDummySpanCommand.cpp:
    (WebCore::WrapContentsInDummySpanCommand::doUnapply):
    (WebCore::WrapContentsInDummySpanCommand::doReapply):
    
    LayoutTests: Multiple Undos removes the last posted comment and/or the ones before it.
    <rdar://problem/6557066>
    https://bugs.webkit.org/show_bug.cgi?id=32079
    
    Reviewed by Adele Peterson.
    
    Added test to verify that undo has no effect when an element is
    no longer editable.
    
    * editing/undo/undo-indent-noneditable-expected.txt: Added.
    * editing/undo/undo-indent-noneditable.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51645 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 965fa11..7908dfb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-03  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Multiple Undos removes the last posted comment and/or the ones before it.
+        <rdar://problem/6557066>
+        https://bugs.webkit.org/show_bug.cgi?id=32079
+
+        Added test to verify that undo has no effect when an element is
+        no longer editable.
+        
+        * editing/undo/undo-indent-noneditable-expected.txt: Added.
+        * editing/undo/undo-indent-noneditable.html: Added.
+
 2009-12-03  Brady Eidson  <beidson at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/LayoutTests/editing/undo/undo-indent-noneditable-expected.txt b/LayoutTests/editing/undo/undo-indent-noneditable-expected.txt
new file mode 100644
index 0000000..2680f02
--- /dev/null
+++ b/LayoutTests/editing/undo/undo-indent-noneditable-expected.txt
@@ -0,0 +1,12 @@
+This tests indenting "three" then executes the undo command after changing the editability to false. You should see one, two numbered 1 through 2 then three and four as a sublist starting with number 1. The undo should have no effect.
+Bugzilla bug 
+Radar bug
+
+one
+two
+three
+four
+Before indent: <li>one</li> <li>two</li> <li id="test">three</li> <ol><li>four</li></ol>
+After indent: <li>one</li> <li>two</li> <ol><li id="test">three</li><li>four</li></ol>
+After undoing: <li>one</li> <li>two</li> <ol><li id="test">three</li><li>four</li></ol>
+The test passed
diff --git a/LayoutTests/editing/undo/undo-indent-noneditable.html b/LayoutTests/editing/undo/undo-indent-noneditable.html
new file mode 100644
index 0000000..96321d1
--- /dev/null
+++ b/LayoutTests/editing/undo/undo-indent-noneditable.html
@@ -0,0 +1,50 @@
+<html>
+<body>
+<div>
+This tests indenting "three" then executes the undo command after changing the editability to false. 
+You should see one, two numbered 1 through 2 then three and four as a sublist starting with number 1.
+The undo should have no effect.
+<p>
+<a href="https://bugs.webkit.org/show_bug.cgi?id=32079">Bugzilla bug</a>
+<br>
+<a href="rdar://problem/6557066">Radar bug</a>
+</p>
+<ol id="e" contenteditable="true">
+<li>one</li>
+<li>two</li>
+<li id="test">three</li>
+<ol><li>four</li></ol>
+</ol>
+</div>
+
+<ul>
+<li>Before indent:<span id="c1"></span></li>
+<li>After indent:<span id="c2"></span></li>
+<li>After undoing:<span id="c3"></span></li>
+</ul>
+
+<script type="text/javascript">
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var e = document.getElementById('e');
+
+document.getElementById('c1').appendChild(document.createTextNode(e.innerHTML));
+
+var s = window.getSelection();
+var r = document.createRange();
+r.selectNode(document.getElementById('test'));
+s.removeAllRanges();
+s.addRange(r);
+document.execCommand("Indent", false, "");
+document.getElementById('c2').appendChild(document.createTextNode(e.innerHTML));
+e.contentEditable = false;
+document.execCommand("Undo");
+document.getElementById('c3').appendChild(document.createTextNode(e.innerHTML));
+
+if (document.getElementById('c2').innerHTML == document.getElementById('c3').innerHTML)
+    document.write("The test passed");
+else
+    document.write("The test failed.");
+</script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f0b3445..5962840 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,49 @@
+2009-12-03  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Multiple Undos removes the last posted comment and/or the ones before it.
+        <rdar://problem/6557066>
+        https://bugs.webkit.org/show_bug.cgi?id=32079
+        
+        The fix consists in preventing Undos and Redos to be applied to elements that
+        are no longer editable. We do not attempt to remove the commands from the queue.
+        It is a relatively simple fix that comes with a little extra overhead for the apply
+        and unapply methods where we are now performing the editability check.
+
+        Test: editing/undo/undo-indent-noneditable.html
+
+        * editing/AppendNodeCommand.cpp:
+        (WebCore::AppendNodeCommand::doApply):
+        (WebCore::AppendNodeCommand::doUnapply):
+        * editing/DeleteFromTextNodeCommand.cpp:
+        (WebCore::DeleteFromTextNodeCommand::doApply):
+        (WebCore::DeleteFromTextNodeCommand::doUnapply):
+        * editing/InsertIntoTextNodeCommand.cpp:
+        (WebCore::InsertIntoTextNodeCommand::doApply):
+        (WebCore::InsertIntoTextNodeCommand::doUnapply):
+        * editing/InsertNodeBeforeCommand.cpp:
+        (WebCore::InsertNodeBeforeCommand::doApply):
+        (WebCore::InsertNodeBeforeCommand::doUnapply):
+        * editing/JoinTextNodesCommand.cpp:
+        (WebCore::JoinTextNodesCommand::doApply):
+        (WebCore::JoinTextNodesCommand::doUnapply):
+        * editing/MergeIdenticalElementsCommand.cpp:
+        (WebCore::MergeIdenticalElementsCommand::doApply):
+        (WebCore::MergeIdenticalElementsCommand::doUnapply):
+        * editing/RemoveNodeCommand.cpp:
+        (WebCore::RemoveNodeCommand::doApply):
+        (WebCore::RemoveNodeCommand::doUnapply):
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::executeApply):
+        (WebCore::SplitElementCommand::doUnapply):
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::doApply):
+        (WebCore::SplitTextNodeCommand::doUnapply):
+        * editing/WrapContentsInDummySpanCommand.cpp:
+        (WebCore::WrapContentsInDummySpanCommand::doUnapply):
+        (WebCore::WrapContentsInDummySpanCommand::doReapply):
+
 2009-12-03  Brady Eidson  <beidson at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebCore/editing/AppendNodeCommand.cpp b/WebCore/editing/AppendNodeCommand.cpp
index ef79e9c..6178641 100644
--- a/WebCore/editing/AppendNodeCommand.cpp
+++ b/WebCore/editing/AppendNodeCommand.cpp
@@ -44,12 +44,18 @@ AppendNodeCommand::AppendNodeCommand(PassRefPtr<Element> parent, PassRefPtr<Node
 
 void AppendNodeCommand::doApply()
 {
+    if (!m_parent->isContentEditable() && m_parent->attached())
+        return;
+        
     ExceptionCode ec;
     m_parent->appendChild(m_node.get(), ec);
 }
 
 void AppendNodeCommand::doUnapply()
 {
+    if (!m_parent->isContentEditable())
+        return;
+        
     ExceptionCode ec;
     m_node->remove(ec);
 }
diff --git a/WebCore/editing/DeleteFromTextNodeCommand.cpp b/WebCore/editing/DeleteFromTextNodeCommand.cpp
index e942fef..f1d79af 100644
--- a/WebCore/editing/DeleteFromTextNodeCommand.cpp
+++ b/WebCore/editing/DeleteFromTextNodeCommand.cpp
@@ -45,6 +45,9 @@ void DeleteFromTextNodeCommand::doApply()
 {
     ASSERT(m_node);
 
+    if (!m_node->isContentEditable())
+        return;
+
     ExceptionCode ec = 0;
     m_text = m_node->substringData(m_offset, m_count, ec);
     if (ec)
@@ -57,6 +60,9 @@ void DeleteFromTextNodeCommand::doUnapply()
 {
     ASSERT(m_node);
 
+    if (!m_node->isContentEditable())
+        return;
+        
     ExceptionCode ec;
     m_node->insertData(m_offset, m_text, ec);
 }
diff --git a/WebCore/editing/InsertIntoTextNodeCommand.cpp b/WebCore/editing/InsertIntoTextNodeCommand.cpp
index 4905fae..9c3423a 100644
--- a/WebCore/editing/InsertIntoTextNodeCommand.cpp
+++ b/WebCore/editing/InsertIntoTextNodeCommand.cpp
@@ -43,12 +43,18 @@ InsertIntoTextNodeCommand::InsertIntoTextNodeCommand(PassRefPtr<Text> node, unsi
 
 void InsertIntoTextNodeCommand::doApply()
 {
+    if (!m_node->isContentEditable())
+        return;
+    
     ExceptionCode ec;
     m_node->insertData(m_offset, m_text, ec);
 }
 
 void InsertIntoTextNodeCommand::doUnapply()
 {
+    if (!m_node->isContentEditable())
+        return;
+        
     ExceptionCode ec;
     m_node->deleteData(m_offset, m_text.length(), ec);
 }
diff --git a/WebCore/editing/InsertNodeBeforeCommand.cpp b/WebCore/editing/InsertNodeBeforeCommand.cpp
index 4f60963..2ce9846 100644
--- a/WebCore/editing/InsertNodeBeforeCommand.cpp
+++ b/WebCore/editing/InsertNodeBeforeCommand.cpp
@@ -46,7 +46,7 @@ InsertNodeBeforeCommand::InsertNodeBeforeCommand(PassRefPtr<Node> insertChild, P
 void InsertNodeBeforeCommand::doApply()
 {
     Node* parent = m_refChild->parentNode();
-    if (!parent)
+    if (!parent || !parent->isContentEditable())
         return;
 
     ExceptionCode ec;
@@ -55,6 +55,9 @@ void InsertNodeBeforeCommand::doApply()
 
 void InsertNodeBeforeCommand::doUnapply()
 {
+    if (!m_insertChild->isContentEditable())
+        return;
+        
     ExceptionCode ec;
     m_insertChild->remove(ec);
 }
diff --git a/WebCore/editing/JoinTextNodesCommand.cpp b/WebCore/editing/JoinTextNodesCommand.cpp
index f981481..fa0987d 100644
--- a/WebCore/editing/JoinTextNodesCommand.cpp
+++ b/WebCore/editing/JoinTextNodesCommand.cpp
@@ -45,6 +45,10 @@ void JoinTextNodesCommand::doApply()
     if (m_text1->nextSibling() != m_text2)
         return;
 
+    Node* parent = m_text2->parentNode();
+    if (!parent || !parent->isContentEditable())
+        return;
+    
     ExceptionCode ec = 0;
     m_text2->insertData(0, m_text1->data(), ec);
     if (ec)
@@ -59,7 +63,7 @@ void JoinTextNodesCommand::doUnapply()
         return;
 
     Node* parent = m_text2->parentNode();
-    if (!parent)
+    if (!parent || !parent->isContentEditable())
         return;
 
     ExceptionCode ec = 0;
diff --git a/WebCore/editing/MergeIdenticalElementsCommand.cpp b/WebCore/editing/MergeIdenticalElementsCommand.cpp
index 99ba286..f56f726 100644
--- a/WebCore/editing/MergeIdenticalElementsCommand.cpp
+++ b/WebCore/editing/MergeIdenticalElementsCommand.cpp
@@ -42,7 +42,7 @@ MergeIdenticalElementsCommand::MergeIdenticalElementsCommand(PassRefPtr<Element>
 
 void MergeIdenticalElementsCommand::doApply()
 {
-    if (m_element1->nextSibling() != m_element2)
+    if (m_element1->nextSibling() != m_element2 || !m_element1->isContentEditable() || !m_element2->isContentEditable())
         return;
 
     m_atChild = m_element2->firstChild();
@@ -68,7 +68,7 @@ void MergeIdenticalElementsCommand::doUnapply()
     RefPtr<Node> atChild = m_atChild.release();
 
     Node* parent = m_element2->parent();
-    if (!parent)
+    if (!parent || !parent->isContentEditable())
         return;
 
     ExceptionCode ec = 0;
diff --git a/WebCore/editing/RemoveNodeCommand.cpp b/WebCore/editing/RemoveNodeCommand.cpp
index 62a36be..f6d6a4b 100644
--- a/WebCore/editing/RemoveNodeCommand.cpp
+++ b/WebCore/editing/RemoveNodeCommand.cpp
@@ -42,7 +42,7 @@ RemoveNodeCommand::RemoveNodeCommand(PassRefPtr<Node> node)
 void RemoveNodeCommand::doApply()
 {
     Node* parent = m_node->parentNode();
-    if (!parent)
+    if (!parent || !parent->isContentEditable())
         return;
 
     m_parent = parent;
@@ -56,7 +56,7 @@ void RemoveNodeCommand::doUnapply()
 {
     RefPtr<Node> parent = m_parent.release();
     RefPtr<Node> refChild = m_refChild.release();
-    if (!parent)
+    if (!parent || !parent->isContentEditable())
         return;
 
     ExceptionCode ec;
diff --git a/WebCore/editing/SplitElementCommand.cpp b/WebCore/editing/SplitElementCommand.cpp
index 37b725c..2998c6a 100644
--- a/WebCore/editing/SplitElementCommand.cpp
+++ b/WebCore/editing/SplitElementCommand.cpp
@@ -53,7 +53,7 @@ void SplitElementCommand::executeApply()
     ExceptionCode ec = 0;
     
     Node* parent = m_element2->parentNode();
-    if (!parent)
+    if (!parent || !parent->isContentEditable())
         return;
     parent->insertBefore(m_element1.get(), m_element2.get(), ec);
     if (ec)
@@ -73,7 +73,7 @@ void SplitElementCommand::doApply()
 
 void SplitElementCommand::doUnapply()
 {
-    if (!m_element1)
+    if (!m_element1 || !m_element1->isContentEditable() || !m_element2->isContentEditable())
         return;
 
     Vector<RefPtr<Node> > children;
diff --git a/WebCore/editing/SplitTextNodeCommand.cpp b/WebCore/editing/SplitTextNodeCommand.cpp
index 3b04e01..15daa49 100644
--- a/WebCore/editing/SplitTextNodeCommand.cpp
+++ b/WebCore/editing/SplitTextNodeCommand.cpp
@@ -49,6 +49,10 @@ SplitTextNodeCommand::SplitTextNodeCommand(PassRefPtr<Text> text, int offset)
 
 void SplitTextNodeCommand::doApply()
 {
+    Node* parent = m_text2->parentNode();
+    if (!parent || !parent->isContentEditable())
+        return;
+
     ExceptionCode ec = 0;
 
     String prefixText = m_text2->substringData(0, m_offset, ec);
@@ -59,9 +63,6 @@ void SplitTextNodeCommand::doApply()
     ASSERT(prefixTextNode);
     document()->copyMarkers(m_text2.get(), 0, m_offset, prefixTextNode.get(), 0);
 
-    Node* parent = m_text2->parentNode();
-    if (!parent)
-        return;
     parent->insertBefore(prefixTextNode.get(), m_text2.get(), ec);
     if (ec)
         return;
@@ -72,7 +73,7 @@ void SplitTextNodeCommand::doApply()
 
 void SplitTextNodeCommand::doUnapply()
 {
-    if (!m_text1)
+    if (!m_text1 || !m_text1->isContentEditable())
         return;
 
     ASSERT(m_text1->document() == document());
diff --git a/WebCore/editing/WrapContentsInDummySpanCommand.cpp b/WebCore/editing/WrapContentsInDummySpanCommand.cpp
index 5320b69..5fa0b39 100644
--- a/WebCore/editing/WrapContentsInDummySpanCommand.cpp
+++ b/WebCore/editing/WrapContentsInDummySpanCommand.cpp
@@ -64,7 +64,7 @@ void WrapContentsInDummySpanCommand::doUnapply()
 {
     ASSERT(m_element);
 
-    if (!m_dummySpan)
+    if (!m_dummySpan || !m_element->isContentEditable())
         return;
 
     Vector<RefPtr<Node> > children;
@@ -84,7 +84,7 @@ void WrapContentsInDummySpanCommand::doReapply()
 {
     ASSERT(m_element);
     
-    if (!m_dummySpan)
+    if (!m_dummySpan || !m_element->isContentEditable())
         return;
 
     executeApply();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list