[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:44:27 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 97b05ef8a404c995a6d5f06e8e2bfb14539718c9
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jun 8 21:49:33 2004 +0000

            Reviewed by Hyatt
    
            Fix for this bug:
    
            <rdar://problem/3654841>: "Hitting delete key with start of block selected
            does not merge content with preceding block"
    
            Selections that span blocks now work correctly for deleting the selection and inserting
            over the selection. The largest part of the change is adding a new field to the
            RemoveNodeAndPruneCommand and its impl version. This was done since the starting block
            for a multi-block selection should always be preserved when deleting, and this was
            a convenient way to express this using the code structure already in place.
    
            * khtml/editing/htmlediting.cpp:
            (khtml::RemoveNodeAndPruneCommand::RemoveNodeAndPruneCommand): Modify this command to
            take two nodes: the node to remove and a node to stop at when pruning back up the tree.
            (khtml::RemoveNodeAndPruneCommand::pruneNode): New accessor, replaces old node() accessor.
            (khtml::RemoveNodeAndPruneCommand::stopNode): New accessor for additional feature described
            above.
            * khtml/editing/htmlediting.h:
            * khtml/editing/htmlediting_impl.cpp:
            (khtml::shouldPruneNode): blow flow renderers can now be deleted, but not if they are a
            rootEditableElement.
            (khtml::CompositeEditCommandImpl::removeNodeAndPrune): Pass new stopNode param and change the
            name of the existing node argument to pruneNode to distinguish it.
            (khtml::DeleteSelectionCommandImpl::doApply): Pass the block containing the start of the
            selection to removeNodeAndPrune in each case. Also, add one little loop to move all
            the content from the block containing the end of the selection if that block is different
            than the start block.
            (khtml::RemoveNodeAndPruneCommandImpl::RemoveNodeAndPruneCommandImpl): Implement the
            pruneNode/stopNode design already described.
            (khtml::RemoveNodeAndPruneCommandImpl::~RemoveNodeAndPruneCommandImpl): Manage the
            lifecycle of stopNode.
            (khtml::RemoveNodeAndPruneCommandImpl::doApply): Add a check to stop at the stop
            node while pruning.
            * khtml/editing/htmlediting_impl.h:
            (khtml::RemoveNodeAndPruneCommandImpl::pruneNode): New accessor.
            (khtml::RemoveNodeAndPruneCommandImpl::stopNode): Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6792 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index f9e6b49..4dbfacb 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,44 @@
+2004-06-08  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Hyatt
+
+        Fix for this bug:
+
+        <rdar://problem/3654841>: "Hitting delete key with start of block selected 
+        does not merge content with preceding block"
+
+        Selections that span blocks now work correctly for deleting the selection and inserting
+        over the selection. The largest part of the change is adding a new field to the 
+        RemoveNodeAndPruneCommand and its impl version. This was done since the starting block
+        for a multi-block selection should always be preserved when deleting, and this was
+        a convenient way to express this using the code structure already in place.
+        
+        * khtml/editing/htmlediting.cpp:
+        (khtml::RemoveNodeAndPruneCommand::RemoveNodeAndPruneCommand): Modify this command to 
+        take two nodes: the node to remove and a node to stop at when pruning back up the tree.
+        (khtml::RemoveNodeAndPruneCommand::pruneNode): New accessor, replaces old node() accessor.
+        (khtml::RemoveNodeAndPruneCommand::stopNode): New accessor for additional feature described 
+        above.
+        * khtml/editing/htmlediting.h:
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::shouldPruneNode): blow flow renderers can now be deleted, but not if they are a 
+        rootEditableElement.
+        (khtml::CompositeEditCommandImpl::removeNodeAndPrune): Pass new stopNode param and change the
+        name of the existing node argument to pruneNode to distinguish it.
+        (khtml::DeleteSelectionCommandImpl::doApply): Pass the block containing the start of the
+        selection to removeNodeAndPrune in each case. Also, add one little loop to move all
+        the content from the block containing the end of the selection if that block is different
+        than the start block.
+        (khtml::RemoveNodeAndPruneCommandImpl::RemoveNodeAndPruneCommandImpl): Implement the
+        pruneNode/stopNode design already described.
+        (khtml::RemoveNodeAndPruneCommandImpl::~RemoveNodeAndPruneCommandImpl): Manage the
+        lifecycle of stopNode.
+        (khtml::RemoveNodeAndPruneCommandImpl::doApply): Add a check to stop at the stop
+        node while pruning.
+        * khtml/editing/htmlediting_impl.h:
+        (khtml::RemoveNodeAndPruneCommandImpl::pruneNode): New accessor.
+        (khtml::RemoveNodeAndPruneCommandImpl::stopNode): Ditto.
+
 2004-06-07  Trey Matteson  <trey at apple.com>
 
 	Clipboard access during DHTML dragging is made secure.
