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. 4 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. 8 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/ipc/gfx_param_traits.h" 28 #include "ui/gfx/point.h" 29 #include "ui/gfx/range/range.h" 30 #include "ui/gfx/rect.h" 31 #include "ui/gfx/vector2d_f.h" 32 33 #undef IPC_MESSAGE_EXPORT 34 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT 35 36 #ifdef IPC_MESSAGE_START 37 #error IPC_MESSAGE_START 38 #endif 39 40 #define IPC_MESSAGE_START InputMsgStart 41 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, ( 51 value >= 0 && 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)))) 57 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() 64 65 IPC_STRUCT_TRAITS_BEGIN(content::EditCommand) 66 IPC_STRUCT_TRAITS_MEMBER(name) 67 IPC_STRUCT_TRAITS_MEMBER(value) 68 IPC_STRUCT_TRAITS_END() 69 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() 75 76 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticGestureParams) 77 IPC_STRUCT_TRAITS_MEMBER(gesture_source_type) 78 IPC_STRUCT_TRAITS_END() 79 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() 87 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() 94 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() 100 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) 107 IPC_STRUCT_END() 108 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 */) 114 115 // Sends the cursor visibility state to the render widget. 116 IPC_MESSAGE_ROUTED1(InputMsg_CursorVisibilityChange, 117 bool /* is_visible */) 118 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, 122 int /* start */, 123 int /* end */, 124 std::vector<blink::WebCompositionUnderline> /* underlines */) 125 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, 129 int /* before */, 130 int /* after */) 131 132 // This message sends a string being composed with an input method. 133 IPC_MESSAGE_ROUTED4( 134 InputMsg_ImeSetComposition, 135 base::string16, /* text */ 136 std::vector<blink::WebCompositionUnderline>, /* underlines */ 137 int, /* selectiont_start */ 138 int /* selection_end */) 139 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 */) 145 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 149 // focused frame. 150 // Parameters 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. 155 // 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 */) 159 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 */) 164 165 IPC_MESSAGE_ROUTED0(InputMsg_MouseCaptureLost) 166 167 // TODO(darin): figure out how this meshes with RestoreFocus 168 IPC_MESSAGE_ROUTED1(InputMsg_SetFocus, 169 bool /* enable */) 170 171 // Tells the renderer to scroll the currently focused node into rect only if 172 // the currently focused node is a Text node (textfield, text area or content 173 // editable divs). 174 IPC_MESSAGE_ROUTED1(InputMsg_ScrollFocusedEditableNodeIntoRect, gfx::Rect) 175 176 // These messages are typically generated from context menus and request the 177 // renderer to apply the specified operation to the current selection. 178 IPC_MESSAGE_ROUTED0(InputMsg_Undo) 179 IPC_MESSAGE_ROUTED0(InputMsg_Redo) 180 IPC_MESSAGE_ROUTED0(InputMsg_Cut) 181 IPC_MESSAGE_ROUTED0(InputMsg_Copy) 182 #if defined(OS_MACOSX) 183 IPC_MESSAGE_ROUTED0(InputMsg_CopyToFindPboard) 184 #endif 185 IPC_MESSAGE_ROUTED0(InputMsg_Paste) 186 IPC_MESSAGE_ROUTED0(InputMsg_PasteAndMatchStyle) 187 // Replaces the selected region or a word around the cursor with the 188 // specified string. 189 IPC_MESSAGE_ROUTED1(InputMsg_Replace, 190 base::string16) 191 // Replaces the misspelling in the selected region with the specified string. 192 IPC_MESSAGE_ROUTED1(InputMsg_ReplaceMisspelling, 193 base::string16) 194 IPC_MESSAGE_ROUTED0(InputMsg_Delete) 195 IPC_MESSAGE_ROUTED0(InputMsg_SelectAll) 196 197 IPC_MESSAGE_ROUTED0(InputMsg_Unselect) 198 199 // Requests the renderer to select the region between two points. 200 // Expects a SelectRange_ACK message when finished. 201 IPC_MESSAGE_ROUTED2(InputMsg_SelectRange, 202 gfx::Point /* start */, 203 gfx::Point /* end */) 204 205 // Requests the renderer to move the caret selection toward the point. 206 // Expects a MoveCaret_ACK message when finished. 207 IPC_MESSAGE_ROUTED1(InputMsg_MoveCaret, 208 gfx::Point /* location */) 209 210 #if defined(OS_ANDROID) 211 // Sent when the user clicks on the find result bar to activate a find result. 212 // The point (x,y) is in fractions of the content document's width and height. 213 IPC_MESSAGE_ROUTED3(InputMsg_ActivateNearestFindResult, 214 int /* request_id */, 215 float /* x */, 216 float /* y */) 217 #endif 218 219 IPC_MESSAGE_ROUTED0(InputMsg_SyntheticGestureCompleted) 220 221 // ----------------------------------------------------------------------------- 222 // Messages sent from the renderer to the browser. 223 224 // Acknowledges receipt of a InputMsg_HandleInputEvent message. 225 IPC_MESSAGE_ROUTED1(InputHostMsg_HandleInputEvent_ACK, 226 InputHostMsg_HandleInputEvent_ACK_Params) 227 228 IPC_MESSAGE_ROUTED1(InputHostMsg_QueueSyntheticGesture, 229 content::SyntheticGesturePacket) 230 231 // Notifies the allowed touch actions for a new touch point. 232 IPC_MESSAGE_ROUTED1(InputHostMsg_SetTouchAction, 233 content::TouchAction /* touch_action */) 234 235 // Sent by the compositor when input scroll events are dropped due to bounds 236 // restrictions on the root scroll offset. 237 IPC_MESSAGE_ROUTED1(InputHostMsg_DidOverscroll, 238 content::DidOverscrollParams /* params */) 239 240 // Required for cancelling an ongoing input method composition. 241 IPC_MESSAGE_ROUTED0(InputHostMsg_ImeCancelComposition) 242 243 #if defined(OS_MACOSX) || defined(USE_AURA) 244 // On Mac and Aura IME can request composition character bounds 245 // synchronously (see crbug.com/120597). This IPC message sends the character 246 // bounds after every composition change to always have correct bound info. 247 IPC_MESSAGE_ROUTED2(InputHostMsg_ImeCompositionRangeChanged, 248 gfx::Range /* composition range */, 249 std::vector<gfx::Rect> /* character bounds */) 250 #endif 251 252 // Adding a new message? Stick to the sort order above: first platform 253 // independent InputMsg, then ifdefs for platform specific InputMsg, then 254 // platform independent InputHostMsg, then ifdefs for platform specific 255 // InputHostMsg. 256