Fix for 3779083, deleting large amount of text is really slow. Don't use NodeLists...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Sep 2004 00:21:49 +0000 (00:21 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Sep 2004 00:21:49 +0000 (00:21 +0000)
        Reviewed by darin

        * khtml/editing/htmlediting_impl.cpp:
        (khtml::RemoveNodeCommandImpl::RemoveNodeCommandImpl):
        (khtml::RemoveNodePreservingChildrenCommandImpl::doApply):

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting_impl.cpp

index 110cac93988c8f7b71db0b6c16fccbcc6d48d27f..34c76997f85d4ff859ecc859fddf275b1cbaf656 100644 (file)
@@ -1,3 +1,13 @@
+2004-09-03  David Hyatt  <hyatt@apple.com>
+
+       Fix for 3779083, deleting large amount of text is really slow.  Don't use NodeLists in editing remove commands.
+       
+        Reviewed by darin
+
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::RemoveNodeCommandImpl::RemoveNodeCommandImpl):
+        (khtml::RemoveNodePreservingChildrenCommandImpl::doApply):
+
 2004-09-03  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
index f18a51eb60061fff134598866d2c52f8b2575a81..77a827d827fa4e102763b61241527cb7c312062f 100644 (file)
@@ -2115,14 +2115,7 @@ RemoveNodeCommandImpl::RemoveNodeCommandImpl(DocumentImpl *document, NodeImpl *r
     ASSERT(m_parent);
     m_parent->ref();
     
-    NodeListImpl *children = m_parent->childNodes();
-    for (int i = children->length(); i >= 0; i--) {
-        NodeImpl *node = children->item(i);
-        if (node == m_removeChild)
-            break;
-        m_refChild = node;
-    }
-    
+    m_refChild = m_removeChild->nextSibling();
     if (m_refChild)
         m_refChild->ref();
 }
@@ -2188,12 +2181,9 @@ int RemoveNodePreservingChildrenCommandImpl::commandID() const
 
 void RemoveNodePreservingChildrenCommandImpl::doApply()
 {
-    NodeListImpl *children = node()->childNodes();
-    int length = children->length();
-    for (int i = 0; i < length; i++) {
-        NodeImpl *child = children->item(0);
-        removeNode(child);
-        insertNodeBefore(child, node());
+    while (NodeImpl* curr = node()->firstChild()) {
+        removeNode(curr);
+        insertNodeBefore(curr, node());
     }
     removeNode(node());
 }