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

Unified 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, 5 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/cpp/text_input_controller.h » ('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 1f368b07c04f6be7c9068bf5daf4892bcf37651d..e4e000393008b9bd9f58a2594a051f49a9cdd9b9 100644
--- a/ppapi/cpp/input_event.cc
+++ b/ppapi/cpp/input_event.cc
@@ -35,6 +35,10 @@ template <> const char* interface_name<PPB_TouchInputEvent_1_0>() {
return PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0;
}
+template <> const char* interface_name<PPB_IMEInputEvent_1_0>() {
+ return PPB_IME_INPUT_EVENT_INTERFACE_1_0;
+}
+
} // namespace
// InputEvent ------------------------------------------------------------------
@@ -280,4 +284,79 @@ TouchPoint TouchInputEvent::GetTouchByIndex(PP_TouchListType list,
GetTouchByIndex(pp_resource(), list, index));
}
+// IMEInputEvent -------------------------------------------------------
+
+IMEInputEvent::IMEInputEvent() : InputEvent() {
+}
+
+IMEInputEvent::IMEInputEvent(const InputEvent& event) : InputEvent() {
+ if (has_interface<PPB_IMEInputEvent_1_0>()) {
+ if (get_interface<PPB_IMEInputEvent_1_0>()->IsIMEInputEvent(
+ event.pp_resource())) {
+ Module::Get()->core()->AddRefResource(event.pp_resource());
+ PassRefFromConstructor(event.pp_resource());
+ }
+ }
+}
+
+IMEInputEvent::IMEInputEvent(
+ const InstanceHandle& instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ const Var& text,
+ const std::vector<uint32_t>& segment_offsets,
+ int32_t target_segment,
+ const std::pair<uint32_t, uint32_t>& selection) : InputEvent() {
+ if (!has_interface<PPB_IMEInputEvent_1_0>())
+ return;
+ uint32_t dummy = 0;
+ PassRefFromConstructor(get_interface<PPB_IMEInputEvent_1_0>()->Create(
+ instance.pp_instance(), type, time_stamp, text.pp_var(),
+ segment_offsets.empty() ? 0 : segment_offsets.size() - 1,
+ segment_offsets.empty() ? &dummy : &segment_offsets[0],
+ target_segment, selection.first, selection.second));
+}
+
+
+Var IMEInputEvent::GetText() const {
+ if (has_interface<PPB_IMEInputEvent_1_0>()) {
+ return Var(PASS_REF,
+ get_interface<PPB_IMEInputEvent_1_0>()->GetText(
+ pp_resource()));
+ }
+ return Var();
+}
+
+uint32_t IMEInputEvent::GetSegmentNumber() const {
+ if (has_interface<PPB_IMEInputEvent_1_0>()) {
+ return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentNumber(
+ pp_resource());
+ }
+ return 0;
+}
+
+uint32_t IMEInputEvent::GetSegmentOffset(uint32_t index) const {
+ if (has_interface<PPB_IMEInputEvent_1_0>()) {
+ return get_interface<PPB_IMEInputEvent_1_0>()->GetSegmentOffset(
+ pp_resource(), index);
+ }
+ return 0;
+}
+
+int32_t IMEInputEvent::GetTargetSegment() const {
+ if (has_interface<PPB_IMEInputEvent_1_0>()) {
+ return get_interface<PPB_IMEInputEvent_1_0>()->GetTargetSegment(
+ pp_resource());
+ }
+ return 0;
+}
+
+void IMEInputEvent::GetSelection(uint32_t* start, uint32_t* end) const {
+ if (has_interface<PPB_IMEInputEvent_1_0>()) {
+ get_interface<PPB_IMEInputEvent_1_0>()->GetSelection(pp_resource(),
+ start,
+ end);
+ }
+}
+
} // namespace pp
« 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