| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/cpp/input_event.h" | 5 #include "ppapi/cpp/input_event.h" |
| 6 | 6 |
| 7 #include "ppapi/cpp/instance.h" | 7 #include "ppapi/cpp/instance.h" |
| 8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
| 9 #include "ppapi/cpp/module_impl.h" | 9 #include "ppapi/cpp/module_impl.h" |
| 10 #include "ppapi/cpp/point.h" | 10 #include "ppapi/cpp/point.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 PassRefFromConstructor(event.pp_resource()); | 83 PassRefFromConstructor(event.pp_resource()); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 MouseInputEvent::MouseInputEvent(Instance* instance, | 87 MouseInputEvent::MouseInputEvent(Instance* instance, |
| 88 PP_InputEvent_Type type, | 88 PP_InputEvent_Type type, |
| 89 PP_TimeTicks time_stamp, | 89 PP_TimeTicks time_stamp, |
| 90 uint32_t modifiers, | 90 uint32_t modifiers, |
| 91 PP_InputEvent_MouseButton mouse_button, | 91 PP_InputEvent_MouseButton mouse_button, |
| 92 const Point& mouse_position, | 92 const Point& mouse_position, |
| 93 int32_t click_count, | 93 int32_t click_count) { |
| 94 const Point& mouse_movement) { | |
| 95 // Type check the input event before setting it. | 94 // Type check the input event before setting it. |
| 96 if (!has_interface<PPB_MouseInputEvent>()) | 95 if (!has_interface<PPB_MouseInputEvent>()) |
| 97 return; | 96 return; |
| 98 PassRefFromConstructor(get_interface<PPB_MouseInputEvent>()->Create( | 97 PassRefFromConstructor(get_interface<PPB_MouseInputEvent>()->Create( |
| 99 instance->pp_instance(), type, time_stamp, modifiers, mouse_button, | 98 instance->pp_instance(), type, time_stamp, modifiers, mouse_button, |
| 100 &mouse_position.pp_point(), click_count, &mouse_movement.pp_point())); | 99 &mouse_position.pp_point(), click_count)); |
| 100 } |
| 101 |
| 102 MouseInputEvent::MouseInputEvent(Instance* instance, |
| 103 PP_InputEvent_Type type, |
| 104 PP_TimeTicks time_stamp, |
| 105 uint32_t modifiers, |
| 106 PP_InputEvent_MouseButton mouse_button, |
| 107 const Point& mouse_position, |
| 108 int32_t click_count, |
| 109 const Point& /*mouse_movement*/) { |
| 110 // Type check the input event before setting it. |
| 111 if (!has_interface<PPB_MouseInputEvent>()) |
| 112 return; |
| 113 PassRefFromConstructor(get_interface<PPB_MouseInputEvent>()->Create( |
| 114 instance->pp_instance(), type, time_stamp, modifiers, mouse_button, |
| 115 &mouse_position.pp_point(), click_count)); |
| 101 } | 116 } |
| 102 | 117 |
| 103 PP_InputEvent_MouseButton MouseInputEvent::GetButton() const { | 118 PP_InputEvent_MouseButton MouseInputEvent::GetButton() const { |
| 104 if (!has_interface<PPB_MouseInputEvent>()) | 119 if (!has_interface<PPB_MouseInputEvent>()) |
| 105 return PP_INPUTEVENT_MOUSEBUTTON_NONE; | 120 return PP_INPUTEVENT_MOUSEBUTTON_NONE; |
| 106 return get_interface<PPB_MouseInputEvent>()->GetButton(pp_resource()); | 121 return get_interface<PPB_MouseInputEvent>()->GetButton(pp_resource()); |
| 107 } | 122 } |
| 108 | 123 |
| 109 Point MouseInputEvent::GetPosition() const { | 124 Point MouseInputEvent::GetPosition() const { |
| 110 if (!has_interface<PPB_MouseInputEvent>()) | 125 if (!has_interface<PPB_MouseInputEvent>()) |
| 111 return Point(); | 126 return Point(); |
| 112 return get_interface<PPB_MouseInputEvent>()->GetPosition(pp_resource()); | 127 return get_interface<PPB_MouseInputEvent>()->GetPosition(pp_resource()); |
| 113 } | 128 } |
| 114 | 129 |
| 115 int32_t MouseInputEvent::GetClickCount() const { | 130 int32_t MouseInputEvent::GetClickCount() const { |
| 116 if (!has_interface<PPB_MouseInputEvent>()) | 131 if (!has_interface<PPB_MouseInputEvent>()) |
| 117 return 0; | 132 return 0; |
| 118 return get_interface<PPB_MouseInputEvent>()->GetClickCount(pp_resource()); | 133 return get_interface<PPB_MouseInputEvent>()->GetClickCount(pp_resource()); |
| 119 } | 134 } |
| 120 | 135 |
| 121 Point MouseInputEvent::GetMovement() const { | |
| 122 if (!has_interface<PPB_MouseInputEvent>()) | |
| 123 return Point(); | |
| 124 return get_interface<PPB_MouseInputEvent>()->GetMovement(pp_resource()); | |
| 125 } | |
| 126 | |
| 127 // WheelInputEvent ------------------------------------------------------------- | 136 // WheelInputEvent ------------------------------------------------------------- |
| 128 | 137 |
| 129 WheelInputEvent::WheelInputEvent() : InputEvent() { | 138 WheelInputEvent::WheelInputEvent() : InputEvent() { |
| 130 } | 139 } |
| 131 | 140 |
| 132 WheelInputEvent::WheelInputEvent(const InputEvent& event) : InputEvent() { | 141 WheelInputEvent::WheelInputEvent(const InputEvent& event) : InputEvent() { |
| 133 // Type check the input event before setting it. | 142 // Type check the input event before setting it. |
| 134 if (!has_interface<PPB_WheelInputEvent>()) | 143 if (!has_interface<PPB_WheelInputEvent>()) |
| 135 return; | 144 return; |
| 136 if (get_interface<PPB_WheelInputEvent>()->IsWheelInputEvent( | 145 if (get_interface<PPB_WheelInputEvent>()->IsWheelInputEvent( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 221 |
| 213 Var KeyboardInputEvent::GetCharacterText() const { | 222 Var KeyboardInputEvent::GetCharacterText() const { |
| 214 if (!has_interface<PPB_KeyboardInputEvent>()) | 223 if (!has_interface<PPB_KeyboardInputEvent>()) |
| 215 return Var(); | 224 return Var(); |
| 216 return Var(Var::PassRef(), | 225 return Var(Var::PassRef(), |
| 217 get_interface<PPB_KeyboardInputEvent>()->GetCharacterText( | 226 get_interface<PPB_KeyboardInputEvent>()->GetCharacterText( |
| 218 pp_resource())); | 227 pp_resource())); |
| 219 } | 228 } |
| 220 | 229 |
| 221 } // namespace pp | 230 } // namespace pp |
| OLD | NEW |