1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
content / common / render_widget_host_ns_view.mojom [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module remote_cocoa.mojom;
import "mojo/public/mojom/base/process_id.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "third_party/blink/public/mojom/choosers/popup_menu.mojom";
import "third_party/blink/public/mojom/input/input_handler.mojom";
import "third_party/blink/public/mojom/webshare/share_error.mojom";
import "ui/base/cursor/mojom/cursor.mojom";
import "ui/base/ime/mojom/ime_types.mojom";
import "ui/base/mojom/attributed_string.mojom";
import "ui/display/mojom/screen_infos.mojom";
import "ui/events/mojom/event.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/ca_layer_params.mojom";
import "ui/gfx/range/mojom/range.mojom";
// Interface that lets the browser process hide/close a popup menu in a
// remote cocoa process, for menus displayed by DisplayPopupMenu().
interface PopupMenuRunner {
// Hide the associated popup menu.
Hide();
};
// Struct to encapsulate all the parameters to a DisplayPopupMenu() call.
// Passed from the browser process to remote cocoa processes, but most of
// the fields are passed unmodified from a renderer process.
struct PopupMenu {
array<blink.mojom.MenuItem> items;
gfx.mojom.Rect bounds;
double item_font_size;
bool right_aligned;
uint32 selected_item;
pending_receiver<PopupMenuRunner> receiver;
};
// 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 RenderWidgetHostNSView {
// Specify that the NSView will a popup (e.g, date/time picker) that will
// create its own NSWindow.
InitAsPopup(gfx.mojom.Rect content_rect, uint64 popup_parent_ns_view_id);
// 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.
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 content::TextInputState.
SetTextInputState(ui.mojom.TextInputType text_input_type, uint32 flags);
// 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(ui.mojom.Cursor cursor);
// Lock or unlock the cursor.
SetCursorLocked(bool locked);
// Set whether unaccelerated (unadjusted) mouse move events are
// generated while the cursor is locked.
SetCursorLockedUnacceleratedMovement(bool unaccelerated_movement);
// 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(ui.mojom.AttributedString 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();
// Show the NSSharingServicePicker using the requested data that is passed and
// returning the result of that action.
ShowSharingServicePicker(string title,
string text,
string url,
array<string> file_paths)
=> (blink.mojom.ShareError error);
// TODO(crbug.com/40226213): This is a work around for a bug in mojo
// where close notifications for associated messages pipes can sometimes be
// delivered later than they should. This method is called before closing the
// remote, and is treated as if a close notification was received.
Destroy();
// Ack gesture scroll event from the renderer.
GestureScrollEventAck(blink.mojom.Event event, bool consumed);
// Ack overscroll message from the renderer.
DidOverscroll(blink.mojom.DidOverscrollParams params);
// Shows a HTML select popup menu. The callback is called with the index of
// the selected item, or nullopt if the menu closed without selecting any
// items.
DisplayPopupMenu(PopupMenu menu) => (uint32? selected_item);
};
// 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::RenderWidgetHostNSViewHost 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 RenderWidgetHostNSViewHost {
// Synchronously query if the RenderWidgetHostView is for a main frame, and
// return the result as |is_for_main_frame|.
[Sync]
SyncIsWidgetForMainFrame() => (bool is_for_main_frame);
// 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 NSScreen hosting the NSView, or other NSScreens.
OnScreenInfosChanged(display.mojom.ScreenInfos screen_infos);
// 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.
ForwardKeyboardEventWithCommands(
blink.mojom.Event event,
array<uint8> native_event_data,
bool skip_if_unhandled,
array<blink.mojom.EditCommand> commands);
// Forward events to the renderer or the input router, as appropriate.
RouteOrProcessMouseEvent(blink.mojom.Event event);
RouteOrProcessTouchEvent(blink.mojom.Event event);
RouteOrProcessWheelEvent(blink.mojom.Event event);
// Special case forwarding of synthetic events to the renderer.
ForwardMouseEvent(blink.mojom.Event event);
ForwardWheelEvent(blink.mojom.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(blink.mojom.Event event, bool is_synthetically_injected);
GestureUpdate(blink.mojom.Event event);
GestureEnd(blink.mojom.Event event);
// Handle a double-tap magnify event.
SmartMagnify(blink.mojom.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 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();
CenterSelection();
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);
// 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.
[Sync]
GetRenderWidgetAccessibilityToken() =>
(mojo_base.mojom.ProcessId host_pid, array<uint8> element_token);
// Send the token for the NSWindow in which this NSView is being displayed.
SetRemoteAccessibilityWindowToken(array<uint8> window_token);
};