Index: ppapi/cpp/input_event.h |
diff --git a/ppapi/cpp/input_event.h b/ppapi/cpp/input_event.h |
index 40e1df1c5e58c777465617c9aef3e1a099e4739f..69651841d01209afba262f677c48473801b7468f 100644 |
--- a/ppapi/cpp/input_event.h |
+++ b/ppapi/cpp/input_event.h |
@@ -6,6 +6,7 @@ |
#define PPAPI_CPP_INPUT_EVENT_H_ |
#include <string> |
+#include <vector> |
#include "ppapi/c/ppb_input_event.h" |
#include "ppapi/cpp/resource.h" |
@@ -342,7 +343,90 @@ class TouchInputEvent : public InputEvent { |
TouchPoint GetTouchById(PP_TouchListType list, uint32_t id) const; |
}; |
+class IMEInputEvent : public InputEvent { |
+ public: |
+ /// Constructs an is_null() IME input event object. |
+ IMEInputEvent(); |
+ |
+ /// Constructs an IME input event object from the provided generic input |
+ /// event. If the given event is itself is_null() or is not an IME input |
+ /// event, the object will be is_null(). |
+ /// |
+ /// @param[in] event A generic input event. |
+ explicit IMEInputEvent(const InputEvent& event); |
+ |
+ /// This constructor manually constructs an IME event from the provided |
+ /// parameters. |
+ /// |
+ /// @param[in] instance The instance for which this event occurred. |
+ /// |
+ /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of |
+ /// input event. The type must be one of the ime event types. |
+ /// |
+ /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time |
+ /// when the event occurred. |
+ /// |
+ /// @param[in] text The string returned by <code>GetText</code>. |
+ /// |
+ /// @param[in] segment_offsets The array of numbers returned by |
+ /// <code>GetSegmentOffset</code>. |
+ /// |
+ /// @param[in] target_segment The number returned by |
+ /// <code>GetTargetSegment</code>. |
+ /// |
+ /// @param[in] selection The range returned by <code>GetSelection</code>. |
+ 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); |
+ |
+ /// Returns the composition text as a UTF-8 string for the given IME event. |
+ /// |
+ /// @return A string var representing the composition text. For non-IME |
+ /// input events the return value will be an undefined var. |
+ Var GetText() const; |
+ /// Returns the number of segments in the composition text. |
+ /// |
+ /// @return The number of segments. For events other than COMPOSITION_UPDATE, |
+ /// returns 0. |
+ uint32_t GetSegmentNumber() const; |
+ |
+ /// Returns the position of the index-th segmentation point in the composition |
+ /// text. The position is given by a byte-offset (not a character-offset) of |
+ /// the string returned by GetText(). It always satisfies |
+ /// 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1) |
+ /// < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()). |
+ /// Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the |
+ /// range of the i-th segment, and hence GetSegmentNumber() can be a valid |
+ /// argument to this function instead of an off-by-1 error. |
+ /// |
+ /// @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME |
+ /// event. |
+ /// |
+ /// @param[in] index An integer indicating a segment. |
+ /// |
+ /// @return The byte-offset of the segmentation point. If the event is not |
+ /// COMPOSITION_UPDATE or index is out of range, returns 0. |
+ uint32_t GetSegmentOffset(uint32_t index) const; |
+ |
+ /// Returns the index of the current target segment of composition. |
+ /// |
+ /// @return An integer indicating the index of the target segment. When there |
+ /// is no active target segment, or the event is not COMPOSITION_UPDATE, |
+ /// returns -1. |
+ int32_t GetTargetSegment() const; |
+ |
+ /// Obtains the range selected by caret in the composition text. |
+ /// |
+ /// @param[out] start An integer indicating a start offset of selection range. |
+ /// |
+ /// @param[out] end An integer indicating an end offset of selection range. |
+ void GetSelection(uint32_t* start, uint32_t* end) const; |
+}; |
} // namespace pp |
#endif // PPAPI_CPP_INPUT_EVENT_H_ |