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 95dc7b50921f3e8563b96b76fdf118ff09d76186..3efdb69b40d6408913957f2a0708c8b4ed713fa6 100644 |
--- a/third_party/WebKit/Source/core/events/InputEvent.cpp |
+++ b/third_party/WebKit/Source/core/events/InputEvent.cpp |
@@ -16,13 +16,14 @@ const struct { |
InputEvent::InputType inputType; |
const char* stringName; |
} kInputTypeStringNameMap[] = { |
- {InputEvent::InputType::None, ""}, |
- {InputEvent::InputType::InsertText, "insertText"}, |
- {InputEvent::InputType::ReplaceContent, "replaceContent"}, |
- {InputEvent::InputType::DeleteContent, "deleteContent"}, |
- {InputEvent::InputType::DeleteComposedCharacter, "deleteComposedCharacter"}, |
- {InputEvent::InputType::Undo, "undo"}, |
- {InputEvent::InputType::Redo, "redo"}, |
+ { InputEvent::InputType::None, "" }, |
+ { InputEvent::InputType::InsertText, "insertText" }, |
+ { InputEvent::InputType::ReplaceContent, "replaceContent" }, |
+ { InputEvent::InputType::DeleteContent, "deleteContent" }, |
+ { InputEvent::InputType::DeleteComposedCharacter, "deleteComposedCharacter" }, |
+ { InputEvent::InputType::Undo, "undo" }, |
+ { InputEvent::InputType::Redo, "redo" }, |
+ { InputEvent::InputType::Bold, "bold" }, |
}; |
static_assert(arraysize(kInputTypeStringNameMap) == static_cast<size_t>(InputEvent::InputType::NumberOfInputTypes), |
@@ -85,6 +86,24 @@ InputEvent* InputEvent::createBeforeInput(InputType inputType, const String& dat |
return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); |
} |
+/* static */ |
+InputEvent* InputEvent::createInput(InputType inputType, const String& data, EventIsComposing isComposing, const RangeVector* ranges) |
+{ |
+ InputEventInit inputEventInit; |
+ |
+ inputEventInit.setBubbles(true); |
+ inputEventInit.setCancelable(false); |
+ // TODO(ojan): We should find a way to prevent conversion like String->enum->String just in order to use initializer. |
tkent
2016/06/22 06:53:21
why ojan?
chongz
2016/06/23 00:32:06
This is the similar issue as in |InputEvent::creat
|
+ // See InputEvent::InputEvent() for the second conversion. |
+ inputEventInit.setInputType(convertInputTypeToString(inputType)); |
+ inputEventInit.setData(data); |
+ inputEventInit.setIsComposing(isComposing == IsComposing); |
+ if (ranges) |
+ inputEventInit.setRanges(*ranges); |
+ |
+ return InputEvent::create(EventTypeNames::input, inputEventInit); |
+} |
+ |
String InputEvent::inputType() const |
{ |
return convertInputTypeToString(m_inputType); |