Chromium Code Reviews| Index: ppapi/cpp/input_event.cc |
| diff --git a/ppapi/cpp/input_event.cc b/ppapi/cpp/input_event.cc |
| index 1f368b07c04f6be7c9068bf5daf4892bcf37651d..bf6e95ee4c552870784d7de75a2e855fc0286a5b 100644 |
| --- a/ppapi/cpp/input_event.cc |
| +++ b/ppapi/cpp/input_event.cc |
| @@ -35,6 +35,10 @@ template <> const char* interface_name<PPB_TouchInputEvent_1_0>() { |
| return PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0; |
| } |
| +template <> const char* interface_name<PPB_IMEInputEvent_1_0>() { |
| + return PPB_IME_INPUT_EVENT_INTERFACE_1_0; |
| +} |
| + |
| } // namespace |
| // InputEvent ------------------------------------------------------------------ |
| @@ -280,4 +284,85 @@ TouchPoint TouchInputEvent::GetTouchByIndex(PP_TouchListType list, |
| GetTouchByIndex(pp_resource(), list, index)); |
| } |
| +// IMEInputEvent ------------------------------------------------------- |
| + |
| +IMEInputEvent::IMEInputEvent() : InputEvent() { |
| +} |
| + |
| +IMEInputEvent::IMEInputEvent(const InputEvent& event) : InputEvent() { |
| + bool is_ime_event = false; |
| + if (has_interface<PPB_IMEInputEvent_1_0>()) { |
| + if (get_interface<PPB_IMEInputEvent_1_0>()->IsIMEInputEvent( |
| + event.pp_resource())) { |
|
dmichael (off chromium)
2013/07/25 22:08:14
nit: I think this should be indented 4 more spaces
Seigo Nonaka
2013/07/26 17:40:41
Done.
|
| + is_ime_event = true; |
| + } |
| + } |
| + if (is_ime_event) { |
|
dmichael (off chromium)
2013/07/25 22:08:14
Why do this instead of just putting the AddRefReso
Seigo Nonaka
2013/07/26 17:40:41
Sorry this weird code was introduced when I move f
|
| + Module::Get()->core()->AddRefResource(event.pp_resource()); |
| + PassRefFromConstructor(event.pp_resource()); |
| + } |
| +} |
| + |
| +IMEInputEvent::IMEInputEvent( |
| + const InstanceHandle& instance, |
| + PP_InputEvent_Type type, |
| + PP_TimeTicks time_stamp, |
| + const Var& text, |
| + const std::vector<uint32_t>& segment_offsets, |
| + int32_t target_segment, |
| + const std::pair<uint32_t, uint32_t>& selection) : InputEvent() { |
| + if (!has_interface<PPB_IMEInputEvent_1_0>()) |
| + return; |
| + uint32_t dummy = 0; |
| + PassRefFromConstructor(get_interface<PPB_IMEInputEvent_1_0>()->Create( |
| + instance.pp_instance(), type, time_stamp, text.pp_var(), |
| + segment_offsets.empty() ? 0 : segment_offsets.size() - 1, |
| + segment_offsets.empty() ? &dummy : &segment_offsets[0], |
| + target_segment, selection.first, selection.second)); |
| +} |
| + |
| + |
| +Var IMEInputEvent::GetText() const { |
| + if (has_interface<PPB_IMEInputEvent_1_0>()) { |
| + return Var(PASS_REF, |
| + get_interface<PPB_IMEInputEvent_1_0>()->GetText( |
| + pp_resource())); |
| + } |
| + return Var(); |
| +} |
| + |
| +uint32_t IMEInputEvent::GetSegmentNumber() const { |
| + if (has_interface<PPB_IMEInputEvent_1_0>()) { |
| + return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentNumber( |
| + pp_resource()); |
| + } |
| + return 0; |
| +} |
| + |
| +uint32_t IMEInputEvent::GetSegmentOffset(uint32_t index) const { |
| + if (has_interface<PPB_IMEInputEvent_1_0>()) { |
| + return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentOffset( |
| + pp_resource(), index); |
| + } |
| + return 0; |
| +} |
| + |
| +int32_t IMEInputEvent::GetTargetSegment() const { |
| + if (has_interface<PPB_IMEInputEvent_1_0>()) { |
| + return get_interface<PPB_IMEInputEvent_1_0>()->GetTargetSegment( |
| + pp_resource()); |
| + } |
| + return 0; |
| +} |
| + |
| +std::pair<uint32_t, uint32_t> IMEInputEvent::GetSelection() const { |
| + std::pair<uint32_t, uint32_t> range(0, 0); |
| + if (has_interface<PPB_IMEInputEvent_1_0>()) { |
| + get_interface<PPB_IMEInputEvent_1_0>()->GetSelection(pp_resource(), |
| + &range.first, |
| + &range.second); |
| + } |
| + return range; |
| +} |
| + |
| } // namespace pp |