| 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/shared_impl/input_event_impl.h" | 5 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
| 6 | 6 |
| 7 #include "ppapi/shared_impl/ppapi_globals.h" | 7 #include "ppapi/shared_impl/ppapi_globals.h" |
| 8 #include "ppapi/shared_impl/var.h" | 8 #include "ppapi/shared_impl/var.h" |
| 9 | 9 |
| 10 using ppapi::thunk::PPB_InputEvent_API; | 10 using ppapi::thunk::PPB_InputEvent_API; |
| 11 | 11 |
| 12 namespace ppapi { | 12 namespace ppapi { |
| 13 | 13 |
| 14 InputEventData::InputEventData() | 14 InputEventData::InputEventData() |
| 15 : is_filtered(false), | 15 : is_filtered(false), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 26 key_code(0), | 26 key_code(0), |
| 27 character_text(), | 27 character_text(), |
| 28 composition_target_segment(-1), | 28 composition_target_segment(-1), |
| 29 composition_selection_start(0), | 29 composition_selection_start(0), |
| 30 composition_selection_end(0) { | 30 composition_selection_end(0) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 InputEventData::~InputEventData() { | 33 InputEventData::~InputEventData() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 InputEventImpl::InputEventImpl(const InitAsImpl&, | 36 PPB_InputEvent_Shared::PPB_InputEvent_Shared(const InitAsImpl&, |
| 37 PP_Instance instance, | 37 PP_Instance instance, |
| 38 const InputEventData& data) | 38 const InputEventData& data) |
| 39 : Resource(instance), | 39 : Resource(instance), |
| 40 data_(data) { | 40 data_(data) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 InputEventImpl::InputEventImpl(const InitAsProxy&, | 43 PPB_InputEvent_Shared::PPB_InputEvent_Shared(const InitAsProxy&, |
| 44 PP_Instance instance, | 44 PP_Instance instance, |
| 45 const InputEventData& data) | 45 const InputEventData& data) |
| 46 : Resource(HostResource::MakeInstanceOnly(instance)), | 46 : Resource(HostResource::MakeInstanceOnly(instance)), |
| 47 data_(data) { | 47 data_(data) { |
| 48 } | 48 } |
| 49 | 49 |
| 50 PPB_InputEvent_API* InputEventImpl::AsPPB_InputEvent_API() { | 50 PPB_InputEvent_API* PPB_InputEvent_Shared::AsPPB_InputEvent_API() { |
| 51 return this; | 51 return this; |
| 52 } | 52 } |
| 53 | 53 |
| 54 const InputEventData& InputEventImpl::GetInputEventData() const { | 54 const InputEventData& PPB_InputEvent_Shared::GetInputEventData() const { |
| 55 return data_; | 55 return data_; |
| 56 } | 56 } |
| 57 | 57 |
| 58 PP_InputEvent_Type InputEventImpl::GetType() { | 58 PP_InputEvent_Type PPB_InputEvent_Shared::GetType() { |
| 59 return data_.event_type; | 59 return data_.event_type; |
| 60 } | 60 } |
| 61 | 61 |
| 62 PP_TimeTicks InputEventImpl::GetTimeStamp() { | 62 PP_TimeTicks PPB_InputEvent_Shared::GetTimeStamp() { |
| 63 return data_.event_time_stamp; | 63 return data_.event_time_stamp; |
| 64 } | 64 } |
| 65 | 65 |
| 66 uint32_t InputEventImpl::GetModifiers() { | 66 uint32_t PPB_InputEvent_Shared::GetModifiers() { |
| 67 return data_.event_modifiers; | 67 return data_.event_modifiers; |
| 68 } | 68 } |
| 69 | 69 |
| 70 PP_InputEvent_MouseButton InputEventImpl::GetMouseButton() { | 70 PP_InputEvent_MouseButton PPB_InputEvent_Shared::GetMouseButton() { |
| 71 return data_.mouse_button; | 71 return data_.mouse_button; |
| 72 } | 72 } |
| 73 | 73 |
| 74 PP_Point InputEventImpl::GetMousePosition() { | 74 PP_Point PPB_InputEvent_Shared::GetMousePosition() { |
| 75 return data_.mouse_position; | 75 return data_.mouse_position; |
| 76 } | 76 } |
| 77 | 77 |
| 78 int32_t InputEventImpl::GetMouseClickCount() { | 78 int32_t PPB_InputEvent_Shared::GetMouseClickCount() { |
| 79 return data_.mouse_click_count; | 79 return data_.mouse_click_count; |
| 80 } | 80 } |
| 81 | 81 |
| 82 PP_Point InputEventImpl::GetMouseMovement() { | 82 PP_Point PPB_InputEvent_Shared::GetMouseMovement() { |
| 83 return data_.mouse_movement; | 83 return data_.mouse_movement; |
| 84 } | 84 } |
| 85 | 85 |
| 86 PP_FloatPoint InputEventImpl::GetWheelDelta() { | 86 PP_FloatPoint PPB_InputEvent_Shared::GetWheelDelta() { |
| 87 return data_.wheel_delta; | 87 return data_.wheel_delta; |
| 88 } | 88 } |
| 89 | 89 |
| 90 PP_FloatPoint InputEventImpl::GetWheelTicks() { | 90 PP_FloatPoint PPB_InputEvent_Shared::GetWheelTicks() { |
| 91 return data_.wheel_ticks; | 91 return data_.wheel_ticks; |
| 92 } | 92 } |
| 93 | 93 |
| 94 PP_Bool InputEventImpl::GetWheelScrollByPage() { | 94 PP_Bool PPB_InputEvent_Shared::GetWheelScrollByPage() { |
| 95 return PP_FromBool(data_.wheel_scroll_by_page); | 95 return PP_FromBool(data_.wheel_scroll_by_page); |
| 96 } | 96 } |
| 97 | 97 |
| 98 uint32_t InputEventImpl::GetKeyCode() { | 98 uint32_t PPB_InputEvent_Shared::GetKeyCode() { |
| 99 return data_.key_code; | 99 return data_.key_code; |
| 100 } | 100 } |
| 101 | 101 |
| 102 PP_Var InputEventImpl::GetCharacterText() { | 102 PP_Var PPB_InputEvent_Shared::GetCharacterText() { |
| 103 return StringVar::StringToPPVar( | 103 return StringVar::StringToPPVar( |
| 104 PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), | 104 PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), |
| 105 data_.character_text); | 105 data_.character_text); |
| 106 } | 106 } |
| 107 | 107 |
| 108 uint32_t InputEventImpl::GetIMESegmentNumber() { | 108 uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { |
| 109 if (data_.composition_segment_offsets.empty()) | 109 if (data_.composition_segment_offsets.empty()) |
| 110 return 0; | 110 return 0; |
| 111 return data_.composition_segment_offsets.size() - 1; | 111 return data_.composition_segment_offsets.size() - 1; |
| 112 } | 112 } |
| 113 | 113 |
| 114 uint32_t InputEventImpl::GetIMESegmentOffset(uint32_t index) { | 114 uint32_t PPB_InputEvent_Shared::GetIMESegmentOffset(uint32_t index) { |
| 115 if (index >= data_.composition_segment_offsets.size()) | 115 if (index >= data_.composition_segment_offsets.size()) |
| 116 return 0; | 116 return 0; |
| 117 return data_.composition_segment_offsets[index]; | 117 return data_.composition_segment_offsets[index]; |
| 118 } | 118 } |
| 119 | 119 |
| 120 int32_t InputEventImpl::GetIMETargetSegment() { | 120 int32_t PPB_InputEvent_Shared::GetIMETargetSegment() { |
| 121 return data_.composition_target_segment; | 121 return data_.composition_target_segment; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void InputEventImpl::GetIMESelection(uint32_t* start, uint32_t* end) { | 124 void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) { |
| 125 if (start) | 125 if (start) |
| 126 *start = data_.composition_selection_start; | 126 *start = data_.composition_selection_start; |
| 127 if (end) | 127 if (end) |
| 128 *end = data_.composition_selection_end; | 128 *end = data_.composition_selection_end; |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace ppapi | 131 } // namespace ppapi |
| OLD | NEW |