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

Unified Diff: third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp

Issue 1752933002: [InputEvent] Fire 'beforeinput' during typing, pressing hot keys and IME composition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/EditorKeyBindings.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp b/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
index 5b7dd0e1a3e4376187624a221a4a81cb560c1320..48708180e3489c23bddee971e11f990ed318916e 100644
--- a/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
+++ b/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
@@ -26,6 +26,7 @@
#include "core/editing/Editor.h"
+#include "core/events/InputEvent.h"
#include "core/events/KeyboardEvent.h"
#include "core/frame/LocalFrame.h"
#include "core/page/EditorClient.h"
@@ -60,6 +61,15 @@ bool Editor::handleEditingKeyboardEvent(KeyboardEvent* evt)
if (!behavior().shouldInsertCharacter(*evt) || !canEdit())
return false;
+ if (RuntimeEnabledFeatures::inputEventEnabled()) {
+ if (EventTarget* target = evt->target()) {
+ RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createBeforeInput("insertText", evt->keyEvent()->text());
chongz 2016/03/01 20:41:10 Will replace "insertText" with constant command na
dtapuska 2016/03/01 21:49:51 you can likely store the atomic string in a static
+ DispatchEventResult dispatchResult = target->dispatchEvent(beforeInputEvent);
+ if (dispatchResult != DispatchEventResult::NotCanceled)
+ return true;
dtapuska 2016/03/01 21:49:51 I'm not certain returning true here is correct. As
chongz 2016/03/04 19:46:50 To my understanding the return value here should b
+ }
+ }
+
return insertText(evt->keyEvent()->text(), evt);
}

Powered by Google App Engine
This is Rietveld 408576698