Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 9405033: Revise gamepad interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comment Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_CURSORTYPE_COPY); 213 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_CURSORTYPE_COPY);
214 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_CURSORTYPE_NONE); 214 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_CURSORTYPE_NONE);
215 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_CURSORTYPE_NOTALLOWED); 215 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_CURSORTYPE_NOTALLOWED);
216 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_CURSORTYPE_ZOOMIN); 216 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_CURSORTYPE_ZOOMIN);
217 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_CURSORTYPE_ZOOMOUT); 217 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_CURSORTYPE_ZOOMOUT);
218 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_CURSORTYPE_GRAB); 218 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_CURSORTYPE_GRAB);
219 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING); 219 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING);
220 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; 220 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM;
221 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. 221 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types.
222 222
223 // Ensure conversion from WebKit::WebGamepads to PP_GamepadsData_Dev is safe.
224 // See also DCHECKs in SampleGamepads below.
225 //
226 // Temporarily disabled for 2-sided WebKit roll.
227 //COMPILE_ASSERT(sizeof(WebKit::WebGamepads) == sizeof(PP_GamepadsData_Dev),
228 // size_difference);
229 //COMPILE_ASSERT(sizeof(WebKit::WebGamepad) == sizeof(PP_GamepadData_Dev),
230 // size_difference);
231
232 // Sets |*security_origin| to be the WebKit security origin associated with the 223 // Sets |*security_origin| to be the WebKit security origin associated with the
233 // document containing the given plugin instance. On success, returns true. If 224 // document containing the given plugin instance. On success, returns true. If
234 // the instance is invalid, returns false and |*security_origin| will be 225 // the instance is invalid, returns false and |*security_origin| will be
235 // unchanged. 226 // unchanged.
236 bool SecurityOriginForInstance(PP_Instance instance_id, 227 bool SecurityOriginForInstance(PP_Instance instance_id,
237 WebKit::WebSecurityOrigin* security_origin) { 228 WebKit::WebSecurityOrigin* security_origin) {
238 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); 229 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
239 if (!instance) 230 if (!instance)
240 return false; 231 return false;
241 232
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 NOTREACHED(); 1338 NOTREACHED();
1348 return false; 1339 return false;
1349 } 1340 }
1350 #else 1341 #else
1351 //FIXME 1342 //FIXME
1352 return container_->isRectTopmost(rect); 1343 return container_->isRectTopmost(rect);
1353 #endif 1344 #endif
1354 } 1345 }
1355 1346
1356 void PluginInstance::SampleGamepads(PP_Instance instance, 1347 void PluginInstance::SampleGamepads(PP_Instance instance,
1357 PP_GamepadsData_Dev* data) { 1348 PP_GamepadsSampleData_Dev* data) {
1349 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.
1350 delegate()->SampleGamepads(&webkit_data);
1358 1351
1359 // Because the WebKit objects have trivial ctors, using offsetof doesn't 1352 data->length = webkit_data.length;
1360 // work. Instead use this version based on src/v8/src/globals.h. This 1353 for (unsigned i = 0; i < webkit_data.length; ++i) {
1361 // workaround doesn't work in constant expressions as required for 1354 PP_GamepadSampleData_Dev& output_pad = data->items[i];
1362 // COMPILE_ASSERT, so DCHECK instead. 1355 const WebKit::WebGamepad& webkit_pad = webkit_data.items[i];
1363 1356 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE;
1364 #define OFFSET_OF(type, field) \ 1357 if (webkit_pad.connected) {
1365 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4) 1358 COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id),
1366 1359 id_size_does_not_match);
1367 #define DCHECK_GAMEPADS_OFFSET(webkit_name, pp_name) \ 1360 COMPILE_ASSERT(sizeof(output_pad.axes) == sizeof(webkit_pad.axes),
1368 DCHECK(OFFSET_OF(WebKit::WebGamepads, webkit_name) \ 1361 axes_size_does_not_match);
1369 == OFFSET_OF(PP_GamepadsData_Dev, pp_name)) 1362 COMPILE_ASSERT(sizeof(output_pad.buttons) == sizeof(webkit_pad.buttons),
1370 1363 buttons_size_does_not_match);
1371 #define DCHECK_GAMEPAD_OFFSET(webkit_name, pp_name) \ 1364 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id));
1372 DCHECK(OFFSET_OF(WebKit::WebGamepad, webkit_name) \ 1365 output_pad.timestamp = webkit_pad.timestamp;
1373 == OFFSET_OF(PP_GamepadData_Dev, pp_name)) 1366 output_pad.axes_length = webkit_pad.axesLength;
1374 1367 memcpy(output_pad.axes, webkit_pad.axes, sizeof(output_pad.axes));
1375 DCHECK_GAMEPADS_OFFSET(length, length); 1368 output_pad.buttons_length = webkit_pad.buttonsLength;
1376 DCHECK_GAMEPADS_OFFSET(items, items); 1369 memcpy(output_pad.buttons,
1377 DCHECK_GAMEPAD_OFFSET(connected, connected); 1370 webkit_pad.buttons,
1378 DCHECK_GAMEPAD_OFFSET(id, id); 1371 sizeof(output_pad.buttons));
1379 DCHECK_GAMEPAD_OFFSET(timestamp, timestamp); 1372 }
1380 DCHECK_GAMEPAD_OFFSET(axesLength, axes_length); 1373 }
1381 DCHECK_GAMEPAD_OFFSET(axes, axes);
1382 DCHECK_GAMEPAD_OFFSET(buttonsLength, buttons_length);
1383 DCHECK_GAMEPAD_OFFSET(buttons, buttons);
1384
1385 #undef OFFSET_OF
1386 #undef DCHECK_GAMEPADS_OFFSET
1387 #undef DCHECK_GAMEPAD_OFFSET
1388
1389 delegate()->SampleGamepads(reinterpret_cast<WebKit::WebGamepads*>(data));
1390 } 1374 }
1391 1375
1392 bool PluginInstance::IsViewAccelerated() { 1376 bool PluginInstance::IsViewAccelerated() {
1393 if (!container_) 1377 if (!container_)
1394 return false; 1378 return false;
1395 1379
1396 WebDocument document = container_->element().document(); 1380 WebDocument document = container_->element().document();
1397 WebFrame* frame = document.frame(); 1381 WebFrame* frame = document.frame();
1398 if (!frame) 1382 if (!frame)
1399 return false; 1383 return false;
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 screen_size_for_fullscreen_ = gfx::Size(); 2103 screen_size_for_fullscreen_ = gfx::Size();
2120 WebElement element = container_->element(); 2104 WebElement element = container_->element();
2121 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2105 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2122 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2106 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2123 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2107 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2124 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2108 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2125 } 2109 }
2126 2110
2127 } // namespace ppapi 2111 } // namespace ppapi
2128 } // namespace webkit 2112 } // namespace webkit
OLDNEW
« ppapi/api/dev/ppb_gamepad_dev.idl ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698