diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
commit | 49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch) | |
tree | 5410cb9a8fd53168bb60d62c54b654d86f03c38d /Source/WebCore/editing/BreakBlockquoteCommand.cpp | |
parent | b211c645d8ab690f713515dfdc84d80b11c27d2c (diff) | |
download | qtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz |
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Source/WebCore/editing/BreakBlockquoteCommand.cpp')
-rw-r--r-- | Source/WebCore/editing/BreakBlockquoteCommand.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/Source/WebCore/editing/BreakBlockquoteCommand.cpp b/Source/WebCore/editing/BreakBlockquoteCommand.cpp index d3639398a..358cccdeb 100644 --- a/Source/WebCore/editing/BreakBlockquoteCommand.cpp +++ b/Source/WebCore/editing/BreakBlockquoteCommand.cpp @@ -126,7 +126,7 @@ void BreakBlockquoteCommand::doApply() } // Build up list of ancestors in between the start node and the top blockquote. - Vector<Element*> ancestors; + Vector<RefPtr<Element> > ancestors; for (Element* node = startNode->parentElement(); node && node != topBlockquote; node = node->parentElement()) ancestors.append(node); @@ -143,7 +143,7 @@ void BreakBlockquoteCommand::doApply() RefPtr<Element> clonedChild = ancestors[i - 1]->cloneElementWithoutChildren(); // Preserve list item numbering in cloned lists. if (clonedChild->isElementNode() && clonedChild->hasTagName(olTag)) { - Node* listChildNode = i > 1 ? ancestors[i - 2] : startNode; + Node* listChildNode = i > 1 ? ancestors[i - 2].get() : startNode; // The first child of the cloned list might not be a list item element, // find the first one so that we know where to start numbering. while (listChildNode && !listChildNode->hasTagName(liTag)) @@ -155,37 +155,23 @@ void BreakBlockquoteCommand::doApply() appendNode(clonedChild.get(), clonedAncestor.get()); clonedAncestor = clonedChild; } - - // Move the startNode and its siblings. - Node *moveNode = startNode; - while (moveNode) { - Node *next = moveNode->nextSibling(); - removeNode(moveNode); - appendNode(moveNode, clonedAncestor.get()); - moveNode = next; - } + + moveRemainingSiblingsToNewParent(startNode, 0, clonedAncestor); if (!ancestors.isEmpty()) { // Split the tree up the ancestor chain until the topBlockquote // Throughout this loop, clonedParent is the clone of ancestor's parent. // This is so we can clone ancestor's siblings and place the clones // into the clone corresponding to the ancestor's parent. - Element* ancestor; - Element* clonedParent; + RefPtr<Element> ancestor; + RefPtr<Element> clonedParent; for (ancestor = ancestors.first(), clonedParent = clonedAncestor->parentElement(); ancestor && ancestor != topBlockquote; - ancestor = ancestor->parentElement(), clonedParent = clonedParent->parentElement()) { - moveNode = ancestor->nextSibling(); - while (moveNode) { - Node *next = moveNode->nextSibling(); - removeNode(moveNode); - appendNode(moveNode, clonedParent); - moveNode = next; - } - } - + ancestor = ancestor->parentElement(), clonedParent = clonedParent->parentElement()) + moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedParent); + // If the startNode's original parent is now empty, remove it - Node* originalParent = ancestors.first(); + Node* originalParent = ancestors.first().get(); if (!originalParent->hasChildNodes()) removeNode(originalParent); } |