1// Copyright 2020 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 5module blink.mojom; 6 7import "cc/mojom/render_frame_metadata.mojom"; 8import "cc/mojom/touch_action.mojom"; 9import "mojo/public/mojom/base/string16.mojom"; 10import "mojo/public/mojom/base/text_direction.mojom"; 11import "mojo/public/mojom/base/time.mojom"; 12import "services/viz/public/mojom/compositing/compositor_frame_sink.mojom"; 13import "services/viz/public/mojom/compositing/local_surface_id.mojom"; 14import "services/viz/public/mojom/hit_test/input_target_client.mojom"; 15import "skia/public/mojom/bitmap.mojom"; 16import "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom"; 17import "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom"; 18import "third_party/blink/public/mojom/input/input_handler.mojom"; 19import "third_party/blink/public/mojom/input/touch_event.mojom"; 20import "third_party/blink/public/mojom/page/drag.mojom"; 21import "third_party/blink/public/mojom/page/record_content_to_visible_time_request.mojom"; 22import "third_party/blink/public/mojom/widget/device_emulation_params.mojom"; 23import "third_party/blink/public/mojom/widget/visual_properties.mojom"; 24import "ui/base/mojom/ui_base_types.mojom"; 25import "ui/base/ime/mojom/text_input_state.mojom"; 26import "ui/base/cursor/mojom/cursor.mojom"; 27import "ui/gfx/geometry/mojom/geometry.mojom"; 28 29[EnableIf=is_mac] 30import "ui/base/mojom/attributed_string.mojom"; 31 32// Implemented in Blink, this interface defines frame-widget-specific methods that 33// will be invoked from the browser process (e.g. blink::WebFrameWidget). 34interface FrameWidget { 35 // Drag-and-drop methods: 36 // |point_in_viewport| is the position of the drag event in the viewport 37 // coordinates. 38 // |screen_point| is the absolute position of the mouse pointer. 39 // |key_modifiers| the event/keyboard modifiers that are active during the 40 // operation. See WebInputEvent::Modifiers. 41 42 // Notifies the Widget of a drag enter operation. |drag_data| only 43 // contains a subset of the actual drag data the browser has and it 44 // used to only start the drag action. Once the item is dropped |drag_data| 45 // will be provided with the complete data. Once the renderer has 46 // completed processing the event the callback is called with the type of 47 // the current drag operation that is active and the browser will update 48 // the mouse cursor displayed to the user. 49 DragTargetDragEnter(DragData drag_data, 50 gfx.mojom.PointF point_in_viewport, 51 gfx.mojom.PointF screen_point, 52 AllowedDragOperations operations_allowed, 53 uint32 key_modifiers) 54 => (DragOperation operation); 55 56 // Notifies the Widget of a drag over operation. Once the renderer has 57 // completed processing the event the callback is called with the type of 58 // the current drag operation that is active and the browser will update 59 // the mouse cursor displayed to the user. 60 DragTargetDragOver(gfx.mojom.PointF point_in_viewport, 61 gfx.mojom.PointF screen_point, 62 AllowedDragOperations operations_allowed, 63 uint32 key_modifiers) 64 => (DragOperation operation); 65 66 // Notifies the Widget of a drag leave operation. 67 DragTargetDragLeave(gfx.mojom.PointF point_in_viewport, 68 gfx.mojom.PointF screen_point); 69 70 // Notifies the Widget of a drag drop operation. 71 DragTargetDrop(DragData drag_data, 72 gfx.mojom.PointF point_in_viewport, 73 gfx.mojom.PointF screen_point, 74 uint32 key_modifiers); 75 76 // Notifies the Widget that a drag has terminated. 77 DragSourceEndedAt(gfx.mojom.PointF point_in_viewport, 78 gfx.mojom.PointF screen_point, 79 DragOperation drag_operation); 80 81 // Notifies the Widget that the system drag and drop operation has ended. 82 DragSourceSystemDragEnded(); 83 84 // Makes the Widget background transparent or opaque. 85 SetBackgroundOpaque(bool opaque); 86 87 // Changes the text direction of the currently selected input field (if any). 88 SetTextDirection(mojo_base.mojom.TextDirection direction); 89 90 // Activate/deactivate the Widget. 91 // Focused window is the window that receives keyboard input. 92 // The focused window is always or is always contained by the Active window. 93 // Active window is the one that contains the focused element. 94 // https://www.chromium.org/developers/design-documents/aura/focus-and-activation 95 SetActive(bool active); 96 97 // Only valid for sub frame local roots. 98 // 99 // Sets the inherited effective touch action on an out-of-process iframe. 100 SetInheritedEffectiveTouchActionForSubFrame(cc.mojom.TouchAction touch_action); 101 102 // Toggles render throttling for an out-of-process iframe. 103 UpdateRenderThrottlingStatusForSubFrame(bool is_throttled, bool subtree_throttled); 104 105 // When the browser receives a call to RenderFrameProxyHost::SetIsInert 106 // from the parent widget's embedding renderer changing its inertness, 107 // it sets the same inertness value to the renderer of the child subframe. 108 // When a widget is inert, it is unable to process input events. 109 // https://html.spec.whatwg.org/multipage/interaction.html#inert 110 SetIsInertForSubFrame(bool inert); 111 112 // Requests the word under the given point relative to the origin of the 113 // widget and its baseline point. 114 [EnableIf=is_mac] 115 GetStringAtPoint(gfx.mojom.Point point_in_local_root) 116 => (ui.mojom.AttributedString? string, gfx.mojom.Point baseline_point); 117 118 // Sent to inform the renderer to invoke a context menu. 119 // The parameter specifies the location in the render widget's coordinates. 120 ShowContextMenu( 121 ui.mojom.MenuSourceType source_type, gfx.mojom.Point location); 122 123 // Enables device emulator. 124 EnableDeviceEmulation(DeviceEmulationParams parameters); 125 126 // Disables device emulator. 127 DisableDeviceEmulation(); 128 129 // Binds an WidgetCompositor interface. 130 BindWidgetCompositor(pending_receiver<WidgetCompositor> host); 131 132 // Binds an InputTargetClient interface. 133 BindInputTargetClient(pending_receiver<viz.mojom.InputTargetClient> host); 134 135 // Sent by a parent frame to notify its child about the state of the child's 136 // intersection with the parent's viewport, primarily for use by the 137 // IntersectionObserver API. Also see 'UpdateViewportIntersection' in 138 // third_party/blink/public/mojom/frame/viewport_intersection_state.mojom 139 SetViewportIntersection(ViewportIntersectionState intersection_state); 140}; 141 142// Implemented in Browser, this interface defines frame-widget-specific methods that 143// will be invoked from the render process (e.g. content::RenderWidgetHostImpl). 144interface FrameWidgetHost { 145 // Sent by a widget to the browser to request a page scale animation in the 146 // main-frame's widget. 147 AnimateDoubleTapZoomInMainFrame( 148 gfx.mojom.Point tap_point, 149 gfx.mojom.Rect rect_to_zoom); 150 151 // Sent by a widget to the browser to request a page scale animation in the 152 // main-frame's widget for find-in-page zoom. 153 ZoomToFindInPageRectInMainFrame(gfx.mojom.Rect rect_to_zoom); 154 155 // Notifies what type of touch event consumers, if any, exist in the renderer, 156 // e.g. JavaScript touch event handlers or hit testable scrollbars. 157 SetHasTouchEventConsumers(TouchEventConsumers touch_event_consumers); 158 159 // Sent by a widget to the browser to be used for SVGs inside of <object> and 160 // not for iframes. Informs the browser that the current frame's intrinsic 161 // sizing info has changed. The browser can then notify a containing frame 162 // that the frame may need to trigger a new layout. 163 // 164 // Also see blink::mojom::RemoteFrame::IntrinsicSizingInfoOfChildChanged. 165 IntrinsicSizingInfoChanged(IntrinsicSizingInfo sizing_info); 166 167 // Requests a non-decelerating synthetic fling animation to be latched on the 168 // scroller at the start point, and whose velocity can be changed over time by 169 // sending multiple AutoscrollFling gestures. Used for features like 170 // middle-click autoscroll. 171 // 172 // Sent by a widget to the browser to notify the start point for the 173 // autoscroll. 174 AutoscrollStart(gfx.mojom.PointF position); 175 176 // Sent by a widget to the browser to notify the velocity for the autoscroll 177 // fling animation. 178 AutoscrollFling(gfx.mojom.Vector2dF velocity); 179 180 // Sent by a widget to the browser to notify the end of the autoscroll. 181 AutoscrollEnd(); 182 183 // Sent once a paint happens after the first non empty layout. In other words, 184 // after the frame widget has painted something. 185 DidFirstVisuallyNonEmptyPaint(); 186 187 // Used to tell the browser the user started dragging in the content area. 188 // |drag_data| contains contextual information about the pieces of the page 189 // the user dragged. The browser uses this notification to initiate a drag 190 // session at the OS level. 191 StartDragging(DragData drag_data, 192 AllowedDragOperations operations_allowed, 193 skia.mojom.Bitmap? image, 194 gfx.mojom.Vector2d bitmap_offset_in_dip, 195 DragEventSourceInfo event_info); 196}; 197 198// Implemented in Blink, this interface defines widget-specific methods that 199// will be invoked from the browser process (e.g. blink::WebWidget). 200interface Widget { 201 // Sent by the browser to ask the renderer to redraw. Robust to events that 202 // can happen in renderer (abortion of the commit or draw, loss of output 203 // surface etc.). 204 ForceRedraw() => (); 205 206 // Setup the input channel for this widget. If the widget is a frame, 207 // then it can also obtain a FrameWidgetInputHandler from the 208 // WidgetInputHandler interface. 209 GetWidgetInputHandler( 210 pending_receiver<blink.mojom.WidgetInputHandler> request, 211 pending_remote<blink.mojom.WidgetInputHandlerHost> host); 212 213 // Update the visual properties of the widget. 214 UpdateVisualProperties(VisualProperties visual_properties); 215 216 // Informs the widget of its position on the user's screen, as well as 217 // the position of the native window holding the widget. 218 // TODO(danakj): These should be part of UpdateVisualProperties. 219 UpdateScreenRects(gfx.mojom.Rect widget_screen_rect, 220 gfx.mojom.Rect window_screen_rect) => (); 221 222 223 // Informs the widget that it was hidden. This allows it to reduce its 224 // resource utilization. 225 WasHidden(); 226 227 // Tells the render view that it is no longer hidden (see WasHidden). 228 WasShown(mojo_base.mojom.TimeTicks show_request_timestamp, 229 bool was_evicted, 230 RecordContentToVisibleTimeRequest? record_tab_switch_time_request); 231}; 232 233// Implemented in Browser, this interface defines widget-specific methods that 234// will be invoked from the render process (e.g. content::RenderWidgetHostImpl). 235interface WidgetHost { 236 // Updates the current cursor to be used by the browser for indicating the 237 // location of a pointing device. 238 SetCursor(ui.mojom.Cursor cursor); 239 240 // Sent by a widget to the browser to set the tooltip text for the current 241 // mouse position. An empty |tooltip_text| will hide the tooltip view. 242 SetToolTipText(mojo_base.mojom.String16 tooltip_text, 243 mojo_base.mojom.TextDirection text_direction_hint); 244 245 // Sent when the text input state is changed. This usually happens when 246 // a text input entry is focused. 247 TextInputStateChanged(ui.mojom.TextInputState state); 248 249 // Sent when the current selection bounds are changed. 250 SelectionBoundsChanged(gfx.mojom.Rect anchor_rect, 251 mojo_base.mojom.TextDirection anchor_dir, 252 gfx.mojom.Rect focus_rect, 253 mojo_base.mojom.TextDirection focus_dir, 254 bool is_anchor_first); 255 256 // Create a CompositorFrameSink that is associated with this widget. 257 // The renderer compositor will use the returned sink to submit 258 // CompositorFrames for this widget. 259 CreateFrameSink( 260 pending_receiver<viz.mojom.CompositorFrameSink> 261 compositor_frame_sink_receiver, 262 pending_remote<viz.mojom.CompositorFrameSinkClient> 263 compositor_frame_sink_client); 264 265 // Register compositor RenderFrameMetadataObserver and client. 266 // This call will be made in conjunction with calling CreateFrameSink. 267 // The renderer compositor will invoke the RenderFrameMetadataObserver 268 // apis when it produces a frame that changes the metadata. 269 RegisterRenderFrameMetadataObserver( 270 pending_receiver<cc.mojom.RenderFrameMetadataObserverClient> 271 render_frame_metadata_observer_client_receiver, 272 pending_remote<cc.mojom.RenderFrameMetadataObserver> 273 render_frame_metadata_observer); 274}; 275 276// This interface is bound on the compositor thread. 277interface WidgetCompositor { 278 // Requests that the RenderWidget sends back a response after the next main 279 // frame is generated and presented in the display compositor. 280 VisualStateRequest() => (); 281}; 282 283// Implemented in Browser, this interface defines popup-widget-specific methods 284// that will be invoked from the render process (e.g. RenderWidgetHostImpl). 285// Popup widgets in the renderer are owned by the PopupWidgetHost in the browser 286// process, so the PopupWidgetHost channel disconnecting indicates that the 287// widget in the renderer should be destroyed. 288interface PopupWidgetHost { 289 // Request that this popup be dismissed. 290 RequestClosePopup(); 291 292 // Request the popup be shown. 293 ShowPopup(gfx.mojom.Rect initial_rect) => (); 294 295 // Request that the browser change the bounds of the widget. 296 SetPopupBounds(gfx.mojom.Rect bounds) => (); 297}; 298