[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 13:46:11 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 17d6d0677d19fc47c29b92a3746be72581efefb0
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 25 20:42:46 2010 +0000

    2010-09-25  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Tony Chang.
    
            FormatBlockCommand's modifyRange and doApply should be merged
            https://bugs.webkit.org/show_bug.cgi?id=46504
    
            Isolated the code in doApply to insert and remove lists for single paragraph into doApplyForSingleParagraph.
            Merged the code in modifyRange into doApply and cleaned up.
    
            No new tests are added since this is a cleanup.
    
            * editing/FormatBlockCommand.cpp:
            (WebCore::FormatBlockCommand::doApply): Merged with modifyRange; calls doApplyForSingleParagraph.
            (WebCore::FormatBlockCommand::doApplyForSingleParagraph): Added.
            * editing/FormatBlockCommand.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68337 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b4a75aa..57df732 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-25  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Tony Chang.
+
+        FormatBlockCommand's modifyRange and doApply should be merged
+        https://bugs.webkit.org/show_bug.cgi?id=46504
+
+        Isolated the code in doApply to insert and remove lists for single paragraph into doApplyForSingleParagraph.
+        Merged the code in modifyRange into doApply and cleaned up.
+
+        No new tests are added since this is a cleanup.
+
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::FormatBlockCommand::doApply): Merged with modifyRange; calls doApplyForSingleParagraph.
+        (WebCore::FormatBlockCommand::doApplyForSingleParagraph): Added.
+        * editing/FormatBlockCommand.h:
+
 2010-09-25  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by John Sullivan.
diff --git a/WebCore/editing/FormatBlockCommand.cpp b/WebCore/editing/FormatBlockCommand.cpp
index 221aecf..6bb8ad5 100644
--- a/WebCore/editing/FormatBlockCommand.cpp
+++ b/WebCore/editing/FormatBlockCommand.cpp
@@ -41,33 +41,6 @@ FormatBlockCommand::FormatBlockCommand(Document* document, const AtomicString& t
 {
 }
 
-bool FormatBlockCommand::modifyRange()
-{
-    ASSERT(endingSelection().isRange());
-    VisiblePosition visibleStart = endingSelection().visibleStart();
-    VisiblePosition visibleEnd = endingSelection().visibleEnd();
-    VisiblePosition startOfLastParagraph = startOfParagraph(visibleEnd);
-    
-    if (startOfParagraph(visibleStart) == startOfLastParagraph)
-        return false;
-
-    setEndingSelection(visibleStart);
-    doApply();
-    visibleStart = endingSelection().visibleStart();
-    VisiblePosition nextParagraph = endOfParagraph(visibleStart).next();
-    while (nextParagraph.isNotNull() && nextParagraph != startOfLastParagraph) {
-        setEndingSelection(nextParagraph);
-        doApply();
-        nextParagraph = endOfParagraph(endingSelection().visibleStart()).next();
-    }
-    setEndingSelection(visibleEnd);
-    doApply();
-    visibleEnd = endingSelection().visibleEnd();
-    setEndingSelection(VisibleSelection(visibleStart.deepEquivalent(), visibleEnd.deepEquivalent(), DOWNSTREAM));
-
-    return true;
-}
-
 void FormatBlockCommand::doApply()
 {
     if (!endingSelection().isNonOrphanedCaretOrRange())
@@ -86,12 +59,35 @@ void FormatBlockCommand::doApply()
     // FIXME: We paint the gap before some paragraphs that are indented with left 
     // margin/padding, but not others.  We should make the gap painting more consistent and 
     // then use a left margin/padding rule here.
-    if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd))
+    if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd)) {
         setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(true)));
+        visibleEnd = endingSelection().visibleEnd();
+    }
 
-    if (endingSelection().isRange() && modifyRange())
+    VisiblePosition startOfLastParagraph = startOfParagraph(visibleEnd);
+    if (endingSelection().isCaret() || startOfParagraph(visibleStart) == startOfLastParagraph) {
+        doApplyForSingleParagraph();
         return;
+    }
+
+    setEndingSelection(visibleStart);
+    doApplyForSingleParagraph();
+    visibleStart = endingSelection().visibleStart();
+    VisiblePosition nextParagraph = endOfParagraph(visibleStart).next();
+    while (nextParagraph.isNotNull() && nextParagraph != startOfLastParagraph) {
+        setEndingSelection(nextParagraph);
+        doApplyForSingleParagraph();
+        nextParagraph = endOfParagraph(endingSelection().visibleStart()).next();
+    }
+    setEndingSelection(visibleEnd);
+    doApplyForSingleParagraph();
+    visibleEnd = endingSelection().visibleEnd();
 
+    setEndingSelection(VisibleSelection(visibleStart.deepEquivalent(), visibleEnd.deepEquivalent(), DOWNSTREAM));
+}
+
+void FormatBlockCommand::doApplyForSingleParagraph()
+{
     ExceptionCode ec;
     String localName, prefix;
     if (!Document::parseQualifiedName(m_tagName, prefix, localName, ec))
@@ -102,14 +98,14 @@ void FormatBlockCommand::doApply()
     if (refNode->hasTagName(qTypeOfBlock))
         // We're already in a block with the format we want, so we don't have to do anything
         return;
-    
+
     VisiblePosition paragraphStart = startOfParagraph(endingSelection().visibleStart());
     VisiblePosition paragraphEnd = endOfParagraph(endingSelection().visibleStart());
     VisiblePosition blockStart = startOfBlock(endingSelection().visibleStart());
     VisiblePosition blockEnd = endOfBlock(endingSelection().visibleStart());
     RefPtr<Element> blockNode = createHTMLElement(document(), m_tagName);
     RefPtr<Element> placeholder = createBreakElement(document());
-    
+
     Node* root = endingSelection().start().node()->rootEditableElement();
     if (validBlockTag(refNode->nodeName().lower()) && 
         paragraphStart == blockStart && paragraphEnd == blockEnd && 
@@ -122,7 +118,7 @@ void FormatBlockCommand::doApply()
         insertNodeAt(blockNode, paragraphStart.deepEquivalent().upstream());
     }
     appendNode(placeholder, blockNode);
-    
+
     VisiblePosition destination(Position(placeholder.get(), 0));
     if (paragraphStart == paragraphEnd && !lineBreakExistsAtVisiblePosition(paragraphStart)) {
         setEndingSelection(destination);
diff --git a/WebCore/editing/FormatBlockCommand.h b/WebCore/editing/FormatBlockCommand.h
index 1c8d814..70e6fa6 100644
--- a/WebCore/editing/FormatBlockCommand.h
+++ b/WebCore/editing/FormatBlockCommand.h
@@ -41,9 +41,9 @@ private:
     FormatBlockCommand(Document*, const AtomicString& tagName);
 
     virtual void doApply();
+    void doApplyForSingleParagraph();
     virtual EditAction editingAction() const { return EditActionFormatBlock; }
 
-    bool modifyRange();
     AtomicString m_tagName;
 };
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list