Chromium Code Reviews| Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| index 1b6ff947aa7bfd1d22902ab6df17623914cb52df..662098a7ec0cc18709f57042b5c7e4eb760f5421 100644 |
| --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| @@ -220,15 +220,6 @@ COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING); |
| // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; |
| // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. |
| -// Ensure conversion from WebKit::WebGamepads to PP_GamepadsData_Dev is safe. |
| -// See also DCHECKs in SampleGamepads below. |
| -// |
| -// Temporarily disabled for 2-sided WebKit roll. |
| -//COMPILE_ASSERT(sizeof(WebKit::WebGamepads) == sizeof(PP_GamepadsData_Dev), |
| -// size_difference); |
| -//COMPILE_ASSERT(sizeof(WebKit::WebGamepad) == sizeof(PP_GamepadData_Dev), |
| -// size_difference); |
| - |
| // Sets |*security_origin| to be the WebKit security origin associated with the |
| // document containing the given plugin instance. On success, returns true. If |
| // the instance is invalid, returns false and |*security_origin| will be |
| @@ -1354,39 +1345,32 @@ bool PluginInstance::IsRectTopmost(const gfx::Rect& rect) { |
| } |
| void PluginInstance::SampleGamepads(PP_Instance instance, |
| - PP_GamepadsData_Dev* data) { |
| - |
| - // Because the WebKit objects have trivial ctors, using offsetof doesn't |
| - // work. Instead use this version based on src/v8/src/globals.h. This |
| - // workaround doesn't work in constant expressions as required for |
| - // COMPILE_ASSERT, so DCHECK instead. |
| - |
| -#define OFFSET_OF(type, field) \ |
| - (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4) |
| - |
| -#define DCHECK_GAMEPADS_OFFSET(webkit_name, pp_name) \ |
| - DCHECK(OFFSET_OF(WebKit::WebGamepads, webkit_name) \ |
| - == OFFSET_OF(PP_GamepadsData_Dev, pp_name)) |
| - |
| -#define DCHECK_GAMEPAD_OFFSET(webkit_name, pp_name) \ |
| - DCHECK(OFFSET_OF(WebKit::WebGamepad, webkit_name) \ |
| - == OFFSET_OF(PP_GamepadData_Dev, pp_name)) |
| - |
| - DCHECK_GAMEPADS_OFFSET(length, length); |
| - DCHECK_GAMEPADS_OFFSET(items, items); |
| - DCHECK_GAMEPAD_OFFSET(connected, connected); |
| - DCHECK_GAMEPAD_OFFSET(id, id); |
| - DCHECK_GAMEPAD_OFFSET(timestamp, timestamp); |
| - DCHECK_GAMEPAD_OFFSET(axesLength, axes_length); |
| - DCHECK_GAMEPAD_OFFSET(axes, axes); |
| - DCHECK_GAMEPAD_OFFSET(buttonsLength, buttons_length); |
| - DCHECK_GAMEPAD_OFFSET(buttons, buttons); |
| - |
| -#undef OFFSET_OF |
| -#undef DCHECK_GAMEPADS_OFFSET |
| -#undef DCHECK_GAMEPAD_OFFSET |
| - |
| - delegate()->SampleGamepads(reinterpret_cast<WebKit::WebGamepads*>(data)); |
| + PP_GamepadsSampleData_Dev* data) { |
| + WebKit::WebGamepads webkit_data; |
|
brettw
2012/02/27 17:44:20
I know it was already here, but can you move this
scottmg
2012/02/27 21:29:48
Done.
|
| + delegate()->SampleGamepads(&webkit_data); |
| + |
| + data->length = webkit_data.length; |
| + for (unsigned i = 0; i < webkit_data.length; ++i) { |
| + PP_GamepadSampleData_Dev& output_pad = data->items[i]; |
| + const WebKit::WebGamepad& webkit_pad = webkit_data.items[i]; |
| + output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE; |
| + if (webkit_pad.connected) { |
| + COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id), |
| + id_size_does_not_match); |
| + COMPILE_ASSERT(sizeof(output_pad.axes) == sizeof(webkit_pad.axes), |
| + axes_size_does_not_match); |
| + COMPILE_ASSERT(sizeof(output_pad.buttons) == sizeof(webkit_pad.buttons), |
| + buttons_size_does_not_match); |
| + memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id)); |
| + output_pad.timestamp = webkit_pad.timestamp; |
| + output_pad.axes_length = webkit_pad.axesLength; |
| + memcpy(output_pad.axes, webkit_pad.axes, sizeof(output_pad.axes)); |
| + output_pad.buttons_length = webkit_pad.buttonsLength; |
| + memcpy(output_pad.buttons, |
| + webkit_pad.buttons, |
| + sizeof(output_pad.buttons)); |
| + } |
| + } |
| } |
| bool PluginInstance::IsViewAccelerated() { |