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