Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: webkit/plugins/ppapi/ppb_scrollbar_impl.cc

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix self-assignment Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_scrollbar_impl.h" 5 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "ppapi/c/dev/ppp_scrollbar_dev.h" 9 #include "ppapi/c/dev/ppp_scrollbar_dev.h"
10 #include "ppapi/thunk/thunk.h" 10 #include "ppapi/thunk/thunk.h"
11 #include "skia/ext/platform_canvas.h" 11 #include "skia/ext/platform_canvas.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScrollbar.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScrollbar.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
16 #include "webkit/plugins/ppapi/common.h" 16 #include "webkit/plugins/ppapi/common.h"
17 #include "webkit/plugins/ppapi/event_conversion.h" 17 #include "webkit/plugins/ppapi/event_conversion.h"
18 #include "webkit/plugins/ppapi/plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 20 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
21 #include "webkit/plugins/ppapi/resource_helper.h"
21 #include "webkit/glue/webkit_glue.h" 22 #include "webkit/glue/webkit_glue.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
25 #endif 26 #endif
26 27
27 using ppapi::thunk::PPB_Scrollbar_API; 28 using ppapi::thunk::PPB_Scrollbar_API;
28 using WebKit::WebInputEvent; 29 using WebKit::WebInputEvent;
29 using WebKit::WebRect; 30 using WebKit::WebRect;
30 using WebKit::WebScrollbar; 31 using WebKit::WebScrollbar;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 &GetValue, 102 &GetValue,
102 &SetValue, 103 &SetValue,
103 &SetDocumentSize, 104 &SetDocumentSize,
104 &SetTickMarks, 105 &SetTickMarks,
105 &ScrollBy 106 &ScrollBy
106 }; 107 };
107 108
108 } // namespace 109 } // namespace
109 110
110 // static 111 // static
111 PP_Resource PPB_Scrollbar_Impl::Create(PluginInstance* instance, 112 PP_Resource PPB_Scrollbar_Impl::Create(PP_Instance instance,
112 bool vertical) { 113 bool vertical) {
113 scoped_refptr<PPB_Scrollbar_Impl> scrollbar( 114 scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
114 new PPB_Scrollbar_Impl(instance)); 115 new PPB_Scrollbar_Impl(instance));
115 scrollbar->Init(vertical); 116 scrollbar->Init(vertical);
116 return scrollbar->GetReference(); 117 return scrollbar->GetReference();
117 } 118 }
118 119
119 PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance) 120 PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PP_Instance instance)
120 : PPB_Widget_Impl(instance), 121 : PPB_Widget_Impl(instance),
121 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 122 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
122 } 123 }
123 124
124 PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { 125 PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() {
125 } 126 }
126 127
127 void PPB_Scrollbar_Impl::Init(bool vertical) { 128 void PPB_Scrollbar_Impl::Init(bool vertical) {
128 scrollbar_.reset(WebScrollbar::createForPlugin( 129 scrollbar_.reset(WebScrollbar::createForPlugin(
129 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal, 130 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal,
130 instance()->container(), 131 ResourceHelper::GetPluginInstance(this)->container(),
131 static_cast<WebKit::WebScrollbarClient*>(this))); 132 static_cast<WebKit::WebScrollbarClient*>(this)));
132 } 133 }
133 134
134 PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { 135 PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() {
135 return this; 136 return this;
136 } 137 }
137 138
138 // static 139 // static
139 const PPB_Scrollbar_0_3_Dev* PPB_Scrollbar_Impl::Get0_3Interface() { 140 const PPB_Scrollbar_0_3_Dev* PPB_Scrollbar_Impl::Get0_3Interface() {
140 return &ppb_scrollbar_0_3; 141 return &ppb_scrollbar_0_3;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 226 }
226 227
227 void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) { 228 void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) {
228 scrollbar_->setLocation(WebRect(location->point.x, 229 scrollbar_->setLocation(WebRect(location->point.x,
229 location->point.y, 230 location->point.y,
230 location->size.width, 231 location->size.width,
231 location->size.height)); 232 location->size.height));
232 } 233 }
233 234
234 void PPB_Scrollbar_Impl::valueChanged(WebKit::WebScrollbar* scrollbar) { 235 void PPB_Scrollbar_Impl::valueChanged(WebKit::WebScrollbar* scrollbar) {
236 PluginModule* module = ResourceHelper::GetPluginModule(this);
235 const PPP_Scrollbar_Dev* ppp_scrollbar = 237 const PPP_Scrollbar_Dev* ppp_scrollbar =
236 static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> 238 static_cast<const PPP_Scrollbar_Dev*>(module->GetPluginInterface(
237 GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); 239 PPP_SCROLLBAR_DEV_INTERFACE));
238 if (!ppp_scrollbar) { 240 if (!ppp_scrollbar) {
239 // Try the old version. This is ok because the old interface is a subset of 241 // Try the old version. This is ok because the old interface is a subset of
240 // the new one, and ValueChanged didn't change. 242 // the new one, and ValueChanged didn't change.
241 ppp_scrollbar = 243 ppp_scrollbar =
242 static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> 244 static_cast<const PPP_Scrollbar_Dev*>(module->GetPluginInterface(
243 GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE_0_2)); 245 PPP_SCROLLBAR_DEV_INTERFACE_0_2));
244 if (!ppp_scrollbar) 246 if (!ppp_scrollbar)
245 return; 247 return;
246 } 248 }
247 ScopedResourceId resource(this); 249 ppp_scrollbar->ValueChanged(pp_instance(), pp_resource(),
248 ppp_scrollbar->ValueChanged( 250 scrollbar_->value());
249 instance()->pp_instance(), resource.id, scrollbar_->value());
250 } 251 }
251 252
252 void PPB_Scrollbar_Impl::overlayChanged(WebScrollbar* scrollbar) { 253 void PPB_Scrollbar_Impl::overlayChanged(WebScrollbar* scrollbar) {
254 PluginModule* module = ResourceHelper::GetPluginModule(this);
253 const PPP_Scrollbar_Dev* ppp_scrollbar = 255 const PPP_Scrollbar_Dev* ppp_scrollbar =
254 static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> 256 static_cast<const PPP_Scrollbar_Dev*>(module->GetPluginInterface(
255 GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); 257 PPP_SCROLLBAR_DEV_INTERFACE));
256 if (!ppp_scrollbar) 258 if (!ppp_scrollbar)
257 return; 259 return;
258 ScopedResourceId resource(this); 260 ppp_scrollbar->OverlayChanged(pp_instance(), pp_resource(),
259 ppp_scrollbar->OverlayChanged( 261 PP_FromBool(IsOverlay()));
260 instance()->pp_instance(), resource.id,
261 PP_FromBool(IsOverlay()));
262 } 262 }
263 263
264 void PPB_Scrollbar_Impl::invalidateScrollbarRect( 264 void PPB_Scrollbar_Impl::invalidateScrollbarRect(
265 WebKit::WebScrollbar* scrollbar, 265 WebKit::WebScrollbar* scrollbar,
266 const WebKit::WebRect& rect) { 266 const WebKit::WebRect& rect) {
267 gfx::Rect gfx_rect(rect.x, 267 gfx::Rect gfx_rect(rect.x,
268 rect.y, 268 rect.y,
269 rect.width, 269 rect.width,
270 rect.height); 270 rect.height);
271 dirty_ = dirty_.Union(gfx_rect); 271 dirty_ = dirty_.Union(gfx_rect);
(...skipping 28 matching lines...) Expand all
300 pp_rect.point.y = dirty_.y(); 300 pp_rect.point.y = dirty_.y();
301 pp_rect.size.width = dirty_.width(); 301 pp_rect.size.width = dirty_.width();
302 pp_rect.size.height = dirty_.height(); 302 pp_rect.size.height = dirty_.height();
303 dirty_ = gfx::Rect(); 303 dirty_ = gfx::Rect();
304 Invalidate(&pp_rect); 304 Invalidate(&pp_rect);
305 } 305 }
306 306
307 } // namespace ppapi 307 } // namespace ppapi
308 } // namespace webkit 308 } // namespace webkit
309 309
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698