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

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

Issue 18671004: PPAPI: Move IMEInputEvent and TextInput to stable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing one comment Created 7 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
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/cpp/text_input_controller.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"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 template <> const char* interface_name<PPB_WheelInputEvent_1_0>() { 30 template <> const char* interface_name<PPB_WheelInputEvent_1_0>() {
31 return PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0; 31 return PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0;
32 } 32 }
33 33
34 template <> const char* interface_name<PPB_TouchInputEvent_1_0>() { 34 template <> const char* interface_name<PPB_TouchInputEvent_1_0>() {
35 return PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0; 35 return PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0;
36 } 36 }
37 37
38 template <> const char* interface_name<PPB_IMEInputEvent_1_0>() {
39 return PPB_IME_INPUT_EVENT_INTERFACE_1_0;
40 }
41
38 } // namespace 42 } // namespace
39 43
40 // InputEvent ------------------------------------------------------------------ 44 // InputEvent ------------------------------------------------------------------
41 45
42 InputEvent::InputEvent() : Resource() { 46 InputEvent::InputEvent() : Resource() {
43 } 47 }
44 48
45 InputEvent::InputEvent(PP_Resource input_event_resource) : Resource() { 49 InputEvent::InputEvent(PP_Resource input_event_resource) : Resource() {
46 // Type check the input event before setting it. 50 // Type check the input event before setting it.
47 if (!has_interface<PPB_InputEvent_1_0>()) 51 if (!has_interface<PPB_InputEvent_1_0>())
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 277 }
274 278
275 TouchPoint TouchInputEvent::GetTouchByIndex(PP_TouchListType list, 279 TouchPoint TouchInputEvent::GetTouchByIndex(PP_TouchListType list,
276 uint32_t index) const { 280 uint32_t index) const {
277 if (!has_interface<PPB_TouchInputEvent_1_0>()) 281 if (!has_interface<PPB_TouchInputEvent_1_0>())
278 return TouchPoint(); 282 return TouchPoint();
279 return TouchPoint(get_interface<PPB_TouchInputEvent_1_0>()-> 283 return TouchPoint(get_interface<PPB_TouchInputEvent_1_0>()->
280 GetTouchByIndex(pp_resource(), list, index)); 284 GetTouchByIndex(pp_resource(), list, index));
281 } 285 }
282 286
287 // IMEInputEvent -------------------------------------------------------
288
289 IMEInputEvent::IMEInputEvent() : InputEvent() {
290 }
291
292 IMEInputEvent::IMEInputEvent(const InputEvent& event) : InputEvent() {
293 if (has_interface<PPB_IMEInputEvent_1_0>()) {
294 if (get_interface<PPB_IMEInputEvent_1_0>()->IsIMEInputEvent(
295 event.pp_resource())) {
296 Module::Get()->core()->AddRefResource(event.pp_resource());
297 PassRefFromConstructor(event.pp_resource());
298 }
299 }
300 }
301
302 IMEInputEvent::IMEInputEvent(
303 const InstanceHandle& instance,
304 PP_InputEvent_Type type,
305 PP_TimeTicks time_stamp,
306 const Var& text,
307 const std::vector<uint32_t>& segment_offsets,
308 int32_t target_segment,
309 const std::pair<uint32_t, uint32_t>& selection) : InputEvent() {
310 if (!has_interface<PPB_IMEInputEvent_1_0>())
311 return;
312 uint32_t dummy = 0;
313 PassRefFromConstructor(get_interface<PPB_IMEInputEvent_1_0>()->Create(
314 instance.pp_instance(), type, time_stamp, text.pp_var(),
315 segment_offsets.empty() ? 0 : segment_offsets.size() - 1,
316 segment_offsets.empty() ? &dummy : &segment_offsets[0],
317 target_segment, selection.first, selection.second));
318 }
319
320
321 Var IMEInputEvent::GetText() const {
322 if (has_interface<PPB_IMEInputEvent_1_0>()) {
323 return Var(PASS_REF,
324 get_interface<PPB_IMEInputEvent_1_0>()->GetText(
325 pp_resource()));
326 }
327 return Var();
328 }
329
330 uint32_t IMEInputEvent::GetSegmentNumber() const {
331 if (has_interface<PPB_IMEInputEvent_1_0>()) {
332 return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentNumber(
333 pp_resource());
334 }
335 return 0;
336 }
337
338 uint32_t IMEInputEvent::GetSegmentOffset(uint32_t index) const {
339 if (has_interface<PPB_IMEInputEvent_1_0>()) {
340 return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentOffset(
341 pp_resource(), index);
342 }
343 return 0;
344 }
345
346 int32_t IMEInputEvent::GetTargetSegment() const {
347 if (has_interface<PPB_IMEInputEvent_1_0>()) {
348 return get_interface<PPB_IMEInputEvent_1_0>()->GetTargetSegment(
349 pp_resource());
350 }
351 return 0;
352 }
353
354 void IMEInputEvent::GetSelection(uint32_t* start, uint32_t* end) const {
355 if (has_interface<PPB_IMEInputEvent_1_0>()) {
356 get_interface<PPB_IMEInputEvent_1_0>()->GetSelection(pp_resource(),
357 start,
358 end);
359 }
360 }
361
283 } // namespace pp 362 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/cpp/text_input_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698