naiveproxy/content/common/render_widget_host_ns_view.mojom
2018-08-14 22:19:20 +00:00

232 lines
8.5 KiB
Plaintext

// 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/ui/public/interfaces/ime/ime.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,
content.mojom.WebPopupType popup_type);
// 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.
DisableDisplay();
// Make the NSView be the first responder of its NSWindow.
MakeFirstResponder();
// 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.
CancelComposition();
// 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.
ShowDictionaryOverlayForSelection();
// 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.
UnlockKeyboard();
};
// 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).
// https://crbug.com/821651
interface RenderWidgetHostNSViewClient {
// Synchronously query if there exists a RenderViewHost for the corresponding
// RenderWidgetHostView's RenderWidgetHost, and return the result as
// |is_render_view|.
[Sync]
SyncIsRenderViewHost() => (bool is_render_view);
// Request that the RenderWidgetHost be shut down (e.g, when a date/time
// picker window is closed).
RequestShutdown();
// 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.
OnBoundsInWindowChanged(
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).
OnWindowFrameInScreenChanged(
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.
BeginKeyboardEvent();
EndKeyboardEvent();
// Forward a keyboard event to the RenderWidgetHost that is currently handling
// the key-down event.
ForwardKeyboardEvent(Event event, bool skip_in_browser);
ForwardKeyboardEventWithCommands(
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.
ImeSetComposition(
mojo_base.mojom.String16 text,
array<ui.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);
ImeFinishComposingText();
// Note that the function name ImeCancelComposition would conflict with a
// method in RenderWidgetHostViewBase.
ImeCancelCompositionFromCocoa();
// 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.
[Sync]
SyncGetCharacterIndexAtPoint(
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.
[Sync]
SyncGetFirstRectForRange(
gfx.mojom.Range
requested_range,
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);
Undo();
Redo();
Cut();
Copy();
CopyToFindPboard();
Paste();
PasteAndMatchStyle();
SelectAll();
// Speak the selected text of the appropriate RenderWidgetHostView using
// TextServicesContextMenu.
StartSpeaking();
// Stop speaking using TextServicesContextMenu.
StopSpeaking();
// Synchronously query if TextServicesContextMenu is currently speaking and
// return the result as |is_speaking|.
[Sync]
SyncIsSpeaking() => (bool is_speaking);
};