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

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: Use "" for html code Created 6 years, 11 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/editing/pasteboard/paste-newline-in-all-selected-textarea-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 if (insertionBlock && !insertionBlock->inDocument()) 1117 if (insertionBlock && !insertionBlock->inDocument())
1118 insertionBlock = 0; 1118 insertionBlock = 0;
1119 1119
1120 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted()); 1120 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted());
1121 1121
1122 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and 1122 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and
1123 // didn't have a br after it, so the inserted content ended up in the same p aragraph. 1123 // didn't have a br after it, so the inserted content ended up in the same p aragraph.
1124 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent)) 1124 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent))
1125 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent()); 1125 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent());
1126 1126
1127 if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBe foreEndBR))) { 1127 if (endBR && (plainTextFragment || (shouldRemoveEndBR(endBR, originalVisPosB eforeEndBR) && !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)) )) {
1128 RefPtr<Node> parent = endBR->parentNode(); 1128 RefPtr<Node> parent = endBR->parentNode();
1129 insertedNodes.willRemoveNode(*endBR); 1129 insertedNodes.willRemoveNode(*endBR);
1130 removeNode(endBR); 1130 removeNode(endBR);
1131 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) { 1131 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
1132 insertedNodes.willRemoveNode(*nodeToRemove); 1132 insertedNodes.willRemoveNode(*nodeToRemove);
1133 removeNode(nodeToRemove); 1133 removeNode(nodeToRemove);
1134 } 1134 }
1135 } 1135 }
1136 1136
1137 makeInsertedContentRoundTrippableWithHTMLTreeBuilder(insertedNodes); 1137 makeInsertedContentRoundTrippableWithHTMLTreeBuilder(insertedNodes);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1493 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1494 1494
1495 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1495 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1496 1496
1497 setEndingSelection(selectionAfterReplace); 1497 setEndingSelection(selectionAfterReplace);
1498 1498
1499 return true; 1499 return true;
1500 } 1500 }
1501 1501
1502 } // namespace WebCore 1502 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/pasteboard/paste-newline-in-all-selected-textarea-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698