diff --git a/WebCore/khtml/editing/htmlediting.cpp b/WebCore/khtml/editing/htmlediting.cpp
index 439a305..d503010 100644
--- a/WebCore/khtml/editing/htmlediting.cpp
+++ b/WebCore/khtml/editing/htmlediting.cpp
@@ -615,8 +615,8 @@ NodeImpl *RemoveNodeCommand::node() const
 //------------------------------------------------------------------------------------------
 // RemoveNodeAndPruneCommand
 
-RemoveNodeAndPruneCommand::RemoveNodeAndPruneCommand(DocumentImpl *document, NodeImpl *node)
-    : CompositeEditCommand(new RemoveNodeAndPruneCommandImpl(document, node))
+RemoveNodeAndPruneCommand::RemoveNodeAndPruneCommand(DocumentImpl *document, NodeImpl *pruneNode, NodeImpl *stopNode)
+    : CompositeEditCommand(new RemoveNodeAndPruneCommandImpl(document, pruneNode, stopNode))
 {
 }
 
@@ -629,10 +629,16 @@ RemoveNodeAndPruneCommandImpl *RemoveNodeAndPruneCommand::impl() const
     return static_cast<RemoveNodeAndPruneCommandImpl *>(get());
 }
 
-NodeImpl *RemoveNodeAndPruneCommand::node() const
+NodeImpl *RemoveNodeAndPruneCommand::pruneNode() const
 {
     IF_IMPL_NULL_RETURN_ARG(0);
-    return impl()->node();
+    return impl()->pruneNode();
+}
+
+NodeImpl *RemoveNodeAndPruneCommand::stopNode() const
+{
+    IF_IMPL_NULL_RETURN_ARG(0);
+    return impl()->stopNode();
 }
 
 //------------------------------------------------------------------------------------------
