| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 module mojo.view_manager { | 5 module mojo.view_manager { |
| 6 | 6 |
| 7 struct INode { | 7 struct INode { |
| 8 uint32 parent_id; | 8 uint32 parent_id; |
| 9 uint32 node_id; | 9 uint32 node_id; |
| 10 uint32 view_id; | 10 uint32 view_id; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // are sent as a result of this. Only the connection that created the node can | 32 // are sent as a result of this. Only the connection that created the node can |
| 33 // delete it. | 33 // delete it. |
| 34 DeleteNode(uint32 node_id) => (bool success); | 34 DeleteNode(uint32 node_id) => (bool success); |
| 35 | 35 |
| 36 // Reparents a node. See description above class for details of |change_id|. | 36 // Reparents a node. See description above class for details of |change_id|. |
| 37 // This fails for any of the following reasons: | 37 // This fails for any of the following reasons: |
| 38 // . |server_change_id| is not the expected id. | 38 // . |server_change_id| is not the expected id. |
| 39 // . |parent| or |child| does not identify a valid node. | 39 // . |parent| or |child| does not identify a valid node. |
| 40 // . |child| is an ancestor of |parent|. | 40 // . |child| is an ancestor of |parent|. |
| 41 // . |child| is already a child of |parent|. | 41 // . |child| is already a child of |parent|. |
| 42 // |
| 43 // This may result in a connection getting OnNodeDeleted(). See |
| 44 // RemoveNodeFromParent for details. |
| 42 AddNode(uint32 parent, | 45 AddNode(uint32 parent, |
| 43 uint32 child, | 46 uint32 child, |
| 44 uint32 server_change_id) => (bool success); | 47 uint32 server_change_id) => (bool success); |
| 45 | 48 |
| 46 // Removes a view from its current parent. See description above class for | 49 // Removes a view from its current parent. See description above class for |
| 47 // details of |change_id|. This fails if the node is not valid, | 50 // details of |change_id|. This fails if the node is not valid, |
| 48 // |server_change_id| doesn't match, or the node already has no parent. | 51 // |server_change_id| doesn't match, or the node already has no parent. |
| 52 // |
| 53 // Removing a node from a parent may result in OnNodeDeleted() being sent to |
| 54 // other connections. For example, connection A has nodes 1 and 2, with 2 a |
| 55 // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets |
| 56 // OnNodeDeleted(). This is done as node 2 is effectively no longer visible to |
| 57 // connection B. |
| 49 RemoveNodeFromParent(uint32 node_id, | 58 RemoveNodeFromParent(uint32 node_id, |
| 50 uint32 server_change_id) => (bool success); | 59 uint32 server_change_id) => (bool success); |
| 51 | 60 |
| 52 // Returns the nodes comprising the tree starting at |node_id|. |node_id| is | 61 // Returns the nodes comprising the tree starting at |node_id|. |node_id| is |
| 53 // the first result in the return value, unless |node_id| is invalid, in which | 62 // the first result in the return value, unless |node_id| is invalid, in which |
| 54 // case an empty vector is returned. The nodes are visited using a depth first | 63 // case an empty vector is returned. The nodes are visited using a depth first |
| 55 // search (pre-order). | 64 // search (pre-order). |
| 56 GetNodeTree(uint32 node_id) => (INode[] nodes); | 65 GetNodeTree(uint32 node_id) => (INode[] nodes); |
| 57 | 66 |
| 58 // Creates a new view with the specified id. It is up to the client to ensure | 67 // Creates a new view with the specified id. It is up to the client to ensure |
| 59 // the id is unique to the connection (the id need not be globally unique). | 68 // the id is unique to the connection (the id need not be globally unique). |
| 60 // Additionally the connection id (embedded in |view_id|) must match that of | 69 // Additionally the connection id (embedded in |view_id|) must match that of |
| 61 // the connection. | 70 // the connection. |
| 62 CreateView(uint32 view_id) => (bool success); | 71 CreateView(uint32 view_id) => (bool success); |
| 63 | 72 |
| 64 // Deletes the view with the specified id. Only the connection that created | 73 // Deletes the view with the specified id. Only the connection that created |
| 65 // the view can delete it. | 74 // the view can delete it. |
| 66 DeleteView(uint32 view_id) => (bool success); | 75 DeleteView(uint32 view_id) => (bool success); |
| 67 | 76 |
| 68 // Sets the view a node is showing. | 77 // Sets the view a node is showing. |
| 69 SetView(uint32 node_id, uint32 view_id) => (bool success); | 78 SetView(uint32 node_id, uint32 view_id) => (bool success); |
| 70 | 79 |
| 71 // Shows the specified image (png encoded) in the specified view. | 80 // Shows the specified image (png encoded) in the specified view. |
| 72 SetViewContents(uint32 view_id, | 81 SetViewContents(uint32 view_id, |
| 73 handle<shared_buffer> buffer, | 82 handle<shared_buffer> buffer, |
| 74 uint32 buffer_size); | 83 uint32 buffer_size); |
| 84 |
| 85 // Sets the ids of the roots for the specified connection. |
| 86 // TODO(sky): this is temporary for testing. This needs to be conveyed at |
| 87 // creation time of a new connection. |
| 88 SetRoots(uint16 connection_id, uint32[] nodes) => (bool success); |
| 75 }; | 89 }; |
| 76 | 90 |
| 77 // Changes to nodes/views are not sent to the connection that originated the | 91 // Changes to nodes/views are not sent to the connection that originated the |
| 78 // change. For example, if connection 1 attaches a view to a node (SetView()) | 92 // change. For example, if connection 1 attaches a view to a node (SetView()) |
| 79 // connection 1 does not receive OnNodeViewReplaced(). | 93 // connection 1 does not receive OnNodeViewReplaced(). |
| 80 interface IViewManagerClient { | 94 interface IViewManagerClient { |
| 81 // Invoked once the connection has been established. |connection_id| is the id | 95 // Invoked once the connection has been established. |connection_id| is the id |
| 82 // that uniquely identifies this connection. |next_server_change_id| is the | 96 // that uniquely identifies this connection. |next_server_change_id| is the |
| 83 // id of the next change the server is expecting. |nodes| are the nodes | 97 // id of the next change the server is expecting. |nodes| are the nodes |
| 84 // parented to the root. | 98 // parented to the root. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 111 | 125 |
| 112 // Invoked when the view associated with a node is replaced by another view. | 126 // Invoked when the view associated with a node is replaced by another view. |
| 113 // 0 is used to identify a null view. | 127 // 0 is used to identify a null view. |
| 114 OnNodeViewReplaced(uint32 node, uint32 new_view_id, uint32 old_view_id); | 128 OnNodeViewReplaced(uint32 node, uint32 new_view_id, uint32 old_view_id); |
| 115 | 129 |
| 116 // Invoked when a view is deleted. | 130 // Invoked when a view is deleted. |
| 117 OnViewDeleted(uint32 view); | 131 OnViewDeleted(uint32 view); |
| 118 }; | 132 }; |
| 119 | 133 |
| 120 } | 134 } |
| OLD | NEW |