[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:45:12 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 97f9029f0a09c6d10cac09a17fa32e020ea5b4c5
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jun 11 19:37:49 2004 +0000

            Reviewed by Hyatt
    
            Fix for this bug:
    
            <rdar://problem/3659587>: "when typing in Blot, bold style does not carry over to next line after pressing 'return'"
    
            Did some work to improve the insert newline command. The refinement is to insert the newline
            at the upstream position of the caret, ensuring that the newline takes on the
            appropriate style, and does not let the caret "escape" from an element that is
            conferring style.
    
            * khtml/editing/htmlediting_impl.cpp:
            (khtml::InputNewlineCommandImpl::insertNodeAfterPosition): New helper. Adds smarts about adding
            newlines when the selection is a caret in a block.
            (khtml::InputNewlineCommandImpl::insertNodeBeforePosition): Ditto.
            (khtml::InputNewlineCommandImpl::doApply): Simplified cases. One case in the code could not
            happen.
            * khtml/editing/htmlediting_impl.h:
    
            Fix for this bug:
    
            <rdar://problem/3654864>: "Pasting content at start of line places it at end of previous line"
    
            (khtml::InputTextCommandImpl::prepareForTextInsertion): Simple code mistake. Content was indeed
            being added to the line before. Fixed to add new content after the line break.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6818 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 4a96206..b9fa011 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,31 @@
+2004-06-11  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Hyatt
+
+        Fix for this bug:
+        
+        <rdar://problem/3659587>: "when typing in Blot, bold style does not carry over to next line after pressing 'return'"
+
+        Did some work to improve the insert newline command. The refinement is to insert the newline
+        at the upstream position of the caret, ensuring that the newline takes on the 
+        appropriate style, and does not let the caret "escape" from an element that is
+        conferring style.
+
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::InputNewlineCommandImpl::insertNodeAfterPosition): New helper. Adds smarts about adding
+        newlines when the selection is a caret in a block.
+        (khtml::InputNewlineCommandImpl::insertNodeBeforePosition): Ditto.
+        (khtml::InputNewlineCommandImpl::doApply): Simplified cases. One case in the code could not
+        happen.
+        * khtml/editing/htmlediting_impl.h:
+
+        Fix for this bug:
+    
+        <rdar://problem/3654864>: "Pasting content at start of line places it at end of previous line"
+
+        (khtml::InputTextCommandImpl::prepareForTextInsertion): Simple code mistake. Content was indeed
+        being added to the line before. Fixed to add new content after the line break.
+
 2004-07-10  Trey Matteson  <trey at apple.com>
 
 	Prep work for latest delegate API for dragging.  In addition, I also straightened out all
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 7d4e332..ecf218c 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -1433,6 +1433,32 @@ int InputNewlineCommandImpl::commandID() const
     return InputNewlineCommandID;
 }
 
+void InputNewlineCommandImpl::insertNodeAfterPosition(NodeImpl *node, const Position &pos)
+{
+    // Insert the BR after the caret position. In the case the
+    // position is a block, do an append. We don't want to insert
+    // the BR *after* the block.
+    Position upstream(pos.equivalentUpstreamPosition());
+    NodeImpl *cb = pos.node()->enclosingBlockFlowElement();
+    if (cb == pos.node())
+        appendNode(cb, node);
+    else
+        insertNodeAfter(node, pos.node());
+}
+
+void InputNewlineCommandImpl::insertNodeBeforePosition(NodeImpl *node, const Position &pos)
+{
+    // Insert the BR after the caret position. In the case the
+    // position is a block, do an append. We don't want to insert
+    // the BR *before* the block.
+    Position upstream(pos.equivalentUpstreamPosition());
+    NodeImpl *cb = pos.node()->enclosingBlockFlowElement();
+    if (cb == pos.node())
+        appendNode(cb, node);
+    else
+        insertNodeBefore(node, pos.node());
+}
+
 void InputNewlineCommandImpl::doApply()
 {
     deleteSelection();
@@ -1454,36 +1480,32 @@ void InputNewlineCommandImpl::doApply()
     }
     
     Position pos(selection.start().equivalentDownstreamPosition());
-    bool atEnd = pos.offset() >= pos.node()->caretMaxOffset();
     bool atStart = pos.offset() <= pos.node()->caretMinOffset();
     bool atEndOfBlock = pos.isLastRenderedPositionInEditableBlock();
     
     if (atEndOfBlock) {
         LOG(Editing, "input newline case 1");
-        NodeImpl *cb = pos.node()->enclosingBlockFlowElement();
-        appendNode(cb, nodeToInsert);
-        
         // Insert an "extra" BR at the end of the block. This makes the "real" BR we want
         // to insert appear in the rendering without any significant side effects (and no
         // real worries either since you can't arrow past this extra one.
+        insertNodeAfterPosition(nodeToInsert, pos);
         exceptionCode = 0;
         ElementImpl *extraBreakNode = document()->createHTMLElement("BR", exceptionCode);
         ASSERT(exceptionCode == 0);
-        appendNode(cb, extraBreakNode);
+        insertNodeAfter(extraBreakNode, nodeToInsert);
         setEndingSelection(Position(extraBreakNode, 0));
     }
-    else if (atEnd) {
-        LOG(Editing, "input newline case 2");
-        insertNodeAfter(nodeToInsert, pos.node());
-        setEndingSelection(Position(breakNode, 0));
-    }
     else if (atStart) {
-        LOG(Editing, "input newline case 3");
-        insertNodeAt(nodeToInsert, pos.node(), 0);
+        LOG(Editing, "input newline case 2");
+        // Insert node, but place the caret into index 0 of the downstream
+        // position. This will make the caret appear after the break, and as we know
+        // there is content at that location, this is OK.
+        insertNodeBeforePosition(nodeToInsert, pos);
         setEndingSelection(Position(pos.node(), 0));
     }
     else {
-        LOG(Editing, "input newline case 4");
+        // Split a text node
+        LOG(Editing, "input newline case 3");
         ASSERT(pos.node()->isTextNode());
         TextImpl *textNode = static_cast<TextImpl *>(pos.node());
         TextImpl *textBeforeNode = document()->createTextNode(textNode->substringData(0, selection.start().offset(), exceptionCode));
@@ -1572,7 +1594,7 @@ Position InputTextCommandImpl::prepareForTextInsertion(bool adjustDownstream)
         }
         else if (pos.node()->id() == ID_BR && pos.offset() == 1) {
             LOG(Editing, "prepareForTextInsertion case 2");
-            insertNodeBefore(nodeToInsert, pos.node());
+            insertNodeAfter(nodeToInsert, pos.node());
         }
         else if (pos.node()->caretMinOffset() == pos.offset()) {
             LOG(Editing, "prepareForTextInsertion case 3");
diff --git a/WebCore/khtml/editing/htmlediting_impl.h b/WebCore/khtml/editing/htmlediting_impl.h
index a9462b2..8fe67bc 100644
--- a/WebCore/khtml/editing/htmlediting_impl.h
+++ b/WebCore/khtml/editing/htmlediting_impl.h
@@ -294,6 +294,10 @@ public:
     virtual int commandID() const;
 
     virtual void doApply();
+
+private:
+    void insertNodeAfterPosition(DOM::NodeImpl *node, const DOM::Position &pos);
+    void insertNodeBeforePosition(DOM::NodeImpl *node, const DOM::Position &pos);
 };
 
 //------------------------------------------------------------------------------------------

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list