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

Side by Side Diff: ppapi/cpp/input_event.cc

Issue 10543159: ppapi: Add support for touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/cpp/touch_point.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/cpp/input_event.h" 5 #include "ppapi/cpp/input_event.h"
6 6
7 #include "ppapi/cpp/instance_handle.h" 7 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module.h" 8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h" 9 #include "ppapi/cpp/module_impl.h"
10 #include "ppapi/cpp/point.h" 10 #include "ppapi/cpp/point.h"
11 #include "ppapi/cpp/touch_point.h"
11 #include "ppapi/cpp/var.h" 12 #include "ppapi/cpp/var.h"
12 13
13 namespace pp { 14 namespace pp {
14 15
15 namespace { 16 namespace {
16 17
17 template <> const char* interface_name<PPB_InputEvent_1_0>() { 18 template <> const char* interface_name<PPB_InputEvent_1_0>() {
18 return PPB_INPUT_EVENT_INTERFACE_1_0; 19 return PPB_INPUT_EVENT_INTERFACE_1_0;
19 } 20 }
20 21
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 212 }
212 213
213 Var KeyboardInputEvent::GetCharacterText() const { 214 Var KeyboardInputEvent::GetCharacterText() const {
214 if (!has_interface<PPB_KeyboardInputEvent_1_0>()) 215 if (!has_interface<PPB_KeyboardInputEvent_1_0>())
215 return Var(); 216 return Var();
216 return Var(PASS_REF, 217 return Var(PASS_REF,
217 get_interface<PPB_KeyboardInputEvent_1_0>()->GetCharacterText( 218 get_interface<PPB_KeyboardInputEvent_1_0>()->GetCharacterText(
218 pp_resource())); 219 pp_resource()));
219 } 220 }
220 221
222 // TouchInputEvent ------------------------------------------------------------
223 TouchInputEvent::TouchInputEvent() : InputEvent() {
224 }
225
226 TouchInputEvent::TouchInputEvent(const InputEvent& event) : InputEvent() {
227 if (!has_interface<PPB_TouchInputEvent_1_0>())
228 return;
229 // Type check the input event before setting it.
230 if (get_interface<PPB_TouchInputEvent_1_0>()->IsTouchInputEvent(
231 event.pp_resource())) {
232 Module::Get()->core()->AddRefResource(event.pp_resource());
233 PassRefFromConstructor(event.pp_resource());
234 }
235 }
236
237 void TouchInputEvent::AddTouchPoint(PP_TouchListType list,
238 PP_TouchPoint point) {
239 if (!has_interface<PPB_TouchInputEvent_1_0>())
240 return;
241 get_interface<PPB_TouchInputEvent_1_0>()->AddTouchPoint(pp_resource(), list,
242 &point);
243 }
244
245 uint32_t TouchInputEvent::GetTouchCount(PP_TouchListType list) const {
246 if (!has_interface<PPB_TouchInputEvent_1_0>())
247 return 0;
248 return get_interface<PPB_TouchInputEvent_1_0>()->GetTouchCount(pp_resource(),
249 list);
250 }
251
252 TouchPoint TouchInputEvent::GetTouchById(PP_TouchListType list,
253 uint32_t id) const {
254 if (!has_interface<PPB_TouchInputEvent_1_0>())
255 return TouchPoint();
256 return TouchPoint(get_interface<PPB_TouchInputEvent_1_0>()->
257 GetTouchById(pp_resource(), list, id));
258 }
259
260 TouchPoint TouchInputEvent::GetTouchByIndex(PP_TouchListType list,
261 uint32_t index) const {
262 if (!has_interface<PPB_TouchInputEvent_1_0>())
263 return TouchPoint();
264 return TouchPoint(get_interface<PPB_TouchInputEvent_1_0>()->
265 GetTouchByIndex(pp_resource(), list, index));
266 }
267
221 } // namespace pp 268 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/cpp/touch_point.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698