Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/events/InputEvent.h" | 5 #include "core/events/InputEvent.h" |
| 6 | 6 |
| 7 #include "core/events/EventDispatcher.h" | 7 #include "core/events/EventDispatcher.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 namespace { | |
| 12 | |
| 13 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.
| |
| 14 { | |
| 15 switch (inputType) { | |
| 16 case InputEvent::InputType::InsertText: | |
| 17 return "insertText"; | |
| 18 case InputEvent::InputType::ReplaceText: | |
| 19 return "replaceText"; | |
| 20 } | |
| 21 ASSERT_NOT_REACHED(); | |
| 22 return ""; | |
| 23 } | |
| 24 | |
| 25 } // anonymous namespace | |
| 26 | |
| 11 InputEvent::InputEvent() | 27 InputEvent::InputEvent() |
| 12 { | 28 { |
| 13 } | 29 } |
| 14 | 30 |
| 15 InputEvent::InputEvent(const AtomicString& type, const InputEventInit& initializ er) | 31 InputEvent::InputEvent(const AtomicString& type, const InputEventInit& initializ er) |
| 16 : UIEvent(type, initializer) | 32 : UIEvent(type, initializer) |
| 17 { | 33 { |
| 34 if (initializer.hasInputType()) | |
| 35 m_inputType = initializer.inputType(); | |
| 36 if (initializer.hasData()) | |
| 37 m_data = initializer.data(); | |
| 38 } | |
| 39 | |
| 40 /* static */ | |
| 41 PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createBeforeInputTyping(InputType inputType, const String& data) | |
| 42 { | |
| 43 InputEventInit inputEventInit; | |
| 44 | |
| 45 inputEventInit.setBubbles(true); | |
| 46 inputEventInit.setCancelable(true); | |
| 47 inputEventInit.setInputType(InputTypeToString(inputType)); | |
| 48 inputEventInit.setData(data); | |
| 49 | |
| 50 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); | |
| 51 } | |
| 52 | |
| 53 /* static */ | |
| 54 PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createBeforeInputCompositionUpdat e(InputType inputType, const String& data) | |
| 55 { | |
| 56 InputEventInit inputEventInit; | |
| 57 | |
| 58 inputEventInit.setBubbles(true); | |
| 59 inputEventInit.setCancelable(false); | |
| 60 inputEventInit.setInputType(InputTypeToString(inputType)); | |
| 61 inputEventInit.setData(data); | |
| 62 | |
| 63 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); | |
| 64 } | |
| 65 | |
| 66 /* static */ | |
| 67 PassRefPtrWillBeRawPtr<InputEvent> InputEvent::createBeforeInputEditorCommand(co nst String& commandName, const String& data) | |
| 68 { | |
| 69 InputEventInit inputEventInit; | |
| 70 | |
| 71 inputEventInit.setBubbles(true); | |
| 72 inputEventInit.setCancelable(true); | |
| 73 inputEventInit.setInputType(commandName); | |
| 74 inputEventInit.setData(data); | |
| 75 | |
| 76 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); | |
| 18 } | 77 } |
| 19 | 78 |
| 20 bool InputEvent::isInputEvent() const | 79 bool InputEvent::isInputEvent() const |
| 21 { | 80 { |
| 22 return true; | 81 return true; |
| 23 } | 82 } |
| 24 | 83 |
| 25 DEFINE_TRACE(InputEvent) | 84 DEFINE_TRACE(InputEvent) |
| 26 { | 85 { |
| 27 UIEvent::trace(visitor); | 86 UIEvent::trace(visitor); |
| 28 } | 87 } |
| 29 | 88 |
| 30 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |