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

Unified Diff: ppapi/cpp/input_event.h

Issue 7882004: Declarations for Pepper IME API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split GetSegments into two functions, and improve comments and style. 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
Index: ppapi/cpp/input_event.h
diff --git a/ppapi/cpp/input_event.h b/ppapi/cpp/input_event.h
index da92742c3b026bcfe934a2fcdb572520c40c536a..c6ac0491f6a88e1691a37ffd165a40635cf3273a 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 <utility>
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/cpp/resource.h"
@@ -102,13 +103,13 @@ class MouseInputEvent : public InputEvent {
/// This constructor manually constructs a mouse event from the provided
/// parameters.
///
- /// @param[in] instance The instance for which this event occured.
+ /// @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.
///
/// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
- /// when the event occured.
+ /// when the event occurred.
///
/// @param[in] modifiers A bit field combination of the
/// <code>PP_InputEvent_Modifier</code> flags.
@@ -118,7 +119,7 @@ class MouseInputEvent : public InputEvent {
/// mouse move, enter, and leave events.
///
/// @param[in] mouse_position A <code>Point</code> containing the x and y
- /// position of the mouse when the eent occurred.
+ /// position of the mouse when the event occurred.
///
/// @param[in] click_count
/// TODO(brettw) figure out exactly what this means.
@@ -184,7 +185,7 @@ class WheelInputEvent : public InputEvent {
/// @param[in] instance The instance for which this event occured.
///
/// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
- /// when the event occured.
+ /// when the event occurred.
///
/// @param[in] modifiers A bit field combination of the
/// <code>PP_InputEvent_Modifier</code> flags.
@@ -219,7 +220,7 @@ class WheelInputEvent : public InputEvent {
/// possible, for example, on some trackpads and newer mice that don't have
/// "clicks".
///
- /// @return The vertial and horizontal scroll values. The units are either in
+ /// @return The vertical and horizontal scroll values. The units are either in
/// pixels (when scroll_by_page is false) or pages (when scroll_by_page is
/// true). For example, y = -3 means scroll up 3 pixels when scroll_by_page
/// is false, and scroll up 3 pages when scroll_by_page is true.
@@ -259,20 +260,20 @@ class KeyboardInputEvent : public InputEvent {
/// Constructs a keyboard input event object from the provided generic input
/// event. If the given event is itself is_null() or is not a keyboard input
- /// event, the keybaord object will be is_null().
+ /// event, the keyboard object will be is_null().
///
/// @param[in] event A generic input event.
explicit KeyboardInputEvent(const InputEvent& event);
/// Constructs a keyboard input even from the given parameters.
///
- /// @param[in] instance The instance for which this event occured.
+ /// @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.
///
/// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
- /// when the event occured.
+ /// when the event occurred.
///
/// @param[in] modifiers A bit field combination of the
/// <code>PP_InputEvent_Modifier</code> flags.
@@ -302,6 +303,56 @@ class KeyboardInputEvent : public InputEvent {
Var GetCharacterText() const;
};
+class CompositionInputEvent : public InputEvent {
+ public:
+ /// Constructs an is_null() composition input event object.
+ CompositionInputEvent();
+
+ /// Constructs a composition input event object from the provided generic
+ /// input event. If the given event is itself is_null() or is not a
+ /// composition input event, the composition object will be is_null().
+ ///
+ /// @param[in] event A generic input event.
+ explicit CompositionInputEvent(const InputEvent& event);
+
+ /// Returns the composition text as a UTF-8 string for the given composition
+ /// event.
+ ///
+ /// @return A string var representing the composition text. For non-
+ /// composition 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 start and the end position of the index-th segment in the
+ /// composition text. The positions are given by byte-indices of the string
+ /// GetText(). They always satisfy 0 <= .first < .second <= (Length of
+ /// GetText()) and GetSegmentAt(index).first < GetSegmentAt(index+1).first.
+ /// When the event is not COMPOSITION_UPDATE or index >= GetSegmentNumber(),
+ /// returns (0, 0).
+ ///
+ /// @param[in] index An integer indicating a segment.
+ ///
+ /// @return A pair of integers representing the index-th segment.
+ std::pair<uint32_t, uint32_t> GetSegmentAt(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;
+
+ /// Returns the range selected by caret in the composition text.
+ ///
+ /// @return A pair of integers indicating the selection range.
+ std::pair<uint32_t, uint32_t> GetSelection() const;
+};
+
} // namespace pp
#endif // PPAPI_CPP_INPUT_EVENT_H_

Powered by Google App Engine
This is Rietveld 408576698