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

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

Issue 2738953003: [InputEvent] Support 'insertFromYank' for macOS (Closed)
Patch Set: yosin's review: Only implement yank Created 3 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/EditorCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
index 478c8b7fccde663f9bbb365f8b1a32b4f2aac3e0..43943aafafc7c621b82a5e19337b355ac8973f41 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -1805,8 +1805,23 @@ static bool executeYank(LocalFrame& frame,
Event*,
EditorCommandSource,
const String&) {
+ const String& yankString = frame.editor().killRing().yank();
+ if (dispatchBeforeInputInsertText(
+ eventTargetNodeForDocument(frame.document()), yankString,
+ InputEvent::InputType::InsertFromYank) !=
+ DispatchEventResult::NotCanceled)
+ return true;
+
+ // 'beforeinput' event handler may destroy document.
+ if (frame.document()->frame() != &frame)
+ return false;
+
+ // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
+ // needs to be audited. see http://crbug.com/590369 for more details.
+ frame.document()->updateStyleAndLayoutIgnorePendingStylesheets();
+
frame.editor().insertTextWithoutSendingTextEvent(
- frame.editor().killRing().yank(), false, 0);
+ yankString, false, 0, InputEvent::InputType::InsertFromYank);
frame.editor().killRing().setToYankedState();
return true;
}
@@ -1815,8 +1830,24 @@ static bool executeYankAndSelect(LocalFrame& frame,
Event*,
EditorCommandSource,
const String&) {
+ const String& yankString = frame.editor().killRing().yank();
+ if (dispatchBeforeInputInsertText(
+ eventTargetNodeForDocument(frame.document()), yankString,
+ InputEvent::InputType::InsertFromYank) !=
+ DispatchEventResult::NotCanceled)
+ return true;
+
+ // 'beforeinput' event handler may destroy document.
+ if (frame.document()->frame() != &frame)
+ return false;
+
+ // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
+ // needs to be audited. see http://crbug.com/590369 for more details.
+ frame.document()->updateStyleAndLayoutIgnorePendingStylesheets();
+
frame.editor().insertTextWithoutSendingTextEvent(
- frame.editor().killRing().yank(), true, 0);
+ frame.editor().killRing().yank(), true, 0,
+ InputEvent::InputType::InsertFromYank);
frame.editor().killRing().setToYankedState();
return true;
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | third_party/WebKit/Source/core/editing/commands/TypingCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698