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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/input_event.h ('k') | ppapi/examples/ime/ime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/input_event.cc
diff --git a/ppapi/cpp/input_event.cc b/ppapi/cpp/input_event.cc
index 632b1eccd93652f9f15e227e28bb9fdbf342756c..06423a731549f48f5717a129b78c7073c57a6477 100644
--- a/ppapi/cpp/input_event.cc
+++ b/ppapi/cpp/input_event.cc
@@ -30,6 +30,10 @@ template <> const char* interface_name<PPB_WheelInputEvent>() {
return PPB_WHEEL_INPUT_EVENT_INTERFACE;
}
+template <> const char* interface_name<PPB_CompositionInputEvent>() {
+ return PPB_COMPOSITION_INPUT_EVENT_INTERFACE;
+}
+
} // namespace
// InputEvent ------------------------------------------------------------------
@@ -218,4 +222,63 @@ Var KeyboardInputEvent::GetCharacterText() const {
pp_resource()));
}
+// CompositionInputEvent -------------------------------------------------------
+
+CompositionInputEvent::CompositionInputEvent() : InputEvent() {
+}
+
+CompositionInputEvent::CompositionInputEvent(const InputEvent& event)
+ : InputEvent() {
+ // Type check the input event before setting it.
+ if (!has_interface<PPB_CompositionInputEvent>())
+ return;
+ if (get_interface<PPB_CompositionInputEvent>()->IsCompositionInputEvent(
+ event.pp_resource())) {
+ Module::Get()->core()->AddRefResource(event.pp_resource());
+ PassRefFromConstructor(event.pp_resource());
+ }
+}
+
+Var CompositionInputEvent::GetText() const {
+ if (!has_interface<PPB_CompositionInputEvent>())
+ return Var();
+ return Var(Var::PassRef(),
+ get_interface<PPB_CompositionInputEvent>()->GetText(
+ pp_resource()));
+}
+
+std::vector< std::pair<uint32_t, uint32_t> >
+CompositionInputEvent::GetSegments() const {
+ std::vector< std::pair<uint32_t, uint32_t> > result;
+ if (!has_interface<PPB_CompositionInputEvent>())
+ return result;
+ uint32_t* segments = 0;
+ uint32_t size = 0;
+ get_interface<PPB_CompositionInputEvent>()->GetSegments(pp_resource(),
+ &segments, &size);
+ if (segments) {
+ for (size_t i=0; i<size; ++i)
+ result.push_back(std::make_pair(segments[2*i], segments[2*i+1]));
+ }
+ return result;
+}
+
+int32_t CompositionInputEvent::GetTargetSegment() const {
+ if (!has_interface<PPB_CompositionInputEvent>())
+ return 0;
+ return get_interface<PPB_CompositionInputEvent>()->GetTargetSegment(
+ pp_resource());
+}
+
+std::pair<uint32_t, uint32_t> CompositionInputEvent::GetSelection() const {
+ std::pair<uint32_t, uint32_t> sel(0,0);
+ if (!has_interface<PPB_CompositionInputEvent>())
+ return sel;
+ get_interface<PPB_CompositionInputEvent>()->GetSelection(pp_resource(),
+ &sel.first,
+ &sel.second);
+ return sel;
+}
+
+
} // namespace pp
« 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