Chromium Code Reviews| Index: ppapi/cpp/input_event.cc |
| diff --git a/ppapi/cpp/input_event.cc b/ppapi/cpp/input_event.cc |
| index 632b1eccd93652f9f15e227e28bb9fdbf342756c..06423a731549f48f5717a129b78c7073c57a6477 100644 |
| --- a/ppapi/cpp/input_event.cc |
| +++ b/ppapi/cpp/input_event.cc |
| @@ -30,6 +30,10 @@ template <> const char* interface_name<PPB_WheelInputEvent>() { |
| return PPB_WHEEL_INPUT_EVENT_INTERFACE; |
| } |
| +template <> const char* interface_name<PPB_CompositionInputEvent>() { |
| + return PPB_COMPOSITION_INPUT_EVENT_INTERFACE; |
| +} |
| + |
| } // namespace |
| // InputEvent ------------------------------------------------------------------ |
| @@ -218,4 +222,63 @@ Var KeyboardInputEvent::GetCharacterText() const { |
| pp_resource())); |
| } |
| +// CompositionInputEvent ------------------------------------------------------- |
| + |
| +CompositionInputEvent::CompositionInputEvent() : InputEvent() { |
| +} |
| + |
| +CompositionInputEvent::CompositionInputEvent(const InputEvent& event) |
| + : InputEvent() { |
|
yzshen1
2011/09/13 06:28:34
Wrong indent.
kinaba
2011/09/13 09:29:01
Done.
|
| + // Type check the input event before setting it. |
| + if (!has_interface<PPB_CompositionInputEvent>()) |
| + return; |
| + if (get_interface<PPB_CompositionInputEvent>()->IsCompositionInputEvent( |
| + event.pp_resource())) { |
|
yzshen1
2011/09/13 06:28:34
Minor: I think it should be 4 spaces indent from "
kinaba
2011/09/13 09:29:01
Done.
|
| + Module::Get()->core()->AddRefResource(event.pp_resource()); |
| + PassRefFromConstructor(event.pp_resource()); |
| + } |
| +} |
| + |
| +Var CompositionInputEvent::GetText() const { |
| + if (!has_interface<PPB_CompositionInputEvent>()) |
| + return Var(); |
| + return Var(Var::PassRef(), |
| + get_interface<PPB_CompositionInputEvent>()->GetText( |
| + pp_resource())); |
| +} |
| + |
| +std::vector< std::pair<uint32_t, uint32_t> > |
| +CompositionInputEvent::GetSegments() const { |
| + std::vector< std::pair<uint32_t, uint32_t> > result; |
| + if (!has_interface<PPB_CompositionInputEvent>()) |
| + return result; |
| + uint32_t* segments = 0; |
| + uint32_t size = 0; |
| + get_interface<PPB_CompositionInputEvent>()->GetSegments(pp_resource(), |
| + &segments, &size); |
| + if (segments) { |
| + for (size_t i=0; i<size; ++i) |
| + result.push_back(std::make_pair(segments[2*i], segments[2*i+1])); |
| + } |
| + return result; |
| +} |
| + |
| +int32_t CompositionInputEvent::GetTargetSegment() const { |
| + if (!has_interface<PPB_CompositionInputEvent>()) |
| + return 0; |
| + return get_interface<PPB_CompositionInputEvent>()->GetTargetSegment( |
| + pp_resource()); |
| +} |
| + |
| +std::pair<uint32_t, uint32_t> CompositionInputEvent::GetSelection() const { |
| + std::pair<uint32_t, uint32_t> sel(0,0); |
| + if (!has_interface<PPB_CompositionInputEvent>()) |
| + return sel; |
| + get_interface<PPB_CompositionInputEvent>()->GetSelection(pp_resource(), |
| + &sel.first, |
| + &sel.second); |
| + return sel; |
| +} |
| + |
| + |
| } // namespace pp |