diff options
60 files changed, 1074 insertions, 1119 deletions
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc index 8a820a9..39f0262 100644 --- a/chrome/test/ui/ppapi_uitest.cc +++ b/chrome/test/ui/ppapi_uitest.cc @@ -444,17 +444,6 @@ TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Broker) TEST_PPAPI_IN_PROCESS(Core) TEST_PPAPI_OUT_OF_PROCESS(Core) -// Times out on Linux. http://crbug.com/108180 -#if defined(OS_LINUX) -#define MAYBE_CursorControl DISABLED_CursorControl -#else -#define MAYBE_CursorControl CursorControl -#endif - -TEST_PPAPI_IN_PROCESS(MAYBE_CursorControl) -TEST_PPAPI_OUT_OF_PROCESS(MAYBE_CursorControl) -TEST_PPAPI_NACL_VIA_HTTP(MAYBE_CursorControl) - // Times out on Linux. http://crbug.com/108859 #if defined(OS_LINUX) #define MAYBE_InputEvent DISABLED_InputEvent @@ -1039,4 +1028,8 @@ TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit) TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics) TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) +TEST_PPAPI_IN_PROCESS(MouseCursor) +TEST_PPAPI_OUT_OF_PROCESS(MouseCursor) +TEST_PPAPI_NACL_VIA_HTTP(MouseCursor) + #endif // ADDRESS_SANITIZER diff --git a/ppapi/api/ppb_mouse_cursor.idl b/ppapi/api/ppb_mouse_cursor.idl new file mode 100644 index 0000000..b939016 --- /dev/null +++ b/ppapi/api/ppb_mouse_cursor.idl @@ -0,0 +1,106 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * This file defines the <code>PPB_MouseCursor</code> interface for setting
+ * the mouse cursor.
+ */
+
+label Chrome {
+ M19 = 1.0
+};
+
+/**
+ * The <code>PP_MouseCursor_Type</code> enumeration lists the available stock
+ * cursor types.
+ */
+[assert_size(4), notypedef]
+enum PP_MouseCursor_Type {
+ PP_MOUSECURSOR_TYPE_CUSTOM = -1,
+ PP_MOUSECURSOR_TYPE_POINTER = 0,
+ PP_MOUSECURSOR_TYPE_CROSS = 1,
+ PP_MOUSECURSOR_TYPE_HAND = 2,
+ PP_MOUSECURSOR_TYPE_IBEAM = 3,
+ PP_MOUSECURSOR_TYPE_WAIT = 4,
+ PP_MOUSECURSOR_TYPE_HELP = 5,
+ PP_MOUSECURSOR_TYPE_EASTRESIZE = 6,
+ PP_MOUSECURSOR_TYPE_NORTHRESIZE = 7,
+ PP_MOUSECURSOR_TYPE_NORTHEASTRESIZE = 8,
+ PP_MOUSECURSOR_TYPE_NORTHWESTRESIZE = 9,
+ PP_MOUSECURSOR_TYPE_SOUTHRESIZE = 10,
+ PP_MOUSECURSOR_TYPE_SOUTHEASTRESIZE = 11,
+ PP_MOUSECURSOR_TYPE_SOUTHWESTRESIZE = 12,
+ PP_MOUSECURSOR_TYPE_WESTRESIZE = 13,
+ PP_MOUSECURSOR_TYPE_NORTHSOUTHRESIZE = 14,
+ PP_MOUSECURSOR_TYPE_EASTWESTRESIZE = 15,
+ PP_MOUSECURSOR_TYPE_NORTHEASTSOUTHWESTRESIZE = 16,
+ PP_MOUSECURSOR_TYPE_NORTHWESTSOUTHEASTRESIZE = 17,
+ PP_MOUSECURSOR_TYPE_COLUMNRESIZE = 18,
+ PP_MOUSECURSOR_TYPE_ROWRESIZE = 19,
+ PP_MOUSECURSOR_TYPE_MIDDLEPANNING = 20,
+ PP_MOUSECURSOR_TYPE_EASTPANNING = 21,
+ PP_MOUSECURSOR_TYPE_NORTHPANNING = 22,
+ PP_MOUSECURSOR_TYPE_NORTHEASTPANNING = 23,
+ PP_MOUSECURSOR_TYPE_NORTHWESTPANNING = 24,
+ PP_MOUSECURSOR_TYPE_SOUTHPANNING = 25,
+ PP_MOUSECURSOR_TYPE_SOUTHEASTPANNING = 26,
+ PP_MOUSECURSOR_TYPE_SOUTHWESTPANNING = 27,
+ PP_MOUSECURSOR_TYPE_WESTPANNING = 28,
+ PP_MOUSECURSOR_TYPE_MOVE = 29,
+ PP_MOUSECURSOR_TYPE_VERTICALTEXT = 30,
+ PP_MOUSECURSOR_TYPE_CELL = 31,
+ PP_MOUSECURSOR_TYPE_CONTEXTMENU = 32,
+ PP_MOUSECURSOR_TYPE_ALIAS = 33,
+ PP_MOUSECURSOR_TYPE_PROGRESS = 34,
+ PP_MOUSECURSOR_TYPE_NODROP = 35,
+ PP_MOUSECURSOR_TYPE_COPY = 36,
+ PP_MOUSECURSOR_TYPE_NONE = 37,
+ PP_MOUSECURSOR_TYPE_NOTALLOWED = 38,
+ PP_MOUSECURSOR_TYPE_ZOOMIN = 39,
+ PP_MOUSECURSOR_TYPE_ZOOMOUT = 40,
+ PP_MOUSECURSOR_TYPE_GRAB = 41,
+ PP_MOUSECURSOR_TYPE_GRABBING = 42
+};
+
+/**
+ * The <code>PPB_MouseCursor</code> allows setting the mouse cursor.
+ */
+interface PPB_MouseCursor {
+ /**
+ * Sets the given mouse cursor. The mouse cursor will be in effect whenever
+ * the mouse is over the given instance until it is set again by another
+ * call. Note that you can hide the mouse cursor by setting it to the
+ * <code>PP_MOUSECURSOR_TYPE_NONE</code> type.
+ *
+ * This function allows setting both system defined mouse cursors and
+ * custom cursors. To set a system-defined cursor, pass the type you want
+ * and set the custom image to 0 and the hot spot to NULL. To set a custom
+ * cursor, set the type to <code>PP_MOUSECURSOR_TYPE_CUSTOM</code> and
+ * specify your image and hot spot.
+ *
+ * @param[in] instance A <code>PP_Instance</code> indentifying the instance
+ * that the mouse cursor will affect.
+ *
+ * @param[in] type A <code>PP_MouseCursor_Type</code> identifying the type of
+ * mouse cursor to show.
+ *
+ * @param[in] image A <code>PPB_ImageData</code> resource identifying the
+ * custom image to set when the type is
+ * <code>PP_MOUSECURSOR_TYPE_CUSTOM</code>. The image must be less than 32
+ * pixels in each direction and must be of the system's native image format.
+ * When you are specifying a predefined cursor, this parameter must be 0.
+ *
+ * @param[in] hot_spot When setting a custom cursor, this idenfifies the
+ * pixel position within the given image of the "hot spot" of the cursor.
+ * When specifying a stock cursor, this parameter is ignored.
+ *
+ * @return PP_TRUE on success, or PP_FALSE if the instance or cursor type
+ * is invalid, or if the image is too large.
+ */
+ PP_Bool SetCursor([in] PP_Instance instance,
+ [in] PP_MouseCursor_Type type,
+ [in] PP_Resource image,
+ [in] PP_Point hot_spot);
+};
diff --git a/ppapi/c/ppb_mouse_cursor.h b/ppapi/c/ppb_mouse_cursor.h new file mode 100644 index 0000000..1be5889 --- /dev/null +++ b/ppapi/c/ppb_mouse_cursor.h @@ -0,0 +1,138 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From ppb_mouse_cursor.idl modified Mon Mar 26 22:05:07 2012. */ + +#ifndef PPAPI_C_PPB_MOUSE_CURSOR_H_ +#define PPAPI_C_PPB_MOUSE_CURSOR_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_point.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" + +#define PPB_MOUSECURSOR_INTERFACE_1_0 "PPB_MouseCursor;1.0" +#define PPB_MOUSECURSOR_INTERFACE PPB_MOUSECURSOR_INTERFACE_1_0 + +/** + * @file + * This file defines the <code>PPB_MouseCursor</code> interface for setting + * the mouse cursor. + */ + + +/** + * @addtogroup Enums + * @{ + */ +/** + * The <code>PP_MouseCursor_Type</code> enumeration lists the available stock + * cursor types. + */ +enum PP_MouseCursor_Type { + PP_MOUSECURSOR_TYPE_CUSTOM = -1, + PP_MOUSECURSOR_TYPE_POINTER = 0, + PP_MOUSECURSOR_TYPE_CROSS = 1, + PP_MOUSECURSOR_TYPE_HAND = 2, + PP_MOUSECURSOR_TYPE_IBEAM = 3, + PP_MOUSECURSOR_TYPE_WAIT = 4, + PP_MOUSECURSOR_TYPE_HELP = 5, + PP_MOUSECURSOR_TYPE_EASTRESIZE = 6, + PP_MOUSECURSOR_TYPE_NORTHRESIZE = 7, + PP_MOUSECURSOR_TYPE_NORTHEASTRESIZE = 8, + PP_MOUSECURSOR_TYPE_NORTHWESTRESIZE = 9, + PP_MOUSECURSOR_TYPE_SOUTHRESIZE = 10, + PP_MOUSECURSOR_TYPE_SOUTHEASTRESIZE = 11, + PP_MOUSECURSOR_TYPE_SOUTHWESTRESIZE = 12, + PP_MOUSECURSOR_TYPE_WESTRESIZE = 13, + PP_MOUSECURSOR_TYPE_NORTHSOUTHRESIZE = 14, + PP_MOUSECURSOR_TYPE_EASTWESTRESIZE = 15, + PP_MOUSECURSOR_TYPE_NORTHEASTSOUTHWESTRESIZE = 16, + PP_MOUSECURSOR_TYPE_NORTHWESTSOUTHEASTRESIZE = 17, + PP_MOUSECURSOR_TYPE_COLUMNRESIZE = 18, + PP_MOUSECURSOR_TYPE_ROWRESIZE = 19, + PP_MOUSECURSOR_TYPE_MIDDLEPANNING = 20, + PP_MOUSECURSOR_TYPE_EASTPANNING = 21, + PP_MOUSECURSOR_TYPE_NORTHPANNING = 22, + PP_MOUSECURSOR_TYPE_NORTHEASTPANNING = 23, + PP_MOUSECURSOR_TYPE_NORTHWESTPANNING = 24, + PP_MOUSECURSOR_TYPE_SOUTHPANNING = 25, + PP_MOUSECURSOR_TYPE_SOUTHEASTPANNING = 26, + PP_MOUSECURSOR_TYPE_SOUTHWESTPANNING = 27, + PP_MOUSECURSOR_TYPE_WESTPANNING = 28, + PP_MOUSECURSOR_TYPE_MOVE = 29, + PP_MOUSECURSOR_TYPE_VERTICALTEXT = 30, + PP_MOUSECURSOR_TYPE_CELL = 31, + PP_MOUSECURSOR_TYPE_CONTEXTMENU = 32, + PP_MOUSECURSOR_TYPE_ALIAS = 33, + PP_MOUSECURSOR_TYPE_PROGRESS = 34, + PP_MOUSECURSOR_TYPE_NODROP = 35, + PP_MOUSECURSOR_TYPE_COPY = 36, + PP_MOUSECURSOR_TYPE_NONE = 37, + PP_MOUSECURSOR_TYPE_NOTALLOWED = 38, + PP_MOUSECURSOR_TYPE_ZOOMIN = 39, + PP_MOUSECURSOR_TYPE_ZOOMOUT = 40, + PP_MOUSECURSOR_TYPE_GRAB = 41, + PP_MOUSECURSOR_TYPE_GRABBING = 42 +}; +PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_MouseCursor_Type, 4); +/** + * @} + */ + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * The <code>PPB_MouseCursor</code> allows setting the mouse cursor. + */ +struct PPB_MouseCursor_1_0 { + /** + * Sets the given mouse cursor. The mouse cursor will be in effect whenever + * the mouse is over the given instance until it is set again by another + * call. Note that you can hide the mouse cursor by setting it to the + * <code>PP_MOUSECURSOR_TYPE_NONE</code> type. + * + * This function allows setting both system defined mouse cursors and + * custom cursors. To set a system-defined cursor, pass the type you want + * and set the custom image to 0 and the hot spot to NULL. To set a custom + * cursor, set the type to <code>PP_MOUSECURSOR_TYPE_CUSTOM</code> and + * specify your image and hot spot. + * + * @param[in] instance A <code>PP_Instance</code> indentifying the instance + * that the mouse cursor will affect. + * + * @param[in] type A <code>PP_MouseCursor_Type</code> identifying the type of + * mouse cursor to show. + * + * @param[in] image A <code>PPB_ImageData</code> resource identifying the + * custom image to set when the type is + * <code>PP_MOUSECURSOR_TYPE_CUSTOM</code>. The image must be less than 32 + * pixels in each direction and must be of the system's native image format. + * When you are specifying a predefined cursor, this parameter must be 0. + * + * @param[in] hot_spot When setting a custom cursor, this idenfifies the + * pixel position within the given image of the "hot spot" of the cursor. + * When specifying a stock cursor, this parameter is ignored. + * + * @return PP_TRUE on success, or PP_FALSE if the instance or cursor type + * is invalid, or if the image is too large. + */ + PP_Bool (*SetCursor)(PP_Instance instance, + enum PP_MouseCursor_Type type, + PP_Resource image, + const struct PP_Point* hot_spot); +}; + +typedef struct PPB_MouseCursor_1_0 PPB_MouseCursor; +/** + * @} + */ + +#endif /* PPAPI_C_PPB_MOUSE_CURSOR_H_ */ + diff --git a/ppapi/cpp/mouse_cursor.cc b/ppapi/cpp/mouse_cursor.cc new file mode 100644 index 0000000..c5ac20a --- /dev/null +++ b/ppapi/cpp/mouse_cursor.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/mouse_cursor.h"
+
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_MouseCursor_1_0>() {
+ return PPB_MOUSECURSOR_INTERFACE_1_0;
+}
+
+} // namespace
+
+// static
+bool MouseCursor::SetCursor(const InstanceHandle& instance,
+ PP_MouseCursor_Type type,
+ const ImageData& image,
+ const Point& hot_spot) {
+ if (!has_interface<PPB_MouseCursor_1_0>())
+ return false;
+ return PP_ToBool(get_interface<PPB_MouseCursor_1_0>()->SetCursor(
+ instance.pp_instance(), type, image.pp_resource(),
+ &hot_spot.pp_point()));
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/mouse_cursor.h b/ppapi/cpp/mouse_cursor.h new file mode 100644 index 0000000..a54084e --- /dev/null +++ b/ppapi/cpp/mouse_cursor.h @@ -0,0 +1,56 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_MOUSE_CURSOR_H_
+#define PPAPI_CPP_MOUSE_CURSOR_H_
+
+#include "ppapi/c/ppb_mouse_cursor.h"
+#include "ppapi/cpp/image_data.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/point.h"
+
+namespace pp {
+
+class MouseCursor {
+ public:
+ /// Sets the given mouse cursor. The mouse cursor will be in effect whenever
+ /// the mouse is over the given instance until it is set again by another
+ /// call. Note that you can hide the mouse cursor by setting it to the
+ /// <code>PP_MOUSECURSOR_TYPE_NONE</code> type.
+ ///
+ /// This function allows setting both system defined mouse cursors and
+ /// custom cursors. To set a system-defined cursor, pass the type you want
+ /// and set the custom image to a default-constructor ImageData object.
+ /// To set a custom cursor, set the type to
+ /// <code>PP_MOUSECURSOR_TYPE_CUSTOM</code> and specify your image and hot
+ /// spot.
+ ///
+ /// @param[in] instance A handle indentifying the instance that the mouse
+ /// cursor will affect.
+ ///
+ /// @param[in] type A <code>PP_MouseCursor_Type</code> identifying the type
+ /// of mouse cursor to show. See <code>ppapi/c/ppb_mouse_cursor.h</code>.
+ ///
+ /// @param[in] image A <code>ImageData</code> object identifying the
+ /// custom image to set when the type is
+ /// <code>PP_MOUSECURSOR_TYPE_CUSTOM</code>. The image must be less than 32
+ /// pixels in each direction and must be of the system's native image format.
+ /// When you are specifying a predefined cursor, this parameter should be a
+ /// default-constructed ImageData.
+ ///
+ /// @param[in] hot_spot When setting a custom cursor, this idenfifies the
+ /// pixel position within the given image of the "hot spot" of the cursor.
+ /// When specifying a stock cursor, this parameter is ignored.
+ ///
+ /// @return true on success, or false if the instance or cursor type
+ /// was invalid or if the image was too large.
+ static bool SetCursor(const InstanceHandle& instance,
+ PP_MouseCursor_Type type,
+ const ImageData& image = ImageData(),
+ const Point& hot_spot = Point(0, 0));
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_MOUSE_CURSOR_H_
diff --git a/ppapi/examples/2d/paint_manager_example.cc b/ppapi/examples/2d/paint_manager_example.cc index d3530cb..86bdbe7 100644 --- a/ppapi/examples/2d/paint_manager_example.cc +++ b/ppapi/examples/2d/paint_manager_example.cc @@ -9,6 +9,7 @@ #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/size.h" +#include "ppapi/cpp/view.h" #include "ppapi/utility/graphics/paint_manager.h" // Number of pixels to each side of the center of the square that we draw. @@ -70,8 +71,8 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { } } - virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip) { - paint_manager_.SetSize(position.size()); + virtual void DidChangeView(const pp::View& view) { + paint_manager_.SetSize(view.GetRect().size()); } // PaintManager::Client implementation. diff --git a/ppapi/examples/mouse_cursor/mouse_cursor.cc b/ppapi/examples/mouse_cursor/mouse_cursor.cc new file mode 100644 index 0000000..0c8b10b --- /dev/null +++ b/ppapi/examples/mouse_cursor/mouse_cursor.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/graphics_2d.h" +#include "ppapi/cpp/image_data.h" +#include "ppapi/cpp/input_event.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/mouse_cursor.h" +#include "ppapi/cpp/view.h" + +void FillRect(pp::ImageData* image, int left, int top, int width, int height, + uint32_t color) { + for (int y = std::max(0, top); + y < std::min(image->size().height() - 1, top + height); + y++) { + for (int x = std::max(0, left); + x < std::min(image->size().width() - 1, left + width); + x++) + *image->GetAddr32(pp::Point(x, y)) = color; + } +} + +class MyInstance : public pp::Instance { + public: + MyInstance(PP_Instance instance) + : pp::Instance(instance), width_(0), height_(0) { + RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); + } + + virtual ~MyInstance() { + } + + virtual void DidChangeView(const pp::View& view) {
+ width_ = view.GetRect().width();
+ height_ = view.GetRect().height();
+ }
+
+ virtual bool HandleInputEvent(const pp::InputEvent& event) { + switch (event.GetType()) { + case PP_INPUTEVENT_TYPE_MOUSEDOWN: + return true; + case PP_INPUTEVENT_TYPE_MOUSEMOVE: + HandleMove(pp::MouseInputEvent(event)); + return true; + case PP_INPUTEVENT_TYPE_KEYDOWN: + return true; + default: + return false; + } + } + + void HandleMove(const pp::MouseInputEvent& event) { + pp::Point point = event.GetPosition(); + int segments = 3; + if (point.y() < height_ / segments) { + // Top part gets custom cursor of wait. + pp::MouseCursor::SetCursor(this, PP_MOUSECURSOR_TYPE_WAIT); + } else if (point.y() < (height_ / segments) * 2) { + // Next part gets custom image cursor. + pp::ImageData cursor(this, pp::ImageData::GetNativeImageDataFormat(), + pp::Size(32, 32), true); + // Note that in real life you will need to handle the case where the + // native format is different. + FillRect(&cursor, 0, 0, 32, 32, 0x80000080); + pp::MouseCursor::SetCursor(this, PP_MOUSECURSOR_TYPE_CUSTOM, cursor, + pp::Point(16, 16)); + } else { + // Next part gets no cursor. + pp::MouseCursor::SetCursor(this, PP_MOUSECURSOR_TYPE_NONE); + } + } + + + private: + int width_; + int height_; +}; + +class MyModule : public pp::Module { + public: + MyModule() : pp::Module() {} + virtual ~MyModule() {} + + virtual pp::Instance* CreateInstance(PP_Instance instance) { + return new MyInstance(instance); + } +}; + +namespace pp { + +// Factory function for your specialization of the Module object. +Module* CreateModule() { + return new MyModule(); +} + +} // namespace pp diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc index e5c0d91..35a6e8f 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc @@ -347,13 +347,6 @@ const PPB_WheelInputEvent* PPBWheelInputEventInterface() { } // Dev interfaces. -const PPB_CursorControl_Dev* PPBCursorControlInterface() { - static const PPB_CursorControl_Dev* ppb = - static_cast<const PPB_CursorControl_Dev*>( - GetBrowserInterfaceSafe(PPB_CURSOR_CONTROL_DEV_INTERFACE)); - return ppb; -} - const PPB_FileIO* PPBFileIOInterface() { static const PPB_FileIO* ppb = static_cast<const PPB_FileIO*>( @@ -403,6 +396,13 @@ const PPB_Gamepad* PPBGamepadInterface() { return ppb; } +const PPB_MouseCursor_1_0* PPBMouseCursorInterface() { + static const PPB_MouseCursor_1_0* ppb = + static_cast<const PPB_MouseCursor_1_0*>( + GetBrowserInterfaceSafe(PPB_MOUSECURSOR_INTERFACE_1_0)); + return ppb; +} + const PPB_MouseLock* PPBMouseLockInterface() { static const PPB_MouseLock* ppb = static_cast<const PPB_MouseLock*>( GetBrowserInterfaceSafe(PPB_MOUSELOCK_INTERFACE)); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h index 62ebd9b..d8f37a9 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h @@ -5,7 +5,6 @@ #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ -#include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/c/dev/ppb_find_dev.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" @@ -28,6 +27,7 @@ #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" +#include "ppapi/c/ppb_mouse_cursor.h" #include "ppapi/c/ppb_mouse_lock.h" #include "ppapi/c/ppb_url_loader.h" #include "ppapi/c/ppb_url_request_info.h" @@ -102,7 +102,7 @@ const void* GetBrowserInterfaceSafe(const char* interface_name); // plugin side of the proxy, so they can be used by the shared proxy code // under both trusted and untrusted compilation. const PPB_Core* PPBCoreInterface(); // shared -const PPB_CursorControl_Dev* PPBCursorControlInterface(); +const PPB_MouseCursor_1_0* PPBMouseCursorInterface(); const PPB_FileIO* PPBFileIOInterface(); const PPB_FileRef* PPBFileRefInterface(); const PPB_FileSystem* PPBFileSystemInterface(); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_cursor_control_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_cursor_control_rpc_server.cc deleted file mode 100644 index b0b3218..0000000 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_cursor_control_rpc_server.cc +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// SRPC-abstraction wrappers around PPB_CursorControl_Dev functions. - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_scoped_ptr.h" -#include "native_client/src/include/portability.h" -#include "native_client/src/shared/ppapi_proxy/browser_globals.h" -#include "native_client/src/shared/ppapi_proxy/utility.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/pp_point.h" -#include "ppapi/c/ppb_image_data.h" -#include "srpcgen/ppb_rpc.h" - -using ppapi_proxy::DebugPrintf; -using ppapi_proxy::PPBCursorControlInterface; - -void PpbCursorControlRpcServer::PPB_CursorControl_SetCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t type, - PP_Resource custom_image, - nacl_abi_size_t hot_spot_size, char* hot_spot, - int32_t* success) { - NaClSrpcClosureRunner runner(done); - rpc->result = NACL_SRPC_RESULT_APP_ERROR; - - PP_Point* pp_hot_spot = NULL; - if (hot_spot_size != 0) { - if (hot_spot_size != sizeof(struct PP_Point)) - return; - pp_hot_spot = reinterpret_cast<struct PP_Point*>(hot_spot); - } - PP_Bool pp_success = PPBCursorControlInterface()->SetCursor( - instance, - static_cast<PP_CursorType_Dev>(type), - custom_image, - pp_hot_spot); - *success = PP_ToBool(pp_success); - - DebugPrintf("PPB_CursorControl::SetCursor: success=%"NACL_PRId32"\n", - *success); - rpc->result = NACL_SRPC_RESULT_OK; -} - -void PpbCursorControlRpcServer::PPB_CursorControl_LockCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success) { - NaClSrpcClosureRunner runner(done); - rpc->result = NACL_SRPC_RESULT_APP_ERROR; - - PP_Bool pp_success = PPBCursorControlInterface()->LockCursor(instance); - *success = PP_ToBool(pp_success); - - DebugPrintf("PPB_CursorControl::LockCursor: success=%"NACL_PRId32"\n", - *success); - rpc->result = NACL_SRPC_RESULT_OK; -} - -void PpbCursorControlRpcServer::PPB_CursorControl_UnlockCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success) { - NaClSrpcClosureRunner runner(done); - rpc->result = NACL_SRPC_RESULT_APP_ERROR; - - PP_Bool pp_success = PPBCursorControlInterface()->UnlockCursor(instance); - *success = PP_ToBool(pp_success); - - DebugPrintf("PPB_CursorControl::UnlockCursor: success=%"NACL_PRId32"\n", - *success); - rpc->result = NACL_SRPC_RESULT_OK; -} - -void PpbCursorControlRpcServer::PPB_CursorControl_HasCursorLock( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success) { - NaClSrpcClosureRunner runner(done); - rpc->result = NACL_SRPC_RESULT_APP_ERROR; - - PP_Bool pp_success = PPBCursorControlInterface()->HasCursorLock(instance); - *success = PP_ToBool(pp_success); - - DebugPrintf("PPB_CursorControl::HasCursorLock: success=%"NACL_PRId32"\n", - *success); - rpc->result = NACL_SRPC_RESULT_OK; -} - -void PpbCursorControlRpcServer::PPB_CursorControl_CanLockCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success) { - NaClSrpcClosureRunner runner(done); - rpc->result = NACL_SRPC_RESULT_APP_ERROR; - - PP_Bool pp_success = PPBCursorControlInterface()->CanLockCursor(instance); - *success = PP_ToBool(pp_success); - - DebugPrintf("PPB_CursorControl::CanLockCursor: success=%"NACL_PRId32"\n", - *success); - rpc->result = NACL_SRPC_RESULT_OK; -} diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_mouse_cursor_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_mouse_cursor_rpc_server.cc new file mode 100644 index 0000000..96c4687 --- /dev/null +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_mouse_cursor_rpc_server.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// SRPC-abstraction wrappers around PPB_MouseCursor functions. + +#include "native_client/src/include/nacl_macros.h" +#include "native_client/src/include/nacl_scoped_ptr.h" +#include "native_client/src/include/portability.h" +#include "native_client/src/shared/ppapi_proxy/browser_globals.h" +#include "native_client/src/shared/ppapi_proxy/utility.h" +#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/pp_point.h" +#include "ppapi/c/ppb_image_data.h" +#include "ppapi/c/ppb_mouse_cursor.h" +#include "srpcgen/ppb_rpc.h" + +using ppapi_proxy::DebugPrintf; +using ppapi_proxy::PPBMouseCursorInterface; + +void PpbMouseCursorRpcServer::PPB_MouseCursor_SetCursor( + NaClSrpcRpc* rpc, + NaClSrpcClosure* done, + PP_Instance instance, + int32_t type, + PP_Resource custom_image, + nacl_abi_size_t hot_spot_size, char* hot_spot, + int32_t* success) { + NaClSrpcClosureRunner runner(done); + rpc->result = NACL_SRPC_RESULT_APP_ERROR; + + PP_Point* pp_hot_spot = NULL; + if (hot_spot_size != 0) { + if (hot_spot_size != sizeof(struct PP_Point)) + return; + pp_hot_spot = reinterpret_cast<struct PP_Point*>(hot_spot); + } + PP_Bool pp_success = PPBMouseCursorInterface()->SetCursor( + instance, + static_cast<PP_MouseCursor_Type>(type), + custom_image, + pp_hot_spot); + *success = PP_ToBool(pp_success); + + DebugPrintf("PPB_MouseCursor::SetCursor: success=%"NACL_PRId32"\n", + *success); + rpc->result = NACL_SRPC_RESULT_OK; +} diff --git a/ppapi/native_client/src/shared/ppapi_proxy/build.scons b/ppapi/native_client/src/shared/ppapi_proxy/build.scons index 83b7d2d..9fa7068 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/build.scons +++ b/ppapi/native_client/src/shared/ppapi_proxy/build.scons @@ -39,7 +39,6 @@ env.DualLibrary('ppapi_browser', 'browser_ppb_audio_rpc_server.cc', 'browser_ppb_audio_config_rpc_server.cc', 'browser_ppb_core_rpc_server.cc', - 'browser_ppb_cursor_control_rpc_server.cc', 'browser_ppb_file_io_rpc_server.cc', 'browser_ppb_file_ref_rpc_server.cc', 'browser_ppb_file_system_rpc_server.cc', @@ -54,6 +53,7 @@ env.DualLibrary('ppapi_browser', 'browser_ppb_input_event_rpc_server.cc', 'browser_ppb_instance_rpc_server.cc', 'browser_ppb_messaging_rpc_server.cc', + 'browser_ppb_mouse_cursor_rpc_server.cc', 'browser_ppb_mouse_lock_rpc_server.cc', 'browser_ppb_net_address_private_rpc_server.cc', 'browser_ppb_pdf_rpc_server.cc', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons index 911a00c..0409965 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons +++ b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons @@ -60,7 +60,6 @@ libppruntime = env.NaClSdkLibrary( 'plugin_ppb_audio_config.cc', 'plugin_ppb_buffer.cc', 'plugin_ppb_core.cc', - 'plugin_ppb_cursor_control.cc', 'plugin_ppb_file_io.cc', 'plugin_ppb_file_system.cc', 'plugin_ppb_file_ref.cc', @@ -76,6 +75,7 @@ libppruntime = env.NaClSdkLibrary( 'plugin_ppb_instance.cc', 'plugin_ppb_memory.cc', 'plugin_ppb_messaging.cc', + 'plugin_ppb_mouse_cursor.cc', 'plugin_ppb_mouse_lock.cc', 'plugin_ppb_net_address_private.cc', 'plugin_ppb_pdf.cc', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc index 2f2a9b1..e2dbe9a 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc @@ -11,7 +11,6 @@ #include "native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_buffer.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_core.h" -#include "native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_file_io.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_file_ref.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_file_system.h" @@ -27,6 +26,7 @@ #include "native_client/src/shared/ppapi_proxy/plugin_ppb_instance.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_memory.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.h" +#include "native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_lock.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_net_address_private.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_pdf.h" @@ -63,7 +63,7 @@ InterfaceMapElement interface_map[] = { { PPB_AUDIO_CONFIG_INTERFACE_1_0, PluginAudioConfig::GetInterface1_0(), true }, { PPB_CORE_INTERFACE, PluginCore::GetInterface(), true }, - { PPB_CURSOR_CONTROL_DEV_INTERFACE, PluginCursorControl::GetInterface(), + { PPB_MOUSECURSOR_INTERFACE_1_0, PluginMouseCursor::GetInterface(), true }, { PPB_FILEIO_INTERFACE, PluginFileIO::GetInterface(), true }, { PPB_FILEREF_INTERFACE, PluginFileRef::GetInterface(), true }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.cc deleted file mode 100644 index a36c992..0000000 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.cc +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.h" - -#include "native_client/src/include/portability.h" -#include "native_client/src/shared/ppapi_proxy/plugin_callback.h" -#include "native_client/src/shared/ppapi_proxy/plugin_globals.h" -#include "native_client/src/shared/ppapi_proxy/utility.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "srpcgen/ppb_rpc.h" - -namespace ppapi_proxy { - -namespace { - -const nacl_abi_size_t kPPPointBytes = - static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); - -PP_Bool SetCursor(PP_Instance instance, - enum PP_CursorType_Dev type, - PP_Resource custom_image, - const struct PP_Point* hot_spot) { - DebugPrintf("PPB_CursorControl::SetCursor: " - "instance=%"NACL_PRId32"\n", instance); - - int32_t hot_spot_size = (hot_spot != NULL) ? kPPPointBytes : 0; - int32_t success = 0; - NaClSrpcError srpc_result = - PpbCursorControlRpcClient::PPB_CursorControl_SetCursor( - GetMainSrpcChannel(), - instance, - type, - custom_image, - hot_spot_size, - reinterpret_cast<char*>(const_cast<struct PP_Point*>(hot_spot)), - &success); - - DebugPrintf("PPB_CursorControl::SetCursor: %s\n", - NaClSrpcErrorString(srpc_result)); - if (srpc_result == NACL_SRPC_RESULT_OK && success) - return PP_TRUE; - return PP_FALSE; -} - -PP_Bool LockCursor(PP_Instance instance) { - DebugPrintf("PPB_CursorControl::LockCursor: " - "instance=%"NACL_PRId32"\n", instance); - - int32_t success = 0; - NaClSrpcError srpc_result = - PpbCursorControlRpcClient::PPB_CursorControl_LockCursor( - GetMainSrpcChannel(), - instance, - &success); - - DebugPrintf("PPB_CursorControl::LockCursor: %s\n", - NaClSrpcErrorString(srpc_result)); - - if (srpc_result == NACL_SRPC_RESULT_OK && success) - return PP_TRUE; - return PP_FALSE; -} - -PP_Bool UnlockCursor(PP_Instance instance) { - DebugPrintf("PPB_CursorControl::UnlockCursor: " - "instance=%"NACL_PRId32"\n", instance); - - int32_t success = 0; - NaClSrpcError srpc_result = - PpbCursorControlRpcClient::PPB_CursorControl_UnlockCursor( - GetMainSrpcChannel(), - instance, - &success); - - DebugPrintf("PPB_CursorControl::UnlockCursor: %s\n", - NaClSrpcErrorString(srpc_result)); - - if (srpc_result == NACL_SRPC_RESULT_OK && success) - return PP_TRUE; - return PP_FALSE; -} - -PP_Bool HasCursorLock(PP_Instance instance) { - DebugPrintf("PPB_CursorControl::HasCursorLock: " - "instance=%"NACL_PRId32"\n", instance); - - int32_t success = 0; - NaClSrpcError srpc_result = - PpbCursorControlRpcClient::PPB_CursorControl_HasCursorLock( - GetMainSrpcChannel(), - instance, - &success); - - DebugPrintf("PPB_CursorControl::HasCursorLock: %s\n", - NaClSrpcErrorString(srpc_result)); - - if (srpc_result == NACL_SRPC_RESULT_OK && success) - return PP_TRUE; - return PP_FALSE; -} - -PP_Bool CanLockCursor(PP_Instance instance) { - DebugPrintf("PPB_CursorControl::CanLockCursor: " - "instance=%"NACL_PRId32"\n", instance); - - int32_t success = 0; - NaClSrpcError srpc_result = - PpbCursorControlRpcClient::PPB_CursorControl_CanLockCursor( - GetMainSrpcChannel(), - instance, - &success); - - DebugPrintf("PPB_CursorControl::CanLockCursor: %s\n", - NaClSrpcErrorString(srpc_result)); - - if (srpc_result == NACL_SRPC_RESULT_OK && success) - return PP_TRUE; - return PP_FALSE; -} - -} // namespace - -const PPB_CursorControl_Dev* PluginCursorControl::GetInterface() { - static const PPB_CursorControl_Dev cursor_control_interface = { - SetCursor, - LockCursor, - UnlockCursor, - HasCursorLock, - CanLockCursor - }; - return &cursor_control_interface; -} - -} // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.h deleted file mode 100644 index a90b26f..0000000 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_cursor_control.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_CURSOR_CONTROL_H_ -#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_CURSOR_CONTROL_H_ - -#include "native_client/src/include/nacl_macros.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" - -namespace ppapi_proxy { - -// Implements the untrusted side of the PPB_CursorControl_Dev interface. -class PluginCursorControl { - public: - PluginCursorControl(); - static const PPB_CursorControl_Dev* GetInterface(); - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(PluginCursorControl); -}; - -} // namespace ppapi_proxy - -#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_CURSOR_CONTROL_H_ - diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.cc new file mode 100644 index 0000000..76a2185 --- /dev/null +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.h" + +#include "native_client/src/include/portability.h" +#include "native_client/src/shared/ppapi_proxy/plugin_callback.h" +#include "native_client/src/shared/ppapi_proxy/plugin_globals.h" +#include "native_client/src/shared/ppapi_proxy/utility.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_mouse_cursor.h" +#include "srpcgen/ppb_rpc.h" + +namespace ppapi_proxy { + +namespace { + +const nacl_abi_size_t kPPPointBytes = + static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); + +PP_Bool SetCursor(PP_Instance instance, + enum PP_MouseCursor_Type type, + PP_Resource custom_image, + const struct PP_Point* hot_spot) { + DebugPrintf("PPB_MouseCursor::SetCursor: " + "instance=%"NACL_PRId32"\n", instance); + + int32_t hot_spot_size = (hot_spot != NULL) ? kPPPointBytes : 0; + int32_t success = 0; + NaClSrpcError srpc_result = + PpbMouseCursorRpcClient::PPB_MouseCursor_SetCursor( + GetMainSrpcChannel(), + instance, + type, + custom_image, + hot_spot_size, + reinterpret_cast<char*>(const_cast<struct PP_Point*>(hot_spot)), + &success); + + DebugPrintf("PPB_MouseCursor::SetCursor: %s\n", + NaClSrpcErrorString(srpc_result)); + if (srpc_result == NACL_SRPC_RESULT_OK && success) + return PP_TRUE; + return PP_FALSE; +} + +} // namespace + +const PPB_MouseCursor_1_0* PluginMouseCursor::GetInterface() { + static const PPB_MouseCursor mouse_cursor_interface = { + SetCursor, + }; + return &mouse_cursor_interface; +} + +} // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.h new file mode 100644 index 0000000..490a8d4 --- /dev/null +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_mouse_cursor.h @@ -0,0 +1,26 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_MOUSE_CURSOR_H_ +#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_MOUSE_CURSOR_H_ + +#include "native_client/src/include/nacl_macros.h" +#include "ppapi/c/ppb_mouse_cursor.h" + +namespace ppapi_proxy { + +// Implements the untrusted side of the PPB_MouseCursor interface. +class PluginMouseCursor { + public: + PluginMouseCursor(); + static const PPB_MouseCursor_1_0* GetInterface(); + + private: + NACL_DISALLOW_COPY_AND_ASSIGN(PluginMouseCursor); +}; + +} // namespace ppapi_proxy + +#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_PPB_MOUSE_CURSOR_H_ + diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy.gyp b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy.gyp index 5922275..4918710 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy.gyp +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy.gyp @@ -34,7 +34,6 @@ 'browser_ppb_audio_config_rpc_server.cc', 'browser_ppb_audio_rpc_server.cc', 'browser_ppb_core_rpc_server.cc', - 'browser_ppb_cursor_control_rpc_server.cc', 'browser_ppb_file_io_rpc_server.cc', 'browser_ppb_file_ref_rpc_server.cc', 'browser_ppb_file_system_rpc_server.cc', @@ -49,6 +48,7 @@ 'browser_ppb_input_event_rpc_server.cc', 'browser_ppb_instance_rpc_server.cc', 'browser_ppb_messaging_rpc_server.cc', + 'browser_ppb_mouse_cursor_rpc_server.cc', 'browser_ppb_mouse_lock_rpc_server.cc', 'browser_ppb_net_address_private_rpc_server.cc', 'browser_ppb_pdf_rpc_server.cc', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp index d2dff3d..5761d0e 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp @@ -57,7 +57,6 @@ 'plugin_ppb_audio_config.cc', 'plugin_ppb_buffer.cc', 'plugin_ppb_core.cc', - 'plugin_ppb_cursor_control.cc', 'plugin_ppb_file_io.cc', 'plugin_ppb_file_system.cc', 'plugin_ppb_file_ref.cc', @@ -73,6 +72,7 @@ 'plugin_ppb_instance.cc', 'plugin_ppb_memory.cc', 'plugin_ppb_messaging.cc', + 'plugin_ppb_mouse_cursor.cc', 'plugin_ppb_mouse_lock.cc', 'plugin_ppb_net_address_private.cc', 'plugin_ppb_pdf.cc', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_cursor_control.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_cursor_control.srpc deleted file mode 100644 index 1b1115b..0000000 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_cursor_control.srpc +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2011 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# RPC methods used to implement PPB_CursorControl calls from the plugin. -# See ppapi/c/ppb_cursor_control_dev.h for interface details. - -{ - 'name': 'PpbCursorControlRpc', - 'rpcs': [ - {'name': 'PPB_CursorControl_SetCursor', - 'inputs': [['instance', 'PP_Instance'], # PP_Instance - ['type', 'int32_t'], # PP_CursorType_Dev - ['custom_image', 'PP_Resource'], # PP_Resource - ['hot_spot', 'char[]'], # PP_Point - ], - 'outputs': [['success', 'int32_t'], # PP_Bool - ] - }, - {'name': 'PPB_CursorControl_LockCursor', - 'inputs': [['instance', 'PP_Instance'], # PP_Instance - ], - 'outputs': [['success', 'int32_t'], # PP_Bool - ] - }, - {'name': 'PPB_CursorControl_UnlockCursor', - 'inputs': [['instance', 'PP_Instance'], # PP_Instance - ], - 'outputs': [['success', 'int32_t'], # PP_Bool - ] - }, - {'name': 'PPB_CursorControl_HasCursorLock', - 'inputs': [['instance', 'PP_Instance'], # PP_Instance - ], - 'outputs': [['success', 'int32_t'], # PP_Bool - ] - }, - {'name': 'PPB_CursorControl_CanLockCursor', - 'inputs': [['instance', 'PP_Instance'], # PP_Instance - ], - 'outputs': [['success', 'int32_t'], # PP_Bool - ] - }, - ] -} diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_mouse_cursor.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_mouse_cursor.srpc new file mode 100644 index 0000000..474e68b --- /dev/null +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_mouse_cursor.srpc @@ -0,0 +1,20 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# RPC methods used to implement PPB_MouseCursor calls from the plugin. + +{ + 'name': 'PpbMouseCursorRpc', + 'rpcs': [ + {'name': 'PPB_MouseCursor_SetCursor', + 'inputs': [['instance', 'PP_Instance'], # PP_Instance + ['type', 'int32_t'], # PP_MouseCursor_Type + ['custom_image', 'PP_Resource'], # PP_Resource + ['hot_spot', 'char[]'], # PP_Point + ], + 'outputs': [['success', 'int32_t'], # PP_Bool + ] + }, + ] +} diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc index c869403..5f139eb 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc @@ -385,97 +385,6 @@ NaClSrpcError PpbCoreRpcClient::PPB_Core_CallOnMainThread( return retval; } -NaClSrpcError PpbCursorControlRpcClient::PPB_CursorControl_SetCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t type, - PP_Resource custom_image, - nacl_abi_size_t hot_spot_bytes, char* hot_spot, - int32_t* success) { - VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), - ("%s: PPAPI calls are not supported off the main thread\n", - __FUNCTION__)); - NaClSrpcError retval; - retval = NaClSrpcInvokeBySignature( - channel, - "PPB_CursorControl_SetCursor:iiiC:i", - instance, - type, - custom_image, - hot_spot_bytes, hot_spot, - success - ); - return retval; -} - -NaClSrpcError PpbCursorControlRpcClient::PPB_CursorControl_LockCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success) { - VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), - ("%s: PPAPI calls are not supported off the main thread\n", - __FUNCTION__)); - NaClSrpcError retval; - retval = NaClSrpcInvokeBySignature( - channel, - "PPB_CursorControl_LockCursor:i:i", - instance, - success - ); - return retval; -} - -NaClSrpcError PpbCursorControlRpcClient::PPB_CursorControl_UnlockCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success) { - VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), - ("%s: PPAPI calls are not supported off the main thread\n", - __FUNCTION__)); - NaClSrpcError retval; - retval = NaClSrpcInvokeBySignature( - channel, - "PPB_CursorControl_UnlockCursor:i:i", - instance, - success - ); - return retval; -} - -NaClSrpcError PpbCursorControlRpcClient::PPB_CursorControl_HasCursorLock( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success) { - VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), - ("%s: PPAPI calls are not supported off the main thread\n", - __FUNCTION__)); - NaClSrpcError retval; - retval = NaClSrpcInvokeBySignature( - channel, - "PPB_CursorControl_HasCursorLock:i:i", - instance, - success - ); - return retval; -} - -NaClSrpcError PpbCursorControlRpcClient::PPB_CursorControl_CanLockCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success) { - VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), - ("%s: PPAPI calls are not supported off the main thread\n", - __FUNCTION__)); - NaClSrpcError retval; - retval = NaClSrpcInvokeBySignature( - channel, - "PPB_CursorControl_CanLockCursor:i:i", - instance, - success - ); - return retval; -} - NaClSrpcError PpbFileIORpcClient::PPB_FileIO_Create( NaClSrpcChannel* channel, PP_Instance instance, @@ -2047,6 +1956,29 @@ NaClSrpcError PpbMessagingRpcClient::PPB_Messaging_PostMessage( return retval; } +NaClSrpcError PpbMouseCursorRpcClient::PPB_MouseCursor_SetCursor( + NaClSrpcChannel* channel, + PP_Instance instance, + int32_t type, + PP_Resource custom_image, + nacl_abi_size_t hot_spot_bytes, char* hot_spot, + int32_t* success) { + VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(), + ("%s: PPAPI calls are not supported off the main thread\n", + __FUNCTION__)); + NaClSrpcError retval; + retval = NaClSrpcInvokeBySignature( + channel, + "PPB_MouseCursor_SetCursor:iiiC:i", + instance, + type, + custom_image, + hot_spot_bytes, hot_spot, + success + ); + return retval; +} + NaClSrpcError PpbMouseLockRpcClient::PPB_MouseLock_LockMouse( NaClSrpcChannel* channel, PP_Instance instance, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc index d059fca..c7ef961 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc @@ -329,79 +329,6 @@ static void PPB_Core_CallOnMainThreadDispatcher( ); } -static void PPB_CursorControl_SetCursorDispatcher( - NaClSrpcRpc* rpc, - NaClSrpcArg** inputs, - NaClSrpcArg** outputs, - NaClSrpcClosure* done -) { - PpbCursorControlRpcServer::PPB_CursorControl_SetCursor( - rpc, - done, - inputs[0]->u.ival, - inputs[1]->u.ival, - inputs[2]->u.ival, - inputs[3]->u.count, inputs[3]->arrays.carr, - &(outputs[0]->u.ival) - ); -} - -static void PPB_CursorControl_LockCursorDispatcher( - NaClSrpcRpc* rpc, - NaClSrpcArg** inputs, - NaClSrpcArg** outputs, - NaClSrpcClosure* done -) { - PpbCursorControlRpcServer::PPB_CursorControl_LockCursor( - rpc, - done, - inputs[0]->u.ival, - &(outputs[0]->u.ival) - ); -} - -static void PPB_CursorControl_UnlockCursorDispatcher( - NaClSrpcRpc* rpc, - NaClSrpcArg** inputs, - NaClSrpcArg** outputs, - NaClSrpcClosure* done -) { - PpbCursorControlRpcServer::PPB_CursorControl_UnlockCursor( - rpc, - done, - inputs[0]->u.ival, - &(outputs[0]->u.ival) - ); -} - -static void PPB_CursorControl_HasCursorLockDispatcher( - NaClSrpcRpc* rpc, - NaClSrpcArg** inputs, - NaClSrpcArg** outputs, - NaClSrpcClosure* done -) { - PpbCursorControlRpcServer::PPB_CursorControl_HasCursorLock( - rpc, - done, - inputs[0]->u.ival, - &(outputs[0]->u.ival) - ); -} - -static void PPB_CursorControl_CanLockCursorDispatcher( - NaClSrpcRpc* rpc, - NaClSrpcArg** inputs, - NaClSrpcArg** outputs, - NaClSrpcClosure* done -) { - PpbCursorControlRpcServer::PPB_CursorControl_CanLockCursor( - rpc, - done, - inputs[0]->u.ival, - &(outputs[0]->u.ival) - ); -} - static void PPB_FileIO_CreateDispatcher( NaClSrpcRpc* rpc, NaClSrpcArg** inputs, @@ -1634,6 +1561,23 @@ static void PPB_Messaging_PostMessageDispatcher( ); } +static void PPB_MouseCursor_SetCursorDispatcher( + NaClSrpcRpc* rpc, + NaClSrpcArg** inputs, + NaClSrpcArg** outputs, + NaClSrpcClosure* done +) { + PpbMouseCursorRpcServer::PPB_MouseCursor_SetCursor( + rpc, + done, + inputs[0]->u.ival, + inputs[1]->u.ival, + inputs[2]->u.ival, + inputs[3]->u.count, inputs[3]->arrays.carr, + &(outputs[0]->u.ival) + ); +} + static void PPB_MouseLock_LockMouseDispatcher( NaClSrpcRpc* rpc, NaClSrpcArg** inputs, @@ -3188,11 +3132,6 @@ NaClSrpcHandlerDesc PpbRpcs::srpc_methods[] = { { "PPB_Core_GetTime::d", PPB_Core_GetTimeDispatcher }, { "PPB_Core_GetTimeTicks::d", PPB_Core_GetTimeTicksDispatcher }, { "PPB_Core_CallOnMainThread:iii:", PPB_Core_CallOnMainThreadDispatcher }, - { "PPB_CursorControl_SetCursor:iiiC:i", PPB_CursorControl_SetCursorDispatcher }, - { "PPB_CursorControl_LockCursor:i:i", PPB_CursorControl_LockCursorDispatcher }, - { "PPB_CursorControl_UnlockCursor:i:i", PPB_CursorControl_UnlockCursorDispatcher }, - { "PPB_CursorControl_HasCursorLock:i:i", PPB_CursorControl_HasCursorLockDispatcher }, - { "PPB_CursorControl_CanLockCursor:i:i", PPB_CursorControl_CanLockCursorDispatcher }, { "PPB_FileIO_Create:i:i", PPB_FileIO_CreateDispatcher }, { "PPB_FileIO_IsFileIO:i:i", PPB_FileIO_IsFileIODispatcher }, { "PPB_FileIO_Open:iiii:i", PPB_FileIO_OpenDispatcher }, @@ -3272,6 +3211,7 @@ NaClSrpcHandlerDesc PpbRpcs::srpc_methods[] = { { "PPB_Instance_BindGraphics:ii:i", PPB_Instance_BindGraphicsDispatcher }, { "PPB_Instance_IsFullFrame:i:i", PPB_Instance_IsFullFrameDispatcher }, { "PPB_Messaging_PostMessage:iC:", PPB_Messaging_PostMessageDispatcher }, + { "PPB_MouseCursor_SetCursor:iiiC:i", PPB_MouseCursor_SetCursorDispatcher }, { "PPB_MouseLock_LockMouse:ii:i", PPB_MouseLock_LockMouseDispatcher }, { "PPB_MouseLock_UnlockMouse:i:", PPB_MouseLock_UnlockMouseDispatcher }, { "PPB_NetAddress_Private_AreEqual:CC:i", PPB_NetAddress_Private_AreEqualDispatcher }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/run_srpcgen.py b/ppapi/native_client/src/shared/ppapi_proxy/run_srpcgen.py index 62b4779..9876124 100755 --- a/ppapi/native_client/src/shared/ppapi_proxy/run_srpcgen.py +++ b/ppapi/native_client/src/shared/ppapi_proxy/run_srpcgen.py @@ -61,7 +61,6 @@ all_units = [ 'ppb_audio.srpc', 'ppb_audio_config.srpc', 'ppb_core.srpc', - 'ppb_cursor_control.srpc', 'ppb_file_io.srpc', 'ppb_file_ref.srpc', 'ppb_file_system.srpc', @@ -76,6 +75,7 @@ all_units = [ 'ppb_input_event.srpc', 'ppb_instance.srpc', 'ppb_messaging.srpc', + 'ppb_mouse_cursor.srpc', 'ppb_mouse_lock.srpc', 'ppb_net_address_private.srpc', 'ppb_pdf.srpc', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h index 863f907..efd393b 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h @@ -174,43 +174,6 @@ class PpbCoreRpcServer { void operator=(const PpbCoreRpcServer); }; // class PpbCoreRpcServer -class PpbCursorControlRpcServer { - public: - static void PPB_CursorControl_SetCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t type, - PP_Resource custom_image, - nacl_abi_size_t hot_spot_bytes, char* hot_spot, - int32_t* success); - static void PPB_CursorControl_LockCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success); - static void PPB_CursorControl_UnlockCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success); - static void PPB_CursorControl_HasCursorLock( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success); - static void PPB_CursorControl_CanLockCursor( - NaClSrpcRpc* rpc, - NaClSrpcClosure* done, - PP_Instance instance, - int32_t* success); - - private: - PpbCursorControlRpcServer(); - PpbCursorControlRpcServer(const PpbCursorControlRpcServer&); - void operator=(const PpbCursorControlRpcServer); -}; // class PpbCursorControlRpcServer - class PpbFileIORpcServer { public: static void PPB_FileIO_Create( @@ -846,6 +809,23 @@ class PpbMessagingRpcServer { void operator=(const PpbMessagingRpcServer); }; // class PpbMessagingRpcServer +class PpbMouseCursorRpcServer { + public: + static void PPB_MouseCursor_SetCursor( + NaClSrpcRpc* rpc, + NaClSrpcClosure* done, + PP_Instance instance, + int32_t type, + PP_Resource custom_image, + nacl_abi_size_t hot_spot_bytes, char* hot_spot, + int32_t* success); + + private: + PpbMouseCursorRpcServer(); + PpbMouseCursorRpcServer(const PpbMouseCursorRpcServer&); + void operator=(const PpbMouseCursorRpcServer); +}; // class PpbMouseCursorRpcServer + class PpbMouseLockRpcServer { public: static void PPB_MouseLock_LockMouse( diff --git a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h index 288455f..a54103b 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h @@ -153,38 +153,6 @@ class PpbCoreRpcClient { void operator=(const PpbCoreRpcClient); }; // class PpbCoreRpcClient -class PpbCursorControlRpcClient { - public: - static NaClSrpcError PPB_CursorControl_SetCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t type, - PP_Resource custom_image, - nacl_abi_size_t hot_spot_bytes, char* hot_spot, - int32_t* success); - static NaClSrpcError PPB_CursorControl_LockCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success); - static NaClSrpcError PPB_CursorControl_UnlockCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success); - static NaClSrpcError PPB_CursorControl_HasCursorLock( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success); - static NaClSrpcError PPB_CursorControl_CanLockCursor( - NaClSrpcChannel* channel, - PP_Instance instance, - int32_t* success); - - private: - PpbCursorControlRpcClient(); - PpbCursorControlRpcClient(const PpbCursorControlRpcClient&); - void operator=(const PpbCursorControlRpcClient); -}; // class PpbCursorControlRpcClient - class PpbFileIORpcClient { public: static NaClSrpcError PPB_FileIO_Create( @@ -741,6 +709,22 @@ class PpbMessagingRpcClient { void operator=(const PpbMessagingRpcClient); }; // class PpbMessagingRpcClient +class PpbMouseCursorRpcClient { + public: + static NaClSrpcError PPB_MouseCursor_SetCursor( + NaClSrpcChannel* channel, + PP_Instance instance, + int32_t type, + PP_Resource custom_image, + nacl_abi_size_t hot_spot_bytes, char* hot_spot, + int32_t* success); + + private: + PpbMouseCursorRpcClient(); + PpbMouseCursorRpcClient(const PpbMouseCursorRpcClient&); + void operator=(const PpbMouseCursorRpcClient); +}; // class PpbMouseCursorRpcClient + class PpbMouseLockRpcClient { public: static NaClSrpcError PPB_MouseLock_LockMouse( diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc b/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc index 964b1f3..6cbd907 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc +++ b/ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc @@ -12,12 +12,11 @@ #include "native_client/src/shared/ppapi_proxy/plugin_nacl_file.h" #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" #include "native_client/tests/ppapi_test_lib/test_interface.h" +#include "ppapi/c/dev/ppb_zoom_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_core.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" - namespace { //////////////////////////////////////////////////////////////////////////////// @@ -25,11 +24,7 @@ namespace { //////////////////////////////////////////////////////////////////////////////// void TestGetDevInterfaces() { - // This test is run as a simple embedded .nexe with --enable-nacl. It should - // have access to all dev interfaces. Only test one to make the test more - // robust as interfaces change. - EXPECT(GetBrowserInterface(PPB_CURSOR_CONTROL_DEV_INTERFACE) != NULL); - + // TODO(brettw) remove this test. TEST_PASSED; } diff --git a/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.cc b/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.cc index 42376a1..c4c419a 100644 --- a/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.cc +++ b/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.cc @@ -4,7 +4,6 @@ #include "native_client/src/shared/platform/nacl_check.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" @@ -24,6 +23,7 @@ #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" +#include "ppapi/c/ppb_mouse_cursor.h" #include "ppapi/c/ppb_opengles2.h" #include "ppapi/c/ppb_url_loader.h" #include "ppapi/c/ppb_url_request_info.h" @@ -118,6 +118,11 @@ const PPB_Messaging* PPBMessaging() { GetBrowserInterfaceSafe(PPB_MESSAGING_INTERFACE)); } +const PPB_MouseCursor_1_0* PPBMouseCursor() { + return reinterpret_cast<const PPB_MouseCursor_1_0*>( + GetBrowserInterfaceSafe(PPB_MOUSECURSOR_INTERFACE_1_0)); +} + const PPB_MouseInputEvent* PPBMouseInputEvent() { return reinterpret_cast<const PPB_MouseInputEvent*>( GetBrowserInterfaceSafe(PPB_MOUSE_INPUT_EVENT_INTERFACE)); @@ -156,12 +161,6 @@ const PPB_WheelInputEvent* PPBWheelInputEvent() { // Dev interfaces. -const PPB_CursorControl_Dev* PPBCursorControlDev() { - return reinterpret_cast<const PPB_CursorControl_Dev*>( - // Change to GetBrowserInterfaceSafe when moving out of dev. - GetBrowserInterface(PPB_CURSOR_CONTROL_DEV_INTERFACE)); -} - const PPB_Font_Dev* PPBFontDev() { return reinterpret_cast<const PPB_Font_Dev*>( // Change to GetBrowserInterfaceSafe when moving out of dev. diff --git a/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h b/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h index 300d92d..30266a2 100644 --- a/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h +++ b/ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h @@ -21,13 +21,13 @@ #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" +#include "ppapi/c/ppb_mouse_cursor.h" #include "ppapi/c/ppb_opengles2.h" #include "ppapi/c/ppb_url_loader.h" #include "ppapi/c/ppb_url_request_info.h" #include "ppapi/c/ppb_url_response_info.h" #include "ppapi/c/ppb_var.h" #include "ppapi/c/ppb_view.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" @@ -58,6 +58,7 @@ const PPB_InputEvent* PPBInputEvent(); const PPB_Instance* PPBInstance(); const PPB_KeyboardInputEvent* PPBKeyboardInputEvent(); const PPB_Messaging* PPBMessaging(); +const PPB_MouseCursor* PPBMouseCursor(); const PPB_MouseInputEvent* PPBMouseInputEvent(); const PPB_OpenGLES2* PPBOpenGLES2(); const PPB_URLLoader* PPBURLLoader(); @@ -72,7 +73,6 @@ const PPB_WheelInputEvent* PPBWheelInputEvent(); // Lookup returns NULL if the interface is not available. // -const PPB_CursorControl_Dev* PPBCursorControlDev(); const PPB_Font_Dev* PPBFontDev(); const PPB_Memory_Dev* PPBMemoryDev(); const PPB_Scrollbar_Dev* PPBScrollbarDev(); diff --git a/ppapi/native_client/tests/ppapi_tests/nacl.scons b/ppapi/native_client/tests/ppapi_tests/nacl.scons index b590a84..50edb2d 100644 --- a/ppapi/native_client/tests/ppapi_tests/nacl.scons +++ b/ppapi/native_client/tests/ppapi_tests/nacl.scons @@ -37,7 +37,6 @@ ppapi_tests_sources = [ #'test_buffer.cc', # Not yet proxied. #'test_char_set.cc', - 'test_cursor_control.cc', # Fails in DeleteDirectoryRecursively. # BUG: http://code.google.com/p/nativeclient/issues/detail?id=2107 #'test_directory_reader.cc', @@ -45,6 +44,7 @@ ppapi_tests_sources = [ 'test_file_ref.cc', 'test_file_system.cc', 'test_memory.cc', + 'test_mouse_cursor.cc', 'test_graphics_2d.cc', 'test_image_data.cc', 'test_paint_aggregator.cc', diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index d28fe32..472d484 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -80,8 +80,6 @@ 'proxy/ppb_buffer_proxy.h', 'proxy/ppb_core_proxy.cc', 'proxy/ppb_core_proxy.h', - 'proxy/ppb_cursor_control_proxy.cc', - 'proxy/ppb_cursor_control_proxy.h', 'proxy/ppb_file_chooser_proxy.cc', 'proxy/ppb_file_chooser_proxy.h', 'proxy/ppb_file_io_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index af2bf84..187afaf 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -210,6 +210,7 @@ 'thunk/ppb_layer_compositor_thunk.cc', 'thunk/ppb_message_loop_api.h', 'thunk/ppb_messaging_thunk.cc', + 'thunk/ppb_mouse_cursor_thunk.cc', 'thunk/ppb_mouse_lock_thunk.cc', 'thunk/ppb_network_list_private_api.h', 'thunk/ppb_network_list_private_thunk.cc', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 3ec8c27..67243b0 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -37,6 +37,7 @@ 'c/ppb_input_event.h', 'c/ppb_instance.h', 'c/ppb_messaging.h', + 'c/ppb_mouse_cursor.h', 'c/ppb_mouse_lock.h', 'c/ppb_opengles2.h', 'c/ppb_url_loader.h', @@ -165,6 +166,8 @@ 'cpp/module.cc', 'cpp/module.h', 'cpp/module_impl.h', + 'cpp/mouse_cursor.cc', + 'cpp/mouse_cursor.h', 'cpp/mouse_lock.cc', 'cpp/mouse_lock.h', 'cpp/output_traits.h', @@ -348,6 +351,7 @@ 'tests/test_graphics_2d.cc', 'tests/test_image_data.cc', 'tests/test_memory.cc', + 'tests/test_mouse_cursor.cc', 'tests/test_paint_aggregator.cc', 'tests/test_post_message.cc', 'tests/test_scrollbar.cc', @@ -413,6 +417,7 @@ 'tests/test_input_event.h', 'tests/test_memory.cc', 'tests/test_memory.h', + 'tests/test_mouse_cursor.cc', 'tests/test_net_address_private.cc', 'tests/test_net_address_private.h', 'tests/test_network_monitor_private.cc', diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi index 96d914f..56f9c66 100644 --- a/ppapi/ppapi_tests.gypi +++ b/ppapi/ppapi_tests.gypi @@ -224,6 +224,16 @@ }, }, { + 'target_name': 'ppapi_example_mouse_cursor', + 'dependencies': [ + 'ppapi_example_skeleton', + 'ppapi.gyp:ppapi_cpp', + ], + 'sources': [ + 'examples/mouse_cursor/mouse_cursor.cc', + ], + }, + { 'target_name': 'ppapi_example_mouse_lock', 'dependencies': [ 'ppapi_example_skeleton', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 5d42468..53b8db1 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -75,7 +75,6 @@ #include "ppapi/proxy/ppb_broker_proxy.h" #include "ppapi/proxy/ppb_buffer_proxy.h" #include "ppapi/proxy/ppb_core_proxy.h" -#include "ppapi/proxy/ppb_cursor_control_proxy.h" #include "ppapi/proxy/ppb_file_chooser_proxy.h" #include "ppapi/proxy/ppb_file_io_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index 11eea64..31e20ba 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -20,7 +20,6 @@ #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/plugin_var_serialization_rules.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_cursor_control_proxy.h" #include "ppapi/proxy/ppb_instance_proxy.h" #include "ppapi/proxy/ppp_class_proxy.h" #include "ppapi/proxy/resource_creation_proxy.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 1d288dd..4c9b744 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -675,26 +675,6 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource, IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_ReleaseResource, ppapi::HostResource) -// PPB_CursorControl. -IPC_SYNC_MESSAGE_ROUTED4_1(PpapiHostMsg_PPBCursorControl_SetCursor, - PP_Instance /* instance */, - int32_t /* type */, - ppapi::HostResource /* custom_image */, - PP_Point /* hot_spot */, - PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_LockCursor, - PP_Instance /* instance */, - PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_UnlockCursor, - PP_Instance /* instance */, - PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_HasCursorLock, - PP_Instance /* instance */, - PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCursorControl_CanLockCursor, - PP_Instance /* instance */, - PP_Bool /* result */) - // PPB_FileChooser. IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFileChooser_Create, PP_Instance /* instance */, @@ -944,6 +924,11 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetDocumentURL, IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, PP_Instance /* active */, ppapi::proxy::SerializedVar /* result */) +IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SetCursor, + PP_Instance /* instance */, + int32_t /* type */, + ppapi::HostResource /* custom_image */, + PP_Point /* hot_spot */) IPC_SYNC_MESSAGE_ROUTED3_1( PpapiHostMsg_PPBPDF_GetFontFileWithFallback, diff --git a/ppapi/proxy/ppb_cursor_control_proxy.cc b/ppapi/proxy/ppb_cursor_control_proxy.cc deleted file mode 100644 index a795975..0000000 --- a/ppapi/proxy/ppb_cursor_control_proxy.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/ppb_cursor_control_proxy.h" - -#include "ppapi/c/dev/pp_cursor_type_dev.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_resource_tracker.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/thunk.h" - -using ppapi::thunk::EnterFunctionNoLock; -using ppapi::thunk::PPB_CursorControl_FunctionAPI; - -namespace ppapi { -namespace proxy { - -PPB_CursorControl_Proxy::PPB_CursorControl_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher) { -} - -PPB_CursorControl_Proxy::~PPB_CursorControl_Proxy() { -} - -ppapi::thunk::PPB_CursorControl_FunctionAPI* -PPB_CursorControl_Proxy::AsPPB_CursorControl_FunctionAPI() { - return this; -} - -PP_Bool PPB_CursorControl_Proxy::SetCursor(PP_Instance instance, - PP_CursorType_Dev type, - PP_Resource custom_image_id, - const PP_Point* hot_spot) { - // It's legal for the image ID to be null if the type is not custom. - HostResource cursor_image_resource; - if (type == PP_CURSORTYPE_CUSTOM) { - Resource* cursor_image = - PpapiGlobals::Get()->GetResourceTracker()->GetResource(custom_image_id); - if (!cursor_image || cursor_image->pp_instance() != instance) - return PP_FALSE; - cursor_image_resource = cursor_image->host_resource(); - } else { - if (custom_image_id) - return PP_FALSE; // Image specified for a predefined type. - } - - PP_Bool result = PP_FALSE; - PP_Point empty_point = { 0, 0 }; - dispatcher()->Send(new PpapiHostMsg_PPBCursorControl_SetCursor( - API_ID_PPB_CURSORCONTROL, - instance, static_cast<int32_t>(type), cursor_image_resource, - hot_spot ? *hot_spot : empty_point, &result)); - return result; -} - -PP_Bool PPB_CursorControl_Proxy::LockCursor(PP_Instance instance) { - PP_Bool result = PP_FALSE; - dispatcher()->Send(new PpapiHostMsg_PPBCursorControl_LockCursor( - API_ID_PPB_CURSORCONTROL, instance, &result)); - return result; -} - -PP_Bool PPB_CursorControl_Proxy::UnlockCursor(PP_Instance instance) { - PP_Bool result = PP_FALSE; - dispatcher()->Send(new PpapiHostMsg_PPBCursorControl_UnlockCursor( - API_ID_PPB_CURSORCONTROL, instance, &result)); - return result; -} - -PP_Bool PPB_CursorControl_Proxy::HasCursorLock(PP_Instance instance) { - PP_Bool result = PP_FALSE; - dispatcher()->Send(new PpapiHostMsg_PPBCursorControl_HasCursorLock( - API_ID_PPB_CURSORCONTROL, instance, &result)); - return result; -} - -PP_Bool PPB_CursorControl_Proxy::CanLockCursor(PP_Instance instance) { - PP_Bool result = PP_FALSE; - dispatcher()->Send(new PpapiHostMsg_PPBCursorControl_CanLockCursor( - API_ID_PPB_CURSORCONTROL, instance, &result)); - return result; -} - -bool PPB_CursorControl_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_CursorControl_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_SetCursor, - OnMsgSetCursor) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_LockCursor, - OnMsgLockCursor) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_UnlockCursor, - OnMsgUnlockCursor) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_HasCursorLock, - OnMsgHasCursorLock) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_CanLockCursor, - OnMsgCanLockCursor) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - // TODO(brettw): handle bad messages! - return handled; -} - -void PPB_CursorControl_Proxy::OnMsgSetCursor(PP_Instance instance, - int32_t type, - const HostResource& custom_image, - const PP_Point& hot_spot, - PP_Bool* result) { - EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.succeeded()) { - *result = enter.functions()->SetCursor( - instance, static_cast<PP_CursorType_Dev>(type), - custom_image.host_resource(), &hot_spot); - } -} - -void PPB_CursorControl_Proxy::OnMsgLockCursor(PP_Instance instance, - PP_Bool* result) { - EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.succeeded()) - *result = enter.functions()->LockCursor(instance); -} - -void PPB_CursorControl_Proxy::OnMsgUnlockCursor(PP_Instance instance, - PP_Bool* result) { - EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.succeeded()) - *result = enter.functions()->UnlockCursor(instance); -} - -void PPB_CursorControl_Proxy::OnMsgHasCursorLock(PP_Instance instance, - PP_Bool* result) { - EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.succeeded()) - *result = enter.functions()->HasCursorLock(instance); -} - -void PPB_CursorControl_Proxy::OnMsgCanLockCursor(PP_Instance instance, - PP_Bool* result) { - EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.succeeded()) - *result = enter.functions()->CanLockCursor(instance); -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_cursor_control_proxy.h b/ppapi/proxy/ppb_cursor_control_proxy.h deleted file mode 100644 index f2d3e2c..0000000 --- a/ppapi/proxy/ppb_cursor_control_proxy.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_PROXY_PPB_CURSOR_CONTROL_PROXY_H_ -#define PPAPI_PROXY_PPB_CURSOR_CONTROL_PROXY_H_ - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_point.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/shared_impl/function_group_base.h" -#include "ppapi/shared_impl/host_resource.h" -#include "ppapi/thunk/ppb_cursor_control_api.h" - -namespace ppapi { -namespace proxy { - -class PPB_CursorControl_Proxy - : public InterfaceProxy, - public ppapi::thunk::PPB_CursorControl_FunctionAPI { - public: - explicit PPB_CursorControl_Proxy(Dispatcher* dispatcher); - virtual ~PPB_CursorControl_Proxy(); - - // FunctionGroupBase overrides. - ppapi::thunk::PPB_CursorControl_FunctionAPI* AsPPB_CursorControl_FunctionAPI() - OVERRIDE; - - // PPB_CursorControl_FunctionAPI implementation. - virtual PP_Bool SetCursor(PP_Instance instance, - PP_CursorType_Dev type, - PP_Resource custom_image_id, - const PP_Point* hot_spot) OVERRIDE; - virtual PP_Bool LockCursor(PP_Instance instance) OVERRIDE; - virtual PP_Bool UnlockCursor(PP_Instance instance) OVERRIDE; - virtual PP_Bool HasCursorLock(PP_Instance instance) OVERRIDE; - virtual PP_Bool CanLockCursor(PP_Instance instance) OVERRIDE; - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; - - static const ApiID kApiID = API_ID_PPB_CURSORCONTROL; - - private: - // Message handlers. - void OnMsgSetCursor(PP_Instance instance, - int32_t type, - const ppapi::HostResource& custom_image, - const PP_Point& hot_spot, - PP_Bool* result); - void OnMsgLockCursor(PP_Instance instance, - PP_Bool* result); - void OnMsgUnlockCursor(PP_Instance instance, - PP_Bool* result); - void OnMsgHasCursorLock(PP_Instance instance, - PP_Bool* result); - void OnMsgCanLockCursor(PP_Instance instance, - PP_Bool* result); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_CURSOR_CONTROL_PROXY_H_ diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 758e67f..d4a2e456 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -124,6 +124,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgGetDocumentURL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, OnHostMsgGetPluginInstanceURL) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, + OnHostMsgSetCursor) // Host -> Plugin messages. IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, @@ -403,6 +405,32 @@ void PPB_Instance_Proxy::PostMessage(PP_Instance instance, instance, SerializedVarSendInput(dispatcher(), message))); } +PP_Bool PPB_Instance_Proxy::SetCursor(PP_Instance instance, + PP_MouseCursor_Type type, + PP_Resource image, + const PP_Point* hot_spot) { + // Some of these parameters are important for security. This check is in the + // plugin process just for the convenience of the caller (since we don't + // bother returning errors from the other process with a sync message). The + // parameters will be validated again in the renderer. + if (!ValidateSetCursorParams(type, image, hot_spot)) + return PP_FALSE; + + HostResource image_host_resource; + if (image) { + Resource* cursor_image = + PpapiGlobals::Get()->GetResourceTracker()->GetResource(image); + if (!cursor_image || cursor_image->pp_instance() != instance) + return PP_FALSE; + image_host_resource = cursor_image->host_resource(); + } + + dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor( + API_ID_PPB_INSTANCE, instance, static_cast<int32_t>(type), + image_host_resource, hot_spot ? *hot_spot : PP_MakePoint(0, 0))); + return PP_TRUE; +} + int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, PP_CompletionCallback callback) { if (!callback.func) @@ -637,6 +665,19 @@ void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( } } +void PPB_Instance_Proxy::OnHostMsgSetCursor( + PP_Instance instance, + int32_t type, + const ppapi::HostResource& custom_image, + const PP_Point& hot_spot) { + EnterInstanceNoLock enter(instance, true); + if (enter.succeeded()) { + enter.functions()->SetCursor( + instance, static_cast<PP_MouseCursor_Type>(type), + custom_image.host_resource(), &hot_spot); + } +} + void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result) { // Save the mouse callback on the instance data. diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 5b17af1..a6efc50 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -100,6 +100,10 @@ class PPB_Instance_Proxy : public InterfaceProxy, PP_Instance instance, PP_URLComponents_Dev* components) OVERRIDE; virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE; + virtual PP_Bool SetCursor(PP_Instance instance, + PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot) OVERRIDE;
virtual int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) OVERRIDE; virtual void UnlockMouse(PP_Instance instance) OVERRIDE; @@ -162,6 +166,10 @@ class PPB_Instance_Proxy : public InterfaceProxy, SerializedVarReturnValue result); void OnHostMsgGetPluginInstanceURL(PP_Instance instance, SerializedVarReturnValue result); + void OnHostMsgSetCursor(PP_Instance instance, + int32_t type, + const ppapi::HostResource& custom_image, + const PP_Point& hot_spot); // Host -> Plugin message handlers. void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result); diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc index 7e931c3..255a92e 100644 --- a/ppapi/shared_impl/ppb_instance_shared.cc +++ b/ppapi/shared_impl/ppb_instance_shared.cc @@ -9,7 +9,10 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_input_event.h" #include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/ppb_image_data_shared.h" #include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_image_data_api.h" namespace ppapi { @@ -52,4 +55,44 @@ int32_t PPB_Instance_Shared::ValidateRequestInputEvents( return PP_OK; } +bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot) {
+ if (static_cast<int>(type) < static_cast<int>(PP_MOUSECURSOR_TYPE_CUSTOM) || + static_cast<int>(type) > static_cast<int>(PP_MOUSECURSOR_TYPE_GRABBING)) + return false; // Cursor type out of range. + if (type != PP_MOUSECURSOR_TYPE_CUSTOM) { + // The image must not be specified if the type isn't custom. However, we + // don't require that the hot spot be null since the C++ wrappers and proxy + // pass the point by reference and it will normally be specified. + return image == 0; + } + + if (!hot_spot) + return false; // Hot spot must be specified for custom cursor. + + thunk::EnterResourceNoLock<thunk::PPB_ImageData_API> enter(image, true); + if (enter.failed()) + return false; // Invalid image resource. + + // Validate the image size. A giant cursor can arbitrarily overwrite parts + // of the screen resulting in potential spoofing attacks. So we force the + // cursor to be a reasonably-sized image. + PP_ImageDataDesc desc; + if (!PP_ToBool(enter.object()->Describe(&desc))) + return false; + if (desc.size.width > 32 || desc.size.height > 32) + return false; + + // Validate image format. + if (desc.format != PPB_ImageData_Shared::GetNativeImageDataFormat()) + return false; + + // Validate the hot spot location. + if (hot_spot->x < 0 || hot_spot->x >= desc.size.width || + hot_spot->y < 0 || hot_spot->y >= desc.size.height) + return false; + return true; +} + } // namespace ppapi diff --git a/ppapi/shared_impl/ppb_instance_shared.h b/ppapi/shared_impl/ppb_instance_shared.h index 2842160..8260a78 100644 --- a/ppapi/shared_impl/ppb_instance_shared.h +++ b/ppapi/shared_impl/ppb_instance_shared.h @@ -29,6 +29,10 @@ class PPAPI_SHARED_EXPORT PPB_Instance_Shared // Error checks the given resquest to Request[Filtering]InputEvents. Returns // PP_OK if the given classes are all valid, PP_ERROR_NOTSUPPORTED if not. int32_t ValidateRequestInputEvents(bool is_filtering, uint32_t event_classes); + + bool ValidateSetCursorParams(PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot);
}; } // namespace ppapi diff --git a/ppapi/tests/test_mouse_cursor.cc b/ppapi/tests/test_mouse_cursor.cc new file mode 100644 index 0000000..0f34682 --- /dev/null +++ b/ppapi/tests/test_mouse_cursor.cc @@ -0,0 +1,82 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/tests/test_mouse_cursor.h" + +#include "ppapi/cpp/image_data.h" +#include "ppapi/tests/test_case.h" +#include "ppapi/tests/testing_instance.h" + +REGISTER_TEST_CASE(MouseCursor); + +TestMouseCursor::TestMouseCursor(TestingInstance* instance) + : TestCase(instance) { +} + +bool TestMouseCursor::Init() { + mouse_cursor_interface_ = static_cast<const PPB_MouseCursor*>( + pp::Module::Get()->GetBrowserInterface(PPB_MOUSECURSOR_INTERFACE)); + return !!mouse_cursor_interface_; +} + +void TestMouseCursor::RunTests(const std::string& filter) { + RUN_TEST(Type, filter); + RUN_TEST(Custom, filter); + RUN_TEST(Point, filter); +} + +std::string TestMouseCursor::TestType() { + ASSERT_TRUE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_POINTER, 0, NULL))); + ASSERT_FALSE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), static_cast<PP_MouseCursor_Type>(-2), + 0, NULL))); + PASS(); +} + +std::string TestMouseCursor::TestCustom() { + // First test a valid image. + pp::ImageData valid_image(instance_, + pp::ImageData::GetNativeImageDataFormat(), + pp::Size(16, 16), true); + PP_Point point = { 0, 0 }; + ASSERT_TRUE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_CUSTOM, + valid_image.pp_resource(), &point))); + + // 0 image resource ID. + ASSERT_FALSE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_CUSTOM, 0, NULL))); + + // Image specified for predefined type. + ASSERT_FALSE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_POINTER, + valid_image.pp_resource(), &point))); + + // A too-big image. + pp::ImageData big_image(instance_, pp::ImageData::GetNativeImageDataFormat(), + pp::Size(65, 12), true); + ASSERT_FALSE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_CUSTOM, + big_image.pp_resource(), &point))); + + PASS(); +} + +std::string TestMouseCursor::TestPoint() { + pp::ImageData valid_image(instance_, + pp::ImageData::GetNativeImageDataFormat(), + pp::Size(16, 16), true); + PP_Point point = { -1, 0 }; + ASSERT_FALSE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_CUSTOM, + valid_image.pp_resource(), &point))); + + point.x = 67; + point.y = 5; + ASSERT_FALSE(PP_ToBool(mouse_cursor_interface_->SetCursor( + instance_->pp_instance(), PP_MOUSECURSOR_TYPE_CUSTOM, + valid_image.pp_resource(), &point))); + PASS(); +} diff --git a/ppapi/tests/test_mouse_cursor.h b/ppapi/tests/test_mouse_cursor.h new file mode 100644 index 0000000..6fb6e77 --- /dev/null +++ b/ppapi/tests/test_mouse_cursor.h @@ -0,0 +1,27 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_TESTS_TEST_MOUSE_CURSOR_H_ +#define PPAPI_TESTS_TEST_MOUSE_CURSOR_H_ + +#include "ppapi/c/ppb_mouse_cursor.h" +#include "ppapi/tests/test_case.h" + +class TestMouseCursor : public TestCase { + public: + explicit TestMouseCursor(TestingInstance* instance); + + // TestCase implementation. + virtual bool Init(); + virtual void RunTests(const std::string& filter); + + private: + std::string TestType(); + std::string TestCustom(); + std::string TestPoint(); + + const PPB_MouseCursor* mouse_cursor_interface_; +}; + +#endif // PPAPI_TESTS_TEST_MOUSE_CURSOR_H_ diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index 0296a2d..73006ce 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -9,7 +9,6 @@ PROXIED_API(PPB_AudioInput) PROXIED_API(PPB_Buffer) -PROXIED_API(PPB_CursorControl) UNPROXIED_API(PPB_DirectoryReader) PROXIED_API(PPB_FileChooser) PROXIED_API(PPB_Graphics3D) @@ -33,7 +32,7 @@ PROXIED_IFACE(PPB_Graphics3D, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE_0_1, PPB_GLESChromiumTextureMapping_Dev_0_1) PROXIED_IFACE(NoAPIName, PPB_CRYPTO_DEV_INTERFACE_0_1, PPB_Crypto_Dev_0_1) -PROXIED_IFACE(PPB_CursorControl, PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4, +PROXIED_IFACE(NoAPIName, PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4, PPB_CursorControl_Dev_0_4) PROXIED_IFACE(NoAPIName, PPB_DEVICEREF_DEV_INTERFACE_0_1, PPB_DeviceRef_Dev_0_1) UNPROXIED_IFACE(PPB_DirectoryReader, PPB_DIRECTORYREADER_DEV_INTERFACE_0_5, diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h index 556a11f..81a3402 100644 --- a/ppapi/thunk/interfaces_ppb_public_stable.h +++ b/ppapi/thunk/interfaces_ppb_public_stable.h @@ -70,6 +70,7 @@ PROXIED_IFACE(NoAPIName, PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0, PPB_WheelInputEvent_1_0) PROXIED_IFACE(PPB_Instance, PPB_FULLSCREEN_INTERFACE_1_0, PPB_Fullscreen_1_0) PROXIED_IFACE(PPB_Instance, PPB_MESSAGING_INTERFACE_1_0, PPB_Messaging_1_0) +PROXIED_IFACE(PPB_Instance, PPB_MOUSECURSOR_INTERFACE_1_0, PPB_MouseCursor_1_0) PROXIED_IFACE(PPB_Instance, PPB_MOUSELOCK_INTERFACE_1_0, PPB_MouseLock_1_0) PROXIED_IFACE(PPB_URLLoader, PPB_URLLOADER_INTERFACE_1_0, PPB_URLLoader_1_0) PROXIED_IFACE(NoAPIName, PPB_URLREQUESTINFO_INTERFACE_1_0, diff --git a/ppapi/thunk/ppb_cursor_control_api.h b/ppapi/thunk/ppb_cursor_control_api.h deleted file mode 100644 index e4882c6..0000000 --- a/ppapi/thunk/ppb_cursor_control_api.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_THUNK_CURSOR_CONTROL_API_H_ -#define PPAPI_THUNK_CURSOR_CONTROL_API_H_ - -#include "ppapi/c/dev/ppb_cursor_control_dev.h" -#include "ppapi/shared_impl/api_id.h" - -namespace ppapi { -namespace thunk { - -class PPB_CursorControl_FunctionAPI { - public: - virtual ~PPB_CursorControl_FunctionAPI() {} - - virtual PP_Bool SetCursor(PP_Instance instance, - PP_CursorType_Dev type, - PP_Resource custom_image_id, - const PP_Point* hot_spot) = 0; - virtual PP_Bool LockCursor(PP_Instance instance) = 0; - virtual PP_Bool UnlockCursor(PP_Instance instance) = 0; - virtual PP_Bool HasCursorLock(PP_Instance instance) = 0; - virtual PP_Bool CanLockCursor(PP_Instance instance) = 0; - - static const ApiID kApiID = API_ID_PPB_CURSORCONTROL; - -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_CURSOR_CONTROL_API_H_ diff --git a/ppapi/thunk/ppb_cursor_control_thunk.cc b/ppapi/thunk/ppb_cursor_control_thunk.cc index b1b2077..743b3e5 100644 --- a/ppapi/thunk/ppb_cursor_control_thunk.cc +++ b/ppapi/thunk/ppb_cursor_control_thunk.cc @@ -2,9 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_cursor_control_api.h" +#include "ppapi/thunk/ppb_instance_api.h" + +// This interface is only for temporary backwards compat and currently just +// forwards to the stable interfaces that implement these features. namespace ppapi { namespace thunk { @@ -15,38 +19,27 @@ PP_Bool SetCursor(PP_Instance instance, PP_CursorType_Dev type, PP_Resource custom_image, const PP_Point* hot_spot) { - EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.failed()) return PP_FALSE; - return enter.functions()->SetCursor(instance, type, custom_image, hot_spot); + return enter.functions()->SetCursor(instance, + static_cast<PP_MouseCursor_Type>(type), custom_image, hot_spot); } PP_Bool LockCursor(PP_Instance instance) { - EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.failed()) - return PP_FALSE; - return enter.functions()->LockCursor(instance); + return PP_FALSE; } PP_Bool UnlockCursor(PP_Instance instance) { - EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.failed()) - return PP_FALSE; - return enter.functions()->UnlockCursor(instance); + return PP_FALSE; } PP_Bool HasCursorLock(PP_Instance instance) { - EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.failed()) - return PP_FALSE; - return enter.functions()->HasCursorLock(instance); + return PP_FALSE; } PP_Bool CanLockCursor(PP_Instance instance) { - EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true); - if (enter.failed()) - return PP_FALSE; - return enter.functions()->CanLockCursor(instance); + return PP_FALSE; } const PPB_CursorControl_Dev g_ppb_cursor_control_thunk = { diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 3a357af..58f119f 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -14,6 +14,7 @@ #include "ppapi/c/ppb_audio_config.h" #include "ppapi/c/ppb_gamepad.h" #include "ppapi/c/ppb_instance.h" +#include "ppapi/c/ppb_mouse_cursor.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/shared_impl/api_id.h" @@ -99,6 +100,12 @@ class PPB_Instance_FunctionAPI { // Messaging. virtual void PostMessage(PP_Instance instance, PP_Var message) = 0; + // Mouse cursor. + virtual PP_Bool SetCursor(PP_Instance instance, + PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot) = 0;
+ // MouseLock. virtual int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) = 0; diff --git a/ppapi/thunk/ppb_mouse_cursor_thunk.cc b/ppapi/thunk/ppb_mouse_cursor_thunk.cc new file mode 100644 index 0000000..f2c6f41 --- /dev/null +++ b/ppapi/thunk/ppb_mouse_cursor_thunk.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/c/ppb_mouse_cursor.h"
+#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+PP_Bool SetCursor(PP_Instance instance,
+ PP_MouseCursor_Type type,
+ PP_Resource image,
+ const PP_Point* hot_spot) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->SetCursor(instance, type, image, hot_spot);
+}
+
+const PPB_MouseCursor_1_0 g_ppb_mouse_cursor_thunk = {
+ &SetCursor
+};
+
+} // namespace
+
+const PPB_MouseCursor_1_0* GetPPB_MouseCursor_1_0_Thunk() {
+ return &g_ppb_mouse_cursor_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_mouse_lock_thunk.cc b/ppapi/thunk/ppb_mouse_lock_thunk.cc index 11d2012..d884ab0 100644 --- a/ppapi/thunk/ppb_mouse_lock_thunk.cc +++ b/ppapi/thunk/ppb_mouse_lock_thunk.cc @@ -14,14 +14,14 @@ namespace thunk { namespace { int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) { - EnterFunction<PPB_Instance_FunctionAPI> enter(instance, callback, true); + EnterInstance enter(instance, callback); if (enter.failed()) return enter.retval(); return enter.SetResult(enter.functions()->LockMouse(instance, callback)); } void UnlockMouse(PP_Instance instance) { - EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.failed()) return; enter.functions()->UnlockMouse(instance); diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 785c4fa..89bc7bd 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -261,8 +261,6 @@ '../plugins/ppapi/ppb_broker_impl.h', '../plugins/ppapi/ppb_buffer_impl.cc', '../plugins/ppapi/ppb_buffer_impl.h', - '../plugins/ppapi/ppb_cursor_control_impl.cc', - '../plugins/ppapi/ppb_cursor_control_impl.h', '../plugins/ppapi/ppb_directory_reader_impl.cc', '../plugins/ppapi/ppb_directory_reader_impl.h', '../plugins/ppapi/ppb_file_chooser_impl.cc', diff --git a/webkit/plugins/ppapi/host_globals.cc b/webkit/plugins/ppapi/host_globals.cc index a3e5f31..d2c2516 100644 --- a/webkit/plugins/ppapi/host_globals.cc +++ b/webkit/plugins/ppapi/host_globals.cc @@ -20,7 +20,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" -#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" #include "webkit/plugins/ppapi/ppb_text_input_impl.h" #include "webkit/plugins/ppapi/resource_creation_impl.h" @@ -141,9 +140,6 @@ HostGlobals::~HostGlobals() { return proxy.get(); switch (id) { - case ::ppapi::API_ID_PPB_CURSORCONTROL: - proxy.reset(new PPB_CursorControl_Impl(instance)); - break; case ::ppapi::API_ID_PPB_TEXT_INPUT: proxy.reset(new PPB_TextInput_Impl(instance)); break; diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index bc9dcaf..a570a40 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -56,6 +56,7 @@ #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" +#include "ppapi/c/ppb_mouse_cursor.h" #include "ppapi/c/ppb_mouse_lock.h" #include "ppapi/c/ppb_opengles2.h" #include "ppapi/c/ppb_url_loader.h" diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 6cd4146..09554fa 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -173,60 +173,66 @@ const char kHeight[] = "height"; const char kBorder[] = "border"; // According to w3c, deprecated. const char kStyle[] = "style"; -COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_CURSORTYPE_POINTER); -COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_CURSORTYPE_CROSS); -COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_CURSORTYPE_HAND); -COMPILE_ASSERT_MATCHING_ENUM(TypeIBeam, PP_CURSORTYPE_IBEAM); -COMPILE_ASSERT_MATCHING_ENUM(TypeWait, PP_CURSORTYPE_WAIT); -COMPILE_ASSERT_MATCHING_ENUM(TypeHelp, PP_CURSORTYPE_HELP); -COMPILE_ASSERT_MATCHING_ENUM(TypeEastResize, PP_CURSORTYPE_EASTRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeNorthResize, PP_CURSORTYPE_NORTHRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); +COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); +COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); +COMPILE_ASSERT_MATCHING_ENUM(TypeIBeam, PP_MOUSECURSOR_TYPE_IBEAM); +COMPILE_ASSERT_MATCHING_ENUM(TypeWait, PP_MOUSECURSOR_TYPE_WAIT); +COMPILE_ASSERT_MATCHING_ENUM(TypeHelp, PP_MOUSECURSOR_TYPE_HELP); +COMPILE_ASSERT_MATCHING_ENUM(TypeEastResize, PP_MOUSECURSOR_TYPE_EASTRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeNorthResize, PP_MOUSECURSOR_TYPE_NORTHRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthEastResize, - PP_CURSORTYPE_NORTHEASTRESIZE); + PP_MOUSECURSOR_TYPE_NORTHEASTRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthWestResize, - PP_CURSORTYPE_NORTHWESTRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeSouthResize, PP_CURSORTYPE_SOUTHRESIZE); + PP_MOUSECURSOR_TYPE_NORTHWESTRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeSouthResize, PP_MOUSECURSOR_TYPE_SOUTHRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeSouthEastResize, - PP_CURSORTYPE_SOUTHEASTRESIZE); + PP_MOUSECURSOR_TYPE_SOUTHEASTRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeSouthWestResize, - PP_CURSORTYPE_SOUTHWESTRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeWestResize, PP_CURSORTYPE_WESTRESIZE); + PP_MOUSECURSOR_TYPE_SOUTHWESTRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeWestResize, PP_MOUSECURSOR_TYPE_WESTRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthSouthResize, - PP_CURSORTYPE_NORTHSOUTHRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeEastWestResize, PP_CURSORTYPE_EASTWESTRESIZE); + PP_MOUSECURSOR_TYPE_NORTHSOUTHRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeEastWestResize, + PP_MOUSECURSOR_TYPE_EASTWESTRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthEastSouthWestResize, - PP_CURSORTYPE_NORTHEASTSOUTHWESTRESIZE); + PP_MOUSECURSOR_TYPE_NORTHEASTSOUTHWESTRESIZE); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthWestSouthEastResize, - PP_CURSORTYPE_NORTHWESTSOUTHEASTRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeColumnResize, PP_CURSORTYPE_COLUMNRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeRowResize, PP_CURSORTYPE_ROWRESIZE); -COMPILE_ASSERT_MATCHING_ENUM(TypeMiddlePanning, PP_CURSORTYPE_MIDDLEPANNING); -COMPILE_ASSERT_MATCHING_ENUM(TypeEastPanning, PP_CURSORTYPE_EASTPANNING); -COMPILE_ASSERT_MATCHING_ENUM(TypeNorthPanning, PP_CURSORTYPE_NORTHPANNING); + PP_MOUSECURSOR_TYPE_NORTHWESTSOUTHEASTRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeColumnResize, + PP_MOUSECURSOR_TYPE_COLUMNRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeRowResize, PP_MOUSECURSOR_TYPE_ROWRESIZE); +COMPILE_ASSERT_MATCHING_ENUM(TypeMiddlePanning, + PP_MOUSECURSOR_TYPE_MIDDLEPANNING); +COMPILE_ASSERT_MATCHING_ENUM(TypeEastPanning, PP_MOUSECURSOR_TYPE_EASTPANNING); +COMPILE_ASSERT_MATCHING_ENUM(TypeNorthPanning, + PP_MOUSECURSOR_TYPE_NORTHPANNING); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthEastPanning, - PP_CURSORTYPE_NORTHEASTPANNING); + PP_MOUSECURSOR_TYPE_NORTHEASTPANNING); COMPILE_ASSERT_MATCHING_ENUM(TypeNorthWestPanning, - PP_CURSORTYPE_NORTHWESTPANNING); -COMPILE_ASSERT_MATCHING_ENUM(TypeSouthPanning, PP_CURSORTYPE_SOUTHPANNING); + PP_MOUSECURSOR_TYPE_NORTHWESTPANNING); +COMPILE_ASSERT_MATCHING_ENUM(TypeSouthPanning, + PP_MOUSECURSOR_TYPE_SOUTHPANNING); COMPILE_ASSERT_MATCHING_ENUM(TypeSouthEastPanning, - PP_CURSORTYPE_SOUTHEASTPANNING); + PP_MOUSECURSOR_TYPE_SOUTHEASTPANNING); COMPILE_ASSERT_MATCHING_ENUM(TypeSouthWestPanning, - PP_CURSORTYPE_SOUTHWESTPANNING); -COMPILE_ASSERT_MATCHING_ENUM(TypeWestPanning, PP_CURSORTYPE_WESTPANNING); -COMPILE_ASSERT_MATCHING_ENUM(TypeMove, PP_CURSORTYPE_MOVE); -COMPILE_ASSERT_MATCHING_ENUM(TypeVerticalText, PP_CURSORTYPE_VERTICALTEXT); -COMPILE_ASSERT_MATCHING_ENUM(TypeCell, PP_CURSORTYPE_CELL); -COMPILE_ASSERT_MATCHING_ENUM(TypeContextMenu, PP_CURSORTYPE_CONTEXTMENU); -COMPILE_ASSERT_MATCHING_ENUM(TypeAlias, PP_CURSORTYPE_ALIAS); -COMPILE_ASSERT_MATCHING_ENUM(TypeProgress, PP_CURSORTYPE_PROGRESS); -COMPILE_ASSERT_MATCHING_ENUM(TypeNoDrop, PP_CURSORTYPE_NODROP); -COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_CURSORTYPE_COPY); -COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_CURSORTYPE_NONE); -COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_CURSORTYPE_NOTALLOWED); -COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_CURSORTYPE_ZOOMIN); -COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_CURSORTYPE_ZOOMOUT); -COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_CURSORTYPE_GRAB); -COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING); + PP_MOUSECURSOR_TYPE_SOUTHWESTPANNING); +COMPILE_ASSERT_MATCHING_ENUM(TypeWestPanning, PP_MOUSECURSOR_TYPE_WESTPANNING); +COMPILE_ASSERT_MATCHING_ENUM(TypeMove, PP_MOUSECURSOR_TYPE_MOVE); +COMPILE_ASSERT_MATCHING_ENUM(TypeVerticalText, + PP_MOUSECURSOR_TYPE_VERTICALTEXT); +COMPILE_ASSERT_MATCHING_ENUM(TypeCell, PP_MOUSECURSOR_TYPE_CELL); +COMPILE_ASSERT_MATCHING_ENUM(TypeContextMenu, PP_MOUSECURSOR_TYPE_CONTEXTMENU); +COMPILE_ASSERT_MATCHING_ENUM(TypeAlias, PP_MOUSECURSOR_TYPE_ALIAS); +COMPILE_ASSERT_MATCHING_ENUM(TypeProgress, PP_MOUSECURSOR_TYPE_PROGRESS); +COMPILE_ASSERT_MATCHING_ENUM(TypeNoDrop, PP_MOUSECURSOR_TYPE_NODROP); +COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); +COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); +COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); +COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); +COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); +COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); +COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. @@ -449,57 +455,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, @@ -2024,6 +1979,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_MOUSECURSOR_TYPE_CUSTOM) { + DoSetCursor(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); + 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) { diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index d19a709..7c8e0de 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -154,11 +154,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : const GURL& plugin_url() const { return plugin_url_; } bool full_frame() const { return full_frame_; } const ::ppapi::ViewData& view_data() const { return view_data_; } - // If |type| is not PP_CURSORTYPE_CUSTOM, |custom_image| and |hot_spot| are - // ignored. - bool SetCursor(PP_CursorType_Dev type, - PP_Resource custom_image, - const PP_Point* hot_spot); // PPP_Instance and PPP_Instance_Private pass-through. bool Initialize(WebKit::WebPluginContainer* container, @@ -379,6 +374,10 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : double minimum_factor, double maximium_factor) OVERRIDE; virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE; + virtual PP_Bool SetCursor(PP_Instance instance, + PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot) OVERRIDE;
virtual int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) OVERRIDE; virtual void UnlockMouse(PP_Instance instance) OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_cursor_control_impl.cc b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc deleted file mode 100644 index 6525563..0000000 --- a/webkit/plugins/ppapi/ppb_cursor_control_impl.cc +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "ppapi/c/dev/pp_cursor_type_dev.h" -#include "ppapi/c/dev/ppb_cursor_control_dev.h" -#include "ppapi/c/pp_point.h" -#include "ppapi/c/pp_resource.h" -#include "webkit/plugins/ppapi/common.h" -#include "webkit/plugins/ppapi/ppb_image_data_impl.h" -#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" - -using ::ppapi::thunk::PPB_CursorControl_FunctionAPI; - -namespace webkit { -namespace ppapi { - -PPB_CursorControl_Impl::PPB_CursorControl_Impl(PluginInstance* instance) - : instance_(instance) { -} - -PPB_CursorControl_Impl::~PPB_CursorControl_Impl() { -} - -PPB_CursorControl_FunctionAPI* -PPB_CursorControl_Impl::AsPPB_CursorControl_FunctionAPI() { - return this; -} - -PP_Bool PPB_CursorControl_Impl::SetCursor(PP_Instance instance, - PP_CursorType_Dev type, - PP_Resource custom_image_id, - const PP_Point* hot_spot) { - return PP_FromBool(instance_->SetCursor(type, custom_image_id, hot_spot)); -} - -PP_Bool PPB_CursorControl_Impl::LockCursor(PP_Instance instance) { - // TODO: implement cursor locking. - return PP_FALSE; -} - -PP_Bool PPB_CursorControl_Impl::UnlockCursor(PP_Instance instance) { - // TODO: implement cursor locking. - return PP_FALSE; -} - -PP_Bool PPB_CursorControl_Impl::HasCursorLock(PP_Instance instance) { - // TODO: implement cursor locking. - return PP_FALSE; -} - -PP_Bool PPB_CursorControl_Impl::CanLockCursor(PP_Instance instance) { - // TODO: implement cursor locking. - return PP_FALSE; -} - -} // namespace ppapi -} // namespace webkit diff --git a/webkit/plugins/ppapi/ppb_cursor_control_impl.h b/webkit/plugins/ppapi/ppb_cursor_control_impl.h deleted file mode 100644 index 6b1242e..0000000 --- a/webkit/plugins/ppapi/ppb_cursor_control_impl.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_ -#define WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/function_group_base.h" -#include "ppapi/thunk/ppb_cursor_control_api.h" - -namespace webkit { -namespace ppapi { - -class PluginInstance; - -class PPB_CursorControl_Impl - : public ::ppapi::FunctionGroupBase, - public ::ppapi::thunk::PPB_CursorControl_FunctionAPI { - public: - PPB_CursorControl_Impl(PluginInstance* instance); - virtual ~PPB_CursorControl_Impl(); - - // FunctionGroupBase overrides. - virtual ::ppapi::thunk::PPB_CursorControl_FunctionAPI* - AsPPB_CursorControl_FunctionAPI() OVERRIDE; - - // PPB_CursorControl_FunctionAPI implementation. - virtual PP_Bool SetCursor(PP_Instance instance, - PP_CursorType_Dev type, - PP_Resource custom_image_id, - const PP_Point* hot_spot) OVERRIDE; - virtual PP_Bool LockCursor(PP_Instance instance) OVERRIDE; - virtual PP_Bool UnlockCursor(PP_Instance instance) OVERRIDE; - virtual PP_Bool HasCursorLock(PP_Instance instance) OVERRIDE; - virtual PP_Bool CanLockCursor(PP_Instance instance) OVERRIDE; - - private: - PluginInstance* instance_; - - DISALLOW_COPY_AND_ASSIGN(PPB_CursorControl_Impl); -}; - -} // namespace ppapi -} // namespace webkit - -#endif // WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_ - |