| 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/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 Loading... |
| 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 Loading... |
| 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) { |
| 1358 | 1349 WebKit::WebGamepads webkit_data; |
| 1359 // Because the WebKit objects have trivial ctors, using offsetof doesn't | 1350 delegate()->SampleGamepads(&webkit_data); |
| 1360 // work. Instead use this version based on src/v8/src/globals.h. This | 1351 ConvertWebKitGamepadData(webkit_data, data); |
| 1361 // workaround doesn't work in constant expressions as required for | |
| 1362 // COMPILE_ASSERT, so DCHECK instead. | |
| 1363 | |
| 1364 #define OFFSET_OF(type, field) \ | |
| 1365 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4) | |
| 1366 | |
| 1367 #define DCHECK_GAMEPADS_OFFSET(webkit_name, pp_name) \ | |
| 1368 DCHECK(OFFSET_OF(WebKit::WebGamepads, webkit_name) \ | |
| 1369 == OFFSET_OF(PP_GamepadsData_Dev, pp_name)) | |
| 1370 | |
| 1371 #define DCHECK_GAMEPAD_OFFSET(webkit_name, pp_name) \ | |
| 1372 DCHECK(OFFSET_OF(WebKit::WebGamepad, webkit_name) \ | |
| 1373 == OFFSET_OF(PP_GamepadData_Dev, pp_name)) | |
| 1374 | |
| 1375 DCHECK_GAMEPADS_OFFSET(length, length); | |
| 1376 DCHECK_GAMEPADS_OFFSET(items, items); | |
| 1377 DCHECK_GAMEPAD_OFFSET(connected, connected); | |
| 1378 DCHECK_GAMEPAD_OFFSET(id, id); | |
| 1379 DCHECK_GAMEPAD_OFFSET(timestamp, timestamp); | |
| 1380 DCHECK_GAMEPAD_OFFSET(axesLength, axes_length); | |
| 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 } | 1352 } |
| 1391 | 1353 |
| 1392 bool PluginInstance::IsViewAccelerated() { | 1354 bool PluginInstance::IsViewAccelerated() { |
| 1393 if (!container_) | 1355 if (!container_) |
| 1394 return false; | 1356 return false; |
| 1395 | 1357 |
| 1396 WebDocument document = container_->element().document(); | 1358 WebDocument document = container_->element().document(); |
| 1397 WebFrame* frame = document.frame(); | 1359 WebFrame* frame = document.frame(); |
| 1398 if (!frame) | 1360 if (!frame) |
| 1399 return false; | 1361 return false; |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2115 screen_size_for_fullscreen_ = gfx::Size(); | 2077 screen_size_for_fullscreen_ = gfx::Size(); |
| 2116 WebElement element = container_->element(); | 2078 WebElement element = container_->element(); |
| 2117 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2079 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2118 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2080 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2119 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2081 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2120 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2082 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2121 } | 2083 } |
| 2122 | 2084 |
| 2123 } // namespace ppapi | 2085 } // namespace ppapi |
| 2124 } // namespace webkit | 2086 } // namespace webkit |
| OLD | NEW |