[M108 Migration][Text Selection] Selection handles & Caret Selection
[platform/framework/web/chromium-efl.git] / third_party / blink / public / mojom / context_menu / context_menu.mojom
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 module blink.mojom;
6
7 import "mojo/public/mojom/base/string16.mojom";
8 import "services/network/public/mojom/referrer_policy.mojom";
9 import "third_party/blink/public/mojom/conversions/conversions.mojom";
10 import "ui/base/mojom/ui_base_types.mojom";
11 import "ui/gfx/geometry/mojom/geometry.mojom";
12 import "url/mojom/url.mojom";
13
14 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blink_public.common
15 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ContextMenuDataMediaType
16 enum ContextMenuDataMediaType {
17   // No special node is in context.
18   kNone,
19
20   // An image node is selected.
21   kImage,
22
23   // A video node is selected.
24   kVideo,
25
26   // An audio node is selected.
27   kAudio,
28
29   // A canvas node is selected.
30   kCanvas,
31
32   // A file node is selected.
33   kFile,
34
35   // A plugin node is selected.
36   kPlugin,
37 };
38
39 enum ContextMenuDataInputFieldType {
40   // Not an input field.
41   kNone,
42
43   // type = text, search, email, url
44   kPlainText,
45
46   // type = password
47   kPassword,
48
49   // type = number
50   kNumber,
51
52   // type = tel
53   kTelephone,
54
55   // type = <etc.>
56   kOther,
57 };
58
59 enum CustomContextMenuItemType {
60   kOption,
61   kCheckableOption,
62   kGroup,
63   kSeparator,
64   kSubMenu
65 };
66
67 // Container for information about the form renderer id from where the context
68 // menu was triggered.
69 // autofill::FormRendererId
70 struct FormRendererId {
71   uint64 id;
72 };
73
74 // Container for information about the field renderer id where the context menu
75 // was triggered.
76 // autofill::FieldRendererId
77 struct FieldRendererId {
78   uint64 id;
79 };
80
81 // Container for information about entries in an HTML select popup menu and
82 // custom entries of the context menu.
83 // TODO(crbug.com/1093904): Consider merging the MenuItem struct in
84 // popup_menu.mojom.
85 struct CustomContextMenuItem {
86   mojo_base.mojom.String16 label;
87   mojo_base.mojom.String16 icon;
88   mojo_base.mojom.String16 tool_tip;
89   CustomContextMenuItemType type;
90   int32 action;
91   bool rtl;
92   bool has_directional_override;
93   bool enabled;
94   bool checked;
95   array<CustomContextMenuItem> submenu;
96 };
97
98 // Mojo struct to represent blink::UntrustworthyContextMenuParams native struct.
99 struct UntrustworthyContextMenuParams {
100   // This is the type of Context Node that the context menu was invoked on.
101   ContextMenuDataMediaType media_type;
102
103   // These values represent the coordinates of the mouse when the context menu
104   // was invoked.  Coords are relative to the associated RenderView's origin.
105   int32 x;
106   int32 y;
107
108   // This is the URL of the link that encloses the node the context menu was
109   // invoked on.
110   url.mojom.Url link_url;
111
112   // The text associated with the link. May be an empty string if the contents
113   // of the link are an image.
114   // Will be empty if |link_url| is empty.
115   mojo_base.mojom.String16 link_text;
116
117   // The impression declared by the link. May be absl::nullopt even if
118   // |link_url| is non-empty.
119   Impression? impression;
120
121   // The link URL to be used ONLY for "copy link address". We don't validate
122   // this field in the frontend process.
123   url.mojom.Url unfiltered_link_url;
124
125   // This is the source URL for the element that the context menu was
126   // invoked on. Example of elements with source URLs are img, audio, and
127   // video.
128   url.mojom.Url src_url;
129
130   // This is true if the context menu was invoked on an image which has
131   // non-empty contents.
132   bool has_image_contents;
133
134   // These are the parameters for the media element that the context menu
135   // was invoked on.
136   int32 media_flags;
137
138   // This is the text of the selection that the context menu was invoked on.
139   mojo_base.mojom.String16 selection_text;
140
141   // This is the title text of the selection that the context menu was
142   // invoked on.
143   mojo_base.mojom.String16 title_text;
144
145   // This is the alt text of the selection that the context menu was
146   // invoked on.
147   mojo_base.mojom.String16 alt_text;
148
149   // This is the suggested filename to be used when saving file through "Save
150   // Link As" option of context menu.
151   mojo_base.mojom.String16 suggested_filename;
152
153   // The misspelled word under the cursor, if any. Used to generate the
154   // |dictionary_suggestions| list.
155   mojo_base.mojom.String16 misspelled_word;
156
157   // Suggested replacements for a misspelled word under the cursor.
158   // This vector gets populated in the render process host
159   // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
160   // and populating dictionary_suggestions if the type is EDITABLE
161   // and the misspelled_word is not empty.
162   array<mojo_base.mojom.String16> dictionary_suggestions;
163
164   // If editable, flag for whether spell check is enabled or not.
165   bool spellcheck_enabled;
166
167   // Whether context is editable.
168   bool is_editable;
169
170   // Whether element is text
171   [EnableIf=is_efl]
172   bool is_text_node;
173
174   // Writing direction menu items.
175   int32 writing_direction_default;
176   int32 writing_direction_left_to_right;
177   int32 writing_direction_right_to_left;
178
179   // These flags indicate to the browser whether the renderer believes it is
180   // able to perform the corresponding action.
181   int32 edit_flags;
182
183   // The character encoding of the frame on which the menu is invoked.
184   string frame_charset;
185
186   // The referrer policy of the frame on which the menu is invoked.
187   network.mojom.ReferrerPolicy referrer_policy;
188
189   // If the context menu was created for a link, and we navigated to that url,
190   // this will contain the url that was navigated. This field may not be set
191   // if, for example, we are transitioning to an incognito window, since we
192   // want to sever any connection to the old renderer.
193   url.mojom.Url link_followed;
194
195   array<CustomContextMenuItem> custom_items;
196
197   ui.mojom.MenuSourceType source_type;
198
199   // If this node is an input field, the type of that field.
200   ContextMenuDataInputFieldType input_field_type;
201
202   // Rect representing the coordinates in the document space of the selection.
203   gfx.mojom.Rect selection_rect;
204
205   // Start position of the selection text.
206   int32 selection_start_offset;
207
208   // Whether the context contains text highlighted by a text fragment.
209   // See TextFragmentAnchor.
210   bool opened_from_highlight;
211
212   // The renderer id of the form that contains the input or textarea field.
213   // Not set if the initiating field is not an input or textarea field.
214   FormRendererId? form_renderer_id;
215
216   // The renderer id of the input or textarea field from where the context menu
217   // is opened. Not set if it is not an input or text area field.
218   FieldRendererId? field_renderer_id;
219 };
220
221 // Defines methods for Context menu to commnicate from the renderer to the
222 // browser.
223 interface ContextMenuClient {
224   // Executes custom context menu action that was provided from Blink.
225   CustomContextMenuAction(uint32 action);
226
227   // Called in response to a blink.mojom.ShowContextMenu to let the renderer
228   // know that the menu has been closed.
229   ContextMenuClosed(url.mojom.Url link_followed);
230 };