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

Side by Side 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: remove wrongly name test file 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 if (insertionBlock && !insertionBlock->inDocument()) 1118 if (insertionBlock && !insertionBlock->inDocument())
1119 insertionBlock = 0; 1119 insertionBlock = 0;
1120 1120
1121 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted()); 1121 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted());
1122 1122
1123 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and 1123 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and
1124 // didn't have a br after it, so the inserted content ended up in the same p aragraph. 1124 // didn't have a br after it, so the inserted content ended up in the same p aragraph.
1125 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent)) 1125 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent))
1126 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent()); 1126 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent());
1127 1127
1128 if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBe foreEndBR))) { 1128 if (endBR && (plainTextFragment || (shouldRemoveEndBR(endBR, originalVisPosB eforeEndBR) && !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)) )) {
1129 RefPtr<Node> parent = endBR->parentNode(); 1129 RefPtr<Node> parent = endBR->parentNode();
1130 insertedNodes.willRemoveNode(*endBR); 1130 insertedNodes.willRemoveNode(*endBR);
1131 removeNode(endBR); 1131 removeNode(endBR);
1132 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) { 1132 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
1133 insertedNodes.willRemoveNode(*nodeToRemove); 1133 insertedNodes.willRemoveNode(*nodeToRemove);
1134 removeNode(nodeToRemove); 1134 removeNode(nodeToRemove);
1135 } 1135 }
1136 } 1136 }
1137 1137
1138 makeInsertedContentRoundTrippableWithHTMLTreeBuilder(insertedNodes); 1138 makeInsertedContentRoundTrippableWithHTMLTreeBuilder(insertedNodes);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1494 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1495 1495
1496 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1496 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1497 1497
1498 setEndingSelection(selectionAfterReplace); 1498 setEndingSelection(selectionAfterReplace);
1499 1499
1500 return true; 1500 return true;
1501 } 1501 }
1502 1502
1503 } // namespace WebCore 1503 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698