15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/input_event.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/instance_handle.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/module.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/module_impl.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/point.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/touch_point.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/var.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace pp {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <> const char* interface_name<PPB_InputEvent_1_0>() {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PPB_INPUT_EVENT_INTERFACE_1_0;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)template <> const char* interface_name<PPB_KeyboardInputEvent_1_2>() {
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2;
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <> const char* interface_name<PPB_KeyboardInputEvent_1_0>() {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0;
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <> const char* interface_name<PPB_MouseInputEvent_1_1>() {
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <> const char* interface_name<PPB_WheelInputEvent_1_0>() {
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <> const char* interface_name<PPB_TouchInputEvent_1_0>() {
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
42a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)template <> const char* interface_name<PPB_IMEInputEvent_1_0>() {
43a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  return PPB_IME_INPUT_EVENT_INTERFACE_1_0;
44a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
45a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// InputEvent ------------------------------------------------------------------
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InputEvent::InputEvent() : Resource() {
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InputEvent::InputEvent(PP_Resource input_event_resource) : Resource() {
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_InputEvent_1_0>())
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (get_interface<PPB_InputEvent_1_0>()->IsInputEvent(input_event_resource)) {
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Module::Get()->core()->AddRefResource(input_event_resource);
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PassRefFromConstructor(input_event_resource);
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InputEvent::~InputEvent() {
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PP_InputEvent_Type InputEvent::GetType() const {
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_InputEvent_1_0>())
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return PP_INPUTEVENT_TYPE_UNDEFINED;
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_InputEvent_1_0>()->GetType(pp_resource());
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PP_TimeTicks InputEvent::GetTimeStamp() const {
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_InputEvent_1_0>())
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return 0.0f;
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_InputEvent_1_0>()->GetTimeStamp(pp_resource());
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)uint32_t InputEvent::GetModifiers() const {
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_InputEvent_1_0>())
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return 0;
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_InputEvent_1_0>()->GetModifiers(pp_resource());
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// MouseInputEvent -------------------------------------------------------------
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)MouseInputEvent::MouseInputEvent() : InputEvent() {
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)MouseInputEvent::MouseInputEvent(const InputEvent& event) : InputEvent() {
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_MouseInputEvent_1_1>())
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (get_interface<PPB_MouseInputEvent_1_1>()->IsMouseInputEvent(
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          event.pp_resource())) {
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Module::Get()->core()->AddRefResource(event.pp_resource());
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PassRefFromConstructor(event.pp_resource());
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)MouseInputEvent::MouseInputEvent(const InstanceHandle& instance,
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 PP_InputEvent_Type type,
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 PP_TimeTicks time_stamp,
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 uint32_t modifiers,
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 PP_InputEvent_MouseButton mouse_button,
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const Point& mouse_position,
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 int32_t click_count,
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const Point& mouse_movement) {
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_MouseInputEvent_1_1>())
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PassRefFromConstructor(get_interface<PPB_MouseInputEvent_1_1>()->Create(
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      instance.pp_instance(), type, time_stamp, modifiers, mouse_button,
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      &mouse_position.pp_point(), click_count, &mouse_movement.pp_point()));
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PP_InputEvent_MouseButton MouseInputEvent::GetButton() const {
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_MouseInputEvent_1_1>())
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return PP_INPUTEVENT_MOUSEBUTTON_NONE;
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_MouseInputEvent_1_1>()->GetButton(pp_resource());
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)Point MouseInputEvent::GetPosition() const {
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_MouseInputEvent_1_1>())
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return Point();
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_MouseInputEvent_1_1>()->GetPosition(pp_resource());
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int32_t MouseInputEvent::GetClickCount() const {
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_MouseInputEvent_1_1>())
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return 0;
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_MouseInputEvent_1_1>()->GetClickCount(pp_resource());
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)Point MouseInputEvent::GetMovement() const {
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_MouseInputEvent_1_1>())
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return Point();
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_MouseInputEvent_1_1>()->GetMovement(pp_resource());
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// WheelInputEvent -------------------------------------------------------------
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WheelInputEvent::WheelInputEvent() : InputEvent() {
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WheelInputEvent::WheelInputEvent(const InputEvent& event) : InputEvent() {
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_WheelInputEvent_1_0>())
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (get_interface<PPB_WheelInputEvent_1_0>()->IsWheelInputEvent(
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          event.pp_resource())) {
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Module::Get()->core()->AddRefResource(event.pp_resource());
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PassRefFromConstructor(event.pp_resource());
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WheelInputEvent::WheelInputEvent(const InstanceHandle& instance,
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 PP_TimeTicks time_stamp,
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 uint32_t modifiers,
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const FloatPoint& wheel_delta,
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const FloatPoint& wheel_ticks,
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 bool scroll_by_page) {
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_WheelInputEvent_1_0>())
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PassRefFromConstructor(get_interface<PPB_WheelInputEvent_1_0>()->Create(
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      instance.pp_instance(), time_stamp, modifiers,
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      &wheel_delta.pp_float_point(), &wheel_ticks.pp_float_point(),
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PP_FromBool(scroll_by_page)));
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)FloatPoint WheelInputEvent::GetDelta() const {
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_WheelInputEvent_1_0>())
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return FloatPoint();
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_WheelInputEvent_1_0>()->GetDelta(pp_resource());
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)FloatPoint WheelInputEvent::GetTicks() const {
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_WheelInputEvent_1_0>())
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return FloatPoint();
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_WheelInputEvent_1_0>()->GetTicks(pp_resource());
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool WheelInputEvent::GetScrollByPage() const {
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_WheelInputEvent_1_0>())
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return false;
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return PP_ToBool(
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      get_interface<PPB_WheelInputEvent_1_0>()->GetScrollByPage(pp_resource()));
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// KeyboardInputEvent ----------------------------------------------------------
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)KeyboardInputEvent::KeyboardInputEvent() : InputEvent() {
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)KeyboardInputEvent::KeyboardInputEvent(const InputEvent& event) : InputEvent() {
1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  PP_Bool is_keyboard_event = PP_FALSE;
1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (has_interface<PPB_KeyboardInputEvent_1_2>()) {
1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    is_keyboard_event =
2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        get_interface<PPB_KeyboardInputEvent_1_2>()->IsKeyboardInputEvent(
2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            event.pp_resource());
2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else if (has_interface<PPB_KeyboardInputEvent_1_0>()) {
2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    is_keyboard_event =
2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        get_interface<PPB_KeyboardInputEvent_1_0>()->IsKeyboardInputEvent(
2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            event.pp_resource());
2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (PP_ToBool(is_keyboard_event)) {
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Module::Get()->core()->AddRefResource(event.pp_resource());
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PassRefFromConstructor(event.pp_resource());
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)KeyboardInputEvent::KeyboardInputEvent(const InstanceHandle& instance,
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       PP_InputEvent_Type type,
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       PP_TimeTicks time_stamp,
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       uint32_t modifiers,
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       uint32_t key_code,
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       const Var& character_text) {
2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (has_interface<PPB_KeyboardInputEvent_1_2>()) {
2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    PassRefFromConstructor(get_interface<PPB_KeyboardInputEvent_1_2>()->Create(
2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        instance.pp_instance(), type, time_stamp, modifiers, key_code,
2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        character_text.pp_var(), Var().pp_var()));
2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else if (has_interface<PPB_KeyboardInputEvent_1_0>()) {
2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    PassRefFromConstructor(get_interface<PPB_KeyboardInputEvent_1_0>()->Create(
2265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        instance.pp_instance(), type, time_stamp, modifiers, key_code,
2275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        character_text.pp_var()));
2285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)KeyboardInputEvent::KeyboardInputEvent(const InstanceHandle& instance,
2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                       PP_InputEvent_Type type,
2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                       PP_TimeTicks time_stamp,
2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                       uint32_t modifiers,
2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                       uint32_t key_code,
2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                       const Var& character_text,
2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                       const Var& code) {
2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (has_interface<PPB_KeyboardInputEvent_1_2>()) {
2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    PassRefFromConstructor(get_interface<PPB_KeyboardInputEvent_1_2>()->Create(
2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        instance.pp_instance(), type, time_stamp, modifiers, key_code,
2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        character_text.pp_var(), code.pp_var()));
2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else if (has_interface<PPB_KeyboardInputEvent_1_0>()) {
2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    PassRefFromConstructor(get_interface<PPB_KeyboardInputEvent_1_0>()->Create(
2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        instance.pp_instance(), type, time_stamp, modifiers, key_code,
2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        character_text.pp_var()));
2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)uint32_t KeyboardInputEvent::GetKeyCode() const {
2505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (has_interface<PPB_KeyboardInputEvent_1_2>()) {
2515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return get_interface<PPB_KeyboardInputEvent_1_2>()->GetKeyCode(
2525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        pp_resource());
2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else if (has_interface<PPB_KeyboardInputEvent_1_0>()) {
2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return get_interface<PPB_KeyboardInputEvent_1_0>()->GetKeyCode(
2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        pp_resource());
2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return 0;
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)Var KeyboardInputEvent::GetCharacterText() const {
2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (has_interface<PPB_KeyboardInputEvent_1_2>()) {
2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return Var(PASS_REF,
2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)               get_interface<PPB_KeyboardInputEvent_1_2>()->GetCharacterText(
2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                   pp_resource()));
2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else if (has_interface<PPB_KeyboardInputEvent_1_0>()) {
2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return Var(PASS_REF,
2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)               get_interface<PPB_KeyboardInputEvent_1_0>()->GetCharacterText(
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                 pp_resource()));
2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return Var();
2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)Var KeyboardInputEvent::GetCode() const {
2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (has_interface<PPB_KeyboardInputEvent_1_2>()) {
2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return Var(PASS_REF,
2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)               get_interface<PPB_KeyboardInputEvent_1_2>()->GetCode(
2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                   pp_resource()));
2785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return Var();
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TouchInputEvent ------------------------------------------------------------
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TouchInputEvent::TouchInputEvent() : InputEvent() {
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TouchInputEvent::TouchInputEvent(const InputEvent& event) : InputEvent() {
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_TouchInputEvent_1_0>())
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (get_interface<PPB_TouchInputEvent_1_0>()->IsTouchInputEvent(
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      event.pp_resource())) {
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Module::Get()->core()->AddRefResource(event.pp_resource());
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PassRefFromConstructor(event.pp_resource());
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TouchInputEvent::TouchInputEvent(const InstanceHandle& instance,
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 PP_InputEvent_Type type,
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 PP_TimeTicks time_stamp,
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 uint32_t modifiers) {
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Type check the input event before setting it.
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_TouchInputEvent_1_0>())
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PassRefFromConstructor(get_interface<PPB_TouchInputEvent_1_0>()->Create(
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      instance.pp_instance(), type, time_stamp, modifiers));
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void TouchInputEvent::AddTouchPoint(PP_TouchListType list,
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    PP_TouchPoint point) {
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_TouchInputEvent_1_0>())
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  get_interface<PPB_TouchInputEvent_1_0>()->AddTouchPoint(pp_resource(), list,
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                          &point);
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)uint32_t TouchInputEvent::GetTouchCount(PP_TouchListType list) const {
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_TouchInputEvent_1_0>())
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return 0;
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return get_interface<PPB_TouchInputEvent_1_0>()->GetTouchCount(pp_resource(),
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                                 list);
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TouchPoint TouchInputEvent::GetTouchById(PP_TouchListType list,
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                             uint32_t id) const {
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_TouchInputEvent_1_0>())
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return TouchPoint();
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return TouchPoint(get_interface<PPB_TouchInputEvent_1_0>()->
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        GetTouchById(pp_resource(), list, id));
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TouchPoint TouchInputEvent::GetTouchByIndex(PP_TouchListType list,
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                uint32_t index) const {
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!has_interface<PPB_TouchInputEvent_1_0>())
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return TouchPoint();
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return TouchPoint(get_interface<PPB_TouchInputEvent_1_0>()->
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        GetTouchByIndex(pp_resource(), list, index));
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
339a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// IMEInputEvent -------------------------------------------------------
340a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
341a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)IMEInputEvent::IMEInputEvent() : InputEvent() {
342a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
343a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
344a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)IMEInputEvent::IMEInputEvent(const InputEvent& event) : InputEvent() {
345a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (has_interface<PPB_IMEInputEvent_1_0>()) {
346a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    if (get_interface<PPB_IMEInputEvent_1_0>()->IsIMEInputEvent(
347a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)            event.pp_resource())) {
348a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      Module::Get()->core()->AddRefResource(event.pp_resource());
349a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      PassRefFromConstructor(event.pp_resource());
350a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    }
351a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
352a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
353a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
354a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)IMEInputEvent::IMEInputEvent(
355a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    const InstanceHandle& instance,
356a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    PP_InputEvent_Type type,
357a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    PP_TimeTicks time_stamp,
358a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    const Var& text,
359a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    const std::vector<uint32_t>& segment_offsets,
360a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    int32_t target_segment,
361a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    const std::pair<uint32_t, uint32_t>& selection) : InputEvent() {
362a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (!has_interface<PPB_IMEInputEvent_1_0>())
363a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    return;
364a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  uint32_t dummy = 0;
365a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  PassRefFromConstructor(get_interface<PPB_IMEInputEvent_1_0>()->Create(
366a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      instance.pp_instance(), type, time_stamp, text.pp_var(),
367a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      segment_offsets.empty() ? 0 : segment_offsets.size() - 1,
368a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      segment_offsets.empty() ? &dummy : &segment_offsets[0],
369a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      target_segment, selection.first, selection.second));
370a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
371a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
372a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
373a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)Var IMEInputEvent::GetText() const {
374a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (has_interface<PPB_IMEInputEvent_1_0>()) {
375a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    return Var(PASS_REF,
376a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)               get_interface<PPB_IMEInputEvent_1_0>()->GetText(
377a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                   pp_resource()));
378a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
379a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  return Var();
380a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
381a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
382a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)uint32_t IMEInputEvent::GetSegmentNumber() const {
383a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (has_interface<PPB_IMEInputEvent_1_0>()) {
384a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentNumber(
385a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        pp_resource());
386a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
387a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  return 0;
388a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
389a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
390a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)uint32_t IMEInputEvent::GetSegmentOffset(uint32_t index) const {
391a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (has_interface<PPB_IMEInputEvent_1_0>()) {
392a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentOffset(
393a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        pp_resource(), index);
394a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
395a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  return 0;
396a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
397a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
398a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)int32_t IMEInputEvent::GetTargetSegment() const {
399a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (has_interface<PPB_IMEInputEvent_1_0>()) {
400a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    return get_interface<PPB_IMEInputEvent_1_0>()->GetTargetSegment(
401a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        pp_resource());
402a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
403a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  return 0;
404a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
405a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
406a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)void IMEInputEvent::GetSelection(uint32_t* start, uint32_t* end) const {
407a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  if (has_interface<PPB_IMEInputEvent_1_0>()) {
408a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    get_interface<PPB_IMEInputEvent_1_0>()->GetSelection(pp_resource(),
409a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                                                         start,
410a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                                                         end);
411a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
412a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
413a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace pp
415