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

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

Issue 18644008: Avoid adding placeholder when deleting last text in root (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
Index: Source/core/editing/CompositeEditCommand.cpp
diff --git a/Source/core/editing/CompositeEditCommand.cpp b/Source/core/editing/CompositeEditCommand.cpp
index c95f16a816d187a377d631ee143b0790b6b0d3de..9c1cfe897bcf573bd6a7827804664ced48026bf5 100644
--- a/Source/core/editing/CompositeEditCommand.cpp
+++ b/Source/core/editing/CompositeEditCommand.cpp
@@ -1050,14 +1050,20 @@ void CompositeEditCommand::cleanupAfterDeletion(VisiblePosition destination)
// Note: We want the rightmost candidate.
Position position = caretAfterDelete.deepEquivalent().downstream();
Node* node = position.deprecatedNode();
+
+ // Bail if we'd remove an ancestor of our destination.
yosin_UTC9 2013/07/12 01:55:28 Could you move this change in another CL? I think
+ if (destinationNode->isDescendantOf(node))
+ return;
+
// Normally deletion will leave a br as a placeholder.
- if (node->hasTagName(brTag))
+ if (node->hasTagName(brTag)) {
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
- // expects this behavior).
- else if (isBlock(node)) {
+
+ // 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
+ // expects this behavior).
+ } else if (isBlock(node)) {
// If caret position after deletion and destination position coincides,
// node should not be removed.
if (!position.rendersInDifferentPosition(destination.deepEquivalent())) {

Powered by Google App Engine
This is Rietveld 408576698