1 // Copyright (c) 2013 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.
5 // IPC messages for input events and other messages that require processing in
6 // order relative to input events.
7 // Multiply-included message file, hence no include guard.
9 #include "base/strings/string16.h"
10 #include "content/common/content_export.h"
11 #include "content/common/content_param_traits.h"
12 #include "content/common/edit_command.h"
13 #include "content/common/input/did_overscroll_params.h"
14 #include "content/common/input/input_event.h"
15 #include "content/common/input/input_event_ack_state.h"
16 #include "content/common/input/input_param_traits.h"
17 #include "content/common/input/synthetic_gesture_packet.h"
18 #include "content/common/input/synthetic_gesture_params.h"
19 #include "content/common/input/synthetic_pinch_gesture_params.h"
20 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
21 #include "content/common/input/synthetic_tap_gesture_params.h"
22 #include "content/common/input/touch_action.h"
23 #include "content/public/common/common_param_traits.h"
24 #include "ipc/ipc_message_macros.h"
25 #include "third_party/WebKit/public/web/WebInputEvent.h"
26 #include "ui/events/ipc/latency_info_param_traits.h"
27 #include "ui/gfx/geometry/point.h"
28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/vector2d_f.h"
30 #include "ui/gfx/ipc/gfx_param_traits.h"
31 #include "ui/gfx/range/range.h"
33 #undef IPC_MESSAGE_EXPORT
34 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
36 #ifdef IPC_MESSAGE_START
37 #error IPC_MESSAGE_START
40 #define IPC_MESSAGE_START InputMsgStart
42 IPC_ENUM_TRAITS_MAX_VALUE(content::InputEventAckState
,
43 content::INPUT_EVENT_ACK_STATE_MAX
)
44 IPC_ENUM_TRAITS_MAX_VALUE(
45 content::SyntheticGestureParams::GestureSourceType
,
46 content::SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX
)
47 IPC_ENUM_TRAITS_MAX_VALUE(
48 content::SyntheticGestureParams::GestureType
,
49 content::SyntheticGestureParams::SYNTHETIC_GESTURE_TYPE_MAX
)
50 IPC_ENUM_TRAITS_VALIDATE(content::TouchAction
, (
52 value
<= content::TOUCH_ACTION_MAX
&&
53 (!(value
& content::TOUCH_ACTION_NONE
) ||
54 (value
== content::TOUCH_ACTION_NONE
)) &&
55 (!(value
& content::TOUCH_ACTION_PINCH_ZOOM
) ||
56 (value
== content::TOUCH_ACTION_MANIPULATION
))))
58 IPC_STRUCT_TRAITS_BEGIN(content::DidOverscrollParams
)
59 IPC_STRUCT_TRAITS_MEMBER(accumulated_overscroll
)
60 IPC_STRUCT_TRAITS_MEMBER(latest_overscroll_delta
)
61 IPC_STRUCT_TRAITS_MEMBER(current_fling_velocity
)
62 IPC_STRUCT_TRAITS_MEMBER(causal_event_viewport_point
)
63 IPC_STRUCT_TRAITS_END()
65 IPC_STRUCT_TRAITS_BEGIN(content::EditCommand
)
66 IPC_STRUCT_TRAITS_MEMBER(name
)
67 IPC_STRUCT_TRAITS_MEMBER(value
)
68 IPC_STRUCT_TRAITS_END()
70 IPC_STRUCT_TRAITS_BEGIN(content::InputEvent
)
71 IPC_STRUCT_TRAITS_MEMBER(web_event
)
72 IPC_STRUCT_TRAITS_MEMBER(latency_info
)
73 IPC_STRUCT_TRAITS_MEMBER(is_keyboard_shortcut
)
74 IPC_STRUCT_TRAITS_END()
76 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticGestureParams
)
77 IPC_STRUCT_TRAITS_MEMBER(gesture_source_type
)
78 IPC_STRUCT_TRAITS_END()
80 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticSmoothScrollGestureParams
)
81 IPC_STRUCT_TRAITS_PARENT(content::SyntheticGestureParams
)
82 IPC_STRUCT_TRAITS_MEMBER(anchor
)
83 IPC_STRUCT_TRAITS_MEMBER(distances
)
84 IPC_STRUCT_TRAITS_MEMBER(prevent_fling
)
85 IPC_STRUCT_TRAITS_MEMBER(speed_in_pixels_s
)
86 IPC_STRUCT_TRAITS_END()
88 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPinchGestureParams
)
89 IPC_STRUCT_TRAITS_PARENT(content::SyntheticGestureParams
)
90 IPC_STRUCT_TRAITS_MEMBER(scale_factor
)
91 IPC_STRUCT_TRAITS_MEMBER(anchor
)
92 IPC_STRUCT_TRAITS_MEMBER(relative_pointer_speed_in_pixels_s
)
93 IPC_STRUCT_TRAITS_END()
95 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticTapGestureParams
)
96 IPC_STRUCT_TRAITS_PARENT(content::SyntheticGestureParams
)
97 IPC_STRUCT_TRAITS_MEMBER(position
)
98 IPC_STRUCT_TRAITS_MEMBER(duration_ms
)
99 IPC_STRUCT_TRAITS_END()
101 IPC_STRUCT_BEGIN(InputHostMsg_HandleInputEvent_ACK_Params
)
102 IPC_STRUCT_MEMBER(blink::WebInputEvent::Type
, type
)
103 IPC_STRUCT_MEMBER(content::InputEventAckState
, state
)
104 IPC_STRUCT_MEMBER(ui::LatencyInfo
, latency
)
105 // TODO(jdduke): Use Optional<T> type to avoid heap alloc, crbug.com/375002.
106 IPC_STRUCT_MEMBER(scoped_ptr
<content::DidOverscrollParams
>, overscroll
)
109 // Sends an input event to the render widget.
110 IPC_MESSAGE_ROUTED3(InputMsg_HandleInputEvent
,
111 IPC::WebInputEventPointer
/* event */,
112 ui::LatencyInfo
/* latency_info */,
113 bool /* is_keyboard_shortcut */)
115 // Sends the cursor visibility state to the render widget.
116 IPC_MESSAGE_ROUTED1(InputMsg_CursorVisibilityChange
,
117 bool /* is_visible */)
119 // Sets the text composition to be between the given start and end offsets in
120 // the currently focused editable field.
121 IPC_MESSAGE_ROUTED3(InputMsg_SetCompositionFromExistingText
,
124 std::vector
<blink::WebCompositionUnderline
> /* underlines */)
126 // Deletes the current selection plus the specified number of characters before
127 // and after the selection or caret.
128 IPC_MESSAGE_ROUTED2(InputMsg_ExtendSelectionAndDelete
,
132 // This message sends a string being composed with an input method.
134 InputMsg_ImeSetComposition
,
135 base::string16
, /* text */
136 std::vector
<blink::WebCompositionUnderline
>, /* underlines */
137 int, /* selectiont_start */
138 int /* selection_end */)
140 // This message confirms an ongoing composition.
141 IPC_MESSAGE_ROUTED3(InputMsg_ImeConfirmComposition
,
142 base::string16
/* text */,
143 gfx::Range
/* replacement_range */,
144 bool /* keep_selection */)
146 // This message notifies the renderer that the next key event is bound to one
147 // or more pre-defined edit commands. If the next key event is not handled
148 // by webkit, the specified edit commands shall be executed against current
151 // * edit_commands (see chrome/common/edit_command_types.h)
152 // Contains one or more edit commands.
153 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed
154 // definition of webkit edit commands.
156 // This message must be sent just before sending a key event.
157 IPC_MESSAGE_ROUTED1(InputMsg_SetEditCommandsForNextKeyEvent
,
158 std::vector
<content::EditCommand
> /* edit_commands */)
160 // Message payload is the name/value of a WebCore edit command to execute.
161 IPC_MESSAGE_ROUTED2(InputMsg_ExecuteEditCommand
,
162 std::string
, /* name */
163 std::string
/* value */)
165 // Message payload is the name of a WebCore edit command to execute.
166 IPC_MESSAGE_ROUTED1(InputMsg_ExecuteNoValueEditCommand
, std::string
/* name */)
168 IPC_MESSAGE_ROUTED0(InputMsg_MouseCaptureLost
)
170 // TODO(darin): figure out how this meshes with RestoreFocus
171 IPC_MESSAGE_ROUTED1(InputMsg_SetFocus
,
174 // Tells the renderer to scroll the currently focused node into rect only if
175 // the currently focused node is a Text node (textfield, text area or content
177 IPC_MESSAGE_ROUTED1(InputMsg_ScrollFocusedEditableNodeIntoRect
, gfx::Rect
)
179 // These messages are typically generated from context menus and request the
180 // renderer to apply the specified operation to the current selection.
181 IPC_MESSAGE_ROUTED0(InputMsg_Undo
)
182 IPC_MESSAGE_ROUTED0(InputMsg_Redo
)
183 IPC_MESSAGE_ROUTED0(InputMsg_Cut
)
184 IPC_MESSAGE_ROUTED0(InputMsg_Copy
)
185 #if defined(OS_MACOSX)
186 IPC_MESSAGE_ROUTED0(InputMsg_CopyToFindPboard
)
188 IPC_MESSAGE_ROUTED0(InputMsg_Paste
)
189 IPC_MESSAGE_ROUTED0(InputMsg_PasteAndMatchStyle
)
190 // Replaces the selected region or a word around the cursor with the
192 IPC_MESSAGE_ROUTED1(InputMsg_Replace
,
194 // Replaces the misspelling in the selected region with the specified string.
195 IPC_MESSAGE_ROUTED1(InputMsg_ReplaceMisspelling
,
197 IPC_MESSAGE_ROUTED0(InputMsg_Delete
)
198 IPC_MESSAGE_ROUTED0(InputMsg_SelectAll
)
200 IPC_MESSAGE_ROUTED0(InputMsg_Unselect
)
202 // Requests the renderer to select the region between two points.
203 // Expects a SelectRange_ACK message when finished.
204 IPC_MESSAGE_ROUTED2(InputMsg_SelectRange
,
205 gfx::Point
/* base */,
206 gfx::Point
/* extent */)
208 // Requests the renderer to move the selection extent point to a new position.
209 // Expects a MoveRangeSelectionExtent_ACK message when finished.
210 IPC_MESSAGE_ROUTED1(InputMsg_MoveRangeSelectionExtent
,
211 gfx::Point
/* extent */)
213 // Requests the renderer to move the caret selection toward the point.
214 // Expects a MoveCaret_ACK message when finished.
215 IPC_MESSAGE_ROUTED1(InputMsg_MoveCaret
,
216 gfx::Point
/* location */)
218 #if defined(OS_ANDROID)
219 // Sent when the user clicks on the find result bar to activate a find result.
220 // The point (x,y) is in fractions of the content document's width and height.
221 IPC_MESSAGE_ROUTED3(InputMsg_ActivateNearestFindResult
,
222 int /* request_id */,
227 IPC_MESSAGE_ROUTED0(InputMsg_SyntheticGestureCompleted
)
229 // -----------------------------------------------------------------------------
230 // Messages sent from the renderer to the browser.
232 // Acknowledges receipt of a InputMsg_HandleInputEvent message.
233 IPC_MESSAGE_ROUTED1(InputHostMsg_HandleInputEvent_ACK
,
234 InputHostMsg_HandleInputEvent_ACK_Params
)
236 IPC_MESSAGE_ROUTED1(InputHostMsg_QueueSyntheticGesture
,
237 content::SyntheticGesturePacket
)
239 // Notifies the allowed touch actions for a new touch point.
240 IPC_MESSAGE_ROUTED1(InputHostMsg_SetTouchAction
,
241 content::TouchAction
/* touch_action */)
243 // Sent by the compositor when input scroll events are dropped due to bounds
244 // restrictions on the root scroll offset.
245 IPC_MESSAGE_ROUTED1(InputHostMsg_DidOverscroll
,
246 content::DidOverscrollParams
/* params */)
248 // Acknowledges receipt of a InputMsg_MoveCaret message.
249 IPC_MESSAGE_ROUTED0(InputHostMsg_MoveCaret_ACK
)
251 // Acknowledges receipt of a InputMsg_MoveRangeSelectionExtent message.
252 IPC_MESSAGE_ROUTED0(InputHostMsg_MoveRangeSelectionExtent_ACK
)
254 // Acknowledges receipt of a InputMsg_SelectRange message.
255 IPC_MESSAGE_ROUTED0(InputHostMsg_SelectRange_ACK
)
257 // Required for cancelling an ongoing input method composition.
258 IPC_MESSAGE_ROUTED0(InputHostMsg_ImeCancelComposition
)
260 // This IPC message sends the character bounds after every composition change
261 // to always have correct bound info.
262 IPC_MESSAGE_ROUTED2(InputHostMsg_ImeCompositionRangeChanged
,
263 gfx::Range
/* composition range */,
264 std::vector
<gfx::Rect
> /* character bounds */)
266 // Adding a new message? Stick to the sort order above: first platform
267 // independent InputMsg, then ifdefs for platform specific InputMsg, then
268 // platform independent InputHostMsg, then ifdefs for platform specific