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

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
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/examples/ime/ime.cc » ('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) 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 std::vector< std::pair<uint32_t, uint32_t> >
251 CompositionInputEvent::GetSegments() const {
252 std::vector< std::pair<uint32_t, uint32_t> > result;
253 if (!has_interface<PPB_CompositionInputEvent>())
254 return result;
255 uint32_t* segments = 0;
256 uint32_t size = 0;
257 get_interface<PPB_CompositionInputEvent>()->GetSegments(pp_resource(),
258 &segments, &size);
259 if (segments) {
260 for (size_t i=0; i<size; ++i)
261 result.push_back(std::make_pair(segments[2*i], segments[2*i+1]));
262 }
263 return result;
264 }
265
266 int32_t CompositionInputEvent::GetTargetSegment() const {
267 if (!has_interface<PPB_CompositionInputEvent>())
268 return 0;
269 return get_interface<PPB_CompositionInputEvent>()->GetTargetSegment(
270 pp_resource());
271 }
272
273 std::pair<uint32_t, uint32_t> CompositionInputEvent::GetSelection() const {
274 std::pair<uint32_t, uint32_t> sel(0,0);
275 if (!has_interface<PPB_CompositionInputEvent>())
276 return sel;
277 get_interface<PPB_CompositionInputEvent>()->GetSelection(pp_resource(),
278 &sel.first,
279 &sel.second);
280 return sel;
281 }
282
283
221 } // namespace pp 284 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/examples/ime/ime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698