OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/pepper_scrollbar.h" | 5 #include "webkit/glue/plugins/pepper_scrollbar.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 "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
10 #include "third_party/ppapi/c/ppp_scrollbar.h" | 10 #include "third_party/ppapi/c/dev/ppp_scrollbar_dev.h" |
11 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebScrollbar.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebScrollbar.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
15 #include "webkit/glue/plugins/pepper_event_conversion.h" | 15 #include "webkit/glue/plugins/pepper_event_conversion.h" |
16 #include "webkit/glue/plugins/pepper_image_data.h" | 16 #include "webkit/glue/plugins/pepper_image_data.h" |
17 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 17 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
18 #include "webkit/glue/plugins/pepper_plugin_module.h" | 18 #include "webkit/glue/plugins/pepper_plugin_module.h" |
19 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
20 | 20 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 void SetTickMarks(PP_Resource resource, | 69 void SetTickMarks(PP_Resource resource, |
70 const PP_Rect* tick_marks, | 70 const PP_Rect* tick_marks, |
71 uint32_t count) { | 71 uint32_t count) { |
72 scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource)); | 72 scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource)); |
73 if (scrollbar) | 73 if (scrollbar) |
74 scrollbar->SetTickMarks(tick_marks, count); | 74 scrollbar->SetTickMarks(tick_marks, count); |
75 } | 75 } |
76 | 76 |
77 void ScrollBy(PP_Resource resource, PP_ScrollBy unit, int32_t multiplier) { | 77 void ScrollBy(PP_Resource resource, PP_ScrollBy_Dev unit, int32_t multiplier) { |
78 scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource)); | 78 scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource)); |
79 if (scrollbar) | 79 if (scrollbar) |
80 scrollbar->ScrollBy(unit, multiplier); | 80 scrollbar->ScrollBy(unit, multiplier); |
81 } | 81 } |
82 | 82 |
83 const PPB_Scrollbar ppb_scrollbar = { | 83 const PPB_Scrollbar_Dev ppb_scrollbar = { |
84 &Create, | 84 &Create, |
85 &IsScrollbar, | 85 &IsScrollbar, |
86 &GetThickness, | 86 &GetThickness, |
87 &GetValue, | 87 &GetValue, |
88 &SetValue, | 88 &SetValue, |
89 &SetDocumentSize, | 89 &SetDocumentSize, |
90 &SetTickMarks, | 90 &SetTickMarks, |
91 &ScrollBy | 91 &ScrollBy |
92 }; | 92 }; |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 Scrollbar::Scrollbar(PluginInstance* instance, bool vertical) | 96 Scrollbar::Scrollbar(PluginInstance* instance, bool vertical) |
97 : Widget(instance) { | 97 : Widget(instance) { |
98 scrollbar_.reset(WebScrollbar::create( | 98 scrollbar_.reset(WebScrollbar::create( |
99 static_cast<WebKit::WebScrollbarClient*>(this), | 99 static_cast<WebKit::WebScrollbarClient*>(this), |
100 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal)); | 100 vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal)); |
101 } | 101 } |
102 | 102 |
103 Scrollbar::~Scrollbar() { | 103 Scrollbar::~Scrollbar() { |
104 } | 104 } |
105 | 105 |
106 // static | 106 // static |
107 const PPB_Scrollbar* Scrollbar::GetInterface() { | 107 const PPB_Scrollbar_Dev* Scrollbar::GetInterface() { |
108 return &ppb_scrollbar; | 108 return &ppb_scrollbar; |
109 } | 109 } |
110 | 110 |
111 uint32_t Scrollbar::GetValue() { | 111 uint32_t Scrollbar::GetValue() { |
112 return scrollbar_->value(); | 112 return scrollbar_->value(); |
113 } | 113 } |
114 | 114 |
115 void Scrollbar::SetValue(uint32_t value) { | 115 void Scrollbar::SetValue(uint32_t value) { |
116 scrollbar_->setValue(value); | 116 scrollbar_->setValue(value); |
117 } | 117 } |
118 | 118 |
119 void Scrollbar::SetDocumentSize(uint32_t size) { | 119 void Scrollbar::SetDocumentSize(uint32_t size) { |
120 scrollbar_->setDocumentSize(size); | 120 scrollbar_->setDocumentSize(size); |
121 } | 121 } |
122 | 122 |
123 void Scrollbar::SetTickMarks(const PP_Rect* tick_marks, uint32_t count) { | 123 void Scrollbar::SetTickMarks(const PP_Rect* tick_marks, uint32_t count) { |
124 tickmarks_.resize(count); | 124 tickmarks_.resize(count); |
125 for (uint32 i = 0; i < count; ++i) { | 125 for (uint32 i = 0; i < count; ++i) { |
126 tickmarks_[i] = WebRect(tick_marks[i].point.x, | 126 tickmarks_[i] = WebRect(tick_marks[i].point.x, |
127 tick_marks[i].point.y, | 127 tick_marks[i].point.y, |
128 tick_marks[i].size.width, | 128 tick_marks[i].size.width, |
129 tick_marks[i].size.height);; | 129 tick_marks[i].size.height);; |
130 } | 130 } |
131 PP_Rect rect = location(); | 131 PP_Rect rect = location(); |
132 Invalidate(&rect); | 132 Invalidate(&rect); |
133 } | 133 } |
134 | 134 |
135 void Scrollbar::ScrollBy(PP_ScrollBy unit, int32_t multiplier) { | 135 void Scrollbar::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) { |
136 WebScrollbar::ScrollDirection direction = multiplier >= 0 ? | 136 WebScrollbar::ScrollDirection direction = multiplier >= 0 ? |
137 WebScrollbar::ScrollForward : WebScrollbar::ScrollBackward; | 137 WebScrollbar::ScrollForward : WebScrollbar::ScrollBackward; |
138 float fmultiplier = 1.0; | 138 float fmultiplier = 1.0; |
139 | 139 |
140 WebScrollbar::ScrollGranularity granularity; | 140 WebScrollbar::ScrollGranularity granularity; |
141 if (unit == PP_SCROLLBY_LINE) { | 141 if (unit == PP_SCROLLBY_LINE) { |
142 granularity = WebScrollbar::ScrollByLine; | 142 granularity = WebScrollbar::ScrollByLine; |
143 } else if (unit == PP_SCROLLBY_PAGE) { | 143 } else if (unit == PP_SCROLLBY_PAGE) { |
144 granularity = WebScrollbar::ScrollByPage; | 144 granularity = WebScrollbar::ScrollByPage; |
145 } else if (unit == PP_SCROLLBY_DOCUMENT) { | 145 } else if (unit == PP_SCROLLBY_DOCUMENT) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 182 } |
183 | 183 |
184 void Scrollbar::SetLocationInternal(const PP_Rect* location) { | 184 void Scrollbar::SetLocationInternal(const PP_Rect* location) { |
185 scrollbar_->setLocation(WebRect(location->point.x, | 185 scrollbar_->setLocation(WebRect(location->point.x, |
186 location->point.y, | 186 location->point.y, |
187 location->size.width, | 187 location->size.width, |
188 location->size.height)); | 188 location->size.height)); |
189 } | 189 } |
190 | 190 |
191 void Scrollbar::valueChanged(WebKit::WebScrollbar* scrollbar) { | 191 void Scrollbar::valueChanged(WebKit::WebScrollbar* scrollbar) { |
192 const PPP_Scrollbar* ppp_scrollbar = static_cast<const PPP_Scrollbar*>( | 192 const PPP_Scrollbar_Dev* ppp_scrollbar = |
193 module()->GetPluginInterface(PPP_SCROLLBAR_INTERFACE)); | 193 static_cast<const PPP_Scrollbar_Dev*>( |
| 194 module()->GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); |
194 if (!ppp_scrollbar) | 195 if (!ppp_scrollbar) |
195 return; | 196 return; |
196 ScopedResourceId resource(this); | 197 ScopedResourceId resource(this); |
197 ppp_scrollbar->ValueChanged( | 198 ppp_scrollbar->ValueChanged( |
198 instance()->GetPPInstance(), resource.id, scrollbar_->value()); | 199 instance()->GetPPInstance(), resource.id, scrollbar_->value()); |
199 } | 200 } |
200 | 201 |
201 void Scrollbar::invalidateScrollbarRect(WebKit::WebScrollbar* scrollbar, | 202 void Scrollbar::invalidateScrollbarRect(WebKit::WebScrollbar* scrollbar, |
202 const WebKit::WebRect& rect) { | 203 const WebKit::WebRect& rect) { |
203 gfx::Rect gfx_rect(rect.x, | 204 gfx::Rect gfx_rect(rect.x, |
(...skipping 26 matching lines...) Expand all Loading... |
230 PP_Rect pp_rect; | 231 PP_Rect pp_rect; |
231 pp_rect.point.x = dirty_.x(); | 232 pp_rect.point.x = dirty_.x(); |
232 pp_rect.point.y = dirty_.y(); | 233 pp_rect.point.y = dirty_.y(); |
233 pp_rect.size.width = dirty_.width(); | 234 pp_rect.size.width = dirty_.width(); |
234 pp_rect.size.height = dirty_.height(); | 235 pp_rect.size.height = dirty_.height(); |
235 dirty_ = gfx::Rect(); | 236 dirty_ = gfx::Rect(); |
236 Invalidate(&pp_rect); | 237 Invalidate(&pp_rect); |
237 } | 238 } |
238 | 239 |
239 } // namespace pepper | 240 } // namespace pepper |
OLD | NEW |