| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/plugins/ppapi/resource_creation_impl.h" | 5 #include "webkit/plugins/ppapi/resource_creation_impl.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_size.h" | 7 #include "ppapi/c/pp_size.h" |
| 8 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 8 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
| 9 #include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" | 9 #include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" |
| 10 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 10 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return (new PPB_HostResolver_Private_Impl(instance))->GetReference(); | 175 return (new PPB_HostResolver_Private_Impl(instance))->GetReference(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance, | 178 PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance, |
| 179 PP_ImageDataFormat format, | 179 PP_ImageDataFormat format, |
| 180 const PP_Size& size, | 180 const PP_Size& size, |
| 181 PP_Bool init_to_zero) { | 181 PP_Bool init_to_zero) { |
| 182 return PPB_ImageData_Impl::Create(instance, format, size, init_to_zero); | 182 return PPB_ImageData_Impl::Create(instance, format, size, init_to_zero); |
| 183 } | 183 } |
| 184 | 184 |
| 185 PP_Resource ResourceCreationImpl::CreateIMEInputEvent( |
| 186 PP_Instance instance, |
| 187 PP_InputEvent_Type type, |
| 188 PP_TimeTicks time_stamp, |
| 189 struct PP_Var text, |
| 190 uint32_t segment_number, |
| 191 const uint32_t* segment_offsets, |
| 192 int32_t target_segment, |
| 193 uint32_t selection_start, |
| 194 uint32_t selection_end) { |
| 195 return PPB_InputEvent_Shared::CreateIMEInputEvent( |
| 196 ::ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, text, segment_number, |
| 197 segment_offsets, target_segment, selection_start, selection_end); |
| 198 } |
| 199 |
| 185 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent( | 200 PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent( |
| 186 PP_Instance instance, | 201 PP_Instance instance, |
| 187 PP_InputEvent_Type type, | 202 PP_InputEvent_Type type, |
| 188 PP_TimeTicks time_stamp, | 203 PP_TimeTicks time_stamp, |
| 189 uint32_t modifiers, | 204 uint32_t modifiers, |
| 190 uint32_t key_code, | 205 uint32_t key_code, |
| 191 struct PP_Var character_text) { | 206 struct PP_Var character_text) { |
| 192 if (type != PP_INPUTEVENT_TYPE_RAWKEYDOWN && | 207 return PPB_InputEvent_Shared::CreateKeyboardInputEvent( |
| 193 type != PP_INPUTEVENT_TYPE_KEYDOWN && | 208 ::ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers, key_code, |
| 194 type != PP_INPUTEVENT_TYPE_KEYUP && | 209 character_text); |
| 195 type != PP_INPUTEVENT_TYPE_CHAR) | |
| 196 return 0; | |
| 197 | |
| 198 InputEventData data; | |
| 199 data.event_type = type; | |
| 200 data.event_time_stamp = time_stamp; | |
| 201 data.event_modifiers = modifiers; | |
| 202 data.key_code = key_code; | |
| 203 if (character_text.type == PP_VARTYPE_STRING) { | |
| 204 StringVar* string_var = StringVar::FromPPVar(character_text); | |
| 205 if (!string_var) | |
| 206 return 0; | |
| 207 data.character_text = string_var->value(); | |
| 208 } | |
| 209 | |
| 210 return (new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, | |
| 211 instance, data))->GetReference(); | |
| 212 } | 210 } |
| 213 | 211 |
| 214 PP_Resource ResourceCreationImpl::CreateMouseInputEvent( | 212 PP_Resource ResourceCreationImpl::CreateMouseInputEvent( |
| 215 PP_Instance instance, | 213 PP_Instance instance, |
| 216 PP_InputEvent_Type type, | 214 PP_InputEvent_Type type, |
| 217 PP_TimeTicks time_stamp, | 215 PP_TimeTicks time_stamp, |
| 218 uint32_t modifiers, | 216 uint32_t modifiers, |
| 219 PP_InputEvent_MouseButton mouse_button, | 217 PP_InputEvent_MouseButton mouse_button, |
| 220 const PP_Point* mouse_position, | 218 const PP_Point* mouse_position, |
| 221 int32_t click_count, | 219 int32_t click_count, |
| 222 const PP_Point* mouse_movement) { | 220 const PP_Point* mouse_movement) { |
| 223 if (type != PP_INPUTEVENT_TYPE_MOUSEDOWN && | 221 return PPB_InputEvent_Shared::CreateMouseInputEvent( |
| 224 type != PP_INPUTEVENT_TYPE_MOUSEUP && | 222 ::ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers, |
| 225 type != PP_INPUTEVENT_TYPE_MOUSEMOVE && | 223 mouse_button, mouse_position, click_count, mouse_movement); |
| 226 type != PP_INPUTEVENT_TYPE_MOUSEENTER && | |
| 227 type != PP_INPUTEVENT_TYPE_MOUSELEAVE) | |
| 228 return 0; | |
| 229 | |
| 230 InputEventData data; | |
| 231 data.event_type = type; | |
| 232 data.event_time_stamp = time_stamp; | |
| 233 data.event_modifiers = modifiers; | |
| 234 data.mouse_button = mouse_button; | |
| 235 data.mouse_position = *mouse_position; | |
| 236 data.mouse_click_count = click_count; | |
| 237 data.mouse_movement = *mouse_movement; | |
| 238 | |
| 239 return (new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, | |
| 240 instance, data))->GetReference(); | |
| 241 } | 224 } |
| 242 | 225 |
| 243 PP_Resource ResourceCreationImpl::CreateNetworkMonitor( | 226 PP_Resource ResourceCreationImpl::CreateNetworkMonitor( |
| 244 PP_Instance instance, | 227 PP_Instance instance, |
| 245 PPB_NetworkMonitor_Callback callback, | 228 PPB_NetworkMonitor_Callback callback, |
| 246 void* user_data) { | 229 void* user_data) { |
| 247 return PPB_NetworkMonitor_Private_Impl::Create(instance, callback, user_data); | 230 return PPB_NetworkMonitor_Private_Impl::Create(instance, callback, user_data); |
| 248 } | 231 } |
| 249 | 232 |
| 250 PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance, | 233 PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 return PPB_WebSocket_Impl::Create(instance); | 306 return PPB_WebSocket_Impl::Create(instance); |
| 324 } | 307 } |
| 325 | 308 |
| 326 PP_Resource ResourceCreationImpl::CreateWheelInputEvent( | 309 PP_Resource ResourceCreationImpl::CreateWheelInputEvent( |
| 327 PP_Instance instance, | 310 PP_Instance instance, |
| 328 PP_TimeTicks time_stamp, | 311 PP_TimeTicks time_stamp, |
| 329 uint32_t modifiers, | 312 uint32_t modifiers, |
| 330 const PP_FloatPoint* wheel_delta, | 313 const PP_FloatPoint* wheel_delta, |
| 331 const PP_FloatPoint* wheel_ticks, | 314 const PP_FloatPoint* wheel_ticks, |
| 332 PP_Bool scroll_by_page) { | 315 PP_Bool scroll_by_page) { |
| 333 InputEventData data; | 316 return PPB_InputEvent_Shared::CreateWheelInputEvent( |
| 334 data.event_type = PP_INPUTEVENT_TYPE_WHEEL; | 317 ::ppapi::OBJECT_IS_IMPL, instance, time_stamp, modifiers, |
| 335 data.event_time_stamp = time_stamp; | 318 wheel_delta, wheel_ticks, scroll_by_page); |
| 336 data.event_modifiers = modifiers; | |
| 337 data.wheel_delta = *wheel_delta; | |
| 338 data.wheel_ticks = *wheel_ticks; | |
| 339 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); | |
| 340 | |
| 341 return (new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, | |
| 342 instance, data))->GetReference(); | |
| 343 } | 319 } |
| 344 | 320 |
| 345 PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate( | 321 PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate( |
| 346 PP_Instance instance) { | 322 PP_Instance instance) { |
| 347 return PPB_X509Certificate_Private_Impl::CreateResource(instance); | 323 return PPB_X509Certificate_Private_Impl::CreateResource(instance); |
| 348 } | 324 } |
| 349 | 325 |
| 350 } // namespace ppapi | 326 } // namespace ppapi |
| 351 } // namespace webkit | 327 } // namespace webkit |
| OLD | NEW |