Chromium Code Reviews| 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..35ccafae25b049189f26c58030f467885570c785 100644 |
| --- a/third_party/WebKit/Source/core/events/InputEvent.cpp |
| +++ b/third_party/WebKit/Source/core/events/InputEvent.cpp |
| @@ -8,6 +8,22 @@ |
| namespace blink { |
| +namespace { |
| + |
| +String InputTypeToString(InputEvent::InputType inputType) |
|
chongz
2016/03/15 19:19:10
Cannot do |InputType m_inputType| because I need t
yosin_UTC9
2016/03/16 01:46:51
|inputType| doesn't hold a command name rather it
yosin_UTC9
2016/03/16 01:51:10
|inputType| is still in discussion, https://github
chongz
2016/03/16 21:51:44
Ok, I also found a list here and I'm not sure whic
yosin_UTC9
2016/03/17 01:52:23
Make sense. Start with well defined one then expan
ojan
2016/03/17 18:12:59
Using strings for code logic is definitely bad and
ojan
2016/03/17 18:21:10
Oh, I see, you added shouldFireInputEvent. For now
chongz
2016/04/13 00:34:28
Done.
|
| +{ |
| + switch (inputType) { |
| + case InputEvent::InputType::InsertText: |
| + return "insertText"; |
| + case InputEvent::InputType::ReplaceText: |
| + return "replaceText"; |
| + } |
| + ASSERT_NOT_REACHED(); |
| + return ""; |
| +} |
| + |
| +} // anonymous namespace |
| + |
| InputEvent::InputEvent() |
| { |
| } |
| @@ -15,6 +31,49 @@ 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::createBeforeInputTyping(InputType inputType, const String& data) |
| +{ |
| + InputEventInit inputEventInit; |
| + |
| + inputEventInit.setBubbles(true); |
| + inputEventInit.setCancelable(true); |
| + inputEventInit.setInputType(InputTypeToString(inputType)); |
| + inputEventInit.setData(data); |
| + |
| + return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); |
| +} |
| + |
| +/* static */ |
| +PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createBeforeInputCompositionUpdate(InputType inputType, const String& data) |
| +{ |
| + InputEventInit inputEventInit; |
| + |
| + inputEventInit.setBubbles(true); |
| + inputEventInit.setCancelable(false); |
| + inputEventInit.setInputType(InputTypeToString(inputType)); |
| + inputEventInit.setData(data); |
| + |
| + return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); |
| +} |
| + |
| +/* static */ |
| +PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createBeforeInputEditorCommand(const String& commandName, const String& data) |
| +{ |
| + InputEventInit inputEventInit; |
| + |
| + inputEventInit.setBubbles(true); |
| + inputEventInit.setCancelable(true); |
| + inputEventInit.setInputType(commandName); |
| + inputEventInit.setData(data); |
| + |
| + return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); |
| } |
| bool InputEvent::isInputEvent() const |