diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc
index 6f144d3e3dd5e5..137c5adb8158f7 100644
--- a/content/renderer/pepper/plugin_module.cc
+++ b/content/renderer/pepper/plugin_module.cc
@@ -79,6 +79,7 @@
#include "ppapi/c/ppb_network_proxy.h"
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/c/ppb_tcp_socket.h"
+#include "ppapi/c/ppb_text_input_controller.h"
#include "ppapi/c/ppb_udp_socket.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/ppb_url_request_info.h"
diff --git a/native_client_sdk/src/libraries/ppapi/library.dsc b/native_client_sdk/src/libraries/ppapi/library.dsc
index 7e2f240595e074..4a7cf902fda4c5 100644
--- a/native_client_sdk/src/libraries/ppapi/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi/library.dsc
@@ -44,6 +44,7 @@
'pp_bool.h',
'ppb_opengles2.h',
'ppb_tcp_socket.h',
+ 'ppb_text_input_controller.h',
'ppb_udp_socket.h',
'ppb_url_loader.h',
'ppb_url_request_info.h',
diff --git a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc
index 061685c46df05e..cd1ae06095acc1 100644
--- a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc
@@ -44,6 +44,7 @@
'rect.cc',
'resource.cc',
'tcp_socket.cc',
+ 'text_input_controller.cc',
'udp_socket.cc',
'url_loader.cc',
'url_request_info.cc',
@@ -142,6 +143,7 @@
'resource.h',
'size.h',
'tcp_socket.h',
+ 'text_input_controller.h',
'touch_point.h',
'udp_socket.h',
'url_loader.h',
diff --git a/ppapi/api/ppb_input_event.idl b/ppapi/api/ppb_input_event.idl
index e50a8798bc3908..2ed2e25ecb00df 100644
--- a/ppapi/api/ppb_input_event.idl
+++ b/ppapi/api/ppb_input_event.idl
@@ -905,3 +905,132 @@ interface PPB_TouchInputEvent {
[in] PP_TouchListType list,
[in] uint32_t touch_id);
};
+
+[macro="PPB_IME_INPUT_EVENT_INTERFACE"]
+interface PPB_IMEInputEvent {
+ /**
+ * Create() creates an IME input event with the given parameters. Normally
+ * you will get an IME event passed through the HandleInputEvent
+ * and will not need to create them, but some applications may want to create
+ * their own for internal use.
+ *
+ * @param[in] instance The instance for which this event occurred.
+ *
+ * @param[in] type A PP_InputEvent_Type
identifying the type of
+ * input event. The type must be one of the IME event types.
+ *
+ * @param[in] time_stamp A PP_TimeTicks
indicating the time
+ * when the event occurred.
+ *
+ * @param[in] text The string returned by GetText
.
+ *
+ * @param[in] segment_number The number returned by
+ * GetSegmentNumber
.
+ *
+ * @param[in] segment_offsets The array of numbers returned by
+ * GetSegmentOffset
. If segment_number
is zero,
+ * the number of elements of the array should be zero. If
+ * segment_number
is non-zero, the length of the array must be
+ * segment_number
+ 1.
+ *
+ * @param[in] target_segment The number returned by
+ * GetTargetSegment
.
+ *
+ * @param[in] selection_start The start index returned by
+ * GetSelection
.
+ *
+ * @param[in] selection_end The end index returned by
+ * GetSelection
.
+ *
+ * @return A PP_Resource
containing the new IME input event.
+ */
+ PP_Resource Create([in] PP_Instance instance,
+ [in] PP_InputEvent_Type type,
+ [in] PP_TimeTicks time_stamp,
+ [in] PP_Var text,
+ [in] uint32_t segment_number,
+ [in] uint32_t[] segment_offsets,
+ [in] int32_t target_segment,
+ [in] uint32_t selection_start,
+ [in] uint32_t selection_end);
+
+ /**
+ * IsIMEInputEvent() determines if a resource is an IME event.
+ *
+ * @param[in] resource A PP_Resource
corresponding to an event.
+ *
+ * @return PP_TRUE
if the given resource is a valid input event.
+ */
+ PP_Bool IsIMEInputEvent([in] PP_Resource resource);
+
+ /**
+ * GetText() returns the composition text as a UTF-8 string for the given IME
+ * event.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @return A string var representing the composition text. For non-IME input
+ * events the return value will be an undefined var.
+ */
+ PP_Var GetText([in] PP_Resource ime_event);
+
+ /**
+ * GetSegmentNumber() returns the number of segments in the composition text.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @return The number of segments. For events other than COMPOSITION_UPDATE,
+ * returns 0.
+ */
+ uint32_t GetSegmentNumber([in] PP_Resource ime_event);
+
+ /**
+ * GetSegmentOffset() 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 PP_Resource
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([in] PP_Resource ime_event,
+ [in] uint32_t index);
+
+ /**
+ * GetTargetSegment() returns the index of the current target segment of
+ * composition.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @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([in] PP_Resource ime_event);
+
+ /**
+ * GetSelection() returns the range selected by caret in the composition text.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @param[out] start The start position of the current selection.
+ *
+ * @param[out] end The end position of the current selection.
+ */
+ void GetSelection([in] PP_Resource ime_event,
+ [out] uint32_t start,
+ [out] uint32_t end);
+};
diff --git a/ppapi/api/ppb_text_input_controller.idl b/ppapi/api/ppb_text_input_controller.idl
new file mode 100644
index 00000000000000..63a9b19bdd1c32
--- /dev/null
+++ b/ppapi/api/ppb_text_input_controller.idl
@@ -0,0 +1,95 @@
+/* Copyright 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * This file defines the PPB_TextInputController
interface.
+ */
+
+label Chrome {
+ M30 = 1.0
+};
+
+/**
+ * PP_TextInput_Type is used to indicate the status of a plugin in regard to
+ * text input.
+ */
+[assert_size(4)]
+enum PP_TextInput_Type {
+ /**
+ * Input caret is not in an editable mode, no input method shall be used.
+ */
+ PP_TEXTINPUT_TYPE_NONE = 0,
+ /**
+ * Input caret is in a normal editable mode, any input method can be used.
+ */
+ PP_TEXTINPUT_TYPE_TEXT = 1,
+ /**
+ * Input caret is in a password box, an input method may be used only if
+ * it's suitable for password input.
+ */
+ PP_TEXTINPUT_TYPE_PASSWORD = 2,
+ PP_TEXTINPUT_TYPE_SEARCH = 3,
+ PP_TEXTINPUT_TYPE_EMAIL = 4,
+ PP_TEXTINPUT_TYPE_NUMBER = 5,
+ PP_TEXTINPUT_TYPE_TELEPHONE = 6,
+ PP_TEXTINPUT_TYPE_URL = 7
+};
+
+/**
+ * PPB_TextInputController
provides a set of functions for giving
+ * hints to the browser about the text input status of plugins, and functions
+ * for controlling input method editors (IMEs).
+ */
+interface PPB_TextInputController {
+ /**
+ * Informs the browser about the current text input mode of the plugin.
+ * Typical use of this information in the browser is to properly
+ * display/suppress tools for supporting text inputs (such as virtual
+ * keyboards in touch screen based devices, or input method editors often
+ * used for composing East Asian characters).
+ */
+ void SetTextInputType([in] PP_Instance instance,
+ [in] PP_TextInput_Type type);
+
+ /**
+ * Informs the browser about the coordinates of the text input caret area.
+ * Typical use of this information in the browser is to layout IME windows
+ * etc.
+ */
+ void UpdateCaretPosition([in] PP_Instance instance,
+ [in] PP_Rect caret);
+
+ /**
+ * Cancels the current composition in IME.
+ */
+ void CancelCompositionText([in] PP_Instance instance);
+
+ /**
+ * Informs the browser about the current text selection and surrounding
+ * text. text
is a UTF-8 string that contains the current range
+ * of text selection in the plugin. caret
is the byte-index of
+ * the caret position within text
. anchor
is the
+ * byte-index of the anchor position (i.e., if a range of text is selected,
+ * it is the other edge of selection different from caret
. If
+ * there are no selection, anchor
is equal to caret
.
+ *
+ * Typical use of this information in the browser is to enable "reconversion"
+ * features of IME that puts back the already committed text into the
+ * pre-commit composition state. Another use is to improve the precision
+ * of suggestion of IME by taking the context into account (e.g., if the caret
+ * looks to be on the beginning of a sentence, suggest capital letters in a
+ * virtual keyboard).
+ *
+ * When the focus is not on text, call this function setting text
+ * to an empty string and caret
and anchor
to zero.
+ * Also, the plugin should send the empty text when it does not want to reveal
+ * the selection to IME (e.g., when the surrounding text is containing
+ * password text).
+ */
+ void UpdateSurroundingText([in] PP_Instance instance,
+ [in] PP_Var text,
+ [in] uint32_t caret,
+ [in] uint32_t anchor);
+};
diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h
index c56d95b796274c..97a4229dfe7261 100644
--- a/ppapi/c/pp_macros.h
+++ b/ppapi/c/pp_macros.h
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-/* From pp_macros.idl modified Thu Mar 14 13:24:42 2013. */
+/* From pp_macros.idl modified Tue Jul 2 14:15:05 2013. */
#ifndef PPAPI_C_PP_MACROS_H_
#define PPAPI_C_PP_MACROS_H_
-#define PPAPI_RELEASE 29
+#define PPAPI_RELEASE 30
/**
* @file
diff --git a/ppapi/c/ppb_input_event.h b/ppapi/c/ppb_input_event.h
index 35ef6be3633e5c..2624f0b96189e4 100644
--- a/ppapi/c/ppb_input_event.h
+++ b/ppapi/c/ppb_input_event.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From ppb_input_event.idl modified Thu Mar 28 10:51:06 2013. */
+/* From ppb_input_event.idl modified Tue Jul 23 19:23:51 2013. */
#ifndef PPAPI_C_PPB_INPUT_EVENT_H_
#define PPAPI_C_PPB_INPUT_EVENT_H_
@@ -35,6 +35,9 @@
#define PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0 "PPB_TouchInputEvent;1.0"
#define PPB_TOUCH_INPUT_EVENT_INTERFACE PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0
+#define PPB_IME_INPUT_EVENT_INTERFACE_1_0 "PPB_IMEInputEvent;1.0"
+#define PPB_IME_INPUT_EVENT_INTERFACE PPB_IME_INPUT_EVENT_INTERFACE_1_0
+
/**
* @file
* This file defines the Input Event interfaces.
@@ -889,6 +892,127 @@ struct PPB_TouchInputEvent_1_0 {
};
typedef struct PPB_TouchInputEvent_1_0 PPB_TouchInputEvent;
+
+struct PPB_IMEInputEvent_1_0 {
+ /**
+ * Create() creates an IME input event with the given parameters. Normally
+ * you will get an IME event passed through the HandleInputEvent
+ * and will not need to create them, but some applications may want to create
+ * their own for internal use.
+ *
+ * @param[in] instance The instance for which this event occurred.
+ *
+ * @param[in] type A PP_InputEvent_Type
identifying the type of
+ * input event. The type must be one of the IME event types.
+ *
+ * @param[in] time_stamp A PP_TimeTicks
indicating the time
+ * when the event occurred.
+ *
+ * @param[in] text The string returned by GetText
.
+ *
+ * @param[in] segment_number The number returned by
+ * GetSegmentNumber
.
+ *
+ * @param[in] segment_offsets The array of numbers returned by
+ * GetSegmentOffset
. If segment_number
is zero,
+ * the number of elements of the array should be zero. If
+ * segment_number
is non-zero, the length of the array must be
+ * segment_number
+ 1.
+ *
+ * @param[in] target_segment The number returned by
+ * GetTargetSegment
.
+ *
+ * @param[in] selection_start The start index returned by
+ * GetSelection
.
+ *
+ * @param[in] selection_end The end index returned by
+ * GetSelection
.
+ *
+ * @return A PP_Resource
containing the new IME input event.
+ */
+ PP_Resource (*Create)(PP_Instance instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ struct PP_Var text,
+ uint32_t segment_number,
+ const uint32_t segment_offsets[],
+ int32_t target_segment,
+ uint32_t selection_start,
+ uint32_t selection_end);
+ /**
+ * IsIMEInputEvent() determines if a resource is an IME event.
+ *
+ * @param[in] resource A PP_Resource
corresponding to an event.
+ *
+ * @return PP_TRUE
if the given resource is a valid input event.
+ */
+ PP_Bool (*IsIMEInputEvent)(PP_Resource resource);
+ /**
+ * GetText() returns the composition text as a UTF-8 string for the given IME
+ * event.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @return A string var representing the composition text. For non-IME input
+ * events the return value will be an undefined var.
+ */
+ struct PP_Var (*GetText)(PP_Resource ime_event);
+ /**
+ * GetSegmentNumber() returns the number of segments in the composition text.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @return The number of segments. For events other than COMPOSITION_UPDATE,
+ * returns 0.
+ */
+ uint32_t (*GetSegmentNumber)(PP_Resource ime_event);
+ /**
+ * GetSegmentOffset() 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 PP_Resource
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)(PP_Resource ime_event, uint32_t index);
+ /**
+ * GetTargetSegment() returns the index of the current target segment of
+ * composition.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @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)(PP_Resource ime_event);
+ /**
+ * GetSelection() returns the range selected by caret in the composition text.
+ *
+ * @param[in] ime_event A PP_Resource
corresponding to an IME
+ * event.
+ *
+ * @param[out] start The start position of the current selection.
+ *
+ * @param[out] end The end position of the current selection.
+ */
+ void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end);
+};
+
+typedef struct PPB_IMEInputEvent_1_0 PPB_IMEInputEvent;
/**
* @}
*/
diff --git a/ppapi/c/ppb_text_input_controller.h b/ppapi/c/ppb_text_input_controller.h
new file mode 100644
index 00000000000000..bc7cdb850f02b8
--- /dev/null
+++ b/ppapi/c/ppb_text_input_controller.h
@@ -0,0 +1,93 @@
+/* Copyright 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* From ppb_text_input_controller.idl modified Sat Jul 27 00:04:53 2013. */
+
+#ifndef PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_
+#define PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_
+
+#include "ppapi/c/dev/ppb_text_input_dev.h"
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_point.h"
+#include "ppapi/c/pp_rect.h"
+#include "ppapi/c/pp_size.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/pp_var.h"
+
+#define PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0 "PPB_TextInputController;1.0"
+#define PPB_TEXTINPUTCONTROLLER_INTERFACE PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0
+
+/**
+ * @file
+ * This file defines the PPB_TextInputController
interface.
+ */
+
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+/**
+ * PPB_TextInputController
provides a set of functions for giving
+ * hints to the browser about the text input status of plugins, and functions
+ * for controlling input method editors (IMEs).
+ */
+struct PPB_TextInputController_1_0 {
+ /**
+ * Informs the browser about the current text input mode of the plugin.
+ * Typical use of this information in the browser is to properly
+ * display/suppress tools for supporting text inputs (such as virtual
+ * keyboards in touch screen based devices, or input method editors often
+ * used for composing East Asian characters).
+ */
+ void (*SetTextInputType)(PP_Instance instance, PP_TextInput_Type type);
+ /**
+ * Informs the browser about the coordinates of the text input caret area.
+ * Typical use of this information in the browser is to layout IME windows
+ * etc.
+ */
+ void (*UpdateCaretPosition)(PP_Instance instance,
+ const struct PP_Rect* caret);
+ /**
+ * Cancels the current composition in IME.
+ */
+ void (*CancelCompositionText)(PP_Instance instance);
+ /**
+ * Informs the browser about the current text selection and surrounding
+ * text. text
is a UTF-8 string that contains the current range
+ * of text selection in the plugin. caret
is the byte-index of
+ * the caret position within text
. anchor
is the
+ * byte-index of the anchor position (i.e., if a range of text is selected,
+ * it is the other edge of selection different from caret
. If
+ * there are no selection, anchor
is equal to caret
.
+ *
+ * Typical use of this information in the browser is to enable "reconversion"
+ * features of IME that puts back the already committed text into the
+ * pre-commit composition state. Another use is to improve the precision
+ * of suggestion of IME by taking the context into account (e.g., if the caret
+ * looks to be on the beginning of a sentence, suggest capital letters in a
+ * virtual keyboard).
+ *
+ * When the focus is not on text, call this function setting text
+ * to an empty string and caret
and anchor
to zero.
+ * Also, the plugin should send the empty text when it does not want to reveal
+ * the selection to IME (e.g., when the surrounding text is containing
+ * password text).
+ */
+ void (*UpdateSurroundingText)(PP_Instance instance,
+ struct PP_Var text,
+ uint32_t caret,
+ uint32_t anchor);
+};
+
+typedef struct PPB_TextInputController_1_0 PPB_TextInputController;
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_ */
+
diff --git a/ppapi/cpp/input_event.cc b/ppapi/cpp/input_event.cc
index 1f368b07c04f6b..e4e000393008b9 100644
--- a/ppapi/cpp/input_event.cc
+++ b/ppapi/cpp/input_event.cc
@@ -35,6 +35,10 @@ template <> const char* interface_name() {
return PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0;
}
+template <> const char* interface_name() {
+ 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()) {
+ if (get_interface()->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& segment_offsets,
+ int32_t target_segment,
+ const std::pair& selection) : InputEvent() {
+ if (!has_interface())
+ return;
+ uint32_t dummy = 0;
+ PassRefFromConstructor(get_interface()->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()) {
+ return Var(PASS_REF,
+ get_interface()->GetText(
+ pp_resource()));
+ }
+ return Var();
+}
+
+uint32_t IMEInputEvent::GetSegmentNumber() const {
+ if (has_interface()) {
+ return get_interface()->GetSegmentNumber(
+ pp_resource());
+ }
+ return 0;
+}
+
+uint32_t IMEInputEvent::GetSegmentOffset(uint32_t index) const {
+ if (has_interface()) {
+ return get_interface()->GetSegmentOffset(
+ pp_resource(), index);
+ }
+ return 0;
+}
+
+int32_t IMEInputEvent::GetTargetSegment() const {
+ if (has_interface()) {
+ return get_interface()->GetTargetSegment(
+ pp_resource());
+ }
+ return 0;
+}
+
+void IMEInputEvent::GetSelection(uint32_t* start, uint32_t* end) const {
+ if (has_interface()) {
+ get_interface()->GetSelection(pp_resource(),
+ start,
+ end);
+ }
+}
+
} // namespace pp
diff --git a/ppapi/cpp/input_event.h b/ppapi/cpp/input_event.h
index 40e1df1c5e58c7..69651841d01209 100644
--- a/ppapi/cpp/input_event.h
+++ b/ppapi/cpp/input_event.h
@@ -6,6 +6,7 @@
#define PPAPI_CPP_INPUT_EVENT_H_
#include
+#include
#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 PP_InputEvent_Type
identifying the type of
+ /// input event. The type must be one of the ime event types.
+ ///
+ /// @param[in] time_stamp A PP_TimeTicks
indicating the time
+ /// when the event occurred.
+ ///
+ /// @param[in] text The string returned by GetText
.
+ ///
+ /// @param[in] segment_offsets The array of numbers returned by
+ /// GetSegmentOffset
.
+ ///
+ /// @param[in] target_segment The number returned by
+ /// GetTargetSegment
.
+ ///
+ /// @param[in] selection The range returned by GetSelection
.
+ IMEInputEvent(const InstanceHandle& instance,
+ PP_InputEvent_Type type,
+ PP_TimeTicks time_stamp,
+ const Var& text,
+ const std::vector& segment_offsets,
+ int32_t target_segment,
+ const std::pair& 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 PP_Resource
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_
diff --git a/ppapi/cpp/text_input_controller.cc b/ppapi/cpp/text_input_controller.cc
new file mode 100644
index 00000000000000..59850d31be0d25
--- /dev/null
+++ b/ppapi/cpp/text_input_controller.cc
@@ -0,0 +1,63 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/text_input_controller.h"
+
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/rect.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name() {
+ return PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0;
+}
+
+} // namespace
+
+
+TextInputController::TextInputController(const InstanceHandle& instance)
+ : instance_(instance) {
+}
+
+TextInputController::~TextInputController() {
+}
+
+void TextInputController::SetTextInputType(PP_TextInput_Type type) {
+ if (has_interface()) {
+ get_interface()->SetTextInputType(
+ instance_.pp_instance(), type);
+ }
+}
+
+void TextInputController::UpdateCaretPosition(const Rect& caret) {
+ if (has_interface()) {
+ get_interface()->UpdateCaretPosition(
+ instance_.pp_instance(), &caret.pp_rect());
+ }
+}
+
+void TextInputController::CancelCompositionText() {
+ if (has_interface()) {
+ get_interface()->CancelCompositionText(
+ instance_.pp_instance());
+ }
+}
+
+void TextInputController::UpdateSurroundingText(const Var& text,
+ uint32_t caret,
+ uint32_t anchor) {
+ if (has_interface()) {
+ get_interface()->UpdateSurroundingText(
+ instance_.pp_instance(),
+ text.pp_var(),
+ caret,
+ anchor);
+ }
+}
+
+
+} // namespace pp
diff --git a/ppapi/cpp/text_input_controller.h b/ppapi/cpp/text_input_controller.h
new file mode 100644
index 00000000000000..8843bd362f26e6
--- /dev/null
+++ b/ppapi/cpp/text_input_controller.h
@@ -0,0 +1,73 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_TEXT_INPUT_CONTROLLER_H_
+#define PPAPI_CPP_TEXT_INPUT_CONTROLLER_H_
+
+#include
+
+#include "ppapi/c/ppb_text_input_controller.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/var.h"
+
+/// @file
+/// This file defines the APIs for text input handling.
+
+namespace pp {
+
+class Rect;
+class Instance;
+
+/// This class can be used for giving hints to the browser about the text input
+/// status of plugins.
+class TextInputController {
+ public:
+ /// A constructor for creating a TextInputController
.
+ ///
+ /// @param[in] instance The instance with which this resource will be
+ /// associated.
+ explicit TextInputController(const InstanceHandle& instance);
+
+ /// Destructor.
+ ~TextInputController();
+
+ /// SetTextInputType() informs the browser about the current text input mode
+ /// of the plugin.
+ ///
+ /// @param[in] type The type of text input type.
+ void SetTextInputType(PP_TextInput_Type type);
+
+ /// UpdateCaretPosition() informs the browser about the coordinates of the
+ /// text input caret area.
+ ///
+ /// @param[in] caret A rectangle indicating the caret area.
+ void UpdateCaretPosition(const Rect& caret);
+
+ /// CancelCompositionText() informs the browser that the current composition
+ /// text is cancelled by the plugin.
+ void CancelCompositionText();
+
+ /// UpdateSurroundingText() informs the browser about the current text
+ /// selection and surrounding text.
+ ///
+ /// @param[in] text A UTF-8 sting indicating string buffer of current input
+ /// context.
+ ///
+ /// @param[in] caret A integer indicating the byte index of caret location in
+ /// text
.
+ ///
+ /// @param[in] caret A integer indicating the byte index of anchor location in
+ /// text
. If there is no selection, this value should be equal to
+ /// caret
.
+ void UpdateSurroundingText(const Var& text,
+ uint32_t caret,
+ uint32_t anchor);
+
+ private:
+ InstanceHandle instance_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_TEXT_INPUT_CONTROLLER_H_
diff --git a/ppapi/examples/ime/ime.cc b/ppapi/examples/ime/ime.cc
index 6f3e65569aaba3..e7307868476b9a 100644
--- a/ppapi/examples/ime/ime.cc
+++ b/ppapi/examples/ime/ime.cc
@@ -10,8 +10,6 @@
#include "ppapi/c/ppb_console.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/font_dev.h"
-#include "ppapi/cpp/dev/ime_input_event_dev.h"
-#include "ppapi/cpp/dev/text_input_dev.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/input_event.h"
@@ -19,6 +17,7 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
+#include "ppapi/cpp/text_input_controller.h"
namespace {
@@ -90,7 +89,7 @@ size_t GetNthCharOffsetUtf8(const std::string& str, size_t n) {
class TextFieldStatusHandler {
public:
virtual ~TextFieldStatusHandler() {}
- virtual void FocusIn(const pp::Rect& caret, const pp::Rect& bounding_box) {}
+ virtual void FocusIn(const pp::Rect& caret) {}
virtual void FocusOut() {}
virtual void UpdateSelection(const std::string& text) {}
};
@@ -103,30 +102,20 @@ class TextFieldStatusNotifyingHandler : public TextFieldStatusHandler {
protected:
// Implement TextFieldStatusHandler.
- virtual void FocusIn(const pp::Rect& caret, const pp::Rect& bounding_box) {
+ virtual void FocusIn(const pp::Rect& caret) {
textinput_control_.SetTextInputType(PP_TEXTINPUT_TYPE_TEXT);
- textinput_control_.UpdateCaretPosition(caret, bounding_box);
+ textinput_control_.UpdateCaretPosition(caret);
}
virtual void FocusOut() {
textinput_control_.CancelCompositionText();
textinput_control_.SetTextInputType(PP_TEXTINPUT_TYPE_NONE);
}
virtual void UpdateSelection(const std::string& text) {
- textinput_control_.SetSelectionText(text);
- textinput_control_.SelectionChanged();
+ textinput_control_.UpdateSurroundingText(text, 0, text.size());
}
private:
- class MyTextInput : public pp::TextInput_Dev {
- public:
- MyTextInput(pp::Instance* instance) : pp::TextInput_Dev(instance) {}
- virtual void RequestSurroundingText(uint32_t characters) {
- UpdateSurroundingText(selection_text_, 0, selection_text_.size());
- }
- void SetSelectionText(const std::string& text) { selection_text_ = text; }
- std::string selection_text_;
- };
- MyTextInput textinput_control_;
+ pp::TextInputController textinput_control_;
};
// Hand-made text field for demonstrating text input API.
@@ -374,7 +363,7 @@ class MyTextField {
str += composition_.substr(0, composition_selection_.first);
int px = font_.MeasureSimpleText(str);
pp::Rect caret(area_.x() + px, area_.y(), 0, area_.height() + 2);
- status_handler_->FocusIn(caret, area_);
+ status_handler_->FocusIn(caret);
status_handler_->UpdateSelection(
utf8_text_.substr(SelectionLeft(),
SelectionRight() - SelectionLeft()));
@@ -428,7 +417,8 @@ class MyInstance : public pp::Instance {
//
// When a plugin never wants to accept text input, at initialization
// explicitly turn off the text input feature by calling:
- pp::TextInput_Dev(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE);
+ pp::TextInputController(this).SetTextInputType(
+ PP_TEXTINPUT_TYPE_NONE);
} else if (argv[i] == std::string("unaware")) {
// Demonstrating the behavior of IME-unaware plugins.
// Never call any text input related APIs.
@@ -502,25 +492,25 @@ class MyInstance : public pp::Instance {
break;
}
case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: {
- const pp::IMEInputEvent_Dev imeEvent(event);
+ const pp::IMEInputEvent imeEvent(event);
Log("CompositionStart [" + imeEvent.GetText().AsString() + "]");
ret = true;
break;
}
case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: {
- const pp::IMEInputEvent_Dev imeEvent(event);
+ const pp::IMEInputEvent imeEvent(event);
Log("CompositionUpdate [" + imeEvent.GetText().AsString() + "]");
ret = OnCompositionUpdate(imeEvent);
break;
}
case PP_INPUTEVENT_TYPE_IME_COMPOSITION_END: {
- const pp::IMEInputEvent_Dev imeEvent(event);
+ const pp::IMEInputEvent imeEvent(event);
Log("CompositionEnd [" + imeEvent.GetText().AsString() + "]");
ret = OnCompositionEnd(imeEvent);
break;
}
case PP_INPUTEVENT_TYPE_IME_TEXT: {
- const pp::IMEInputEvent_Dev imeEvent(event);
+ const pp::IMEInputEvent imeEvent(event);
Log("ImeText [" + imeEvent.GetText().AsString() + "]");
ret = OnImeText(imeEvent);
break;
@@ -541,7 +531,7 @@ class MyInstance : public pp::Instance {
}
private:
- bool OnCompositionUpdate(const pp::IMEInputEvent_Dev& ev) {
+ bool OnCompositionUpdate(const pp::IMEInputEvent& ev) {
for (std::vector::iterator it = textfield_.begin();
it != textfield_.end();
++it) {
@@ -550,17 +540,20 @@ class MyInstance : public pp::Instance {
for (uint32_t i = 0; i < ev.GetSegmentNumber(); ++i)
segs.push_back(std::make_pair(ev.GetSegmentOffset(i),
ev.GetSegmentOffset(i + 1)));
+ uint32_t selection_start;
+ uint32_t selection_end;
+ ev.GetSelection(&selection_start, &selection_end);
it->SetComposition(ev.GetText().AsString(),
segs,
ev.GetTargetSegment(),
- ev.GetSelection());
+ std::make_pair(selection_start, selection_end));
return true;
}
}
return false;
}
- bool OnCompositionEnd(const pp::IMEInputEvent_Dev& ev) {
+ bool OnCompositionEnd(const pp::IMEInputEvent& ev) {
for (std::vector::iterator it = textfield_.begin();
it != textfield_.end();
++it) {
@@ -667,7 +660,7 @@ class MyInstance : public pp::Instance {
return false;
}
- bool OnImeText(const pp::IMEInputEvent_Dev ev) {
+ bool OnImeText(const pp::IMEInputEvent ev) {
for (std::vector::iterator it = textfield_.begin();
it != textfield_.end();
++it) {
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index d543664a4f099e..b4efb515ea1cf9 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -66,6 +66,7 @@
#include "ppapi/c/ppb_net_address.h"
#include "ppapi/c/ppb_network_proxy.h"
#include "ppapi/c/ppb_tcp_socket.h"
+#include "ppapi/c/ppb_text_input_controller.h"
#include "ppapi/c/ppb_udp_socket.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/ppb_url_request_info.h"
@@ -149,12 +150,14 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MouseInputEvent_1_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WheelInputEvent_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_KeyboardInputEvent_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TouchInputEvent_1_0;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MessageLoop_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Messaging_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MouseLock_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkProxy_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_0;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInputController_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLLoader_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLRequestInfo_1_0;
@@ -860,6 +863,45 @@ static void Pnacl_M13_PPB_TouchInputEvent_GetTouchById(struct PP_TouchPoint* _st
/* End wrapper methods for PPB_TouchInputEvent_1_0 */
+/* Begin wrapper methods for PPB_IMEInputEvent_1_0 */
+
+static PP_Resource Pnacl_M13_PPB_IMEInputEvent_Create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var* text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ return iface->Create(instance, type, time_stamp, *text, segment_number, segment_offsets, target_segment, selection_start, selection_end);
+}
+
+static PP_Bool Pnacl_M13_PPB_IMEInputEvent_IsIMEInputEvent(PP_Resource resource) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ return iface->IsIMEInputEvent(resource);
+}
+
+static void Pnacl_M13_PPB_IMEInputEvent_GetText(struct PP_Var* _struct_result, PP_Resource ime_event) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ *_struct_result = iface->GetText(ime_event);
+}
+
+static uint32_t Pnacl_M13_PPB_IMEInputEvent_GetSegmentNumber(PP_Resource ime_event) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ return iface->GetSegmentNumber(ime_event);
+}
+
+static uint32_t Pnacl_M13_PPB_IMEInputEvent_GetSegmentOffset(PP_Resource ime_event, uint32_t index) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ return iface->GetSegmentOffset(ime_event, index);
+}
+
+static int32_t Pnacl_M13_PPB_IMEInputEvent_GetTargetSegment(PP_Resource ime_event) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ return iface->GetTargetSegment(ime_event);
+}
+
+static void Pnacl_M13_PPB_IMEInputEvent_GetSelection(PP_Resource ime_event, uint32_t* start, uint32_t* end) {
+ const struct PPB_IMEInputEvent_1_0 *iface = Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0.real_iface;
+ iface->GetSelection(ime_event, start, end);
+}
+
+/* End wrapper methods for PPB_IMEInputEvent_1_0 */
+
/* Not generating wrapper methods for PPB_Instance_1_0 */
/* Begin wrapper methods for PPB_MessageLoop_1_0 */
@@ -1023,6 +1065,30 @@ static int32_t Pnacl_M29_PPB_TCPSocket_SetOption(PP_Resource tcp_socket, PP_TCPS
/* End wrapper methods for PPB_TCPSocket_1_0 */
+/* Begin wrapper methods for PPB_TextInputController_1_0 */
+
+static void Pnacl_M30_PPB_TextInputController_SetTextInputType(PP_Instance instance, PP_TextInput_Type type) {
+ const struct PPB_TextInputController_1_0 *iface = Pnacl_WrapperInfo_PPB_TextInputController_1_0.real_iface;
+ iface->SetTextInputType(instance, type);
+}
+
+static void Pnacl_M30_PPB_TextInputController_UpdateCaretPosition(PP_Instance instance, const struct PP_Rect* caret) {
+ const struct PPB_TextInputController_1_0 *iface = Pnacl_WrapperInfo_PPB_TextInputController_1_0.real_iface;
+ iface->UpdateCaretPosition(instance, caret);
+}
+
+static void Pnacl_M30_PPB_TextInputController_CancelCompositionText(PP_Instance instance) {
+ const struct PPB_TextInputController_1_0 *iface = Pnacl_WrapperInfo_PPB_TextInputController_1_0.real_iface;
+ iface->CancelCompositionText(instance);
+}
+
+static void Pnacl_M30_PPB_TextInputController_UpdateSurroundingText(PP_Instance instance, struct PP_Var* text, uint32_t caret, uint32_t anchor) {
+ const struct PPB_TextInputController_1_0 *iface = Pnacl_WrapperInfo_PPB_TextInputController_1_0.real_iface;
+ iface->UpdateSurroundingText(instance, *text, caret, anchor);
+}
+
+/* End wrapper methods for PPB_TextInputController_1_0 */
+
/* Begin wrapper methods for PPB_UDPSocket_1_0 */
static PP_Resource Pnacl_M29_PPB_UDPSocket_Create(PP_Instance instance) {
@@ -1912,6 +1978,8 @@ static void Pnacl_M28_PPB_Testing_Dev_SetMinimumArrayBufferSizeForShmem(PP_Insta
/* Not generating wrapper methods for PPB_TextInput_Dev_0_2 */
+/* Not generating wrapper methods for PPB_TextInput_Dev_None */
+
/* Not generating wrapper methods for PPB_Trace_Event_Dev_0_1 */
/* Not generating wrapper methods for PPB_Trace_Event_Dev_0_2 */
@@ -2633,6 +2701,8 @@ static int32_t Pnacl_M21_PPB_Flash_DeviceID_GetDeviceID(PP_Resource device_id, s
/* End wrapper methods for PPB_Flash_DeviceID_1_0 */
+/* Not generating wrapper methods for PPB_Flash_DeviceID_1_1 */
+
/* Begin wrapper methods for PPB_Flash_DRM_1_0 */
static PP_Resource Pnacl_M29_PPB_Flash_DRM_Create(PP_Instance instance) {
@@ -3994,6 +4064,16 @@ struct PPB_TouchInputEvent_1_0 Pnacl_Wrappers_PPB_TouchInputEvent_1_0 = {
.GetTouchById = (struct PP_TouchPoint (*)(PP_Resource resource, PP_TouchListType list, uint32_t touch_id))&Pnacl_M13_PPB_TouchInputEvent_GetTouchById
};
+struct PPB_IMEInputEvent_1_0 Pnacl_Wrappers_PPB_IMEInputEvent_1_0 = {
+ .Create = (PP_Resource (*)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end))&Pnacl_M13_PPB_IMEInputEvent_Create,
+ .IsIMEInputEvent = (PP_Bool (*)(PP_Resource resource))&Pnacl_M13_PPB_IMEInputEvent_IsIMEInputEvent,
+ .GetText = (struct PP_Var (*)(PP_Resource ime_event))&Pnacl_M13_PPB_IMEInputEvent_GetText,
+ .GetSegmentNumber = (uint32_t (*)(PP_Resource ime_event))&Pnacl_M13_PPB_IMEInputEvent_GetSegmentNumber,
+ .GetSegmentOffset = (uint32_t (*)(PP_Resource ime_event, uint32_t index))&Pnacl_M13_PPB_IMEInputEvent_GetSegmentOffset,
+ .GetTargetSegment = (int32_t (*)(PP_Resource ime_event))&Pnacl_M13_PPB_IMEInputEvent_GetTargetSegment,
+ .GetSelection = (void (*)(PP_Resource ime_event, uint32_t* start, uint32_t* end))&Pnacl_M13_PPB_IMEInputEvent_GetSelection
+};
+
/* Not generating wrapper interface for PPB_Instance_1_0 */
struct PPB_MessageLoop_1_0 Pnacl_Wrappers_PPB_MessageLoop_1_0 = {
@@ -4043,6 +4123,13 @@ struct PPB_TCPSocket_1_0 Pnacl_Wrappers_PPB_TCPSocket_1_0 = {
.SetOption = (int32_t (*)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_TCPSocket_SetOption
};
+struct PPB_TextInputController_1_0 Pnacl_Wrappers_PPB_TextInputController_1_0 = {
+ .SetTextInputType = (void (*)(PP_Instance instance, PP_TextInput_Type type))&Pnacl_M30_PPB_TextInputController_SetTextInputType,
+ .UpdateCaretPosition = (void (*)(PP_Instance instance, const struct PP_Rect* caret))&Pnacl_M30_PPB_TextInputController_UpdateCaretPosition,
+ .CancelCompositionText = (void (*)(PP_Instance instance))&Pnacl_M30_PPB_TextInputController_CancelCompositionText,
+ .UpdateSurroundingText = (void (*)(PP_Instance instance, struct PP_Var text, uint32_t caret, uint32_t anchor))&Pnacl_M30_PPB_TextInputController_UpdateSurroundingText
+};
+
struct PPB_UDPSocket_1_0 Pnacl_Wrappers_PPB_UDPSocket_1_0 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M29_PPB_UDPSocket_Create,
.IsUDPSocket = (PP_Bool (*)(PP_Resource resource))&Pnacl_M29_PPB_UDPSocket_IsUDPSocket,
@@ -4318,6 +4405,8 @@ struct PPB_Testing_Dev_0_92 Pnacl_Wrappers_PPB_Testing_Dev_0_92 = {
/* Not generating wrapper interface for PPB_TextInput_Dev_0_2 */
+/* Not generating wrapper interface for PPB_TextInput_Dev_None */
+
/* Not generating wrapper interface for PPB_Trace_Event_Dev_0_1 */
/* Not generating wrapper interface for PPB_Trace_Event_Dev_0_2 */
@@ -4526,6 +4615,8 @@ struct PPB_Flash_DeviceID_1_0 Pnacl_Wrappers_PPB_Flash_DeviceID_1_0 = {
.GetDeviceID = (int32_t (*)(PP_Resource device_id, struct PP_Var* id, struct PP_CompletionCallback callback))&Pnacl_M21_PPB_Flash_DeviceID_GetDeviceID
};
+/* Not generating wrapper interface for PPB_Flash_DeviceID_1_1 */
+
struct PPB_Flash_DRM_1_0 Pnacl_Wrappers_PPB_Flash_DRM_1_0 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M29_PPB_Flash_DRM_Create,
.GetDeviceID = (int32_t (*)(PP_Resource drm, struct PP_Var* id, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Flash_DRM_GetDeviceID,
@@ -4935,6 +5026,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TouchInputEvent_1_0 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0 = {
+ .iface_macro = PPB_IME_INPUT_EVENT_INTERFACE_1_0,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_IMEInputEvent_1_0,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MessageLoop_1_0 = {
.iface_macro = PPB_MESSAGELOOP_INTERFACE_1_0,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_MessageLoop_1_0,
@@ -4971,6 +5068,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_0 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInputController_1_0 = {
+ .iface_macro = PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_TextInputController_1_0,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_0 = {
.iface_macro = PPB_UDPSOCKET_INTERFACE_1_0,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_UDPSocket_1_0,
@@ -5408,12 +5511,14 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_WheelInputEvent_1_0,
&Pnacl_WrapperInfo_PPB_KeyboardInputEvent_1_0,
&Pnacl_WrapperInfo_PPB_TouchInputEvent_1_0,
+ &Pnacl_WrapperInfo_PPB_IMEInputEvent_1_0,
&Pnacl_WrapperInfo_PPB_MessageLoop_1_0,
&Pnacl_WrapperInfo_PPB_Messaging_1_0,
&Pnacl_WrapperInfo_PPB_MouseLock_1_0,
&Pnacl_WrapperInfo_PPB_NetAddress_1_0,
&Pnacl_WrapperInfo_PPB_NetworkProxy_1_0,
&Pnacl_WrapperInfo_PPB_TCPSocket_1_0,
+ &Pnacl_WrapperInfo_PPB_TextInputController_1_0,
&Pnacl_WrapperInfo_PPB_UDPSocket_1_0,
&Pnacl_WrapperInfo_PPB_URLLoader_1_0,
&Pnacl_WrapperInfo_PPB_URLRequestInfo_1_0,
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 9183de2b4444e8..c6f7b0190aea31 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -21,6 +21,7 @@
'c/pp_size.h',
'c/pp_stdint.h',
'c/pp_time.h',
+ 'c/pp_touch_point.h',
'c/pp_var.h',
'c/ppb.h',
'c/ppb_audio.h',
@@ -42,12 +43,12 @@
'c/ppb_messaging.h',
'c/ppb_mouse_cursor.h',
'c/ppb_mouse_lock.h',
- 'c/ppb_network_proxy.h',
'c/ppb_net_address.h',
'c/ppb_network_proxy.h',
+ 'c/ppb_network_proxy.h',
'c/ppb_opengles2.h',
'c/ppb_tcp_socket.h',
- 'c/pp_touch_point.h',
+ 'c/ppb_text_input_controller.h',
'c/ppb_udp_socket.h',
'c/ppb_url_loader.h',
'c/ppb_url_request_info.h',
@@ -204,6 +205,8 @@
'cpp/size.h',
'cpp/tcp_socket.cc',
'cpp/tcp_socket.h',
+ 'cpp/text_input_controller.cc',
+ 'cpp/text_input_controller.h',
'cpp/touch_point.h',
'cpp/udp_socket.cc',
'cpp/udp_socket.h',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 0c84ae88e50b2a..4de170b9658adc 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -51,6 +51,7 @@
#include "ppapi/c/ppb_network_proxy.h"
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/c/ppb_tcp_socket.h"
+#include "ppapi/c/ppb_text_input_controller.h"
#include "ppapi/c/ppb_udp_socket.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/ppb_url_request_info.h"
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 11b432e0586155..5950c4ea706419 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -86,6 +86,7 @@
#include "ppapi/c/ppb_network_proxy.h"
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/c/ppb_tcp_socket.h"
+#include "ppapi/c/ppb_text_input_controller.h"
#include "ppapi/c/ppb_udp_socket.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/ppb_url_request_info.h"
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index d85cae7309bb08..3e57c29dc7e5dc 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -68,6 +68,7 @@
#include "ppapi/cpp/resource.h"
#include "ppapi/cpp/size.h"
#include "ppapi/cpp/tcp_socket.h"
+#include "ppapi/cpp/text_input_controller.h"
#include "ppapi/cpp/touch_point.h"
#include "ppapi/cpp/udp_socket.h"
#include "ppapi/cpp/url_loader.h"
diff --git a/ppapi/tests/test_ime_input_event.cc b/ppapi/tests/test_ime_input_event.cc
index 500fcbbf08c823..70b77e7aeb158a 100644
--- a/ppapi/tests/test_ime_input_event.cc
+++ b/ppapi/tests/test_ime_input_event.cc
@@ -4,11 +4,9 @@
#include "ppapi/tests/test_ime_input_event.h"
-#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_input_event.h"
-#include "ppapi/cpp/dev/ime_input_event_dev.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/module.h"
#include "ppapi/tests/test_utils.h"
@@ -63,9 +61,9 @@ bool TestImeInputEvent::Init() {
static_cast(
pp::Module::Get()->GetBrowserInterface(
PPB_KEYBOARD_INPUT_EVENT_INTERFACE));
- ime_input_event_interface_ = static_cast(
+ ime_input_event_interface_ = static_cast(
pp::Module::Get()->GetBrowserInterface(
- PPB_IME_INPUT_EVENT_DEV_INTERFACE));
+ PPB_IME_INPUT_EVENT_INTERFACE));
bool success =
input_event_interface_ &&
@@ -136,7 +134,7 @@ void TestImeInputEvent::DidChangeView(const pp::View& view) {
}
pp::InputEvent TestImeInputEvent::CreateImeCompositionStartEvent() {
- return pp::IMEInputEvent_Dev(
+ return pp::IMEInputEvent(
instance_,
PP_INPUTEVENT_TYPE_IME_COMPOSITION_START,
100, // time_stamp
@@ -152,7 +150,7 @@ pp::InputEvent TestImeInputEvent::CreateImeCompositionUpdateEvent(
const std::vector& segments,
int32_t target_segment,
const std::pair& selection) {
- return pp::IMEInputEvent_Dev(
+ return pp::IMEInputEvent(
instance_,
PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE,
100, // time_stamp
@@ -165,7 +163,7 @@ pp::InputEvent TestImeInputEvent::CreateImeCompositionUpdateEvent(
pp::InputEvent TestImeInputEvent::CreateImeCompositionEndEvent(
const std::string& text) {
- return pp::IMEInputEvent_Dev(
+ return pp::IMEInputEvent(
instance_,
PP_INPUTEVENT_TYPE_IME_COMPOSITION_END,
100, // time_stamp
@@ -177,7 +175,7 @@ pp::InputEvent TestImeInputEvent::CreateImeCompositionEndEvent(
}
pp::InputEvent TestImeInputEvent::CreateImeTextEvent(const std::string& text) {
- return pp::IMEInputEvent_Dev(
+ return pp::IMEInputEvent(
instance_,
PP_INPUTEVENT_TYPE_IME_TEXT,
100, // time_stamp
diff --git a/ppapi/tests/test_ime_input_event.h b/ppapi/tests/test_ime_input_event.h
index 483167c5cc113b..db929358b541d8 100644
--- a/ppapi/tests/test_ime_input_event.h
+++ b/ppapi/tests/test_ime_input_event.h
@@ -9,7 +9,6 @@
#include
#include
-#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/tests/test_case.h"
@@ -49,7 +48,7 @@ class TestImeInputEvent : public TestCase {
const PPB_InputEvent* input_event_interface_;
const PPB_KeyboardInputEvent* keyboard_input_event_interface_;
- const PPB_IMEInputEvent_Dev* ime_input_event_interface_;
+ const PPB_IMEInputEvent* ime_input_event_interface_;
pp::Rect view_rect_;
bool received_unexpected_event_;
diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h
index d3addcb4465408..b0918a3f056b5e 100644
--- a/ppapi/thunk/interfaces_ppb_public_stable.h
+++ b/ppapi/thunk/interfaces_ppb_public_stable.h
@@ -59,6 +59,8 @@ PROXIED_IFACE(NoAPIName, PPB_FILEIO_INTERFACE_1_1, PPB_FileIO_1_1)
PROXIED_IFACE(NoAPIName, PPB_GRAPHICS_2D_INTERFACE_1_0, PPB_Graphics2D_1_0)
PROXIED_IFACE(NoAPIName, PPB_GRAPHICS_2D_INTERFACE_1_1, PPB_Graphics2D_1_1)
PROXIED_IFACE(NoAPIName, PPB_HOSTRESOLVER_INTERFACE_1_0, PPB_HostResolver_1_0)
+PROXIED_IFACE(NoAPIName, PPB_IME_INPUT_EVENT_INTERFACE_1_0,
+ PPB_IMEInputEvent_1_0)
PROXIED_IFACE(NoAPIName, PPB_INPUT_EVENT_INTERFACE_1_0, PPB_InputEvent_1_0)
PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0,
PPB_KeyboardInputEvent_1_0)
@@ -77,6 +79,8 @@ PROXIED_IFACE(PPB_Instance, PPB_MOUSELOCK_INTERFACE_1_0, PPB_MouseLock_1_0)
PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_INTERFACE_1_0, PPB_NetAddress_1_0)
PROXIED_IFACE(NoAPIName, PPB_NETWORKPROXY_INTERFACE_1_0, PPB_NetworkProxy_1_0)
PROXIED_IFACE(PPB_TCPSocket, PPB_TCPSOCKET_INTERFACE_1_0, PPB_TCPSocket_1_0)
+PROXIED_IFACE(NoAPIName, PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0,
+ PPB_TextInputController_1_0)
PROXIED_IFACE(NoAPIName, PPB_UDPSOCKET_INTERFACE_1_0, PPB_UDPSocket_1_0)
PROXIED_IFACE(NoAPIName, PPB_URLLOADER_INTERFACE_1_0, PPB_URLLoader_1_0)
PROXIED_IFACE(NoAPIName, PPB_URLREQUESTINFO_INTERFACE_1_0,
diff --git a/ppapi/thunk/ppb_input_event_thunk.cc b/ppapi/thunk/ppb_input_event_thunk.cc
index ef495d111f1798..f54eefa8a02326 100644
--- a/ppapi/thunk/ppb_input_event_thunk.cc
+++ b/ppapi/thunk/ppb_input_event_thunk.cc
@@ -411,6 +411,16 @@ const PPB_IMEInputEvent_Dev_0_2 g_ppb_ime_input_event_0_2_thunk = {
&GetIMESelection
};
+const PPB_IMEInputEvent_1_0 g_ppb_ime_input_event_1_0_thunk = {
+ &CreateIMEInputEvent,
+ &IsIMEInputEvent,
+ &GetIMEText,
+ &GetIMESegmentNumber,
+ &GetIMESegmentOffset,
+ &GetIMETargetSegment,
+ &GetIMESelection
+};
+
// Touch -----------------------------------------------------------------------
PP_Resource CreateTouchInputEvent(PP_Instance instance,
@@ -518,6 +528,10 @@ const PPB_IMEInputEvent_Dev_0_2* GetPPB_IMEInputEvent_Dev_0_2_Thunk() {
return &g_ppb_ime_input_event_0_2_thunk;
}
+const PPB_IMEInputEvent_1_0* GetPPB_IMEInputEvent_1_0_Thunk() {
+ return &g_ppb_ime_input_event_1_0_thunk;
+}
+
const PPB_TouchInputEvent_1_0* GetPPB_TouchInputEvent_1_0_Thunk() {
return &g_ppb_touch_input_event_thunk;
}
diff --git a/ppapi/thunk/ppb_text_input_thunk.cc b/ppapi/thunk/ppb_text_input_thunk.cc
index 7d35e2a799fbb3..55fb4c922bde4b 100644
--- a/ppapi/thunk/ppb_text_input_thunk.cc
+++ b/ppapi/thunk/ppb_text_input_thunk.cc
@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/c/ppb_text_input_controller.h"
+
+#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace thunk {
@@ -17,7 +20,7 @@ void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) {
enter.functions()->SetTextInputType(instance, type);
}
-void UpdateCaretPosition(PP_Instance instance,
+void UpdateCaretPosition_0_2(PP_Instance instance,
const PP_Rect* caret,
const PP_Rect* bounding_box) {
EnterInstance enter(instance);
@@ -25,19 +28,37 @@ void UpdateCaretPosition(PP_Instance instance,
enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box);
}
+void UpdateCaretPosition(PP_Instance instance,
+ const PP_Rect* caret) {
+ EnterInstance enter(instance);
+ if (enter.succeeded() && caret)
+ enter.functions()->UpdateCaretPosition(instance, *caret, PP_Rect());
+}
+
void CancelCompositionText(PP_Instance instance) {
EnterInstance enter(instance);
if (enter.succeeded())
enter.functions()->CancelCompositionText(instance);
}
-void UpdateSurroundingText(PP_Instance instance, const char* text,
- uint32_t caret, uint32_t anchor) {
+void UpdateSurroundingText_0_2(PP_Instance instance, const char* text,
+ uint32_t caret, uint32_t anchor) {
EnterInstance enter(instance);
if (enter.succeeded())
enter.functions()->UpdateSurroundingText(instance, text, caret, anchor);
}
+void UpdateSurroundingText_1_0(PP_Instance instance, PP_Var text,
+ uint32_t caret, uint32_t anchor) {
+ EnterInstance enter(instance);
+ StringVar* var = StringVar::FromPPVar(text);
+ if (enter.succeeded() && var)
+ enter.functions()->UpdateSurroundingText(instance,
+ var->value().c_str(),
+ caret,
+ anchor);
+}
+
void SelectionChanged(PP_Instance instance) {
EnterInstance enter(instance);
if (enter.succeeded())
@@ -46,18 +67,25 @@ void SelectionChanged(PP_Instance instance) {
const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = {
&SetTextInputType,
- &UpdateCaretPosition,
+ &UpdateCaretPosition_0_2,
&CancelCompositionText,
};
-const PPB_TextInput_Dev g_ppb_textinput_0_2_thunk = {
+const PPB_TextInput_Dev_0_2 g_ppb_textinput_0_2_thunk = {
&SetTextInputType,
- &UpdateCaretPosition,
+ &UpdateCaretPosition_0_2,
&CancelCompositionText,
- &UpdateSurroundingText,
+ &UpdateSurroundingText_0_2,
&SelectionChanged,
};
+const PPB_TextInputController_1_0 g_ppb_textinputcontroller_1_0_thunk = {
+ &SetTextInputType,
+ &UpdateCaretPosition,
+ &CancelCompositionText,
+ &UpdateSurroundingText_1_0,
+};
+
} // namespace
const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() {
@@ -68,5 +96,9 @@ const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() {
return &g_ppb_textinput_0_2_thunk;
}
+const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() {
+ return &g_ppb_textinputcontroller_1_0_thunk;
+}
+
} // namespace thunk
} // namespace ppapi
diff --git a/webkit/common/plugins/ppapi/ppapi_utils.cc b/webkit/common/plugins/ppapi/ppapi_utils.cc
index 6f67b24cf59ae7..619b03d925484c 100644
--- a/webkit/common/plugins/ppapi/ppapi_utils.cc
+++ b/webkit/common/plugins/ppapi/ppapi_utils.cc
@@ -58,6 +58,7 @@
#include "ppapi/c/ppb_network_proxy.h"
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/c/ppb_tcp_socket.h"
+#include "ppapi/c/ppb_text_input_controller.h"
#include "ppapi/c/ppb_udp_socket.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/ppb_url_request_info.h"