1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
7 * This file defines the <code>PPB_IMEInputEvent_Dev</code> interface.
15 [macro
="PPB_IME_INPUT_EVENT_DEV_INTERFACE"]
16 interface PPB_IMEInputEvent_Dev
{
18 * Create() creates an IME input event with the given parameters. Normally
19 * you will get an IME event passed through the <code>HandleInputEvent</code>
20 * and will not need to create them, but some applications may want to create
21 * their own for internal use.
23 * @param[in] instance The instance for which this event occurred.
25 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
26 * input event. The type must be one of the IME event types.
28 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
29 * when the event occurred.
31 * @param[in] text The string returned by <code>GetText</code>.
33 * @param[in] segment_number The number returned by
34 * <code>GetSegmentNumber</code>.
36 * @param[in] segment_offsets The array of numbers returned by
37 * <code>GetSegmentOffset</code>. If <code>segment_number</code> is zero,
38 * the number of elements of the array should be zero. If
39 * <code>segment_number</code> is non-zero, the length of the array must be
40 * <code>segment_number</code> + 1.
42 * @param[in] target_segment The number returned by
43 * <code>GetTargetSegment</code>.
45 * @param[in] selection_start The start index returned by
46 * <code>GetSelection</code>.
48 * @param[in] selection_end The end index returned by
49 * <code>GetSelection</code>.
51 * @return A <code>PP_Resource</code> containing the new IME input event.
54 PP_Resource Create
([in] PP_Instance instance
,
55 [in] PP_InputEvent_Type type
,
56 [in] PP_TimeTicks time_stamp
,
58 [in] uint32_t segment_number
,
59 [in] uint32_t
[] segment_offsets
,
60 [in] int32_t target_segment
,
61 [in] uint32_t selection_start
,
62 [in] uint32_t selection_end
);
65 * IsIMEInputEvent() determines if a resource is an IME event.
67 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
69 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
71 PP_Bool IsIMEInputEvent
([in] PP_Resource resource
);
74 * GetText() returns the composition text as a UTF-8 string for the given IME
77 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
80 * @return A string var representing the composition text. For non-IME input
81 * events the return value will be an undefined var.
83 PP_Var GetText
([in] PP_Resource ime_event
);
86 * GetSegmentNumber() returns the number of segments in the composition text.
88 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
91 * @return The number of segments. For events other than COMPOSITION_UPDATE,
94 uint32_t GetSegmentNumber
([in] PP_Resource ime_event
);
97 * GetSegmentOffset() returns the position of the index-th segmentation point
98 * in the composition text. The position is given by a byte-offset (not a
99 * character-offset) of the string returned by GetText(). It always satisfies
100 * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1)
101 * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()).
102 * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range
103 * of the i-th segment, and hence GetSegmentNumber() can be a valid argument
104 * to this function instead of an off-by-1 error.
106 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
109 * @param[in] index An integer indicating a segment.
111 * @return The byte-offset of the segmentation point. If the event is not
112 * COMPOSITION_UPDATE or index is out of range, returns 0.
114 uint32_t GetSegmentOffset
([in] PP_Resource ime_event
,
115 [in] uint32_t index
);
118 * GetTargetSegment() returns the index of the current target segment of
121 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
124 * @return An integer indicating the index of the target segment. When there
125 * is no active target segment, or the event is not COMPOSITION_UPDATE,
128 int32_t GetTargetSegment
([in] PP_Resource ime_event
);
131 * GetSelection() returns the range selected by caret in the composition text.
133 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
136 * @param[out] start The start position of the current selection.
138 * @param[out] end The end position of the current selection.
140 void GetSelection
([in] PP_Resource ime_event
,
141 [out] uint32_t start
,