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

Unified Diff: third_party/WebKit/Source/core/editing/commands/EditorCommand.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/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 240080bb55bfea13f1708e02bf9ba3cb23b7e199..aa82d5768d41eab1ee5ace76dcc5ba7d655e22b4 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -48,6 +48,7 @@
#include "core/editing/serializers/Serialization.h"
#include "core/editing/spellcheck/SpellChecker.h"
#include "core/events/Event.h"
+#include "core/events/InputEvent.h"
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
@@ -1779,6 +1780,16 @@ bool Editor::Command::execute(const String& parameter, Event* triggeringEvent) c
if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled)
return false;
}
+
+ if (RuntimeEnabledFeatures::inputEventEnabled()) {
+ if (EventTarget* target = eventTargetNodeForDocument(m_frame->document())) {
+ RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createBeforeInput("executeCommand", "");
chongz 2016/03/01 20:41:10 Didn't find a way to get command name from Editor:
dtapuska 2016/03/01 21:49:51 Ya I think you'd want to load it from the EditorIn
+ DispatchEventResult dispatchResult = target->dispatchEvent(beforeInputEvent);
+ if (dispatchResult != DispatchEventResult::NotCanceled)
+ return true;
+ }
+ }
+
frame().document()->updateLayoutIgnorePendingStylesheets();
DEFINE_STATIC_LOCAL(SparseHistogram, commandHistogram, ("WebCore.Editing.Commands"));
commandHistogram.sample(m_command->idForUserMetrics);

Powered by Google App Engine
This is Rietveld 408576698