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

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

Issue 7621010: Never submit: tentative Pepper IME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: snapshot Created 9 years, 3 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
OLDNEW
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 "ppapi/cpp/input_event.h" 5 #include "ppapi/cpp/input_event.h"
6 6
7 #include "ppapi/cpp/instance.h" 7 #include "ppapi/cpp/instance.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 12 matching lines...) Expand all
23 } 23 }
24 24
25 template <> const char* interface_name<PPB_MouseInputEvent>() { 25 template <> const char* interface_name<PPB_MouseInputEvent>() {
26 return PPB_MOUSE_INPUT_EVENT_INTERFACE; 26 return PPB_MOUSE_INPUT_EVENT_INTERFACE;
27 } 27 }
28 28
29 template <> const char* interface_name<PPB_WheelInputEvent>() { 29 template <> const char* interface_name<PPB_WheelInputEvent>() {
30 return PPB_WHEEL_INPUT_EVENT_INTERFACE; 30 return PPB_WHEEL_INPUT_EVENT_INTERFACE;
31 } 31 }
32 32
33 template <> const char* interface_name<PPB_CompositionInputEvent>() {
34 return PPB_COMPOSITION_INPUT_EVENT_INTERFACE;
35 }
36
33 } // namespace 37 } // namespace
34 38
35 // InputEvent ------------------------------------------------------------------ 39 // InputEvent ------------------------------------------------------------------
36 40
37 InputEvent::InputEvent() : Resource() { 41 InputEvent::InputEvent() : Resource() {
38 } 42 }
39 43
40 InputEvent::InputEvent(PP_Resource input_event_resource) : Resource() { 44 InputEvent::InputEvent(PP_Resource input_event_resource) : Resource() {
41 // Type check the input event before setting it. 45 // Type check the input event before setting it.
42 if (!has_interface<PPB_InputEvent>()) 46 if (!has_interface<PPB_InputEvent>())
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 215 }
212 216
213 Var KeyboardInputEvent::GetCharacterText() const { 217 Var KeyboardInputEvent::GetCharacterText() const {
214 if (!has_interface<PPB_KeyboardInputEvent>()) 218 if (!has_interface<PPB_KeyboardInputEvent>())
215 return Var(); 219 return Var();
216 return Var(Var::PassRef(), 220 return Var(Var::PassRef(),
217 get_interface<PPB_KeyboardInputEvent>()->GetCharacterText( 221 get_interface<PPB_KeyboardInputEvent>()->GetCharacterText(
218 pp_resource())); 222 pp_resource()));
219 } 223 }
220 224
225 // CompositionInputEvent -------------------------------------------------------
226
227 CompositionInputEvent::CompositionInputEvent() : InputEvent() {
228 }
229
230 CompositionInputEvent::CompositionInputEvent(const InputEvent& event)
231 : InputEvent() {
232 // Type check the input event before setting it.
233 if (!has_interface<PPB_CompositionInputEvent>())
234 return;
235 if (get_interface<PPB_CompositionInputEvent>()->IsCompositionInputEvent(
236 event.pp_resource())) {
237 Module::Get()->core()->AddRefResource(event.pp_resource());
238 PassRefFromConstructor(event.pp_resource());
239 }
240 }
241
242 Var CompositionInputEvent::GetText() const {
243 if (!has_interface<PPB_CompositionInputEvent>())
244 return Var();
245 return Var(Var::PassRef(),
246 get_interface<PPB_CompositionInputEvent>()->GetText(
247 pp_resource()));
248 }
249
250 uint32_t CompositionInputEvent::GetTargetSegment() const {
251 if (!has_interface<PPB_CompositionInputEvent>())
252 return 0;
253 return get_interface<PPB_CompositionInputEvent>()->GetTargetSegment(
254 pp_resource());
255 }
256
257 std::vector<uint32_t> CompositionInputEvent::GetSegments() const {
258 std::vector<uint32_t> result;
259 if (!has_interface<PPB_CompositionInputEvent>())
260 return result;
261 uint32_t* segments = 0;
262 uint32_t size = 0;
263 get_interface<PPB_CompositionInputEvent>()->GetSegments(pp_resource(),
264 &segments, &size);
265 if (segments && size)
266 result.assign(segments, segments+size);
267 return result;
268 }
269
221 } // namespace pp 270 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698