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

Side by Side Diff: mojo/services/ui/views/interfaces/views.mojom

Issue 1410693003: mozart: Introduce new view manager interfaces. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « mojo/services/ui/views/interfaces/view_trees.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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.ui;
7
8 import "mojo/public/interfaces/application/service_provider.mojom";
9 import "mojo/services/ui/views/interfaces/layouts.mojom";
10
11 // A view token is an opaque transferable reference to a view.
12 //
13 // The ViewManager provides each view with a unique view token when
14 // it is registered. The token can subsequently be passed to other
15 // applications and may be used to add the view as a child of some
16 // other view or to set it as the root of a view tree.
17 //
18 // View tokens should be kept secret and should only be shared with
19 // the view's intended container.
20 //
21 // TODO(jeffbrown): This implementation is a temporary placeholder until
22 // we extend Mojo to provide a way to create tokens which cannot be forged.
23 struct ViewToken {
24 uint32 value;
25 };
26
27 // A view is a graphical user interface component which is responsible
28 // for drawing and supporting user interactions in the area of the screen
29 // that it occupies.
30 //
31 // A view may also act as a container for other views (known as the
32 // view's children) which it may freely layout and position anywhere
33 // within its bounds to form a composite user interface. The hierarchy
34 // of views thus formed is called a view tree.
35 //
36 // A view must registered with the view manager before it can be shown.
37 interface View {
38 // Called when the view needs to update its layout and provide its size.
39 //
40 // This method may be called for one or more of the following reasons:
41 //
42 // 1. The view called RequestLayout() to mark itself as needing layout.
43 // 2. The view's parent called LayoutChild() for the first time to
44 // provide layout parameters to this view.
45 // 3. The view's parent called LayoutChild() and provided a
46 // set of layout parameters which differ from its prior call to
47 // OnLayout().
48 // 4. One or more of the view's children were just added to the view
49 // tree using AddChild() or removed from the tree using RemoveChild().
50 // 5. One or more of the view's children produced different layout
51 // information during their last layout pass causing a recursive
52 // layout to occur.
53 //
54 // The |children_needing_layout| array includes the keys of all children
55 // which require a layout. The view is responsible for calling LayoutChild()
56 // at least once for each child in the array in addition to any other
57 // children which might also need to be updated.
58 //
59 // Layout requests are coalesced for efficiency. Certain intermediate
60 // updates may be dropped if the view is unable to keep up with them
61 // in a timely manner. Do nothing updates are always dropped.
62 //
63 // The implementation should invoke the callback once the event has
64 // been handled and the view is ready to be shown in its new aspect.
65 //
66 // The result of the layout may cause the parent's layout to be invalidated.
67 // When this happens, the parent's own OnLayout() method will be called
68 // and will be informed that this child needs layout.
69 //
70 // Recursive layout happens in any of the following circumstances:
71 //
72 // 1. If the resulting surface has changed since the last layout.
73 // 2. If the resulting size has changed since the last layout.
74 //
75 // It is an error to return a malformed |info| which does not satisfy
76 // the requested |layout_params|, such as by returning a size which
77 // exceeds the requested constraints; the view's connection will be closed.
78 OnLayout(mojo.ui.ViewLayoutParams layout_params,
79 array<uint32> children_needing_layout) => (mojo.ui.ViewLayoutInfo info);
80
81 // Called when a child view has become unavailable.
82 //
83 // A child may become unavailable for many reasons such being unregistered
84 // by its application, abnormal termination of its application, or
85 // cycles being introduced in the view tree.
86 //
87 // To complete removal of an unavailable child, this view component must
88 // call RemoveChild() on its view host with |child_key|.
89 //
90 // The implementation should invoke the callback once the event has
91 // been handled.
92 OnChildUnavailable(uint32 child_key) => ();
93 };
94
95 // The view host provides an interface for a view to configure itself and
96 // interact with its local environment, such as adding and removing
97 // children and specifying layout constraints.
98 //
99 // Each view obtains its own view host when registered with the ViewManager.
100 // To unregister the view, close its view host message pipe.
101 interface ViewHost {
102 // Gets a service provider to access services which are associated with
103 // the view such as input, accessibility and editing capabilities.
104 // The view service provider is private to the view and should not be
105 // shared with anyone else.
106 GetServiceProvider(mojo.ServiceProvider& service_provider);
107
108 // Requests that the view's OnLayout() method be called to compute a
109 // new layout due to a change in the view's layout information.
110 RequestLayout();
111
112 // Adds the view referenced by |child_view_token| as a child and assigns
113 // it the provided |child_key| to identify it among its children.
114 // The parent may remove the child later by passing the same |child_key|
115 // to RemoveChild().
116 //
117 // It is important for the parent to choose locally unique values for
118 // |child_key| to ensure that each child can be distinguished even as
119 // more children are added or removed. We recommend using a simple
120 // counter which is incremented on each (re-)addition.
121 //
122 // If the child becomes unavailable at any time prior to being removed
123 // then an OnChildUnavailable() message will be sent.
124 //
125 // If |child_view_token| refers to a view which is already unavailable or
126 // if adding the view would create a cycle in the view tree then the
127 // call proceeds as if it succeeded but an OnChildUnavailable() message
128 // will be sent.
129 //
130 // If |child_view_token| refers to a view which already has a parent or is
131 // the root of a view tree then an OnChildUnavailable() or OnRootUnavailable()
132 // message will be sent to its old parent or root and the the view will be
133 // (re-)added to its new parent as usual. This special case also applies
134 // when the specified view is already a child of this view, in which
135 // case the behavior is similar to the view having been transferred to
136 // some other parent and then back again.
137 //
138 // Note that an unavailable child will remain in its parent's list of
139 // children until its parent explicitly calls RemoveChild() to remove
140 // it.
141 //
142 // It is an error to add a view whose |child_key| already appears
143 // in the view's list of children; the connection will be closed.
144 AddChild(uint32 child_key, mojo.ui.ViewToken child_view_token);
145
146 // Removes the view referenced by |child_key| from the view's
147 // list of children.
148 //
149 // It is an error to remove a view whose |child_key| does not appear
150 // in the parent's list of children; the connection will be closed.
151 RemoveChild(uint32 child_key);
152
153 // Sets the layout parameters of the child view referenced by |child_key|
154 // and retrieves its layout information.
155 //
156 // The returned |info| is null if this layout request was canceled either
157 // because it has been superceded by a subsequently issued layout request
158 // or because the child has become unavailable.
159 //
160 // It is an error to specify a |child_key| that does not appear in
161 // the parent's list of children; the connection will be closed.
162 //
163 // It is an error to specify malformed |child_layout_params| such
164 // as invalid size constraints; the connection will be closed.
165 LayoutChild(uint32 child_key, mojo.ui.ViewLayoutParams child_layout_params)
166 => (mojo.ui.ViewLayoutInfo? info);
167 };
OLDNEW
« no previous file with comments | « mojo/services/ui/views/interfaces/view_trees.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698