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

Side by Side Diff: mojo/services/public/interfaces/view_manager/view_manager.mojom

Issue 790623003: Restructure public side of view_manager service. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: BUILD.gn file reorderings Created 6 years 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 "mojo/public/interfaces/application/service_provider.mojom";
8 import "mojo/services/public/interfaces/geometry/geometry.mojom";
9 import "mojo/services/public/interfaces/input_events/input_events.mojom";
10 import "mojo/services/public/interfaces/surfaces/surface_id.mojom";
11 import "mojo/services/public/interfaces/view_manager/view_manager_constants.mojo m";
12
13 struct ViewData {
14 uint32 parent_id;
15 uint32 view_id;
16 mojo.Rect bounds;
17 map<string, array<uint8>> properties;
18 // True if this view is visible. The view may not be drawn on screen (see
19 // drawn for specifics).
20 bool visible;
21 // True if this view is drawn on screen. A view is drawn if attached to the
22 // root and all ancestors (including this view) are visible.
23 bool drawn;
24 };
25
26 enum ErrorCode {
27 NONE,
28 VALUE_IN_USE,
29 ILLEGAL_ARGUMENT,
30 };
31
32 // Views are identified by a uint32. The upper 16 bits are the connection id,
33 // and the lower 16 the id assigned by the client.
34 //
35 // The root view is identified with a connection id of 0, and value of 1.
36 [Client=ViewManagerClient]
37 interface ViewManagerService {
38 // Creates a new view with the specified id. It is up to the client to ensure
39 // the id is unique to the connection (the id need not be globally unique).
40 // Additionally the connection id (embedded in |view_id|) must match that of
41 // the connection.
42 // Errors:
43 // ERROR_CODE_VALUE_IN_USE: a view already exists with the specified id.
44 // ERROR_CODE_ILLEGAL_ARGUMENT: The connection part of |view_id| does not
45 // match the connection id of the client.
46 //
47 // TODO(erg): Once we have default values in mojo, make this take a map of
48 // properties.
49 CreateView(uint32 view_id) => (ErrorCode error_code);
50
51 // Deletes a view. This does not recurse. No hierarchy change notifications
52 // are sent as a result of this. Only the connection that created the view can
53 // delete it.
54 DeleteView(uint32 view_id) => (bool success);
55
56 // Sets the specified bounds of the specified view.
57 SetViewBounds(uint32 view_id, mojo.Rect bounds) => (bool success);
58
59 // Sets the visibility of the specified view to |visible|. Connections are
60 // allowed to change the visibility of any view they have created, as well as
61 // any of their roots.
62 SetViewVisibility(uint32 view_id, bool visible) => (bool success);
63
64 // Sets an individual named property. Setting an individual property to null
65 // deletes the property.
66 SetViewProperty(uint32 view_id,
67 string name,
68 array<uint8>? value) => (bool success);
69
70 // Reparents a view.
71 // This fails for any of the following reasons:
72 // . |parent| or |child| does not identify a valid view.
73 // . |child| is an ancestor of |parent|.
74 // . |child| is already a child of |parent|.
75 //
76 // This may result in a connection getting OnViewDeleted(). See
77 // RemoveViewFromParent for details.
78 AddView(uint32 parent, uint32 child) => (bool success);
79
80 // Removes a view from its current parent. This fails if the view is not
81 // valid or the view already has no parent.
82 //
83 // Removing a view from a parent may result in OnViewDeleted() being sent to
84 // other connections. For example, connection A has views 1 and 2, with 2 a
85 // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets
86 // OnViewDeleted(). This is done as view 2 is effectively no longer visible to
87 // connection B.
88 RemoveViewFromParent(uint32 view_id) => (bool success);
89
90 // Reorders a view in its parent, relative to |relative_view_id| according to
91 // |direction|.
92 // Only the connection that created the view's parent can reorder its
93 // children.
94 ReorderView(uint32 view_id,
95 uint32 relative_view_id,
96 OrderDirection direction) => (bool success);
97
98 // Returns the views comprising the tree starting at |view_id|. |view_id| is
99 // the first result in the return value, unless |view_id| is invalid, in which
100 // case an empty vector is returned. The views are visited using a depth first
101 // search (pre-order).
102 GetViewTree(uint32 view_id) => (array<ViewData> views);
103
104 // Shows the surface in the specified view.
105 SetViewSurfaceId(uint32 view_id, SurfaceId surface_id) => (bool success);
106
107 // Embeds the app for |url| in the specified view. More specifically this
108 // creates a new connection to the specified url, expecting to get a
109 // ViewManagerClient and configures it with the root view |view|. Fails
110 // if |view| was not created by this connection.
111 //
112 // A view may only be a root of one connection at a time. Subsequent calls to
113 // Embed() for the same view result in the view being removed from the
114 // currently embedded app. The embedded app is told this by way of
115 // OnViewDeleted().
116 //
117 // The embedder can detect when the embedded app disconnects by way of
118 // OnEmbeddedAppDisconnected().
119 //
120 // When a connection embeds an app the connection no longer has priviledges
121 // to access or see any of the children of the view. If the view had existing
122 // children the children are removed. The one exception is the root
123 // connection.
124 //
125 // |service_provider| encapsulates services offered by the embedder to the
126 // embedded app alongside this Embed() call. It also provides a means for
127 // the embedder to connect to services symmetrically exposed by the embedded
128 // app. Note that if a different app is subsequently embedded at |view_id|
129 // the |service_provider|'s connection to its client in the embedded app and
130 // any services it provided are not broken and continue to be valid.
131 Embed(string url,
132 uint32 view_id,
133 ServiceProvider&? service_provider) => (bool success);
134 };
135
136 // Changes to views are not sent to the connection that originated the
137 // change. For example, if connection 1 changes the bounds of a view by calling
138 // SetBounds(), connection 1 does not receive OnViewBoundsChanged().
139 [Client=ViewManagerService]
140 interface ViewManagerClient {
141 // Invoked when the client application has been embedded at |root|.
142 // See Embed() on ViewManagerService for more details. |window_manager_pipe|
143 // is a pipe to the WindowManager.
144 OnEmbed(uint16 connection_id,
145 string embedder_url,
146 ViewData root,
147 ServiceProvider&? parent_service_provider,
148 handle<message_pipe> window_manager_pipe);
149
150 // Invoked when the application embedded at |view| is disconnected.
151 OnEmbeddedAppDisconnected(uint32 view);
152
153 // Invoked when a view's bounds have changed.
154 OnViewBoundsChanged(uint32 view,
155 mojo.Rect old_bounds,
156 mojo.Rect new_bounds);
157
158 // Invoked when a change is done to the hierarchy. A value of 0 is used to
159 // identify a null view. For example, if the old_parent is NULL, 0 is
160 // supplied.
161 // |views| contains any views that are that the client has not been told
162 // about. This is not sent for hierarchy changes of views not known to this
163 // client or not attached to the tree.
164 OnViewHierarchyChanged(uint32 view,
165 uint32 new_parent,
166 uint32 old_parent,
167 array<ViewData> views);
168
169 // Invoked when the order of views within a parent changes.
170 OnViewReordered(uint32 view_id,
171 uint32 relative_view_id,
172 OrderDirection direction);
173
174 // Invoked when a view is deleted.
175 OnViewDeleted(uint32 view);
176
177 // Invoked when the visibility of the specified view changes.
178 OnViewVisibilityChanged(uint32 view, bool visible);
179
180 // Invoked when a change to the visibility of |view| or one if it's ancestors
181 // is done such that the drawn state changes. This is only invoked for the
182 // top most view of a particular connection. For example, if you have the
183 // hierarchy: A -> B1 -> B2 (B2 is a child of B1 and B1 a child of A), B1/B2
184 // are from connection 2 and A from connection 1 with all views visible and
185 // drawn and the visiblity of A changes to false, then connection 2 is told
186 // the drawn state of B1 has changed (to false), but is not told anything
187 // about B2 as it's drawn state can be calculated from that of B1.
188 //
189 // NOTE: This is not invoked if OnViewVisibilityChanged() is invoked.
190 OnViewDrawnStateChanged(uint32 view, bool drawn);
191
192 // Invoked when a view property is changed. If this change is a removal,
193 // |new_data| is null.
194 OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data);
195
196 // Invoked when an event is targeted at the specified view.
197 OnViewInputEvent(uint32 view, mojo.Event event) => ();
198 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698