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 aa8ac8fcd4165cde1a0cf82edce3e81bf46d8012..96845e07b7dbf08e1a3bdadce0cb0d8188f77701 100644 |
| --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| @@ -449,57 +449,6 @@ void PluginInstance::InstanceCrashed() { |
| delegate()->PluginCrashed(this); |
| } |
| -bool PluginInstance::SetCursor(PP_CursorType_Dev type, |
| - PP_Resource custom_image, |
| - const PP_Point* hot_spot) { |
| - if (type != PP_CURSORTYPE_CUSTOM) { |
| - DoSetCursor(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); |
| - return true; |
| - } |
| - |
| - if (!hot_spot) |
| - return false; |
| - |
| - EnterResourceNoLock<PPB_ImageData_API> enter(custom_image, true); |
| - if (enter.failed()) |
| - return false; |
| - PPB_ImageData_Impl* image_data = |
| - static_cast<PPB_ImageData_Impl*>(enter.object()); |
| - |
| - if (image_data->format() != PPB_ImageData_Impl::GetNativeImageDataFormat()) { |
| - // TODO(yzshen): Handle the case that the image format is different from the |
| - // native format. |
| - NOTIMPLEMENTED(); |
| - return false; |
| - } |
| - |
| - ImageDataAutoMapper auto_mapper(image_data); |
| - if (!auto_mapper.is_valid()) |
| - return false; |
| - |
| - scoped_ptr<WebCursorInfo> custom_cursor( |
| - new WebCursorInfo(WebCursorInfo::TypeCustom)); |
| - custom_cursor->hotSpot.x = hot_spot->x; |
| - custom_cursor->hotSpot.y = hot_spot->y; |
| - |
| -#if WEBKIT_USING_SKIA |
| - const SkBitmap* bitmap = image_data->GetMappedBitmap(); |
| - // Make a deep copy, so that the cursor remains valid even after the original |
| - // image data gets freed. |
| - if (!bitmap->copyTo(&custom_cursor->customImage.getSkBitmap(), |
| - bitmap->config())) { |
| - return false; |
| - } |
| -#elif WEBKIT_USING_CG |
| - // TODO(yzshen): Implement it. |
| - NOTIMPLEMENTED(); |
| - return false; |
| -#endif |
| - |
| - DoSetCursor(custom_cursor.release()); |
| - return true; |
| -} |
| - |
| bool PluginInstance::Initialize(WebPluginContainer* container, |
| const std::vector<std::string>& arg_names, |
| const std::vector<std::string>& arg_values, |
| @@ -2020,6 +1969,51 @@ void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { |
| message_channel_->PostMessageToJavaScript(message); |
| } |
| +PP_Bool PluginInstance::SetCursor(PP_Instance instance, |
| + PP_MouseCursor_Type type, |
| + PP_Resource image, |
| + const PP_Point* hot_spot) { |
| + if (!ValidateSetCursorParams(type, image, hot_spot)) |
| + return PP_FALSE; |
| + |
| + if (type != PP_CURSORTYPE_CUSTOM) { |
| + DoSetCursor(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); |
|
dmichael (off chromium)
2012/03/26 17:43:17
Would it be possible to have a test or something t
brettw
2012/03/27 05:17:19
There were already compiler asserts for this in pp
|
| + return PP_TRUE; |
| + } |
| + |
| + EnterResourceNoLock<PPB_ImageData_API> enter(image, true); |
| + if (enter.failed()) |
| + return PP_FALSE; |
| + PPB_ImageData_Impl* image_data = |
| + static_cast<PPB_ImageData_Impl*>(enter.object()); |
| + |
| + ImageDataAutoMapper auto_mapper(image_data); |
| + if (!auto_mapper.is_valid()) |
| + return PP_FALSE; |
| + |
| + scoped_ptr<WebCursorInfo> custom_cursor( |
| + new WebCursorInfo(WebCursorInfo::TypeCustom)); |
| + custom_cursor->hotSpot.x = hot_spot->x; |
| + custom_cursor->hotSpot.y = hot_spot->y; |
| + |
| +#if WEBKIT_USING_SKIA |
| + const SkBitmap* bitmap = image_data->GetMappedBitmap(); |
| + // Make a deep copy, so that the cursor remains valid even after the original |
| + // image data gets freed. |
| + if (!bitmap->copyTo(&custom_cursor->customImage.getSkBitmap(), |
| + bitmap->config())) { |
| + return PP_FALSE; |
| + } |
| +#elif WEBKIT_USING_CG |
| + // TODO(yzshen): Implement it. |
| + NOTIMPLEMENTED(); |
| + return false; |
| +#endif |
| + |
| + DoSetCursor(custom_cursor.release()); |
| + return PP_TRUE; |
| +} |
| + |
| int32_t PluginInstance::LockMouse(PP_Instance instance, |
| PP_CompletionCallback callback) { |
| if (!callback.func) { |