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

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

Issue 1780413002: Editing: Skip TestRendering in ReplaceSelectionCommand if the editing host is plain-text editable a… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: accept only last interchangenewline 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/Source/core/editing/commands/CompositeEditCommand.cpp ('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 d9fce93cb4e0287efdb0195fa6061f18d8865a78..a521d6fb7e4eb21fd182355703a05b4d55387d9d 100644
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -176,6 +176,30 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
return;
}
+ if (!editableRoot->layoutObjectIsRichlyEditable()) {
+ bool isPlainText = true;
+ for (Node& node : NodeTraversal::childrenOf(*m_fragment)) {
+ if (isInterchangeHTMLBRElement(&node) && &node == m_fragment->lastChild())
+ continue;
+ if (!node.isTextNode()) {
+ isPlainText = false;
+ break;
+ }
+ }
+ // We don't need TestRendering for plain-text editing + plain-text insertion.
+ if (isPlainText) {
+ removeInterchangeNodes(m_fragment.get());
+ String originalText = m_fragment->textContent();
+ RefPtrWillBeRawPtr<BeforeTextInsertedEvent> event = BeforeTextInsertedEvent::create(originalText);
+ editableRoot->dispatchEvent(event);
+ if (originalText != event->text()) {
+ m_fragment = createFragmentFromText(selection.toNormalizedEphemeralRange(), event->text());
+ removeInterchangeNodes(m_fragment.get());
+ }
+ return;
+ }
+ }
+
RefPtrWillBeRawPtr<HTMLElement> holder = insertFragmentForTestRendering(editableRoot.get());
if (!holder) {
removeInterchangeNodes(m_fragment.get());
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698