Reviewed by Hyatt
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2004 18:02:05 +0000 (18:02 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2004 18:02:05 +0000 (18:02 +0000)
        * khtml/editing/htmlediting_impl.cpp:
        (khtml::DeleteSelectionCommandImpl::moveNodesAfterNode): Renamed from moveNodesToBlock.
        Just some simplification and cleanup in this function.
        (khtml::DeleteSelectionCommandImpl::doApply): Remove a hunk of start-of-block code I thought
        I was going to get around to improving and refining. However, I no longer need this case.
        * khtml/editing/htmlediting_impl.h: Function name change.

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

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

index 4ff9f2c..5c0fae8 100644 (file)
@@ -1,3 +1,14 @@
+2004-09-15  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Hyatt
+
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::DeleteSelectionCommandImpl::moveNodesAfterNode): Renamed from moveNodesToBlock.
+        Just some simplification and cleanup in this function.
+        (khtml::DeleteSelectionCommandImpl::doApply): Remove a hunk of start-of-block code I thought
+        I was going to get around to improving and refining. However, I no longer need this case.
+        * khtml/editing/htmlediting_impl.h: Function name change.
+
 2004-09-14  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej.
index 5036f79..7df661e 100644 (file)
@@ -1010,30 +1010,19 @@ CSSStyleDeclarationImpl *DeleteSelectionCommandImpl::computeTypingStyle(const Po
 // startNode that appear in document order before startNode are not moved.
 // This function is an important helper for deleting selections that cross block
 // boundaries.
-void DeleteSelectionCommandImpl::moveNodesToBlock(NodeImpl *startNode, NodeImpl *dstBlock)
+void DeleteSelectionCommandImpl::moveNodesAfterNode(NodeImpl *startNode, NodeImpl *dstNode)
 {
-    ASSERT(!dstBlock->isAncestor(startNode));
-
     NodeImpl *startBlock = startNode->enclosingBlockFlowElement();
-    unsigned long index = dstBlock->childNodeCount();
     
-    // Fix the right index to use for inserting content in dstBlock, based on the
-    // position of startNode relative to dstBlock.
-    if (startNode->isAncestor(dstBlock)) {
-        NodeImpl *n = startNode;
-        while (n->parentNode() != dstBlock)
-            n = n->parentNode();
-        index = n->nodeIndex();
-    }
-
     // Do the move.
     NodeImpl *node = startNode == startBlock ? startBlock->firstChild() : startNode;
-    while (node && (node == startBlock || node->isAncestor(startBlock))) {
+    NodeImpl *refNode = dstNode;
+    while (node && node->isAncestor(startBlock)) {
         NodeImpl *moveNode = node;
         node = node->nextSibling();
         removeNode(moveNode);
-        insertNodeAt(moveNode, dstBlock, index);
-        index++;
+        insertNodeAfter(moveNode, refNode);
+        refNode = moveNode;
     }
 
     // If the startBlock no longer has any kids, we may need to deal with adding a BR
@@ -1051,14 +1040,11 @@ void DeleteSelectionCommandImpl::moveNodesToBlock(NodeImpl *startNode, NodeImpl
     if (!startBlock->firstChild()) {
         removeNode(startBlock);
         document()->updateLayout();
-        if (index != dstBlock->childNodeCount()) {
-            NodeImpl *node = dstBlock->childNode(index);
-            if (node->renderer() && node->renderer()->inlineBox() && node->renderer()->inlineBox()->prevOnLineExists()) {
-                int exceptionCode = 0;
-                ElementImpl *breakNode = document()->createHTMLElement("BR", exceptionCode);
-                ASSERT(exceptionCode == 0);
-                insertNodeBefore(breakNode, node);
-            }
+        if (refNode->renderer() && refNode->renderer()->inlineBox() && refNode->renderer()->inlineBox()->nextOnLineExists()) {
+            int exceptionCode = 0;
+            ElementImpl *breakNode = document()->createHTMLElement("BR", exceptionCode);
+            ASSERT(exceptionCode == 0);
+            insertNodeAfter(breakNode, refNode);
         }
     }
 }
@@ -1118,18 +1104,7 @@ void DeleteSelectionCommandImpl::doApply()
         startOffset = 0;
     }
 
-    if (upstreamStart == upstreamEnd && downstreamStart == downstreamEnd && upstreamStart.node()->isBlockFlow()) {
-        // handle a delete when the selection is a caret placed at the start of a block.
-        ASSERT(startBlock == endBlock);
-        NodeImpl *block = upstreamStart.node()->traversePreviousNode()->enclosingBlockFlowElement();
-        while (block && !block->isContentEditable())
-            block = block->traversePreviousNode()->enclosingBlockFlowElement();
-        if (block && block->rootEditableElement() == upstreamStart.node()->rootEditableElement())
-            startBlock = block;
-        else
-            return; // nothing to do; at the start of a root editable block.
-    }
-    else if (startNode == downstreamEnd.node()) {
+    if (startNode == downstreamEnd.node()) {
         // handle delete in one node
         if (!startNode->renderer() || 
             (startOffset <= startNode->caretMinOffset() && downstreamEnd.offset() >= startNode->caretMaxOffset())) {
@@ -1204,7 +1179,7 @@ void DeleteSelectionCommandImpl::doApply()
         deleteUnrenderedText(upstreamStart);
         // move the downstream end position's node, and all other nodes in its
         // block to the start block.
-        moveNodesToBlock(downstreamEnd.node(), startBlock);
+        moveNodesAfterNode(downstreamEnd.node(), upstreamStart.node());
     }
       
     // Figure out where the end position should be
index 7a1af99..d0c5308 100644 (file)
@@ -243,7 +243,7 @@ private:
     void deleteDownstreamWS(const DOM::Position &start);
     bool containsOnlyWhitespace(const DOM::Position &start, const DOM::Position &end);
     DOM::CSSStyleDeclarationImpl *computeTypingStyle(const DOM::Position &pos) const;
-    void moveNodesToBlock(DOM::NodeImpl *startNode, DOM::NodeImpl *dstBlock);
+    void moveNodesAfterNode(DOM::NodeImpl *startNode, DOM::NodeImpl *dstNode);
 
     DOM::Selection m_selectionToDelete;
     bool m_hasSelectionToDelete;