OLD | NEW |
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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // the GetThickness call which has no parameters. | 41 // the GetThickness call which has no parameters. |
42 | 42 |
43 PP_Resource Create(PP_Instance instance, PP_Bool vertical) { | 43 PP_Resource Create(PP_Instance instance, PP_Bool vertical) { |
44 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->Create(instance, vertical); | 44 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->Create(instance, vertical); |
45 } | 45 } |
46 | 46 |
47 PP_Bool IsScrollbar(PP_Resource resource) { | 47 PP_Bool IsScrollbar(PP_Resource resource) { |
48 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->IsScrollbar(resource); | 48 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->IsScrollbar(resource); |
49 } | 49 } |
50 | 50 |
51 uint32_t GetThickness() { | 51 uint32_t GetThickness3() { |
52 return WebScrollbar::defaultThickness(); | 52 return WebScrollbar::defaultThickness(); |
53 } | 53 } |
54 | 54 |
| 55 uint32_t GetThickness4(PP_Resource resource) { |
| 56 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->GetThickness(resource); |
| 57 } |
| 58 |
55 uint32_t GetValue(PP_Resource resource) { | 59 uint32_t GetValue(PP_Resource resource) { |
56 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->GetValue(resource); | 60 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->GetValue(resource); |
57 } | 61 } |
58 | 62 |
59 void SetValue(PP_Resource resource, uint32_t value) { | 63 void SetValue(PP_Resource resource, uint32_t value) { |
60 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetValue(resource, value); | 64 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetValue(resource, value); |
61 } | 65 } |
62 | 66 |
63 void SetDocumentSize(PP_Resource resource, uint32_t size) { | 67 void SetDocumentSize(PP_Resource resource, uint32_t size) { |
64 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetDocumentSize(resource, | 68 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetDocumentSize(resource, |
(...skipping 10 matching lines...) Expand all Loading... |
75 | 79 |
76 void ScrollBy(PP_Resource resource, PP_ScrollBy_Dev unit, int32_t multiplier) { | 80 void ScrollBy(PP_Resource resource, PP_ScrollBy_Dev unit, int32_t multiplier) { |
77 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->ScrollBy(resource, | 81 return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->ScrollBy(resource, |
78 unit, | 82 unit, |
79 multiplier); | 83 multiplier); |
80 } | 84 } |
81 | 85 |
82 const PPB_Scrollbar_0_3_Dev ppb_scrollbar_0_3 = { | 86 const PPB_Scrollbar_0_3_Dev ppb_scrollbar_0_3 = { |
83 &Create, | 87 &Create, |
84 &IsScrollbar, | 88 &IsScrollbar, |
85 &GetThickness, | 89 &GetThickness3, |
86 &GetValue, | 90 &GetValue, |
87 &SetValue, | 91 &SetValue, |
88 &SetDocumentSize, | 92 &SetDocumentSize, |
89 &SetTickMarks, | 93 &SetTickMarks, |
90 &ScrollBy | 94 &ScrollBy |
91 }; | 95 }; |
92 | 96 |
| 97 const PPB_Scrollbar_0_4_Dev ppb_scrollbar_0_4 = { |
| 98 &Create, |
| 99 &IsScrollbar, |
| 100 &GetThickness4, |
| 101 &GetValue, |
| 102 &SetValue, |
| 103 &SetDocumentSize, |
| 104 &SetTickMarks, |
| 105 &ScrollBy |
| 106 }; |
| 107 |
93 } // namespace | 108 } // namespace |
94 | 109 |
95 PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical) | 110 PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical) |
96 : PPB_Widget_Impl(instance) { | 111 : PPB_Widget_Impl(instance) { |
97 scrollbar_.reset(WebScrollbar::create( | 112 scrollbar_.reset(WebScrollbar::create( |
98 static_cast<WebKit::WebScrollbarClient*>(this), | 113 static_cast<WebKit::WebScrollbarClient*>(this), |
99 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal)); | 114 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal)); |
100 } | 115 } |
101 | 116 |
102 PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { | 117 PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { |
103 } | 118 } |
104 | 119 |
105 PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { | 120 PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { |
106 return this; | 121 return this; |
107 } | 122 } |
108 | 123 |
109 // static | 124 // static |
110 const PPB_Scrollbar_0_3_Dev* PPB_Scrollbar_Impl::Get0_3Interface() { | 125 const PPB_Scrollbar_0_3_Dev* PPB_Scrollbar_Impl::Get0_3Interface() { |
111 return &ppb_scrollbar_0_3; | 126 return &ppb_scrollbar_0_3; |
112 } | 127 } |
113 | 128 |
| 129 // static |
| 130 const PPB_Scrollbar_0_4_Dev* PPB_Scrollbar_Impl::Get0_4Interface() { |
| 131 return &ppb_scrollbar_0_4; |
| 132 } |
| 133 |
114 uint32_t PPB_Scrollbar_Impl::GetThickness() { | 134 uint32_t PPB_Scrollbar_Impl::GetThickness() { |
115 return WebScrollbar::defaultThickness(); | 135 return WebScrollbar::defaultThickness(); |
116 } | 136 } |
117 | 137 |
| 138 bool PPB_Scrollbar_Impl::IsOverlay() { |
| 139 return scrollbar_->isOverlay(); |
| 140 } |
| 141 |
118 uint32_t PPB_Scrollbar_Impl::GetValue() { | 142 uint32_t PPB_Scrollbar_Impl::GetValue() { |
119 return scrollbar_->value(); | 143 return scrollbar_->value(); |
120 } | 144 } |
121 | 145 |
122 void PPB_Scrollbar_Impl::SetValue(uint32_t value) { | 146 void PPB_Scrollbar_Impl::SetValue(uint32_t value) { |
123 scrollbar_->setValue(value); | 147 scrollbar_->setValue(value); |
124 } | 148 } |
125 | 149 |
126 void PPB_Scrollbar_Impl::SetDocumentSize(uint32_t size) { | 150 void PPB_Scrollbar_Impl::SetDocumentSize(uint32_t size) { |
127 scrollbar_->setDocumentSize(size); | 151 scrollbar_->setDocumentSize(size); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 const PPP_Scrollbar_Dev* ppp_scrollbar = | 221 const PPP_Scrollbar_Dev* ppp_scrollbar = |
198 static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> | 222 static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> |
199 GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); | 223 GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); |
200 if (!ppp_scrollbar) | 224 if (!ppp_scrollbar) |
201 return; | 225 return; |
202 ScopedResourceId resource(this); | 226 ScopedResourceId resource(this); |
203 ppp_scrollbar->ValueChanged( | 227 ppp_scrollbar->ValueChanged( |
204 instance()->pp_instance(), resource.id, scrollbar_->value()); | 228 instance()->pp_instance(), resource.id, scrollbar_->value()); |
205 } | 229 } |
206 | 230 |
| 231 void PPB_Scrollbar_Impl::overlayChanged(WebScrollbar* scrollbar) { |
| 232 const PPP_Scrollbar_Dev* ppp_scrollbar = |
| 233 static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> |
| 234 GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); |
| 235 if (!ppp_scrollbar) |
| 236 return; |
| 237 ScopedResourceId resource(this); |
| 238 ppp_scrollbar->OverlayChanged( |
| 239 instance()->pp_instance(), resource.id, |
| 240 PP_FromBool(scrollbar_->isOverlay())); |
| 241 } |
| 242 |
207 void PPB_Scrollbar_Impl::invalidateScrollbarRect( | 243 void PPB_Scrollbar_Impl::invalidateScrollbarRect( |
208 WebKit::WebScrollbar* scrollbar, | 244 WebKit::WebScrollbar* scrollbar, |
209 const WebKit::WebRect& rect) { | 245 const WebKit::WebRect& rect) { |
210 gfx::Rect gfx_rect(rect.x, | 246 gfx::Rect gfx_rect(rect.x, |
211 rect.y, | 247 rect.y, |
212 rect.width, | 248 rect.width, |
213 rect.height); | 249 rect.height); |
214 dirty_ = dirty_.Union(gfx_rect); | 250 dirty_ = dirty_.Union(gfx_rect); |
215 // Can't call into the client to tell them about the invalidate right away, | 251 // Can't call into the client to tell them about the invalidate right away, |
216 // since the PPB_Scrollbar_Impl code is still in the middle of updating its | 252 // since the PPB_Scrollbar_Impl code is still in the middle of updating its |
(...skipping 22 matching lines...) Expand all Loading... |
239 pp_rect.point.y = dirty_.y(); | 275 pp_rect.point.y = dirty_.y(); |
240 pp_rect.size.width = dirty_.width(); | 276 pp_rect.size.width = dirty_.width(); |
241 pp_rect.size.height = dirty_.height(); | 277 pp_rect.size.height = dirty_.height(); |
242 dirty_ = gfx::Rect(); | 278 dirty_ = gfx::Rect(); |
243 Invalidate(&pp_rect); | 279 Invalidate(&pp_rect); |
244 } | 280 } |
245 | 281 |
246 } // namespace ppapi | 282 } // namespace ppapi |
247 } // namespace webkit | 283 } // namespace webkit |
248 | 284 |
OLD | NEW |