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

Unified Diff: third_party/WebKit/Source/core/editing/EditingUtilities.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/editing/EditingUtilities.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
index fed03353f55ed4fa03b8f0b67ffc02d2b62934ef..ec5d02b531d951e17b83816cc01684a65a1d86fd 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -41,6 +41,7 @@
#include "core/editing/VisibleUnits.h"
#include "core/editing/iterators/TextIterator.h"
#include "core/editing/serializers/HTMLInterchange.h"
+#include "core/events/InputEvent.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLBRElement.h"
@@ -1652,4 +1653,33 @@ bool isTextSecurityNode(const Node* node)
return node && node->layoutObject() && node->layoutObject()->style()->textSecurity() != TSNONE;
}
+DispatchEventResult dispatchBeforeInputInsertText(EventTarget* target, const String& data)
+{
+ static const char* kInputTypeInsertText = "insertText";
yosin_UTC9 2016/03/15 08:32:32 Could you move |kInputTypeXXX| into "InputEvent.h"
+ return dispatchBeforeInputEditorCommand(target, kInputTypeInsertText, data);
+}
+
+DispatchEventResult dispatchBeforeInputEditorCommand(EventTarget* target, const char* commandName, const String& data)
+{
+ if (RuntimeEnabledFeatures::inputEventEnabled()) {
+ if (target) {
+ RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createCancelableBeforeInput(commandName, data);
+ return target->dispatchEvent(beforeInputEvent);
+ }
+ }
+ return DispatchEventResult::NotCanceled;
+}
+
+DispatchEventResult dispatchBeforeInputCompositionUpdate(EventTarget* target, const String& data)
+{
+ if (RuntimeEnabledFeatures::inputEventEnabled()) {
+ if (target) {
+ static const char* kInputTypeReplaceText = "replaceText";
+ RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createBeforeInput(kInputTypeReplaceText, data);
chongz 2016/03/04 19:46:50 I'm not so sure about the inputType we want to use
+ return target->dispatchEvent(beforeInputEvent);
+ }
+ }
+ return DispatchEventResult::NotCanceled;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698