Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: Source/core/editing/CompositeEditCommand.cpp

Issue 16053005: Avoid removing destination during moving paragrahs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-07-11T15:13:49 Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/CompositeEditCommand.h ('k') | Source/core/editing/htmlediting.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/CompositeEditCommand.cpp
diff --git a/Source/core/editing/CompositeEditCommand.cpp b/Source/core/editing/CompositeEditCommand.cpp
index 17d3111a78db8ebe6e8bb12d19817a154ac695c7..c95f16a816d187a377d631ee143b0790b6b0d3de 100644
--- a/Source/core/editing/CompositeEditCommand.cpp
+++ b/Source/core/editing/CompositeEditCommand.cpp
@@ -393,11 +393,12 @@ void CompositeEditCommand::removeNodePreservingChildren(PassRefPtr<Node> node, S
applyCommandToComposite(RemoveNodePreservingChildrenCommand::create(node, shouldAssumeContentIsAlwaysEditable));
}
-void CompositeEditCommand::removeNodeAndPruneAncestors(PassRefPtr<Node> node)
+void CompositeEditCommand::removeNodeAndPruneAncestors(PassRefPtr<Node> node, Node* excludeNode)
{
+ ASSERT(node.get() != excludeNode);
RefPtr<ContainerNode> parent = node->parentNode();
removeNode(node);
- prune(parent.release());
+ prune(parent.release(), excludeNode);
}
void CompositeEditCommand::moveRemainingSiblingsToNewParent(Node* node, Node* pastLastNodeToMove, PassRefPtr<Element> prpNewParent)
@@ -436,9 +437,9 @@ HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAt
return command->spanElement();
}
-void CompositeEditCommand::prune(PassRefPtr<Node> node)
+void CompositeEditCommand::prune(PassRefPtr<Node> node, Node* excludeNode)
{
- if (RefPtr<Node> highestNodeToRemove = highestNodeToRemoveInPruning(node.get()))
+ if (RefPtr<Node> highestNodeToRemove = highestNodeToRemoveInPruning(node.get(), excludeNode))
removeNode(highestNodeToRemove.release());
}
@@ -1044,13 +1045,14 @@ void CompositeEditCommand::cloneParagraphUnderNewElement(Position& start, Positi
void CompositeEditCommand::cleanupAfterDeletion(VisiblePosition destination)
{
VisiblePosition caretAfterDelete = endingSelection().visibleStart();
+ Node* destinationNode = destination.deepEquivalent().anchorNode();
if (caretAfterDelete != destination && isStartOfParagraph(caretAfterDelete) && isEndOfParagraph(caretAfterDelete)) {
// Note: We want the rightmost candidate.
Position position = caretAfterDelete.deepEquivalent().downstream();
Node* node = position.deprecatedNode();
// Normally deletion will leave a br as a placeholder.
if (node->hasTagName(brTag))
- removeNodeAndPruneAncestors(node);
+ removeNodeAndPruneAncestors(node, destinationNode);
// If the selection to move was empty and in an empty block that
// doesn't require a placeholder to prop itself open (like a bordered
// div or an li), remove it during the move (the list removal code
@@ -1059,17 +1061,17 @@ void CompositeEditCommand::cleanupAfterDeletion(VisiblePosition destination)
// If caret position after deletion and destination position coincides,
// node should not be removed.
if (!position.rendersInDifferentPosition(destination.deepEquivalent())) {
- prune(node);
+ prune(node, destinationNode);
return;
}
- removeNodeAndPruneAncestors(node);
+ removeNodeAndPruneAncestors(node, destinationNode);
}
else if (lineBreakExistsAtPosition(position)) {
// There is a preserved '\n' at caretAfterDelete.
// We can safely assume this is a text node.
Text* textNode = toText(node);
if (textNode->length() == 1)
- removeNodeAndPruneAncestors(node);
+ removeNodeAndPruneAncestors(node, destinationNode);
else
deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1);
}
« no previous file with comments | « Source/core/editing/CompositeEditCommand.h ('k') | Source/core/editing/htmlediting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698