| 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 [DartPackage="mojo_services"] | |
| 6 module mojo; | |
| 7 | |
| 8 import "geometry/interfaces/geometry.mojom"; | |
| 9 import "input_events/interfaces/input_events.mojom"; | |
| 10 import "mojo/public/interfaces/application/service_provider.mojom"; | |
| 11 import "native_viewport/interfaces/native_viewport.mojom"; | |
| 12 import "surfaces/interfaces/surface_id.mojom"; | |
| 13 import "view_manager/public/interfaces/view_manager_constants.mojom"; | |
| 14 | |
| 15 struct ViewData { | |
| 16 uint32 parent_id; | |
| 17 uint32 view_id; | |
| 18 mojo.Rect bounds; | |
| 19 map<string, array<uint8>> properties; | |
| 20 // True if this view is visible. The view may not be drawn on screen (see | |
| 21 // drawn for specifics). | |
| 22 bool visible; | |
| 23 // True if this view is drawn on screen. A view is drawn if attached to the | |
| 24 // root and all ancestors (including this view) are visible. | |
| 25 bool drawn; | |
| 26 ViewportMetrics viewport_metrics; | |
| 27 }; | |
| 28 | |
| 29 enum ErrorCode { | |
| 30 NONE, | |
| 31 VALUE_IN_USE, | |
| 32 ILLEGAL_ARGUMENT, | |
| 33 }; | |
| 34 | |
| 35 // Views are identified by a uint32. The upper 16 bits are the connection id, | |
| 36 // and the lower 16 the id assigned by the client. | |
| 37 // | |
| 38 // The root view is identified with a connection id of 0, and value of 1. | |
| 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 // A connection may grant access to a view from another connection by way of | |
| 110 // the embed functions. There are two variants of this call: | |
| 111 // | |
| 112 // . EmbedUrl: the ViewManager connects to the app at the supplied url and | |
| 113 // asks it for a ViewManagerClient. | |
| 114 // . With the second variant a ViewManagerClient is directly supplied. | |
| 115 // | |
| 116 // In both cases the new ViewManagerClient is configured with a root of | |
| 117 // |view_id|. | |
| 118 // | |
| 119 // The caller must have created |view_id|. If not the request fails and the | |
| 120 // response is false. | |
| 121 // | |
| 122 // A view may only be a root of one connection at a time. Subsequent calls to | |
| 123 // Embed() for the same view result in the view being removed from the | |
| 124 // currently embedded app. The embedded app is told this by way of | |
| 125 // OnViewDeleted(). | |
| 126 // | |
| 127 // The embedder can detect when the embedded app disconnects by way of | |
| 128 // OnEmbeddedAppDisconnected(). | |
| 129 // | |
| 130 // When a connection embeds an app the connection no longer has priviledges | |
| 131 // to access or see any of the children of the view. If the view had existing | |
| 132 // children the children are removed. The one exception is the root | |
| 133 // connection. | |
| 134 // | |
| 135 // |services| encapsulates services offered by the embedder to the embedded | |
| 136 // app alongside this Embed() call. |exposed_services| provides a means for | |
| 137 // the embedder to connect to services exposed by the embedded app. Note that | |
| 138 // if a different app is subsequently embedded at |view_id| the | |
| 139 // ServiceProvider connections to its client in the embedded app and any | |
| 140 // services it provided are not broken and continue to be valid. | |
| 141 EmbedUrl(string url, | |
| 142 uint32 view_id, | |
| 143 ServiceProvider&? services, | |
| 144 ServiceProvider? exposed_services) => (bool success); | |
| 145 Embed(uint32 view_id, ViewManagerClient client) => (bool success); | |
| 146 | |
| 147 // Requests the WindowManager to perform an action on the specified view. | |
| 148 // It's up to the WindowManager to decide what |action| is. | |
| 149 // | |
| 150 // TODO(sky): nuke this. This is here to guarantee the state of the | |
| 151 // WindowManager matches that of the ViewManager at the time the client | |
| 152 // invokes the function. When we can enforce ordering this won't be necessary. | |
| 153 PerformAction(uint32 view_id, string action) => (bool success); | |
| 154 }; | |
| 155 | |
| 156 // Changes to views are not sent to the connection that originated the | |
| 157 // change. For example, if connection 1 changes the bounds of a view by calling | |
| 158 // SetBounds(), connection 1 does not receive OnViewBoundsChanged(). | |
| 159 interface ViewManagerClient { | |
| 160 // Invoked when the client application has been embedded at |root|. | |
| 161 // See Embed() on ViewManagerService for more details. |view_manager_service| | |
| 162 // will be a handle back to the view manager service, unless the connection is | |
| 163 // to the WindowManager in which case it will be null. | |
| 164 // |window_manager_pipe| is a pipe to the WindowManager. | |
| 165 OnEmbed(uint16 connection_id, | |
| 166 string embedder_url, | |
| 167 ViewData root, | |
| 168 ViewManagerService? view_manager_service, | |
| 169 ServiceProvider&? services, | |
| 170 ServiceProvider? exposed_services, | |
| 171 handle<message_pipe> window_manager_pipe); | |
| 172 | |
| 173 // Invoked when the application embedded at |view| is disconnected. | |
| 174 OnEmbeddedAppDisconnected(uint32 view); | |
| 175 | |
| 176 // Invoked when a view's bounds have changed. | |
| 177 OnViewBoundsChanged(uint32 view, | |
| 178 mojo.Rect old_bounds, | |
| 179 mojo.Rect new_bounds); | |
| 180 | |
| 181 // Invoked when the viewport metrics for the view have changed. | |
| 182 // Clients are expected to propagate this to the view tree. | |
| 183 OnViewViewportMetricsChanged(mojo.ViewportMetrics old_metrics, | |
| 184 mojo.ViewportMetrics new_metrics); | |
| 185 | |
| 186 // Invoked when a change is done to the hierarchy. A value of 0 is used to | |
| 187 // identify a null view. For example, if the old_parent is NULL, 0 is | |
| 188 // supplied. | |
| 189 // |views| contains any views that are that the client has not been told | |
| 190 // about. This is not sent for hierarchy changes of views not known to this | |
| 191 // client or not attached to the tree. | |
| 192 OnViewHierarchyChanged(uint32 view, | |
| 193 uint32 new_parent, | |
| 194 uint32 old_parent, | |
| 195 array<ViewData> views); | |
| 196 | |
| 197 // Invoked when the order of views within a parent changes. | |
| 198 OnViewReordered(uint32 view_id, | |
| 199 uint32 relative_view_id, | |
| 200 OrderDirection direction); | |
| 201 | |
| 202 // Invoked when a view is deleted. | |
| 203 OnViewDeleted(uint32 view); | |
| 204 | |
| 205 // Invoked when the visibility of the specified view changes. | |
| 206 OnViewVisibilityChanged(uint32 view, bool visible); | |
| 207 | |
| 208 // Invoked when a change to the visibility of |view| or one if it's ancestors | |
| 209 // is done such that the drawn state changes. This is only invoked for the | |
| 210 // top most view of a particular connection. For example, if you have the | |
| 211 // hierarchy: A -> B1 -> B2 (B2 is a child of B1 and B1 a child of A), B1/B2 | |
| 212 // are from connection 2 and A from connection 1 with all views visible and | |
| 213 // drawn and the visiblity of A changes to false, then connection 2 is told | |
| 214 // the drawn state of B1 has changed (to false), but is not told anything | |
| 215 // about B2 as it's drawn state can be calculated from that of B1. | |
| 216 // | |
| 217 // NOTE: This is not invoked if OnViewVisibilityChanged() is invoked. | |
| 218 OnViewDrawnStateChanged(uint32 view, bool drawn); | |
| 219 | |
| 220 // Invoked when a view property is changed. If this change is a removal, | |
| 221 // |new_data| is null. | |
| 222 OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data); | |
| 223 | |
| 224 // Invoked when an event is targeted at the specified view. | |
| 225 OnViewInputEvent(uint32 view, mojo.Event event) => (); | |
| 226 | |
| 227 // Invoked solely on the WindowManager. See comments in PerformAction() above | |
| 228 // for details. | |
| 229 // TODO(sky): nuke this. | |
| 230 OnPerformAction(uint32 view_id, string action) => (bool success); | |
| 231 }; | |
| OLD | NEW |