1 // Copyright 2018 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 #ifndef CONTENT_COMMON_WIDGET_MESSAGES_H_ 6 #define CONTENT_COMMON_WIDGET_MESSAGES_H_ 7 8 // IPC messages for controlling painting and input events. 9 10 #include "base/optional.h" 11 #include "base/time/time.h" 12 #include "cc/input/touch_action.h" 13 #include "content/common/common_param_traits_macros.h" 14 #include "content/common/content_param_traits.h" 15 #include "content/common/content_to_visible_time_reporter.h" 16 #include "content/common/cursors/webcursor.h" 17 #include "content/common/text_input_state.h" 18 #include "content/common/visual_properties.h" 19 #include "content/public/common/common_param_traits.h" 20 #include "ipc/ipc_message_macros.h" 21 #include "third_party/blink/public/common/screen_orientation/web_screen_orientation_type.h" 22 #include "third_party/blink/public/platform/viewport_intersection_state.h" 23 #include "third_party/blink/public/platform/web_float_rect.h" 24 #include "third_party/blink/public/platform/web_intrinsic_sizing_info.h" 25 #include "ui/base/ime/text_input_action.h" 26 #include "ui/base/ime/text_input_mode.h" 27 #include "ui/base/ui_base_types.h" 28 #include "ui/gfx/geometry/point.h" 29 #include "ui/gfx/geometry/rect.h" 30 31 #undef IPC_MESSAGE_EXPORT 32 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT 33 34 #define IPC_MESSAGE_START WidgetMsgStart 35 36 // Traits for WebDeviceEmulationParams. 37 IPC_STRUCT_TRAITS_BEGIN(blink::WebFloatRect) 38 IPC_STRUCT_TRAITS_MEMBER(x) 39 IPC_STRUCT_TRAITS_MEMBER(y) 40 IPC_STRUCT_TRAITS_MEMBER(width) 41 IPC_STRUCT_TRAITS_MEMBER(height) 42 IPC_STRUCT_TRAITS_END() 43 44 IPC_STRUCT_TRAITS_BEGIN(blink::WebSize) 45 IPC_STRUCT_TRAITS_MEMBER(width) 46 IPC_STRUCT_TRAITS_MEMBER(height) 47 IPC_STRUCT_TRAITS_END() 48 49 IPC_STRUCT_TRAITS_BEGIN(blink::WebDeviceEmulationParams) 50 IPC_STRUCT_TRAITS_MEMBER(screen_position) 51 IPC_STRUCT_TRAITS_MEMBER(screen_size) 52 IPC_STRUCT_TRAITS_MEMBER(view_position) 53 IPC_STRUCT_TRAITS_MEMBER(device_scale_factor) 54 IPC_STRUCT_TRAITS_MEMBER(view_size) 55 IPC_STRUCT_TRAITS_MEMBER(scale) 56 IPC_STRUCT_TRAITS_MEMBER(viewport_offset) 57 IPC_STRUCT_TRAITS_MEMBER(viewport_scale) 58 IPC_STRUCT_TRAITS_MEMBER(screen_orientation_angle) 59 IPC_STRUCT_TRAITS_MEMBER(screen_orientation_type) 60 IPC_STRUCT_TRAITS_END() 61 62 IPC_ENUM_TRAITS_MAX_VALUE(base::i18n::TextDirection, 63 base::i18n::TEXT_DIRECTION_MAX) 64 65 IPC_STRUCT_BEGIN(WidgetHostMsg_SelectionBounds_Params) 66 IPC_STRUCT_MEMBER(gfx::Rect, anchor_rect) 67 IPC_STRUCT_MEMBER(base::i18n::TextDirection, anchor_dir) 68 IPC_STRUCT_MEMBER(gfx::Rect, focus_rect) 69 IPC_STRUCT_MEMBER(base::i18n::TextDirection, focus_dir) 70 IPC_STRUCT_MEMBER(bool, is_anchor_first) 71 IPC_STRUCT_END() 72 73 // Traits for TextInputState. 74 IPC_ENUM_TRAITS_MAX_VALUE(ui::TextInputAction, ui::TextInputAction::kMaxValue) 75 IPC_ENUM_TRAITS_MAX_VALUE(ui::TextInputMode, ui::TEXT_INPUT_MODE_MAX) 76 77 IPC_STRUCT_TRAITS_BEGIN(content::TextInputState) 78 IPC_STRUCT_TRAITS_MEMBER(type) 79 IPC_STRUCT_TRAITS_MEMBER(mode) 80 IPC_STRUCT_TRAITS_MEMBER(action) 81 IPC_STRUCT_TRAITS_MEMBER(flags) 82 IPC_STRUCT_TRAITS_MEMBER(value) 83 IPC_STRUCT_TRAITS_MEMBER(selection_start) 84 IPC_STRUCT_TRAITS_MEMBER(selection_end) 85 IPC_STRUCT_TRAITS_MEMBER(composition_start) 86 IPC_STRUCT_TRAITS_MEMBER(composition_end) 87 IPC_STRUCT_TRAITS_MEMBER(can_compose_inline) 88 IPC_STRUCT_TRAITS_MEMBER(show_ime_if_needed) 89 IPC_STRUCT_TRAITS_MEMBER(always_hide_ime) 90 IPC_STRUCT_TRAITS_MEMBER(reply_to_request) 91 IPC_STRUCT_TRAITS_MEMBER(edit_context_control_bounds) 92 IPC_STRUCT_TRAITS_MEMBER(edit_context_selection_bounds) 93 IPC_STRUCT_TRAITS_END() 94 95 // 96 // Browser -> Renderer Messages. 97 // 98 99 // Sent to inform the renderer to invoke a context menu. 100 // The parameter specifies the location in the render widget's coordinates. 101 IPC_MESSAGE_ROUTED2(WidgetMsg_ShowContextMenu, 102 ui::MenuSourceType, 103 gfx::Point /* location where menu should be shown */) 104 105 // Tells the render widget to close. 106 // Expects a Close_ACK message when finished. 107 IPC_MESSAGE_ROUTED0(WidgetMsg_Close) 108 109 // Enables device emulation. See WebDeviceEmulationParams for description. 110 IPC_MESSAGE_ROUTED1(WidgetMsg_EnableDeviceEmulation, 111 blink::WebDeviceEmulationParams /* params */) 112 113 // Disables device emulation, enabled previously by EnableDeviceEmulation. 114 IPC_MESSAGE_ROUTED0(WidgetMsg_DisableDeviceEmulation) 115 116 // Sent to inform the widget that it was hidden. This allows it to reduce its 117 // resource utilization. 118 IPC_MESSAGE_ROUTED0(WidgetMsg_WasHidden) 119 120 // Tells the render view that it is no longer hidden (see WasHidden). 121 IPC_MESSAGE_ROUTED3(WidgetMsg_WasShown, 122 base::TimeTicks /* show_request_timestamp */, 123 bool /* was_evicted */, 124 base::Optional<content::RecordContentToVisibleTimeRequest> 125 /* record_tab_switch_time_request */) 126 127 // Activate/deactivate the RenderWidget (i.e., set its controls' tint 128 // accordingly, etc.). 129 IPC_MESSAGE_ROUTED1(WidgetMsg_SetActive, bool /* active */) 130 131 // Changes the text direction of the currently selected input field (if any). 132 IPC_MESSAGE_ROUTED1(WidgetMsg_SetTextDirection, 133 base::i18n::TextDirection /* direction */) 134 135 // Reply to WidgetHostMsg_RequestSetBounds, WidgetHostMsg_ShowWidget, and 136 // FrameHostMsg_ShowCreatedWindow, to inform the renderer that the browser has 137 // processed the bounds-setting. The browser may have ignored the new bounds, 138 // but it finished processing. This is used because the renderer keeps a 139 // temporary cache of the widget position while these asynchronous operations 140 // are in progress. 141 IPC_MESSAGE_ROUTED0(WidgetMsg_SetBounds_ACK) 142 143 // Updates a RenderWidget's visual properties. This should include all 144 // geometries and compositing inputs so that they are updated atomically. 145 IPC_MESSAGE_ROUTED1(WidgetMsg_UpdateVisualProperties, 146 content::VisualProperties /* visual_properties */) 147 148 // Informs the RenderWidget of its position on the user's screen, as well as 149 // the position of the native window holding the RenderWidget. 150 // TODO(danakj): These should be part of UpdateVisualProperties. 151 IPC_MESSAGE_ROUTED2(WidgetMsg_UpdateScreenRects, 152 gfx::Rect /* widget_screen_rect */, 153 gfx::Rect /* window_screen_rect */) 154 155 // Sent by the browser to ask the renderer to redraw. Robust to events that can 156 // happen in renderer (abortion of the commit or draw, loss of output surface 157 // etc.). 158 IPC_MESSAGE_ROUTED1(WidgetMsg_ForceRedraw, int /* snapshot_id */) 159 160 // Sent by a parent frame to notify its child about the state of the child's 161 // intersection with the parent's viewport, primarily for use by the 162 // IntersectionObserver API. Also see FrameHostMsg_UpdateViewportIntersection. 163 IPC_MESSAGE_ROUTED1(WidgetMsg_SetViewportIntersection, 164 blink::ViewportIntersectionState /* intersection_state */) 165 166 // Sent to an OOPIF widget when the browser receives a FrameHostMsg_SetIsInert 167 // from the target widget's embedding renderer changing its inertness. When a 168 // widget is inert, it is unable to process input events. 169 // 170 // https://html.spec.whatwg.org/multipage/interaction.html#inert 171 IPC_MESSAGE_ROUTED1(WidgetMsg_SetIsInert, bool /* inert */) 172 173 // Sets the inherited effective touch action on an out-of-process iframe. 174 IPC_MESSAGE_ROUTED1(WidgetMsg_SetInheritedEffectiveTouchAction, cc::TouchAction) 175 176 // Toggles render throttling for an out-of-process iframe. 177 IPC_MESSAGE_ROUTED2(WidgetMsg_UpdateRenderThrottlingStatus, 178 bool /* is_throttled */, 179 bool /* subtree_throttled */) 180 181 // Sent by the browser to synchronize with the next compositor frame by 182 // requesting an ACK be queued. Used only for tests. 183 IPC_MESSAGE_ROUTED1(WidgetMsg_WaitForNextFrameForTests, 184 int /* main_frame_thread_observer_routing_id */) 185 186 // 187 // Renderer -> Browser Messages. 188 // 189 190 // Sent by the renderer process to request that the browser close the widget. 191 // This corresponds to the window.close() API, and the browser may ignore 192 // this message. Otherwise, the browser will generate a WidgetMsg_Close 193 // message to close the widget. 194 IPC_MESSAGE_ROUTED0(WidgetHostMsg_Close) 195 196 // Notification that the selection bounds have changed. 197 IPC_MESSAGE_ROUTED1(WidgetHostMsg_SelectionBoundsChanged, 198 WidgetHostMsg_SelectionBounds_Params) 199 200 // Sent in response to a WidgetMsg_UpdateScreenRects so that the renderer can 201 // throttle these messages. 202 IPC_MESSAGE_ROUTED0(WidgetHostMsg_UpdateScreenRects_ACK) 203 204 // Only used for SVGs inside of <object> and not for iframes. Informs the 205 // browser that hte current frame's intrinsic sizing info has changed. The 206 // browser can then notify a containing frame that the frame may need to 207 // trigger a new layout. 208 // 209 // Also see blink::mojom::RemoteFrame::IntrinsicSizingInfoOfChildChanged. 210 IPC_MESSAGE_ROUTED1(WidgetHostMsg_IntrinsicSizingInfoChanged, 211 blink::WebIntrinsicSizingInfo) 212 213 // Send the tooltip text for the current mouse position to the browser. 214 IPC_MESSAGE_ROUTED2(WidgetHostMsg_SetTooltipText, 215 base::string16 /* tooltip text string */, 216 base::i18n::TextDirection /* text direction hint */) 217 218 // Updates the current cursor to be used by the browser for indicating the 219 // location of a pointing device. 220 IPC_MESSAGE_ROUTED1(WidgetHostMsg_SetCursor, content::WebCursor) 221 222 // Request a non-decelerating synthetic fling animation to be latched on the 223 // scroller at the start point, and whose velocity can be changed over time by 224 // sending multiple AutoscrollFling gestures. Used for features like 225 // middle-click autoscroll. 226 IPC_MESSAGE_ROUTED1(WidgetHostMsg_AutoscrollStart, gfx::PointF /* start */) 227 IPC_MESSAGE_ROUTED1(WidgetHostMsg_AutoscrollFling, 228 gfx::Vector2dF /* velocity */) 229 IPC_MESSAGE_ROUTED0(WidgetHostMsg_AutoscrollEnd) 230 231 // Notifies the browser if the text input state has changed. Primarily useful 232 // for IME as they need to know of all changes to update their interpretation 233 // of the characters that have been input. 234 IPC_MESSAGE_ROUTED1(WidgetHostMsg_TextInputStateChanged, 235 content::TextInputState /* text_input_state */) 236 237 // Sent by the renderer process to request that the browser change the bounds of 238 // the widget. This corresponds to the window.resizeTo() and window.moveTo() 239 // APIs, and the browser may ignore this message. 240 IPC_MESSAGE_ROUTED1(WidgetHostMsg_RequestSetBounds, gfx::Rect /* bounds */) 241 242 // Sent by the renderer process in response to an earlier WidgetMsg_ForceRedraw 243 // message. The reply includes the snapshot-id from the request. 244 IPC_MESSAGE_ROUTED1(WidgetHostMsg_ForceRedrawComplete, int /* snapshot_id */) 245 246 // Sends a set of queued messages that were being held until the next 247 // CompositorFrame is being submitted from the renderer. These messages are 248 // sent before the OnRenderFrameMetadataChanged message is sent (via mojo) and 249 // before the CompositorFrame is sent to the viz service. The |frame_token| 250 // will match the token in the about-to-be-submitted CompositorFrame. 251 IPC_MESSAGE_ROUTED2(WidgetHostMsg_FrameSwapMessages, 252 uint32_t /* frame_token */, 253 std::vector<IPC::Message> /* messages */) 254 255 // Indicates that the render widget has been closed in response to a 256 // Close message. 257 IPC_MESSAGE_CONTROL1(WidgetHostMsg_Close_ACK, int /* old_route_id */) 258 259 // Sent in reply to WidgetMsg_WaitForNextFrameForTests. 260 IPC_MESSAGE_ROUTED0(WidgetHostMsg_WaitForNextFrameForTests_ACK) 261 262 // Sent once a paint happens after the first non empty layout. In other words, 263 // after the frame widget has painted something. 264 IPC_MESSAGE_ROUTED0(WidgetHostMsg_DidFirstVisuallyNonEmptyPaint) 265 266 // Notifies whether there are JavaScript touch event handlers or not. 267 IPC_MESSAGE_ROUTED1(WidgetHostMsg_HasTouchEventHandlers, 268 bool /* has_handlers */) 269 270 // Sent by a widget to the browser to request a page scale animation in the 271 // main-frame's widget. 272 IPC_MESSAGE_ROUTED2(WidgetHostMsg_AnimateDoubleTapZoomInMainFrame, 273 gfx::Point /* tap point */, 274 gfx::Rect /* rect_to_zoom */) 275 276 // Sent by a widget to the browser to request a page scale animation in the 277 // main-frame's widget for find-in-page zoom. 278 IPC_MESSAGE_ROUTED1(WidgetHostMsg_ZoomToFindInPageRectInMainFrame, 279 gfx::Rect /* rect_to_zoom */) 280 281 #endif // CONTENT_COMMON_WIDGET_MESSAGES_H_ 282