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

Unified Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp

Issue 1809033002: Pasting \n into an empty TEXTAREA should set the caret after the \n. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « third_party/WebKit/LayoutTests/fast/forms/textarea/textarea-paste-newline.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
index 23f606a43b9af5bcd6e86e3895515c768d2e4559..ad72342c92d7fc2d2736fa2d0cc30a4b62a8e180 100644
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -1329,7 +1329,16 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState)
VisiblePosition next = nextPositionOf(endOfInsertedContent, CannotCrossEditingBoundary);
if (selectionEndWasEndOfParagraph || !isEndOfParagraph(endOfInsertedContent) || next.isNull()) {
- if (!isStartOfParagraph(endOfInsertedContent)) {
+ if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(currentRoot)) {
+ if (!insertedNodes.lastLeafInserted()->nextSibling()) {
+ insertNodeAfter(textControl->createPlaceholderBreakElement(), insertedNodes.lastLeafInserted(), editingState);
+ if (editingState->isAborted())
+ return;
+ }
+ setEndingSelection(createVisiblePosition(positionAfterNode(insertedNodes.lastLeafInserted())));
+ // Select up to the paragraph separator that was added.
+ lastPositionToSelect = endingSelection().visibleStart().deepEquivalent();
+ } else if (!isStartOfParagraph(endOfInsertedContent)) {
setEndingSelection(endOfInsertedContent);
Element* enclosingBlockElement = enclosingBlock(endOfInsertedContent.deepEquivalent().anchorNode());
if (isListItem(enclosingBlockElement)) {
@@ -1338,11 +1347,6 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState)
if (editingState->isAborted())
return;
setEndingSelection(createVisiblePosition(firstPositionInNode(newListItem.get())));
- } else if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(enclosingBlockElement)) {
- insertNodeAfter(textControl->createPlaceholderBreakElement(), insertedNodes.lastLeafInserted(), editingState);
- if (editingState->isAborted())
- return;
- setEndingSelection(createVisiblePosition(positionAfterNode(insertedNodes.lastLeafInserted())));
} else {
// Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph
// block's style seems to annoy users.
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/textarea/textarea-paste-newline.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698