| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/ppb_scrollbar_impl.h" | 5 #include "content/renderer/pepper/ppb_scrollbar_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/renderer/pepper/common.h" | 10 #include "content/renderer/pepper/common.h" |
| 11 #include "content/renderer/pepper/event_conversion.h" | 11 #include "content/renderer/pepper/event_conversion.h" |
| 12 #include "content/renderer/pepper/host_globals.h" |
| 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 13 #include "content/renderer/pepper/plugin_module.h" | 14 #include "content/renderer/pepper/plugin_module.h" |
| 14 #include "content/renderer/pepper/ppb_image_data_impl.h" | 15 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 15 #include "content/renderer/pepper/resource_helper.h" | |
| 16 #include "ppapi/c/dev/ppp_scrollbar_dev.h" | 16 #include "ppapi/c/dev/ppp_scrollbar_dev.h" |
| 17 #include "ppapi/thunk/thunk.h" | 17 #include "ppapi/thunk/thunk.h" |
| 18 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
| 19 #include "third_party/WebKit/public/platform/WebCanvas.h" | 19 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 20 #include "third_party/WebKit/public/platform/WebRect.h" | 20 #include "third_party/WebKit/public/platform/WebRect.h" |
| 21 #include "third_party/WebKit/public/platform/WebVector.h" | 21 #include "third_party/WebKit/public/platform/WebVector.h" |
| 22 #include "third_party/WebKit/public/web/WebInputEvent.h" | 22 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 23 #include "third_party/WebKit/public/web/WebPluginScrollbar.h" | 23 #include "third_party/WebKit/public/web/WebPluginScrollbar.h" |
| 24 | 24 |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PP_Instance instance) | 46 PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PP_Instance instance) |
| 47 : PPB_Widget_Impl(instance), | 47 : PPB_Widget_Impl(instance), |
| 48 weak_ptr_factory_(this) { | 48 weak_ptr_factory_(this) { |
| 49 } | 49 } |
| 50 | 50 |
| 51 PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { | 51 PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void PPB_Scrollbar_Impl::Init(bool vertical) { | 54 void PPB_Scrollbar_Impl::Init(bool vertical) { |
| 55 PepperPluginInstanceImpl* plugin_instance = | 55 PepperPluginInstanceImpl* plugin_instance = |
| 56 ResourceHelper::GetPluginInstance(this); | 56 HostGlobals::Get()->GetInstance(pp_instance()); |
| 57 if (!plugin_instance) | 57 if (!plugin_instance) |
| 58 return; | 58 return; |
| 59 scrollbar_.reset(WebPluginScrollbar::createForPlugin( | 59 scrollbar_.reset(WebPluginScrollbar::createForPlugin( |
| 60 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal, | 60 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal, |
| 61 ResourceHelper::GetPluginInstance(this)->container(), | 61 plugin_instance->container(), |
| 62 static_cast<WebKit::WebPluginScrollbarClient*>(this))); | 62 static_cast<WebKit::WebPluginScrollbarClient*>(this))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { | 65 PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { |
| 66 return this; | 66 return this; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PPB_Scrollbar_Impl::InstanceWasDeleted() { | 69 void PPB_Scrollbar_Impl::InstanceWasDeleted() { |
| 70 scrollbar_.reset(); | 70 scrollbar_.reset(); |
| 71 } | 71 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) { | 162 void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) { |
| 163 if (!scrollbar_) | 163 if (!scrollbar_) |
| 164 return; | 164 return; |
| 165 scrollbar_->setLocation(WebRect(location->point.x, | 165 scrollbar_->setLocation(WebRect(location->point.x, |
| 166 location->point.y, | 166 location->point.y, |
| 167 location->size.width, | 167 location->size.width, |
| 168 location->size.height)); | 168 location->size.height)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void PPB_Scrollbar_Impl::valueChanged(WebKit::WebPluginScrollbar* scrollbar) { | 171 void PPB_Scrollbar_Impl::valueChanged(WebKit::WebPluginScrollbar* scrollbar) { |
| 172 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); | 172 PluginModule* plugin_module = |
| 173 HostGlobals::Get()->GetInstance(pp_instance())->module(); |
| 173 if (!plugin_module) | 174 if (!plugin_module) |
| 174 return; | 175 return; |
| 175 | 176 |
| 176 const PPP_Scrollbar_Dev* ppp_scrollbar = | 177 const PPP_Scrollbar_Dev* ppp_scrollbar = |
| 177 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( | 178 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( |
| 178 PPP_SCROLLBAR_DEV_INTERFACE)); | 179 PPP_SCROLLBAR_DEV_INTERFACE)); |
| 179 if (!ppp_scrollbar) { | 180 if (!ppp_scrollbar) { |
| 180 // Try the old version. This is ok because the old interface is a subset of | 181 // Try the old version. This is ok because the old interface is a subset of |
| 181 // the new one, and ValueChanged didn't change. | 182 // the new one, and ValueChanged didn't change. |
| 182 ppp_scrollbar = | 183 ppp_scrollbar = |
| 183 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( | 184 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( |
| 184 PPP_SCROLLBAR_DEV_INTERFACE_0_2)); | 185 PPP_SCROLLBAR_DEV_INTERFACE_0_2)); |
| 185 if (!ppp_scrollbar) | 186 if (!ppp_scrollbar) |
| 186 return; | 187 return; |
| 187 } | 188 } |
| 188 ppp_scrollbar->ValueChanged(pp_instance(), pp_resource(), | 189 ppp_scrollbar->ValueChanged(pp_instance(), pp_resource(), |
| 189 scrollbar_->value()); | 190 scrollbar_->value()); |
| 190 } | 191 } |
| 191 | 192 |
| 192 void PPB_Scrollbar_Impl::overlayChanged(WebPluginScrollbar* scrollbar) { | 193 void PPB_Scrollbar_Impl::overlayChanged(WebPluginScrollbar* scrollbar) { |
| 193 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); | 194 PluginModule* plugin_module = |
| 195 HostGlobals::Get()->GetInstance(pp_instance())->module(); |
| 194 if (!plugin_module) | 196 if (!plugin_module) |
| 195 return; | 197 return; |
| 196 | 198 |
| 197 const PPP_Scrollbar_Dev* ppp_scrollbar = | 199 const PPP_Scrollbar_Dev* ppp_scrollbar = |
| 198 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( | 200 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( |
| 199 PPP_SCROLLBAR_DEV_INTERFACE)); | 201 PPP_SCROLLBAR_DEV_INTERFACE)); |
| 200 if (!ppp_scrollbar) | 202 if (!ppp_scrollbar) |
| 201 return; | 203 return; |
| 202 ppp_scrollbar->OverlayChanged(pp_instance(), pp_resource(), | 204 ppp_scrollbar->OverlayChanged(pp_instance(), pp_resource(), |
| 203 PP_FromBool(IsOverlay())); | 205 PP_FromBool(IsOverlay())); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 PP_Rect pp_rect; | 242 PP_Rect pp_rect; |
| 241 pp_rect.point.x = dirty_.x(); | 243 pp_rect.point.x = dirty_.x(); |
| 242 pp_rect.point.y = dirty_.y(); | 244 pp_rect.point.y = dirty_.y(); |
| 243 pp_rect.size.width = dirty_.width(); | 245 pp_rect.size.width = dirty_.width(); |
| 244 pp_rect.size.height = dirty_.height(); | 246 pp_rect.size.height = dirty_.height(); |
| 245 dirty_ = gfx::Rect(); | 247 dirty_ = gfx::Rect(); |
| 246 Invalidate(&pp_rect); | 248 Invalidate(&pp_rect); |
| 247 } | 249 } |
| 248 | 250 |
| 249 } // namespace content | 251 } // namespace content |
| OLD | NEW |