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

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

Issue 1785603002: TEXTAREA: Cutting last line without EOL should not remove the remaining EOL in the previous line. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove an ASSERT, update a comment 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
Index: third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp
index 52210eb53ab2f01087665ea4242d85e097e08a13..44c6fd92e72a991fe899896183e4c44b6ba404ae 100644
--- a/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp
@@ -36,6 +36,7 @@
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLBRElement.h"
#include "core/html/HTMLElement.h"
+#include "core/html/HTMLTextFormControlElement.h"
#include "core/layout/LayoutObject.h"
#include "core/layout/LayoutText.h"
@@ -60,7 +61,7 @@ bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos)
// the input element, and in that case we need to check the input element's
// parent's layoutObject.
Position p(insertionPos.parentAnchoredEquivalent());
- return p.anchorNode()->layoutObject() && !p.anchorNode()->layoutObject()->style()->preserveNewline();
+ return isRichlyEditablePosition(p) && p.anchorNode()->layoutObject() && !p.anchorNode()->layoutObject()->style()->preserveNewline();
}
void InsertLineBreakCommand::doApply(EditingState* editingState)
@@ -102,9 +103,16 @@ void InsertLineBreakCommand::doApply(EditingState* editingState)
return;
if (needExtraLineBreak) {
- insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert, editingState);
+ RefPtrWillBeRawPtr<Node> extraNode;
+ // TODO(tkent): Can we remove HTMLTextFormControlElement dependency?
+ if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(nodeToInsert.get()))
+ extraNode = textControl->createPlaceholderBreakElement();
+ else
+ extraNode = nodeToInsert->cloneNode(false);
+ insertNodeAfter(extraNode.get(), nodeToInsert, editingState);
if (editingState->isAborted())
return;
+ nodeToInsert = extraNode.release();
}
VisiblePosition endingPosition = createVisiblePosition(positionBeforeNode(nodeToInsert.get()));

Powered by Google App Engine
This is Rietveld 408576698