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

Unified Diff: third_party/WebKit/Source/core/events/InputEvent.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: dtapuska's review, also add layout tests 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/events/InputEvent.cpp
diff --git a/third_party/WebKit/Source/core/events/InputEvent.cpp b/third_party/WebKit/Source/core/events/InputEvent.cpp
index f7eb07a65d040c9cb0071ccc8a29dc660983bf09..5ace994f4b4bceafe3e1c958655d7bd3026dcefe 100644
--- a/third_party/WebKit/Source/core/events/InputEvent.cpp
+++ b/third_party/WebKit/Source/core/events/InputEvent.cpp
@@ -15,6 +15,36 @@ InputEvent::InputEvent()
InputEvent::InputEvent(const AtomicString& type, const InputEventInit& initializer)
: UIEvent(type, initializer)
{
+ if (initializer.hasInputType())
+ m_inputType = initializer.inputType();
+ if (initializer.hasData())
+ m_data = initializer.data();
+}
+
+/* static */
+PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createBeforeInput(const String& inputType, const String& data)
+{
+ InputEventInit inputEventInit;
+
+ inputEventInit.setBubbles(true);
+ inputEventInit.setCancelable(false);
+ inputEventInit.setInputType(inputType);
+ inputEventInit.setData(data);
+
+ return InputEvent::create(EventTypeNames::beforeinput, inputEventInit);
+}
+
+/* static */
+PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createCancelableBeforeInput(const String& inputType, const String& data)
+{
+ InputEventInit inputEventInit;
+
+ inputEventInit.setBubbles(true);
+ inputEventInit.setCancelable(true);
+ inputEventInit.setInputType(inputType);
+ inputEventInit.setData(data);
+
+ return InputEvent::create(EventTypeNames::beforeinput, inputEventInit);
}
bool InputEvent::isInputEvent() const

Powered by Google App Engine
This is Rietveld 408576698