| 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) { |
| 94 // Type check the input event before setting it. | 95 // Type check the input event before setting it. |
| 95 if (!has_interface<PPB_MouseInputEvent>()) | 96 if (!has_interface<PPB_MouseInputEvent>()) |
| 96 return; | 97 return; |
| 97 PassRefFromConstructor(get_interface<PPB_MouseInputEvent>()->Create( | 98 PassRefFromConstructor(get_interface<PPB_MouseInputEvent>()->Create( |
| 98 instance->pp_instance(), type, time_stamp, modifiers, mouse_button, | 99 instance->pp_instance(), type, time_stamp, modifiers, mouse_button, |
| 99 &mouse_position.pp_point(), click_count)); | 100 &mouse_position.pp_point(), click_count, &mouse_movement.pp_point())); |
| 100 } | 101 } |
| 101 | 102 |
| 102 PP_InputEvent_MouseButton MouseInputEvent::GetButton() const { | 103 PP_InputEvent_MouseButton MouseInputEvent::GetButton() const { |
| 103 if (!has_interface<PPB_MouseInputEvent>()) | 104 if (!has_interface<PPB_MouseInputEvent>()) |
| 104 return PP_INPUTEVENT_MOUSEBUTTON_NONE; | 105 return PP_INPUTEVENT_MOUSEBUTTON_NONE; |
| 105 return get_interface<PPB_MouseInputEvent>()->GetButton(pp_resource()); | 106 return get_interface<PPB_MouseInputEvent>()->GetButton(pp_resource()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 Point MouseInputEvent::GetPosition() const { | 109 Point MouseInputEvent::GetPosition() const { |
| 109 if (!has_interface<PPB_MouseInputEvent>()) | 110 if (!has_interface<PPB_MouseInputEvent>()) |
| 110 return Point(); | 111 return Point(); |
| 111 return get_interface<PPB_MouseInputEvent>()->GetPosition(pp_resource()); | 112 return get_interface<PPB_MouseInputEvent>()->GetPosition(pp_resource()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 int32_t MouseInputEvent::GetClickCount() const { | 115 int32_t MouseInputEvent::GetClickCount() const { |
| 115 if (!has_interface<PPB_MouseInputEvent>()) | 116 if (!has_interface<PPB_MouseInputEvent>()) |
| 116 return 0; | 117 return 0; |
| 117 return get_interface<PPB_MouseInputEvent>()->GetClickCount(pp_resource()); | 118 return get_interface<PPB_MouseInputEvent>()->GetClickCount(pp_resource()); |
| 118 } | 119 } |
| 119 | 120 |
| 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 |
| 120 // WheelInputEvent ------------------------------------------------------------- | 127 // WheelInputEvent ------------------------------------------------------------- |
| 121 | 128 |
| 122 WheelInputEvent::WheelInputEvent() : InputEvent() { | 129 WheelInputEvent::WheelInputEvent() : InputEvent() { |
| 123 } | 130 } |
| 124 | 131 |
| 125 WheelInputEvent::WheelInputEvent(const InputEvent& event) : InputEvent() { | 132 WheelInputEvent::WheelInputEvent(const InputEvent& event) : InputEvent() { |
| 126 // Type check the input event before setting it. | 133 // Type check the input event before setting it. |
| 127 if (!has_interface<PPB_WheelInputEvent>()) | 134 if (!has_interface<PPB_WheelInputEvent>()) |
| 128 return; | 135 return; |
| 129 if (get_interface<PPB_WheelInputEvent>()->IsWheelInputEvent( | 136 if (get_interface<PPB_WheelInputEvent>()->IsWheelInputEvent( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 212 |
| 206 Var KeyboardInputEvent::GetCharacterText() const { | 213 Var KeyboardInputEvent::GetCharacterText() const { |
| 207 if (!has_interface<PPB_KeyboardInputEvent>()) | 214 if (!has_interface<PPB_KeyboardInputEvent>()) |
| 208 return Var(); | 215 return Var(); |
| 209 return Var(Var::PassRef(), | 216 return Var(Var::PassRef(), |
| 210 get_interface<PPB_KeyboardInputEvent>()->GetCharacterText( | 217 get_interface<PPB_KeyboardInputEvent>()->GetCharacterText( |
| 211 pp_resource())); | 218 pp_resource())); |
| 212 } | 219 } |
| 213 | 220 |
| 214 } // namespace pp | 221 } // namespace pp |
| OLD | NEW |