diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 21:49:48 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 21:49:48 +0000 |
commit | 0b94c614fe0d76578a84b4e0543f58650d3ad49c (patch) | |
tree | f08dab436f29cd17bff34e5b80bf14ad62f00a2c /ppapi | |
parent | 4c75b2543443e1b9faca724fc665b0c0fc68c15f (diff) | |
download | chromium_src-0b94c614fe0d76578a84b4e0543f58650d3ad49c.zip chromium_src-0b94c614fe0d76578a84b4e0543f58650d3ad49c.tar.gz chromium_src-0b94c614fe0d76578a84b4e0543f58650d3ad49c.tar.bz2 |
Make scrollbar GetThickness take a resource argument. This allows simlper
routing of the request using the new thunk system.
Support for the old interface is kept to keep pdf and nacl building.
This removes the old Resource type introspection since this was the last
resource using it.
TEST=it compiles
BUG=non
Review URL: http://codereview.chromium.org/7228003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90272 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/dev/ppb_scrollbar_dev.h | 26 | ||||
-rw-r--r-- | ppapi/cpp/dev/scrollbar_dev.h | 2 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 6 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/ppb_scrollbar_api.h | 26 | ||||
-rw-r--r-- | ppapi/thunk/ppb_scrollbar_thunk.cc | 87 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/thunk.h | 2 |
9 files changed, 152 insertions, 3 deletions
diff --git a/ppapi/c/dev/ppb_scrollbar_dev.h b/ppapi/c/dev/ppb_scrollbar_dev.h index 774fa95..d283cbc 100644 --- a/ppapi/c/dev/ppb_scrollbar_dev.h +++ b/ppapi/c/dev/ppb_scrollbar_dev.h @@ -22,11 +22,12 @@ typedef enum { PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ScrollBy_Dev, 4); #define PPB_SCROLLBAR_DEV_INTERFACE_0_3 "PPB_Scrollbar(Dev);0.3" +#define PPB_SCROLLBAR_DEV_INTERFACE_0_4 "PPB_Scrollbar(Dev);0.4" #define PPB_SCROLLBAR_DEV_INTERFACE PPB_SCROLLBAR_DEV_INTERFACE_0_3 // The interface for a scrollbar. A scrollbar is a widget, so the functions // in PPB_Widget can also be used with scrollbar objects. -struct PPB_Scrollbar_Dev { +struct PPB_Scrollbar_0_4_Dev { // Create a new scrollbar. Returns 0 if the instance is invalid. PP_Resource (*Create)(PP_Instance instance, PP_Bool vertical); @@ -36,7 +37,7 @@ struct PPB_Scrollbar_Dev { PP_Bool (*IsScrollbar)(PP_Resource resource); // Gets the thickness of a scrollbar. - uint32_t (*GetThickness)(); + uint32_t (*GetThickness)(PP_Resource resource); // Get/set the value of the scrollbar. uint32_t (*GetValue)(PP_Resource scrollbar); @@ -63,5 +64,26 @@ struct PPB_Scrollbar_Dev { int32_t multiplier); }; +// Old version with no resource argument to GetThickness. +struct PPB_Scrollbar_Dev { + PP_Resource (*Create)(PP_Instance instance, + PP_Bool vertical); + PP_Bool (*IsScrollbar)(PP_Resource resource); + uint32_t (*GetThickness)(); + uint32_t (*GetValue)(PP_Resource scrollbar); + void (*SetValue)(PP_Resource scrollbar, + uint32_t value); + void (*SetDocumentSize)(PP_Resource scrollbar, + uint32_t size); + void (*SetTickMarks)(PP_Resource scrollbar, + const struct PP_Rect* tick_marks, + uint32_t count); + void (*ScrollBy)(PP_Resource scrollbar, + PP_ScrollBy_Dev unit, + int32_t multiplier); +}; + +typedef struct PPB_Scrollbar_Dev PPB_Scrollbar_0_3_Dev; + #endif /* PPAPI_C_DEV_PPB_SCROLLBAR_DEV_H_ */ diff --git a/ppapi/cpp/dev/scrollbar_dev.h b/ppapi/cpp/dev/scrollbar_dev.h index 1890c64..c742a9b 100644 --- a/ppapi/cpp/dev/scrollbar_dev.h +++ b/ppapi/cpp/dev/scrollbar_dev.h @@ -25,7 +25,7 @@ class Scrollbar_Dev : public Widget_Dev { Scrollbar_Dev& operator=(const Scrollbar_Dev& other); // PPB_Scrollbar methods: - static uint32_t GetThickness(); + uint32_t GetThickness(); uint32_t GetValue(); void SetValue(uint32_t value); void SetDocumentSize(uint32_t size); diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 3c9b9f2..c09157b 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -101,6 +101,8 @@ 'thunk/ppb_layer_compositor_api.h', 'thunk/ppb_layer_compositor_thunk.cc', 'thunk/ppb_pdf_api.h', + 'thunk/ppb_scrollbar_api.h', + 'thunk/ppb_scrollbar_thunk.cc', 'thunk/ppb_surface_3d_api.h', 'thunk/ppb_surface_3d_thunk.cc', 'thunk/ppb_transport_api.h', diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 353aeba..095efb0 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -191,6 +191,12 @@ PP_Resource ResourceCreationProxy::CreateGraphics3D( return 0; } +PP_Resource ResourceCreationProxy::CreateScrollbar(PP_Instance instance, + PP_Bool vertical) { + NOTIMPLEMENTED(); // Not proxied yet. + return 0; +} + PP_Resource ResourceCreationProxy::CreateSurface3D( PP_Instance instance, PP_Config3D_Dev config, diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 04ebc5d..107ac3c 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -77,6 +77,8 @@ class ResourceCreationProxy : public ::ppapi::FunctionGroupBase, PP_ImageDataFormat format, const PP_Size& size, PP_Bool init_to_zero) OVERRIDE; + virtual PP_Resource CreateScrollbar(PP_Instance instance, + PP_Bool vertical) OVERRIDE; virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) OVERRIDE; diff --git a/ppapi/thunk/ppb_scrollbar_api.h b/ppapi/thunk/ppb_scrollbar_api.h new file mode 100644 index 0000000..aa0541a --- /dev/null +++ b/ppapi/thunk/ppb_scrollbar_api.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 PPAPI_THUNK_PPB_SCROLLBAR_API_H_ +#define PPAPI_THUNK_PPB_SCROLLBAR_API_H_ + +#include "ppapi/c/dev/ppb_scrollbar_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Scrollbar_API { + public: + virtual uint32_t GetThickness() = 0; + virtual uint32_t GetValue() = 0; + virtual void SetValue(uint32_t value) = 0; + virtual void SetDocumentSize(uint32_t size) = 0; + virtual void SetTickMarks(const PP_Rect* tick_marks, uint32_t count) = 0; + virtual void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_SCROLLBAR_API_H_ diff --git a/ppapi/thunk/ppb_scrollbar_thunk.cc b/ppapi/thunk/ppb_scrollbar_thunk.cc new file mode 100644 index 0000000..572312d --- /dev/null +++ b/ppapi/thunk/ppb_scrollbar_thunk.cc @@ -0,0 +1,87 @@ +// 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/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_scrollbar_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +typedef EnterResource<PPB_Scrollbar_API> EnterScrollbar; + +namespace { + +PP_Resource Create(PP_Instance instance, PP_Bool vertical) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateScrollbar(instance, vertical); +} + +PP_Bool IsScrollbar(PP_Resource resource) { + EnterScrollbar enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +uint32_t GetThickness(PP_Resource scrollbar) { + EnterScrollbar enter(scrollbar, true); + if (enter.failed()) + return 0; + return enter.object()->GetThickness(); +} + +uint32_t GetValue(PP_Resource scrollbar) { + EnterScrollbar enter(scrollbar, true); + if (enter.failed()) + return 0; + return enter.object()->GetValue(); +} + +void SetValue(PP_Resource scrollbar, uint32_t value) { + EnterScrollbar enter(scrollbar, true); + if (enter.succeeded()) + enter.object()->GetValue(); +} + +void SetDocumentSize(PP_Resource scrollbar, uint32_t size) { + EnterScrollbar enter(scrollbar, true); + if (enter.succeeded()) + enter.object()->SetDocumentSize(size); +} + +void SetTickMarks(PP_Resource scrollbar, + const PP_Rect* tick_marks, + uint32_t count) { + EnterScrollbar enter(scrollbar, true); + if (enter.succeeded()) + enter.object()->SetTickMarks(tick_marks, count); +} + +void ScrollBy(PP_Resource scrollbar, PP_ScrollBy_Dev unit, int32_t multiplier) { + EnterScrollbar enter(scrollbar, true); + if (enter.succeeded()) + enter.object()->ScrollBy(unit, multiplier); +} + +const PPB_Scrollbar_0_4_Dev g_ppb_scrollbar_thunk = { + &Create, + &IsScrollbar, + &GetThickness, + &GetValue, + &SetValue, + &SetDocumentSize, + &SetTickMarks, + &ScrollBy +}; + +} // namespace + +const PPB_Scrollbar_0_4_Dev* GetPPB_Scrollbar_Thunk() { + return &g_ppb_scrollbar_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index ed86584..3c7c3df 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -79,6 +79,8 @@ class ResourceCreationAPI { PP_ImageDataFormat format, const PP_Size& size, PP_Bool init_to_zero) = 0; + virtual PP_Resource CreateScrollbar(PP_Instance instance, + PP_Bool vertical) = 0; virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) = 0; diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index d9ad39e..645c5c6 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -34,6 +34,7 @@ struct PPB_ImageDataTrusted; struct PPB_Instance; struct PPB_Instance_Private; struct PPB_LayerCompositor_Dev; +struct PPB_Scrollbar_0_4_Dev; struct PPB_Surface3D_Dev; struct PPB_Transport_Dev; struct PPB_URLLoader; @@ -86,6 +87,7 @@ const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk(); const PPB_Instance_0_5* GetPPB_Instance_0_5_Thunk(); const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); const PPB_LayerCompositor_Dev* GetPPB_LayerCompositor_Thunk(); +const PPB_Scrollbar_0_4_Dev* GetPPB_Scrollbar_Thunk(); const PPB_Surface3D_Dev* GetPPB_Surface3D_Thunk(); const PPB_Transport_Dev* GetPPB_Transport_Thunk(); const PPB_URLLoader* GetPPB_URLLoader_Thunk(); |