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

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

Issue 113663003: Keep br while replacing plain texts with content ending with newline (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test case for paste newline in a all selected textarea Created 7 years 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/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index 5b7939ef51b9433aab5a09051892b28cd4dab46e..c2109e940290cefc4217ca1adc601bc70e1e2208 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -1126,12 +1126,15 @@ void ReplaceSelectionCommand::doApply()
insertNodeAt(createBreakElement(document()).get(), startOfInsertedContent.deepEquivalent());
if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR))) {
- RefPtr<Node> parent = endBR->parentNode();
- insertedNodes.willRemoveNode(*endBR);
- removeNode(endBR);
- if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
- insertedNodes.willRemoveNode(*nodeToRemove);
- removeNode(nodeToRemove);
+ // Don't remove br if we are replacing plain texts with content ending with newline
+ if (!(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)) {
yosin_UTC9 2013/12/20 01:23:06 nit: Please merge L1130 condition into L1129.
+ RefPtr<Node> parent = endBR->parentNode();
+ insertedNodes.willRemoveNode(*endBR);
+ removeNode(endBR);
+ if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
+ insertedNodes.willRemoveNode(*nodeToRemove);
+ removeNode(nodeToRemove);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698