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

Side by Side Diff: content/renderer/pepper/ppb_scrollbar_impl.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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) 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/host_globals.h"
13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
14 #include "content/renderer/pepper/plugin_module.h" 14 #include "content/renderer/pepper/plugin_module.h"
15 #include "content/renderer/pepper/ppb_image_data_impl.h" 15 #include "content/renderer/pepper/ppb_image_data_impl.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)
26 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
27 #endif 27 #endif
28 28
29 using ppapi::thunk::PPB_Scrollbar_API; 29 using ppapi::thunk::PPB_Scrollbar_API;
30 using WebKit::WebInputEvent; 30 using blink::WebInputEvent;
31 using WebKit::WebRect; 31 using blink::WebRect;
32 using WebKit::WebScrollbar; 32 using blink::WebScrollbar;
33 using WebKit::WebPluginScrollbar; 33 using blink::WebPluginScrollbar;
34 34
35 namespace content { 35 namespace content {
36 36
37 // static 37 // static
38 PP_Resource PPB_Scrollbar_Impl::Create(PP_Instance instance, 38 PP_Resource PPB_Scrollbar_Impl::Create(PP_Instance instance,
39 bool vertical) { 39 bool vertical) {
40 scoped_refptr<PPB_Scrollbar_Impl> scrollbar( 40 scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
41 new PPB_Scrollbar_Impl(instance)); 41 new PPB_Scrollbar_Impl(instance));
42 scrollbar->Init(vertical); 42 scrollbar->Init(vertical);
43 return scrollbar->GetReference(); 43 return scrollbar->GetReference();
44 } 44 }
45 45
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 HostGlobals::Get()->GetInstance(pp_instance()); 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 plugin_instance->container(), 61 plugin_instance->container(),
62 static_cast<WebKit::WebPluginScrollbarClient*>(this))); 62 static_cast<blink::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 }
72 72
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
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(blink::WebPluginScrollbar* scrollbar) {
172 PluginModule* plugin_module = 172 PluginModule* plugin_module =
173 HostGlobals::Get()->GetInstance(pp_instance())->module(); 173 HostGlobals::Get()->GetInstance(pp_instance())->module();
174 if (!plugin_module) 174 if (!plugin_module)
175 return; 175 return;
176 176
177 const PPP_Scrollbar_Dev* ppp_scrollbar = 177 const PPP_Scrollbar_Dev* ppp_scrollbar =
178 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( 178 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface(
179 PPP_SCROLLBAR_DEV_INTERFACE)); 179 PPP_SCROLLBAR_DEV_INTERFACE));
180 if (!ppp_scrollbar) { 180 if (!ppp_scrollbar) {
181 // 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
(...skipping 17 matching lines...) Expand all
199 const PPP_Scrollbar_Dev* ppp_scrollbar = 199 const PPP_Scrollbar_Dev* ppp_scrollbar =
200 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( 200 static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface(
201 PPP_SCROLLBAR_DEV_INTERFACE)); 201 PPP_SCROLLBAR_DEV_INTERFACE));
202 if (!ppp_scrollbar) 202 if (!ppp_scrollbar)
203 return; 203 return;
204 ppp_scrollbar->OverlayChanged(pp_instance(), pp_resource(), 204 ppp_scrollbar->OverlayChanged(pp_instance(), pp_resource(),
205 PP_FromBool(IsOverlay())); 205 PP_FromBool(IsOverlay()));
206 } 206 }
207 207
208 void PPB_Scrollbar_Impl::invalidateScrollbarRect( 208 void PPB_Scrollbar_Impl::invalidateScrollbarRect(
209 WebKit::WebPluginScrollbar* scrollbar, 209 blink::WebPluginScrollbar* scrollbar,
210 const WebKit::WebRect& rect) { 210 const blink::WebRect& rect) {
211 gfx::Rect gfx_rect(rect.x, 211 gfx::Rect gfx_rect(rect.x,
212 rect.y, 212 rect.y,
213 rect.width, 213 rect.width,
214 rect.height); 214 rect.height);
215 dirty_.Union(gfx_rect); 215 dirty_.Union(gfx_rect);
216 // Can't call into the client to tell them about the invalidate right away, 216 // Can't call into the client to tell them about the invalidate right away,
217 // since the PPB_Scrollbar_Impl code is still in the middle of updating its 217 // since the PPB_Scrollbar_Impl code is still in the middle of updating its
218 // internal state. 218 // internal state.
219 // Note: we use a WeakPtrFactory here so that a lingering callback can not 219 // Note: we use a WeakPtrFactory here so that a lingering callback can not
220 // modify the lifetime of this object. Otherwise, WebKit::WebPluginScrollbar 220 // modify the lifetime of this object. Otherwise, blink::WebPluginScrollbar
221 // could outlive WebKit::WebPluginContainer, which is against its contract. 221 // could outlive blink::WebPluginContainer, which is against its contract.
222 base::MessageLoop::current()->PostTask( 222 base::MessageLoop::current()->PostTask(
223 FROM_HERE, 223 FROM_HERE,
224 base::Bind(&PPB_Scrollbar_Impl::NotifyInvalidate, 224 base::Bind(&PPB_Scrollbar_Impl::NotifyInvalidate,
225 weak_ptr_factory_.GetWeakPtr())); 225 weak_ptr_factory_.GetWeakPtr()));
226 } 226 }
227 227
228 void PPB_Scrollbar_Impl::getTickmarks( 228 void PPB_Scrollbar_Impl::getTickmarks(
229 WebKit::WebPluginScrollbar* scrollbar, 229 blink::WebPluginScrollbar* scrollbar,
230 WebKit::WebVector<WebKit::WebRect>* tick_marks) const { 230 blink::WebVector<blink::WebRect>* tick_marks) const {
231 if (tickmarks_.empty()) { 231 if (tickmarks_.empty()) {
232 WebRect* rects = NULL; 232 WebRect* rects = NULL;
233 tick_marks->assign(rects, 0); 233 tick_marks->assign(rects, 0);
234 } else { 234 } else {
235 tick_marks->assign(&tickmarks_[0], tickmarks_.size()); 235 tick_marks->assign(&tickmarks_[0], tickmarks_.size());
236 } 236 }
237 } 237 }
238 238
239 void PPB_Scrollbar_Impl::NotifyInvalidate() { 239 void PPB_Scrollbar_Impl::NotifyInvalidate() {
240 if (dirty_.IsEmpty()) 240 if (dirty_.IsEmpty())
241 return; 241 return;
242 PP_Rect pp_rect; 242 PP_Rect pp_rect;
243 pp_rect.point.x = dirty_.x(); 243 pp_rect.point.x = dirty_.x();
244 pp_rect.point.y = dirty_.y(); 244 pp_rect.point.y = dirty_.y();
245 pp_rect.size.width = dirty_.width(); 245 pp_rect.size.width = dirty_.width();
246 pp_rect.size.height = dirty_.height(); 246 pp_rect.size.height = dirty_.height();
247 dirty_ = gfx::Rect(); 247 dirty_ = gfx::Rect();
248 Invalidate(&pp_rect); 248 Invalidate(&pp_rect);
249 } 249 }
250 250
251 } // namespace content 251 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_scrollbar_impl.h ('k') | content/renderer/pepper/ppb_var_deprecated_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698