diff options
Diffstat (limited to 'ppapi/cpp/dev')
-rw-r--r-- | ppapi/cpp/dev/scrollbar_dev.cc | 87 | ||||
-rw-r--r-- | ppapi/cpp/dev/scrollbar_dev.h | 39 | ||||
-rw-r--r-- | ppapi/cpp/dev/selection_dev.cc | 44 | ||||
-rw-r--r-- | ppapi/cpp/dev/selection_dev.h | 52 | ||||
-rw-r--r-- | ppapi/cpp/dev/widget_client_dev.cc | 88 | ||||
-rw-r--r-- | ppapi/cpp/dev/widget_client_dev.h | 52 | ||||
-rw-r--r-- | ppapi/cpp/dev/widget_dev.cc | 83 | ||||
-rw-r--r-- | ppapi/cpp/dev/widget_dev.h | 37 | ||||
-rw-r--r-- | ppapi/cpp/dev/zoom_dev.cc | 62 | ||||
-rw-r--r-- | ppapi/cpp/dev/zoom_dev.h | 59 |
10 files changed, 0 insertions, 603 deletions
diff --git a/ppapi/cpp/dev/scrollbar_dev.cc b/ppapi/cpp/dev/scrollbar_dev.cc deleted file mode 100644 index 26eb9ef..0000000 --- a/ppapi/cpp/dev/scrollbar_dev.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2010 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 <vector> - -#include "ppapi/cpp/dev/scrollbar_dev.h" - -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/rect.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_Scrollbar_Dev>() { - return PPB_SCROLLBAR_DEV_INTERFACE; -} - -} // namespace - -Scrollbar_Dev::Scrollbar_Dev(PP_Resource resource) : Widget_Dev(resource) { -} - -Scrollbar_Dev::Scrollbar_Dev(const InstanceHandle& instance, bool vertical) { - if (!has_interface<PPB_Scrollbar_Dev>()) - return; - PassRefFromConstructor(get_interface<PPB_Scrollbar_Dev>()->Create( - instance.pp_instance(), PP_FromBool(vertical))); -} - -Scrollbar_Dev::Scrollbar_Dev(const Scrollbar_Dev& other) - : Widget_Dev(other) { -} - -uint32_t Scrollbar_Dev::GetThickness() { - if (!has_interface<PPB_Scrollbar_Dev>()) - return 0; - return get_interface<PPB_Scrollbar_Dev>()->GetThickness(pp_resource()); -} - -bool Scrollbar_Dev::IsOverlay() { - if (!has_interface<PPB_Scrollbar_Dev>()) - return false; - return - PP_ToBool(get_interface<PPB_Scrollbar_Dev>()->IsOverlay(pp_resource())); -} - -uint32_t Scrollbar_Dev::GetValue() { - if (!has_interface<PPB_Scrollbar_Dev>()) - return 0; - return get_interface<PPB_Scrollbar_Dev>()->GetValue(pp_resource()); -} - -void Scrollbar_Dev::SetValue(uint32_t value) { - if (has_interface<PPB_Scrollbar_Dev>()) - get_interface<PPB_Scrollbar_Dev>()->SetValue(pp_resource(), value); -} - -void Scrollbar_Dev::SetDocumentSize(uint32_t size) { - if (has_interface<PPB_Scrollbar_Dev>()) - get_interface<PPB_Scrollbar_Dev>()->SetDocumentSize(pp_resource(), size); -} - -void Scrollbar_Dev::SetTickMarks(const Rect* tick_marks, uint32_t count) { - if (!has_interface<PPB_Scrollbar_Dev>()) - return; - - std::vector<PP_Rect> temp; - temp.resize(count); - for (uint32_t i = 0; i < count; ++i) - temp[i] = tick_marks[i]; - - get_interface<PPB_Scrollbar_Dev>()->SetTickMarks( - pp_resource(), count ? &temp[0] : NULL, count); -} - -void Scrollbar_Dev::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) { - if (has_interface<PPB_Scrollbar_Dev>()) - get_interface<PPB_Scrollbar_Dev>()->ScrollBy(pp_resource(), - unit, - multiplier); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/scrollbar_dev.h b/ppapi/cpp/dev/scrollbar_dev.h deleted file mode 100644 index fabbbd7..0000000 --- a/ppapi/cpp/dev/scrollbar_dev.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2010 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_DEV_SCROLLBAR_DEV_H_ -#define PPAPI_CPP_DEV_SCROLLBAR_DEV_H_ - -#include "ppapi/c/dev/ppb_scrollbar_dev.h" -#include "ppapi/cpp/dev/widget_dev.h" - -namespace pp { - -class InstanceHandle; - -// This class allows a plugin to use the browser's scrollbar widget. -class Scrollbar_Dev : public Widget_Dev { - public: - // Creates an is_null() Scrollbar object. - Scrollbar_Dev() {} - - explicit Scrollbar_Dev(PP_Resource resource); - Scrollbar_Dev(const InstanceHandle& instance, bool vertical); - Scrollbar_Dev(const Scrollbar_Dev& other); - - Scrollbar_Dev& operator=(const Scrollbar_Dev& other); - - // PPB_Scrollbar methods: - uint32_t GetThickness(); - bool IsOverlay(); - uint32_t GetValue(); - void SetValue(uint32_t value); - void SetDocumentSize(uint32_t size); - void SetTickMarks(const Rect* tick_marks, uint32_t count); - void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier); -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_SCROLLBAR_DEV_H_ diff --git a/ppapi/cpp/dev/selection_dev.cc b/ppapi/cpp/dev/selection_dev.cc deleted file mode 100644 index 7e1284b..0000000 --- a/ppapi/cpp/dev/selection_dev.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2010 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/dev/selection_dev.h" - -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -namespace { - -static const char kPPPSelectionInterface[] = PPP_SELECTION_DEV_INTERFACE; - -PP_Var GetSelectedText(PP_Instance instance, PP_Bool html) { - void* object = - pp::Instance::GetPerInstanceObject(instance, kPPPSelectionInterface); - if (!object) - return Var().Detach(); - return static_cast<Selection_Dev*>(object)-> - GetSelectedText(PP_ToBool(html)).Detach(); -} - -const PPP_Selection_Dev ppp_selection = { - &GetSelectedText -}; - -} // namespace - -Selection_Dev::Selection_Dev(Instance* instance) - : associated_instance_(instance) { - Module::Get()->AddPluginInterface(kPPPSelectionInterface, &ppp_selection); - instance->AddPerInstanceObject(kPPPSelectionInterface, this); -} - -Selection_Dev::~Selection_Dev() { - Instance::RemovePerInstanceObject(associated_instance_, - kPPPSelectionInterface, this); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/selection_dev.h b/ppapi/cpp/dev/selection_dev.h deleted file mode 100644 index 629d361..0000000 --- a/ppapi/cpp/dev/selection_dev.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2010 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_DEV_SELECTION_DEV_H_ -#define PPAPI_CPP_DEV_SELECTION_DEV_H_ - -#include "ppapi/c/dev/ppp_selection_dev.h" -#include "ppapi/cpp/instance_handle.h" - -namespace pp { - -class Var; - -// This class allows you to associate the PPP_Selection_Dev C-based interface -// with an object. It registers as the global handler for handling the -// PPP_Selection_Dev interface that the browser calls. -// -// You would typically use this either via inheritance on your instance: -// class MyInstance : public pp::Instance, public pp::Selection_Dev { -// class MyInstance() : pp::Selection_Dev(this) { -// } -// ... -// }; -// -// or by composition: -// class MySelection : public pp::Selection_Dev { -// ... -// }; -// -// class MyInstance : public pp::Instance { -// MyInstance() : selection_(this) { -// } -// -// MySelection selection_; -// }; -class Selection_Dev { - public: - explicit Selection_Dev(Instance* instance); - virtual ~Selection_Dev(); - - // PPP_Selection_Dev functions exposed as virtual functions for you to - // override. - virtual Var GetSelectedText(bool html) = 0; - - private: - InstanceHandle associated_instance_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_SELECTION_DEV_H_ diff --git a/ppapi/cpp/dev/widget_client_dev.cc b/ppapi/cpp/dev/widget_client_dev.cc deleted file mode 100644 index 731f292..0000000 --- a/ppapi/cpp/dev/widget_client_dev.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2010 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/dev/widget_client_dev.h" - -#include "ppapi/c/dev/ppp_scrollbar_dev.h" -#include "ppapi/c/dev/ppp_widget_dev.h" -#include "ppapi/cpp/dev/scrollbar_dev.h" -#include "ppapi/cpp/dev/widget_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/rect.h" - -namespace pp { - -namespace { - -// PPP_Widget_Dev -------------------------------------------------------------- - -const char kPPPWidgetInterface[] = PPP_WIDGET_DEV_INTERFACE; - -void Widget_Invalidate(PP_Instance instance, - PP_Resource widget_id, - const PP_Rect* dirty_rect) { - void* object = Instance::GetPerInstanceObject(instance, kPPPWidgetInterface); - if (!object) - return; - return static_cast<WidgetClient_Dev*>(object)->InvalidateWidget( - Widget_Dev(widget_id), *dirty_rect); -} - -static PPP_Widget_Dev widget_interface = { - &Widget_Invalidate, -}; - -// PPP_Scrollbar_Dev ----------------------------------------------------------- - -const char kPPPScrollbarInterface[] = PPP_SCROLLBAR_DEV_INTERFACE; - -void Scrollbar_ValueChanged(PP_Instance instance, - PP_Resource scrollbar_id, - uint32_t value) { - void* object = - Instance::GetPerInstanceObject(instance, kPPPScrollbarInterface); - if (!object) - return; - return static_cast<WidgetClient_Dev*>(object)->ScrollbarValueChanged( - Scrollbar_Dev(scrollbar_id), value); -} - -void Scrollbar_OverlayChanged(PP_Instance instance, - PP_Resource scrollbar_id, - PP_Bool overlay) { - void* object = - Instance::GetPerInstanceObject(instance, kPPPScrollbarInterface); - if (!object) - return; - return static_cast<WidgetClient_Dev*>(object)->ScrollbarOverlayChanged( - Scrollbar_Dev(scrollbar_id), PP_ToBool(overlay)); -} - -static PPP_Scrollbar_Dev scrollbar_interface = { - &Scrollbar_ValueChanged, - &Scrollbar_OverlayChanged, -}; - -} // namespace - -WidgetClient_Dev::WidgetClient_Dev(Instance* instance) - : associated_instance_(instance) { - Module::Get()->AddPluginInterface(kPPPWidgetInterface, &widget_interface); - instance->AddPerInstanceObject(kPPPWidgetInterface, this); - Module::Get()->AddPluginInterface(kPPPScrollbarInterface, - &scrollbar_interface); - instance->AddPerInstanceObject(kPPPScrollbarInterface, this); -} - -WidgetClient_Dev::~WidgetClient_Dev() { - Instance::RemovePerInstanceObject(associated_instance_, - kPPPScrollbarInterface, this); - Instance::RemovePerInstanceObject(associated_instance_, - kPPPWidgetInterface, this); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/widget_client_dev.h b/ppapi/cpp/dev/widget_client_dev.h deleted file mode 100644 index c638cef..0000000 --- a/ppapi/cpp/dev/widget_client_dev.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2010 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_DEV_WIDGET_CLIENT_DEV_H_ -#define PPAPI_CPP_DEV_WIDGET_CLIENT_DEV_H_ - -#include "ppapi/c/pp_stdint.h" -#include "ppapi/cpp/instance_handle.h" - -namespace pp { - -class Instance; -class Rect; -class Scrollbar_Dev; -class Widget_Dev; - -// This class provides a C++ interface for callbacks related to widgets. You -// would normally use multiple inheritance to derive from this class in your -// instance. -class WidgetClient_Dev { - public: - explicit WidgetClient_Dev(Instance* instance); - virtual ~WidgetClient_Dev(); - - /** - * Notification that the given widget should be repainted. This is the - * implementation for PPP_Widget_Dev. - */ - virtual void InvalidateWidget(Widget_Dev widget, const Rect& dirty_rect) = 0; - - /** - * Notification that the given scrollbar should change value. This is the - * implementation for PPP_Scrollbar_Dev. - */ - virtual void ScrollbarValueChanged(Scrollbar_Dev scrollbar, - uint32_t value) = 0; - - /** - * Notification that the given scrollbar's overlay type has changed. This is - * the implementation for PPP_Scrollbar_Dev. - */ - virtual void ScrollbarOverlayChanged(Scrollbar_Dev scrollbar, - bool type) = 0; - - private: - InstanceHandle associated_instance_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_WIDGET_CLIENT_DEV_H_ diff --git a/ppapi/cpp/dev/widget_dev.cc b/ppapi/cpp/dev/widget_dev.cc deleted file mode 100644 index 14efe1d..0000000 --- a/ppapi/cpp/dev/widget_dev.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2010 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/dev/widget_dev.h" - -#include "ppapi/c/dev/ppb_widget_dev.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/rect.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_Widget_Dev_0_3>() { - return PPB_WIDGET_DEV_INTERFACE_0_3; -} - -template <> const char* interface_name<PPB_Widget_Dev_0_4>() { - return PPB_WIDGET_DEV_INTERFACE_0_4; -} - -} // namespace - -Widget_Dev::Widget_Dev(PP_Resource resource) : Resource(resource) { -} - -Widget_Dev::Widget_Dev(const Widget_Dev& other) : Resource(other) { -} - -bool Widget_Dev::Paint(const Rect& rect, ImageData* image) { - if (has_interface<PPB_Widget_Dev_0_4>()) { - return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->Paint( - pp_resource(), &rect.pp_rect(), image->pp_resource())); - } else if (has_interface<PPB_Widget_Dev_0_3>()) { - return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->Paint( - pp_resource(), &rect.pp_rect(), image->pp_resource())); - } - return false; -} - -bool Widget_Dev::HandleEvent(const InputEvent& event) { - if (has_interface<PPB_Widget_Dev_0_4>()) { - return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->HandleEvent( - pp_resource(), event.pp_resource())); - } else if (has_interface<PPB_Widget_Dev_0_3>()) { - return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->HandleEvent( - pp_resource(), event.pp_resource())); - } - return false; -} - -bool Widget_Dev::GetLocation(Rect* location) { - if (has_interface<PPB_Widget_Dev_0_4>()) { - return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->GetLocation( - pp_resource(), &location->pp_rect())); - } else if (has_interface<PPB_Widget_Dev_0_3>()) { - return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->GetLocation( - pp_resource(), &location->pp_rect())); - } - return false; -} - -void Widget_Dev::SetLocation(const Rect& location) { - if (has_interface<PPB_Widget_Dev_0_4>()) { - get_interface<PPB_Widget_Dev_0_4>()->SetLocation(pp_resource(), - &location.pp_rect()); - } else if (has_interface<PPB_Widget_Dev_0_3>()) { - get_interface<PPB_Widget_Dev_0_3>()->SetLocation(pp_resource(), - &location.pp_rect()); - } -} - -void Widget_Dev::SetScale(float scale) { - if (has_interface<PPB_Widget_Dev_0_4>()) - get_interface<PPB_Widget_Dev_0_4>()->SetScale(pp_resource(), scale); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/widget_dev.h b/ppapi/cpp/dev/widget_dev.h deleted file mode 100644 index ef14c3c..0000000 --- a/ppapi/cpp/dev/widget_dev.h +++ /dev/null @@ -1,37 +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_CPP_DEV_WIDGET_DEV_H_ -#define PPAPI_CPP_DEV_WIDGET_DEV_H_ - -#include "ppapi/c/pp_stdint.h" -#include "ppapi/cpp/resource.h" - -namespace pp { - -class ImageData; -class InputEvent; -class Rect; - -// This is the base class for widget elements. As such, it can't be created -// directly. -class Widget_Dev : public Resource { - public: - // Creates an is_null() Widget object. - Widget_Dev() {} - - explicit Widget_Dev(PP_Resource resource); - Widget_Dev(const Widget_Dev& other); - - // PPB_Widget methods: - bool Paint(const Rect& rect, ImageData* image); - bool HandleEvent(const InputEvent& event); - bool GetLocation(Rect* location); - void SetLocation(const Rect& location); - void SetScale(float scale); -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_WIDGET_DEV_H_ diff --git a/ppapi/cpp/dev/zoom_dev.cc b/ppapi/cpp/dev/zoom_dev.cc deleted file mode 100644 index 0b19c09..0000000 --- a/ppapi/cpp/dev/zoom_dev.cc +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2010 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/dev/zoom_dev.h" - -#include "ppapi/c/dev/ppb_zoom_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -static const char kPPPZoomInterface[] = PPP_ZOOM_DEV_INTERFACE; - -void Zoom(PP_Instance instance, - double factor, - PP_Bool text_only) { - void* object = Instance::GetPerInstanceObject(instance, kPPPZoomInterface); - if (!object) - return; - static_cast<Zoom_Dev*>(object)->Zoom(factor, PP_ToBool(text_only)); -} - -const PPP_Zoom_Dev ppp_zoom = { - &Zoom -}; - -template <> const char* interface_name<PPB_Zoom_Dev>() { - return PPB_ZOOM_DEV_INTERFACE; -} - -} // namespace - -Zoom_Dev::Zoom_Dev(Instance* instance) : associated_instance_(instance) { - Module::Get()->AddPluginInterface(kPPPZoomInterface, &ppp_zoom); - instance->AddPerInstanceObject(kPPPZoomInterface, this); -} - -Zoom_Dev::~Zoom_Dev() { - Instance::RemovePerInstanceObject(associated_instance_, - kPPPZoomInterface, this); -} - -void Zoom_Dev::ZoomChanged(double factor) { - if (has_interface<PPB_Zoom_Dev>()) - get_interface<PPB_Zoom_Dev>()->ZoomChanged( - associated_instance_.pp_instance(), factor); -} - -void Zoom_Dev::ZoomLimitsChanged(double minimum_factor, - double maximium_factor) { - if (!has_interface<PPB_Zoom_Dev>()) - return; - get_interface<PPB_Zoom_Dev>()->ZoomLimitsChanged( - associated_instance_.pp_instance(), minimum_factor, maximium_factor); -} - -} // namespace pp diff --git a/ppapi/cpp/dev/zoom_dev.h b/ppapi/cpp/dev/zoom_dev.h deleted file mode 100644 index b63c019..0000000 --- a/ppapi/cpp/dev/zoom_dev.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2010 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_DEV_ZOOM_DEV_H_ -#define PPAPI_CPP_DEV_ZOOM_DEV_H_ - -#include <string> - -#include "ppapi/c/dev/ppp_zoom_dev.h" -#include "ppapi/cpp/instance_handle.h" - -namespace pp { - -class Instance; - -// This class allows you to associate the PPP_Zoom_Dev and PPB_Zoom_Dev C-based -// interfaces with an object. It associates itself with the given instance, and -// registers as the global handler for handling the PPP_Zoom_Dev interface that -// the browser calls. -// -// You would typically use this either via inheritance on your instance: -// class MyInstance : public pp::Instance, public pp::Zoom_Dev { -// class MyInstance() : pp::Zoom_Dev(this) { -// } -// ... -// }; -// -// or by composition: -// class MyZoom : public pp::Zoom_Dev { -// ... -// }; -// -// class MyInstance : public pp::Instance { -// MyInstance() : zoom_(this) { -// } -// -// MyZoom zoom_; -// }; -class Zoom_Dev { - public: - explicit Zoom_Dev(Instance* instance); - virtual ~Zoom_Dev(); - - // PPP_Zoom_Dev functions exposed as virtual functions for you to - // override. - virtual void Zoom(double factor, bool text_only) = 0; - - // PPB_Zoom_Def functions for you to call to report new zoom factor. - void ZoomChanged(double factor); - void ZoomLimitsChanged(double minimum_factor, double maximium_factor); - - private: - InstanceHandle associated_instance_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_ZOOM_DEV_H_ |