[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 11:25:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 29a9bb6c35d48bb34b18c0c2580ab326285c342d
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jul 23 02:26:47 2010 +0000

    [cleanup] logic to extract adjacent lists and list children in listifyParagraph and unlistifyParagraph should be isolated
    https://bugs.webkit.org/show_bug.cgi?id=42841
    
    Reviewed by Kent Tamura.
    
    Added enclosingListChild that takes the list node containing the node for the second argument
    to ensure that it only returns the enclosing list child of the specified list node.
    
    Added adjacentEnclosingList that finds adjacent lists of the specified position.
    It takes the current position, the adjacent position that may or may not have a list, and the list type,
    and avoids a list that belongs to a different table cell or an outer list that contains the current position.
    
    No new tests needed.
    
    * editing/InsertListCommand.cpp:
    (WebCore::enclosingListChild): Added. See above.
    (WebCore::InsertListCommand::unlistifyParagraph): Uses enclosingListChild.
    (WebCore::adjacentEnclosingList): Added. See above.
    (WebCore::InsertListCommand::listifyParagraph): Uses adjacentEnclosingList.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63941 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 122a5e8..ed6c1b3 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-07-22  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Kent Tamura.
+
+        [cleanup] logic to extract adjacent lists and list children in listifyParagraph and unlistifyParagraph should be isolated
+        https://bugs.webkit.org/show_bug.cgi?id=42841
+
+        Added enclosingListChild that takes the list node containing the node for the second argument
+        to ensure that it only returns the enclosing list child of the specified list node.
+
+        Added adjacentEnclosingList that finds adjacent lists of the specified position.
+        It takes the current position, the adjacent position that may or may not have a list, and the list type,
+        and avoids a list that belongs to a different table cell or an outer list that contains the current position.
+
+        No new tests needed.
+
+        * editing/InsertListCommand.cpp:
+        (WebCore::enclosingListChild): Added. See above.
+        (WebCore::InsertListCommand::unlistifyParagraph): Uses enclosingListChild.
+        (WebCore::adjacentEnclosingList): Added. See above.
+        (WebCore::InsertListCommand::listifyParagraph): Uses adjacentEnclosingList.
+
 2010-07-22  Patrick Gansterer  <paroga at paroga.com>
 
         Reviewed by Adam Roben.
diff --git a/WebCore/editing/InsertListCommand.cpp b/WebCore/editing/InsertListCommand.cpp
index 06162c9..8f9c0de 100644
--- a/WebCore/editing/InsertListCommand.cpp
+++ b/WebCore/editing/InsertListCommand.cpp
@@ -150,6 +150,14 @@ void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList)
         m_listElement = listifyParagraph(endingSelection().visibleStart(), listTag);
 }
 
+static Node* enclosingListChild(Node* node, Node* listNode)
+{
+    Node* listChild = enclosingListChild(node);
+    if (enclosingList(listChild) != listNode)
+        return 0;
+    return listChild;
+}
+
 void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart, HTMLElement* listNode, Node* listChildNode)
 {
     Node* nextListChild;
@@ -165,14 +173,10 @@ void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart,
         // A paragraph is visually a list item minus a list marker.  The paragraph will be moved.
         start = startOfParagraph(originalStart);
         end = endOfParagraph(start);
-        nextListChild = enclosingListChild(end.next().deepEquivalent().node());
+        nextListChild = enclosingListChild(end.next().deepEquivalent().node(), listNode);
         ASSERT(nextListChild != listChildNode);
-        if (enclosingList(nextListChild) != listNode)
-            nextListChild = 0;
-        previousListChild = enclosingListChild(start.previous().deepEquivalent().node());
+        previousListChild = enclosingListChild(start.previous().deepEquivalent().node(), listNode);
         ASSERT(previousListChild != listChildNode);
-        if (enclosingList(previousListChild) != listNode)
-            previousListChild = 0;
     }
     // When removing a list, we must always create a placeholder to act as a point of insertion
     // for the list content being removed.
@@ -210,28 +214,37 @@ void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart,
     moveParagraphs(start, end, insertionPoint, true);
 }
 
+static Element* adjacentEnclosingList(const VisiblePosition& pos, const VisiblePosition& adjacentPos, const QualifiedName& listTag)
+{
+    Element* listNode = outermostEnclosingList(adjacentPos.deepEquivalent().node());
+
+    if (!listNode)
+        return 0;
+
+    Node* previousCell = enclosingTableCell(pos.deepEquivalent());
+    Node* currentCell = enclosingTableCell(adjacentPos.deepEquivalent());
+
+    if (!listNode->hasTagName(listTag)
+        || listNode->contains(pos.deepEquivalent().node())
+        || previousCell != currentCell)
+        return 0;
+
+    return listNode;
+}
+
 PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePosition& originalStart, const QualifiedName& listTag)
 {
     VisiblePosition start = startOfParagraph(originalStart);
     VisiblePosition end = endOfParagraph(start);
 
     // Check for adjoining lists.
-    VisiblePosition previousPosition = start.previous(true);
-    VisiblePosition nextPosition = end.next(true);
     RefPtr<HTMLElement> listItemElement = createListItemElement(document());
     RefPtr<HTMLElement> placeholder = createBreakElement(document());
     appendNode(placeholder, listItemElement);
-    Element* previousList = outermostEnclosingList(previousPosition.deepEquivalent().node());
-    Element* nextList = outermostEnclosingList(nextPosition.deepEquivalent().node());
-    Node* startNode = start.deepEquivalent().node();
-    Node* previousCell = enclosingTableCell(previousPosition.deepEquivalent());
-    Node* nextCell = enclosingTableCell(nextPosition.deepEquivalent());
-    Node* currentCell = enclosingTableCell(start.deepEquivalent());
-    if (previousList && (!previousList->hasTagName(listTag) || startNode->isDescendantOf(previousList) || previousCell != currentCell))
-        previousList = 0;
-    if (nextList && (!nextList->hasTagName(listTag) || startNode->isDescendantOf(nextList) || nextCell != currentCell))
-        nextList = 0;
+
     // Place list item into adjoining lists.
+    Element* previousList = adjacentEnclosingList(start.deepEquivalent(), start.previous(true), listTag);
+    Element* nextList = adjacentEnclosingList(start.deepEquivalent(), end.next(true), listTag);
     RefPtr<HTMLElement> listElement;
     if (previousList)
         appendNode(listItemElement, previousList);
@@ -268,8 +281,6 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio
         // Update the start of content, so we don't try to move the list into itself.  bug 19066
         if (insertionPos == start.deepEquivalent())
             start = startOfParagraph(originalStart);
-        previousList = outermostEnclosingList(previousPosition.deepEquivalent().node(), enclosingList(listElement.get()));
-        nextList = outermostEnclosingList(nextPosition.deepEquivalent().node(), enclosingList(listElement.get()));
     }
 
     moveParagraph(start, end, VisiblePosition(Position(placeholder.get(), 0)), true);
@@ -281,6 +292,8 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio
         listElement = m_listElement;
 
     if (listElement) {
+        previousList = listElement->previousElementSibling();
+        nextList = listElement->nextElementSibling();
         if (canMergeLists(previousList, listElement.get()))
             mergeIdenticalElements(previousList, listElement.get());
         if (canMergeLists(listElement.get(), nextList))

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list