summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/ppb_input_event_shared.cc118
-rw-r--r--ppapi/shared_impl/ppb_input_event_shared.h36
2 files changed, 154 insertions, 0 deletions
diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc
index cdb0565..7b07de9 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.cc
+++ b/ppapi/shared_impl/ppb_input_event_shared.cc
@@ -127,4 +127,122 @@ void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) {
*end = data_.composition_selection_end;
}
+//static
+PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent(
+ ResourceObjectType type,
+ PP_Instance instance,
+ PP_InputEvent_Type event_type,
+ PP_TimeTicks time_stamp,
+ struct PP_Var text,
+ uint32_t segment_number,
+ const uint32_t* segment_offsets,
+ int32_t target_segment,
+ uint32_t selection_start,
+ uint32_t selection_end) {
+ if (event_type != PP_INPUTEVENT_TYPE_IME_COMPOSITION_START &&
+ event_type != PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE &&
+ event_type != PP_INPUTEVENT_TYPE_IME_COMPOSITION_END &&
+ event_type != PP_INPUTEVENT_TYPE_IME_TEXT)
+ return 0;
+
+ InputEventData data;
+ data.event_type = event_type;
+ data.event_time_stamp = time_stamp;
+ if (text.type == PP_VARTYPE_STRING) {
+ StringVar* text_str = StringVar::FromPPVar(text);
+ if (!text_str)
+ return 0;
+ data.character_text = text_str->value();
+ }
+ data.composition_target_segment = target_segment;
+ if (segment_number != 0) {
+ data.composition_segment_offsets.assign(
+ &segment_offsets[0], &segment_offsets[segment_number + 1]);
+ }
+ data.composition_selection_start = selection_start;
+ data.composition_selection_end = selection_end;
+
+ return (new PPB_InputEvent_Shared(type, instance, data))->GetReference();
+}
+
+//static
+PP_Resource PPB_InputEvent_Shared::CreateKeyboardInputEvent(
+ ResourceObjectType type,
+ PP_Instance instance,
+ PP_InputEvent_Type event_type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ uint32_t key_code,
+ struct PP_Var character_text) {
+ if (event_type != PP_INPUTEVENT_TYPE_RAWKEYDOWN &&
+ event_type != PP_INPUTEVENT_TYPE_KEYDOWN &&
+ event_type != PP_INPUTEVENT_TYPE_KEYUP &&
+ event_type != PP_INPUTEVENT_TYPE_CHAR)
+ return 0;
+
+ InputEventData data;
+ data.event_type = event_type;
+ data.event_time_stamp = time_stamp;
+ data.event_modifiers = modifiers;
+ data.key_code = key_code;
+ if (character_text.type == PP_VARTYPE_STRING) {
+ StringVar* text_str = StringVar::FromPPVar(character_text);
+ if (!text_str)
+ return 0;
+ data.character_text = text_str->value();
+ }
+
+ return (new PPB_InputEvent_Shared(type, instance, data))->GetReference();
+}
+
+//static
+PP_Resource PPB_InputEvent_Shared::CreateMouseInputEvent(
+ ResourceObjectType type,
+ PP_Instance instance,
+ PP_InputEvent_Type event_type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ PP_InputEvent_MouseButton mouse_button,
+ const PP_Point* mouse_position,
+ int32_t click_count,
+ const PP_Point* mouse_movement) {
+ if (event_type != PP_INPUTEVENT_TYPE_MOUSEDOWN &&
+ event_type != PP_INPUTEVENT_TYPE_MOUSEUP &&
+ event_type != PP_INPUTEVENT_TYPE_MOUSEMOVE &&
+ event_type != PP_INPUTEVENT_TYPE_MOUSEENTER &&
+ event_type != PP_INPUTEVENT_TYPE_MOUSELEAVE)
+ return 0;
+
+ InputEventData data;
+ data.event_type = event_type;
+ data.event_time_stamp = time_stamp;
+ data.event_modifiers = modifiers;
+ data.mouse_button = mouse_button;
+ data.mouse_position = *mouse_position;
+ data.mouse_click_count = click_count;
+ data.mouse_movement = *mouse_movement;
+
+ return (new PPB_InputEvent_Shared(type, instance, data))->GetReference();
+}
+
+//static
+PP_Resource PPB_InputEvent_Shared::CreateWheelInputEvent(
+ ResourceObjectType type,
+ PP_Instance instance,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ const PP_FloatPoint* wheel_delta,
+ const PP_FloatPoint* wheel_ticks,
+ PP_Bool scroll_by_page) {
+ InputEventData data;
+ data.event_type = PP_INPUTEVENT_TYPE_WHEEL;
+ data.event_time_stamp = time_stamp;
+ data.event_modifiers = modifiers;
+ data.wheel_delta = *wheel_delta;
+ data.wheel_ticks = *wheel_ticks;
+ data.wheel_scroll_by_page = PP_ToBool(scroll_by_page);
+
+ return (new PPB_InputEvent_Shared(type, instance, data))->GetReference();
+}
+
} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_input_event_shared.h b/ppapi/shared_impl/ppb_input_event_shared.h
index c62befa..74108b3 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.h
+++ b/ppapi/shared_impl/ppb_input_event_shared.h
@@ -84,6 +84,42 @@ class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared
virtual int32_t GetIMETargetSegment() OVERRIDE;
virtual void GetIMESelection(uint32_t* start, uint32_t* end) OVERRIDE;
+ // Implementations for event creation.
+ static PP_Resource CreateIMEInputEvent(ResourceObjectType type,
+ PP_Instance instance,
+ PP_InputEvent_Type event_type,
+ PP_TimeTicks time_stamp,
+ struct PP_Var text,
+ uint32_t segment_number,
+ const uint32_t* segment_offsets,
+ int32_t target_segment,
+ uint32_t selection_start,
+ uint32_t selection_end);
+ static PP_Resource CreateKeyboardInputEvent(ResourceObjectType type,
+ PP_Instance instance,
+ PP_InputEvent_Type event_type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ uint32_t key_code,
+ struct PP_Var character_text);
+ static PP_Resource CreateMouseInputEvent(
+ ResourceObjectType type,
+ PP_Instance instance,
+ PP_InputEvent_Type event_type,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ PP_InputEvent_MouseButton mouse_button,
+ const PP_Point* mouse_position,
+ int32_t click_count,
+ const PP_Point* mouse_movement);
+ static PP_Resource CreateWheelInputEvent(ResourceObjectType type,
+ PP_Instance instance,
+ PP_TimeTicks time_stamp,
+ uint32_t modifiers,
+ const PP_FloatPoint* wheel_delta,
+ const PP_FloatPoint* wheel_ticks,
+ PP_Bool scroll_by_page);
+
private:
InputEventData data_;