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

Unified Diff: third_party/WebKit/Source/core/editing/serializers/Serialization.cpp

Issue 1776913002: Do not produce BR elements on pasting plain text in TEXTAREA (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-nowrap-paste-eol-expected.txt ('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/serializers/Serialization.cpp
diff --git a/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp b/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp
index 98af5bdb7dd95ea101545e7ff4c84edb266e1e7b..173e4a4ef1d6b62a6f11e8e2ef32aa8dec696ded 100644
--- a/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp
+++ b/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp
@@ -467,7 +467,7 @@ PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromText(const EphemeralR
string.replace("\r\n", "\n");
string.replace('\r', '\n');
- if (shouldPreserveNewline(context)) {
+ if (!isRichlyEditablePosition(context.startPosition()) || shouldPreserveNewline(context)) {
fragment->appendChild(document.createTextNode(string));
if (string.endsWith('\n')) {
RefPtrWillBeRawPtr<HTMLBRElement> element = HTMLBRElement::create(document);
@@ -489,7 +489,6 @@ PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromText(const EphemeralR
&& !isHTMLBodyElement(*block)
&& !isHTMLHtmlElement(*block)
&& block != rootEditableElementOf(context.startPosition());
- bool useLineBreak = enclosingTextFormControl(context.startPosition());
Vector<String> list;
string.split('\n', true, list); // true gets us empty strings in the list
@@ -502,9 +501,6 @@ PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromText(const EphemeralR
// For last line, use the "magic BR" rather than a P.
element = HTMLBRElement::create(document);
element->setAttribute(classAttr, AppleInterchangeNewline);
- } else if (useLineBreak) {
- element = HTMLBRElement::create(document);
- fillContainerFromString(fragment.get(), s);
} else {
if (useClonesOfEnclosingBlock)
element = block->cloneElementWithoutChildren();
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/textarea/textarea-nowrap-paste-eol-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698