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