diff --git a/WebCore/khtml/editing/htmlediting.h b/WebCore/khtml/editing/htmlediting.h
index 13feb74..7b8216a 100644
--- a/WebCore/khtml/editing/htmlediting.h
+++ b/WebCore/khtml/editing/htmlediting.h
@@ -418,10 +418,11 @@ private:
 class RemoveNodeAndPruneCommand : public CompositeEditCommand
 {
 public:
-	RemoveNodeAndPruneCommand(DOM::DocumentImpl *, DOM::NodeImpl *);
+	RemoveNodeAndPruneCommand(DOM::DocumentImpl *, DOM::NodeImpl *pruneNode, DOM::NodeImpl *stopNode=0);
 	virtual ~RemoveNodeAndPruneCommand();
 
-    DOM::NodeImpl *node() const;
+    DOM::NodeImpl *pruneNode() const;
+    DOM::NodeImpl *stopNode() const;
     
 private:
     inline RemoveNodeAndPruneCommandImpl *impl() const;
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 48742ab..323296d 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -136,7 +136,10 @@ static bool shouldPruneNode(NodeImpl *node)
     if (node->hasChildNodes())
         return false;
         
-    if (renderer->isBR() || renderer->isBlockFlow() || renderer->isReplaced())
+    if (node->rootEditableElement() == node)
+        return false;
+        
+    if (renderer->isBR() || renderer->isReplaced())
         return false;
         
     if (node->isTextNode()) {
@@ -434,9 +437,9 @@ void CompositeEditCommandImpl::removeNode(NodeImpl *removeChild)
     applyCommandToComposite(cmd);
 }
 
-void CompositeEditCommandImpl::removeNodeAndPrune(NodeImpl *removeChild)
+void CompositeEditCommandImpl::removeNodeAndPrune(NodeImpl *pruneNode, NodeImpl *stopNode)
 {
-    RemoveNodeAndPruneCommand cmd(document(), removeChild);
+    RemoveNodeAndPruneCommand cmd(document(), pruneNode, stopNode);
     applyCommandToComposite(cmd);
 }
 
@@ -1412,6 +1415,10 @@ void DeleteSelectionCommandImpl::doApply()
         (startRenderedOffset == 0 && downstreamStart.inFirstEditableInContainingEditableBlock());
     bool endAtEndOfBlock = downstreamEnd.isLastRenderedPositionInEditableBlock();
 
+    NodeImpl *startBlock = upstreamStart.node()->enclosingBlockFlowElement();
+    NodeImpl *endBlock = downstreamEnd.node()->enclosingBlockFlowElement();
+    bool startBlockEndBlockAreSiblings = startBlock->parentNode() == endBlock->parentNode();
+
     debugPosition("upstreamStart:       ", upstreamStart);
     debugPosition("downstreamStart:     ", downstreamStart);
     debugPosition("upstreamEnd:         ", upstreamEnd);
@@ -1422,10 +1429,10 @@ void DeleteSelectionCommandImpl::doApply()
     LOG(Editing,  "at end block:        %s", endAtEndOfBlock ? "YES" : "NO");
     LOG(Editing,  "only whitespace:     %s", onlyWhitespace ? "YES" : "NO");
 
-    // Start is not completely selected
+    // Determine where to put the caret after the deletion
     if (startAtStartOfBlock) {
         LOG(Editing,  "ending position case 1");
-        endingPosition = Position(downstreamStart.node()->enclosingBlockFlowElement(), 1);
+        endingPosition = Position(startBlock, 0);
         adjustEndingPositionDownstream = true;
     }
     else if (!startCompletelySelected) {
@@ -1484,7 +1491,7 @@ void DeleteSelectionCommandImpl::doApply()
     // work on start node
     if (startCompletelySelected) {
         LOG(Editing,  "start node delete case 1");
-        removeNodeAndPrune(downstreamStart.node());
+        removeNodeAndPrune(downstreamStart.node(), startBlock);
     }
     else if (onlyWhitespace) {
         // Selection only contains whitespace. This is really a special-case to 
@@ -1521,13 +1528,13 @@ void DeleteSelectionCommandImpl::doApply()
             NodeImpl *d = n;
             n = n->traverseNextNode();
             if (d->renderer() && d->renderer()->isEditable())
-                removeNodeAndPrune(d);
+                removeNodeAndPrune(d, startBlock);
         }
         
         // work on end node
         ASSERT(n == upstreamEnd.node());
         if (endCompletelySelected) {
-            removeNodeAndPrune(upstreamEnd.node());
+            removeNodeAndPrune(upstreamEnd.node(), startBlock);
         }
         else if (upstreamEnd.node()->isTextNode()) {
             if (upstreamEnd.offset() > 0) {
@@ -1542,6 +1549,22 @@ void DeleteSelectionCommandImpl::doApply()
         }
     }
 
+    // Do block merge if start and end of selection are in different blocks
+    // and the blocks are siblings. This is a first cut at this rule arrived
+    // at by doing a bunch of edits and settling on the behavior that made
+    // the most sense. This could change in the future as we get more
+    // experience with how this should behave.
+    if (startBlock != endBlock && startBlockEndBlockAreSiblings) {
+        LOG(Editing,  "merging content to start block");
+        NodeImpl *node = endBlock->firstChild();
+        while (node) {
+            NodeImpl *moveNode = node;
+            node = node->nextSibling();
+            removeNode(moveNode);
+            appendNode(startBlock, moveNode);
+        }
+    }
+
     if (adjustEndingPositionDownstream) {
         LOG(Editing,  "adjust ending position downstream");
         endingPosition = endingPosition.equivalentDownstreamPosition();
@@ -2318,17 +2341,20 @@ void RemoveNodeCommandImpl::doUnapply()
 //------------------------------------------------------------------------------------------
 // RemoveNodeAndPruneCommandImpl
 
-RemoveNodeAndPruneCommandImpl::RemoveNodeAndPruneCommandImpl(DocumentImpl *document, NodeImpl *removeChild)
-    : CompositeEditCommandImpl(document), m_removeChild(removeChild)
+RemoveNodeAndPruneCommandImpl::RemoveNodeAndPruneCommandImpl(DocumentImpl *document, NodeImpl *pruneNode, NodeImpl *stopNode)
+    : CompositeEditCommandImpl(document), m_pruneNode(pruneNode), m_stopNode(stopNode)
 {
-    ASSERT(m_removeChild);
-    m_removeChild->ref();
+    ASSERT(m_pruneNode);
+    m_pruneNode->ref();
+    if (m_stopNode)
+        m_stopNode->ref();
 }
 
 RemoveNodeAndPruneCommandImpl::~RemoveNodeAndPruneCommandImpl()
 {
-    if (m_removeChild)
-        m_removeChild->deref();
+    m_pruneNode->deref();
+    if (m_stopNode)
+        m_stopNode->deref();
 }
 
 int RemoveNodeAndPruneCommandImpl::commandID() const
@@ -2338,12 +2364,12 @@ int RemoveNodeAndPruneCommandImpl::commandID() const
 
 void RemoveNodeAndPruneCommandImpl::doApply()
 {
-    NodeImpl *editableBlock = m_removeChild->enclosingBlockFlowElement();
-    NodeImpl *pruneNode = m_removeChild;
+    NodeImpl *editableBlock = m_pruneNode->enclosingBlockFlowElement();
+    NodeImpl *pruneNode = m_pruneNode;
     NodeImpl *node = pruneNode->traversePreviousNode();
     removeNode(pruneNode);
     while (1) {
-        if (editableBlock != node->enclosingBlockFlowElement() || !shouldPruneNode(node))
+        if (node == m_stopNode || editableBlock != node->enclosingBlockFlowElement() || !shouldPruneNode(node))
             break;
         pruneNode = node;
         node = node->traversePreviousNode();
diff --git a/WebCore/khtml/editing/htmlediting_impl.h b/WebCore/khtml/editing/htmlediting_impl.h
index 33e79a7..2031a47 100644
--- a/WebCore/khtml/editing/htmlediting_impl.h
+++ b/WebCore/khtml/editing/htmlediting_impl.h
@@ -133,7 +133,7 @@ protected:
     void removeCSSProperty(DOM::CSSStyleDeclarationImpl *, int property);
     void removeNodeAttribute(DOM::ElementImpl *, int attribute);
     void removeNode(DOM::NodeImpl *removeChild);
-    void removeNodeAndPrune(DOM::NodeImpl *removeChild);
+    void removeNodeAndPrune(DOM::NodeImpl *pruneNode, DOM::NodeImpl *stopNode=0);
     void removeNodePreservingChildren(DOM::NodeImpl *node);
     void replaceText(DOM::TextImpl *node, long offset, long count, const DOM::DOMString &replacementText);
     void setNodeAttribute(DOM::ElementImpl *, int attribute, const DOM::DOMString &);
@@ -518,17 +518,19 @@ private:
 class RemoveNodeAndPruneCommandImpl : public CompositeEditCommandImpl
 {
 public:
-	RemoveNodeAndPruneCommandImpl(DOM::DocumentImpl *, DOM::NodeImpl *);
+	RemoveNodeAndPruneCommandImpl(DOM::DocumentImpl *, DOM::NodeImpl *pruneNode, DOM::NodeImpl *stopNode=0);
 	virtual ~RemoveNodeAndPruneCommandImpl();
 	
     virtual int commandID() const;
 
 	virtual void doApply();
 
-    DOM::NodeImpl *node() const { return m_removeChild; }
+    DOM::NodeImpl *pruneNode() const { return m_pruneNode; }
+    DOM::NodeImpl *stopNode() const { return m_stopNode; }
 
 private:
-    DOM::NodeImpl *m_removeChild;
+    DOM::NodeImpl *m_pruneNode;
+    DOM::NodeImpl *m_stopNode;
 };
 
 //------------------------------------------------------------------------------------------

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list