Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Side by Side Diff: components/mus/public/interfaces/view_tree.mojom

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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
5 module mojo;
6
7 import "components/mus/public/interfaces/compositor_frame.mojom";
8 import "components/mus/public/interfaces/surface_id.mojom";
9 import "components/mus/public/interfaces/mus_constants.mojom";
10 import "mojo/application/public/interfaces/service_provider.mojom";
11 import "network/public/interfaces/url_loader.mojom";
12 import "ui/mojo/events/input_events.mojom";
13 import "ui/mojo/ime/text_input_state.mojom";
14 import "ui/mojo/geometry/geometry.mojom";
15
16 struct ViewportMetrics {
17 Size size_in_pixels;
18 // A value of 0 indicates the real value is not yet available.
19 float device_pixel_ratio = 0.0;
20 };
21
22 struct ViewData {
23 uint32 parent_id;
24 uint32 view_id;
25 mojo.Rect bounds;
26 map<string, array<uint8>> properties;
27 // True if this view is visible. The view may not be drawn on screen (see
28 // drawn for specifics).
29 bool visible;
30 // True if this view is drawn on screen. A view is drawn if attached to the
31 // root and all ancestors (including this view) are visible.
32 bool drawn;
33 ViewportMetrics viewport_metrics;
34 };
35
36 enum ErrorCode {
37 NONE,
38 VALUE_IN_USE,
39 ILLEGAL_ARGUMENT,
40 };
41
42 // Views are identified by a uint32. The upper 16 bits are the connection id,
43 // and the lower 16 the id assigned by the client.
44 //
45 // The root view is identified with a connection id of 0, and value of 1.
46 interface ViewTree {
47 enum AccessPolicy {
48 DEFAULT = 0,
49
50 // An embed root has the following abilities:
51 // . The app sees all the descendants of the view the app is ebmedded at,
52 // even those from separate connections.
53 // . The app is able to Embed() in all the descendants of the view the app
54 // is embedded at, even those from separate connections.
55 // Only connections originating from the ViewTreeHostFactory can grant this
56 // policy.
57 EMBED_ROOT = 1,
58 };
59
60 // Creates a new view with the specified id. It is up to the client to ensure
61 // the id is unique to the connection (the id need not be globally unique).
62 // Additionally the connection id (embedded in |view_id|) must match that of
63 // the connection.
64 // Errors:
65 // ERROR_CODE_VALUE_IN_USE: a view already exists with the specified id.
66 // ERROR_CODE_ILLEGAL_ARGUMENT: The connection part of |view_id| does not
67 // match the connection id of the client.
68 //
69 // TODO(erg): Once we have default values in mojo, make this take a map of
70 // properties.
71 CreateView(uint32 view_id) => (ErrorCode error_code);
72
73 // Deletes a view. This does not recurse. No hierarchy change notifications
74 // are sent as a result of this. Only the connection that created the view can
75 // delete it.
76 DeleteView(uint32 view_id) => (bool success);
77
78 // Sets the specified bounds of the specified view.
79 SetViewBounds(uint32 view_id, mojo.Rect bounds) => (bool success);
80
81 // Sets the client area of the specified window. Areas outside the client
82 // area are treated specially.
83 SetClientArea(uint32 window_id, Rect rect);
84
85 // Sets the visibility of the specified view to |visible|. Connections are
86 // allowed to change the visibility of any view they have created, as well as
87 // any of their roots.
88 SetViewVisibility(uint32 view_id, bool visible) => (bool success);
89
90 // Sets an individual named property. Setting an individual property to null
91 // deletes the property.
92 SetViewProperty(uint32 view_id,
93 string name,
94 array<uint8>? value) => (bool success);
95
96 // Requests a Surface for a particular view.
97 RequestSurface(uint32 view_id, Surface& surface, SurfaceClient client);
98
99 // Reparents a view.
100 // This fails for any of the following reasons:
101 // . |parent| or |child| does not identify a valid view.
102 // . |child| is an ancestor of |parent|.
103 // . |child| is already a child of |parent|.
104 //
105 // This may result in a connection getting OnWindowDeleted(). See
106 // RemoveViewFromParent for details.
107 AddView(uint32 parent, uint32 child) => (bool success);
108
109 // Removes a view from its current parent. This fails if the view is not
110 // valid or the view already has no parent.
111 //
112 // Removing a view from a parent may result in OnWindowDeleted() being sent to
113 // other connections. For example, connection A has views 1 and 2, with 2 a
114 // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets
115 // OnWindowDeleted(). This is done as view 2 is effectively no longer visible to
116 // connection B.
117 RemoveViewFromParent(uint32 view_id) => (bool success);
118
119 // Reorders a view in its parent, relative to |relative_view_id| according to
120 // |direction|.
121 // Only the connection that created the view's parent can reorder its
122 // children.
123 ReorderView(uint32 view_id,
124 uint32 relative_view_id,
125 OrderDirection direction) => (bool success);
126
127 // Returns the views comprising the tree starting at |view_id|. |view_id| is
128 // the first result in the return value, unless |view_id| is invalid, in which
129 // case an empty vector is returned. The views are visited using a depth first
130 // search (pre-order).
131 GetViewTree(uint32 view_id) => (array<ViewData> views);
132
133 // A connection may grant access to another connection by way of Embed().
134 // Embed() results in the supplied ViewTreeClient being configured with a
135 // root view of |view_id|. The supplied ViewTreeClient may create child
136 // views and do other various tree operations (including Embed()), but does
137 // not see nor have access to any of the views above the embed point.
138 //
139 // The caller must have created |view_id|. If not the request fails and the
140 // response is false.
141 //
142 // When a connection embeds a ViewTreeClient the originating connection no
143 // longer has privileges to access or see any of the children of the view. If
144 // the view had existing children the children are removed. The one exception
145 // is the root connection and any connections with the policy
146 // ACCESS_POLICY_EMBED_ROOT.
147 //
148 // A view may only have one embedding in it at a time. Subsequent calls to
149 // Embed() for the same view result in the currently embedded
150 // ViewTreeClient being removed. The embedded app is told this by way of
151 // OnUnembed(), which is followed by OnWindowDeleted() (as the connection no
152 // longer has access to the view).
153 //
154 // The embedder can detect when the embedded app disconnects by way of
155 // OnEmbeddedAppDisconnected().
156 //
157 // The callback returns whether the embedding was successful, and if the
158 // embedding was successful and the originating connection is an embed root
159 // the resulting id of the new connection.
160 //
161 // policy_bitmask is a bitmask of the kAccessPolicy constants. See them for
162 // details.
163 Embed(uint32 view_id,
164 ViewTreeClient client,
165 uint32 policy_bitmask) => (bool success, uint16 connection_id);
166
167 SetFocus(uint32 view_id);
168
169 // Set text input state for the given view.
170 SetViewTextInputState(uint32 view_id, TextInputState state);
171
172 // Set the input method editor UI (software keyboard, etc) visibility.
173 // If state is non-null, the specified view's text input state is updated.
174 // Otherwise the existing state is used.
175 SetImeVisibility(uint32 view_id, bool visible, TextInputState? state);
176 };
177
178 // Changes to views are not sent to the connection that originated the
179 // change. For example, if connection 1 changes the bounds of a view by calling
180 // SetBounds(), connection 1 does not receive OnWindowBoundsChanged().
181 interface ViewTreeClient {
182 // Invoked when the client application has been embedded at |root|.
183 // See Embed() on ViewTree for more details. |tree| will be a handle back to
184 // the view manager service, unless the connection is to the root connection
185 // in which case it will be null.
186 OnEmbed(uint16 connection_id,
187 ViewData root,
188 ViewTree? tree,
189 uint32 focused_view,
190 uint32 access_policy);
191
192 // Invoked when the application embedded at |view| is disconnected. In other
193 // words the embedded app closes the connection to the server. This is called
194 // on the connection that created |view| as well as any ancestors that have
195 // the embed root policy.
196 OnEmbeddedAppDisconnected(uint32 view);
197
198 // Sent when another connection is embedded in the View this connection was
199 // previously embedded in. See Embed() for more information.
200 OnUnembed();
201
202 // Invoked when a view's bounds have changed.
203 OnWindowBoundsChanged(uint32 view,
204 mojo.Rect old_bounds,
205 mojo.Rect new_bounds);
206
207 OnClientAreaChanged(uint32 window_id,
208 mojo.Rect old_client_area,
209 mojo.Rect new_client_area);
210
211 // Invoked when the viewport metrics for the view have changed.
212 // Clients are expected to propagate this to the view tree.
213 OnWindowViewportMetricsChanged(mojo.ViewportMetrics old_metrics,
214 mojo.ViewportMetrics new_metrics);
215
216 // Invoked when a change is done to the hierarchy. A value of 0 is used to
217 // identify a null view. For example, if the old_parent is NULL, 0 is
218 // supplied.
219 // |views| contains any views that are that the client has not been told
220 // about. This is not sent for hierarchy changes of views not known to this
221 // client or not attached to the tree.
222 OnWindowHierarchyChanged(uint32 view,
223 uint32 new_parent,
224 uint32 old_parent,
225 array<ViewData> views);
226
227 // Invoked when the order of views within a parent changes.
228 OnWindowReordered(uint32 view_id,
229 uint32 relative_view_id,
230 OrderDirection direction);
231
232 // Invoked when a view is deleted.
233 OnWindowDeleted(uint32 view);
234
235 // Invoked when the visibility of the specified view changes.
236 OnWindowVisibilityChanged(uint32 view, bool visible);
237
238 // Invoked when a change to the visibility of |view| or one if it's ancestors
239 // is done such that the drawn state changes. This is only invoked for the
240 // top most view of a particular connection. For example, if you have the
241 // hierarchy: A -> B1 -> B2 (B2 is a child of B1 and B1 a child of A), B1/B2
242 // are from connection 2 and A from connection 1 with all views visible and
243 // drawn and the visiblity of A changes to false, then connection 2 is told
244 // the drawn state of B1 has changed (to false), but is not told anything
245 // about B2 as it's drawn state can be calculated from that of B1.
246 //
247 // NOTE: This is not invoked if OnWindowVisibilityChanged() is invoked.
248 OnWindowDrawnStateChanged(uint32 view, bool drawn);
249
250 // Invoked when a view property is changed. If this change is a removal,
251 // |new_data| is null.
252 OnWindowSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data );
253
254 // Invoked when an event is targeted at the specified view.
255 OnWindowInputEvent(uint32 view, mojo.Event event) => ();
256
257 OnWindowFocused(uint32 focused_view_id);
258 };
OLDNEW
« no previous file with comments | « components/mus/public/interfaces/surface_id.mojom ('k') | components/mus/public/interfaces/view_tree_host.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698