blob: 0dbe01404641ef84936598826351460a9fa9a8eb [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
import "content/common/native_types.mojom";
import "content/common/input/input_handler.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "services/ws/public/mojom/ime/ime.mojom";
import "ui/base/ime/mojo/ime_types.mojom";
import "ui/display/mojo/display.mojom";
import "ui/events/mojo/event.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/mojo/ca_layer_params.mojom";
import "ui/gfx/range/mojo/range.mojom";
import "ui/platform_window/mojo/text_input_state.mojom";
// The interface through which code in the browser process, in
// RenderWidgetHostViewMac, sends messages to the app shim process, targeting
// the RenderWidgetHostViewCocoa NSView. No synchronous communication is allowed
// in this direction.
interface RenderWidgetHostNSViewBridge {
// Specify that the NSView will a popup (e.g, date/time picker) that will
// create its own NSWindow.
InitAsPopup(gfx.mojom.Rect content_rect);
// Set this to be a child NSView of the NSView mapped to by
// |parent_ns_view_id|.
SetParentWebContentsNSView(uint64 parent_ns_view_id);
// Disable displaying any content (including the background color). This is
// to be called on views that are to be displayed via a parent ui::Compositor.
// Make the NSView be the first responder of its NSWindow.
// Set the bounds of the NSView or its enclosing NSWindow (depending on the
// window type).
SetBounds(gfx.mojom.Rect rect);
// Set the contents to display in the NSView.
SetCALayerParams(gfx.mojom.CALayerParams ca_layer_params);
// Set the background SkColor color of the hosted CALayer.
SetBackgroundColor(uint32 color);
// Call the -[NSView setHidden:] method.
SetVisible(bool visible);
// Call the -[NSView setToolTipAtMousePoint] method.
SetTooltipText(mojo_base.mojom.String16 display_text);
// Forward changes in ui::TextInputType.
SetTextInputType(ui.mojom.TextInputType text_input_type);
// Forward the TextInputManager::TextSelection from the renderer.
SetTextSelection(mojo_base.mojom.String16 text,
uint64 offset,
gfx.mojom.Range range);
// Forward the TextInputManager::CompositionRangeInfo from the renderer.
SetCompositionRangeInfo(gfx.mojom.Range range);
// Clear the marked range.
// Indicate if the WebContext is showing a context menu or not.
SetShowingContextMenu(bool showing);
// Set the cursor type to display.
DisplayCursor(WebCursor cursor);
// Lock or unlock the cursor.
SetCursorLocked(bool locked);
// Open the dictionary overlay for the currently selected string. This
// will roundtrip to the NSView to determine the selected range.
// Open the dictionary overlay for the specified string at the specified
// point.
ShowDictionaryOverlay(EncodedAttributedString attributed_string,
gfx.mojom.Point baseline_point);
// Start intercepting keyboard events for the specified codes.
LockKeyboard(array<uint32>? dom_codes);
// Stop intercepting keyboard events.
// The interface through which the RenderWidgetHostViewCocoa NSView in the app
// shim process communicates to the RenderWidgetHostViewMac in the browser
// process. Synchronous calls are allowed to be made through this interface.
// TODO(ccameron): This corresponds almost one-to-one with the
// content::RenderWidgetHostNSViewClient interface. It may be possible to merge
// these two interfaces, though that may come at the cost of extra work (e.g,
// de-serializing and re-serializing all events).
interface RenderWidgetHostNSViewClient {
// Synchronously query if the RenderWidgetHostView is for a main frame, and
// return the result as |is_for_main_frame|.
SyncIsWidgetForMainFrame() => (bool is_for_main_frame);
// Request that the RenderWidgetHost be shut down (e.g, when a date/time
// picker window is closed).
// Indicates whether or not the NSView is its NSWindow's first responder.
OnFirstResponderChanged(bool is_first_responder);
// Indicates whether or not the NSView is its NSWindow's first responder.
OnWindowIsKeyChanged(bool is_key);
// Indicates whether or not the NSView's NSWindow is key.
gfx.mojom.Rect view_bounds_in_window_dip,
bool attached_to_window);
// Indicates the NSView's bounds in its NSWindow's DIP coordinate system (with
// the origin at the upper-left corner), and indicate if the the NSView is
// attached to an NSWindow (if it is not, then |view_bounds_in_window_dip|'s
// origin is meaningless, but its size is still relevant).
gfx.mojom.Rect window_frame_in_screen_dip);
// Indicate changes to the NSView's NSScreen's properties.
OnDisplayChanged(display.mojom.Display display);
// Indicate the begin and end block of a keyboard event. The beginning of this
// block will record the active RenderWidgetHost, and will forward all
// remaining keyboard and Ime messages to that RenderWidgetHost.
// Forward a keyboard event to the RenderWidgetHost that is currently handling
// the key-down event.
ForwardKeyboardEvent(Event event, bool skip_in_browser);
Event event,
bool skip_in_browser,
array<content.mojom.EditCommand> commands);
// Forward events to the renderer or the input router, as appropriate.
RouteOrProcessMouseEvent(Event event);
RouteOrProcessTouchEvent(Event event);
RouteOrProcessWheelEvent(Event event);
// Special case forwarding of synthetic events to the renderer.
ForwardMouseEvent(Event event);
ForwardWheelEvent(Event event);
// Handling pinch gesture events. Note that for GestureBegin, the type of the
// event is ignored, and is inferred from subsequent GestureUpdate calls.
GestureBegin(Event event, bool is_synthetically_injected);
GestureUpdate(Event event);
GestureEnd(Event event);
// Handle a double-tap magnify event.
SmartMagnify(Event event);
// Forward the corresponding Ime commands to the appropriate RenderWidgetHost.
// Appropriate, has two meanings here. If this is during a key-down event,
// then the target is the RWH that is handling that key-down event. Otherwise,
// it is the result of GetActiveWidget.
mojo_base.mojom.String16 text,
array<ws.mojom.ImeTextSpan> ime_text_spans,
gfx.mojom.Range replacement_range,
int32 selection_start,
int32 selection_end);
ImeCommitText(mojo_base.mojom.String16 text,
gfx.mojom.Range replacement_range);
// Note that the function name ImeCancelComposition would conflict with a
// method in RenderWidgetHostViewBase.
// Request an overlay dictionary be displayed for the text at the specified
// point.
LookUpDictionaryOverlayAtPoint(gfx.mojom.PointF root_point);
// Request an overlay dictionary be displayed for the text in the the
// specified character range.
LookUpDictionaryOverlayFromRange(gfx.mojom.Range range);
// Synchronously query the character index for |root_point|. Return UINT32_MAX
// if the request fails or is not completed.
gfx.mojom.PointF root_point) => (uint32 index);
// Synchronously query the composition character boundary rectangle and return
// it as |out_rect|. Return |out_actual_range| as the range actually used for
// the returned rectangle. If there was no focused RenderWidgetHost to query,
// then return |success| as false.
gfx.mojom.Rect rect,
gfx.mojom.Range actual_range) =>
(gfx.mojom.Rect out_rect,
gfx.mojom.Range out_actual_range,
bool success);
// Forward the corresponding edit menu command to the RenderWidgetHost's
// delegate.
ExecuteEditCommand(string command);
// Speak the selected text of the appropriate RenderWidgetHostView using
// TextServicesContextMenu.
// Stop speaking using TextServicesContextMenu.
// Synchronously query if TextServicesContextMenu is currently speaking and
// return the result as |is_speaking|.
SyncIsSpeaking() => (bool is_speaking);
// Return in |element_token| the token for the root content AX node for this
// view and in |host_pid| the pid for the host process.
SyncGetRootAccessibilityElement() =>
(int64 host_pid, array<uint8> element_token);
// Send the token for the NSWindow in which this NSView is being displayed.
SetRemoteAccessibilityWindowToken(array<uint8> window_token);