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

Side by Side Diff: services/ui/view_manager/view_state.h

Issue 1415493003: mozart: Initial commit of the view manager. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: applied review comments 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
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 #ifndef SERVICES_UI_VIEW_MANAGER_VIEW_STATE_H_
6 #define SERVICES_UI_VIEW_MANAGER_VIEW_STATE_H_
7
8 #include <memory>
9 #include <set>
10 #include <unordered_map>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "mojo/services/ui/views/interfaces/views.mojom.h"
16 #include "services/ui/view_manager/view_layout_request.h"
17
18 namespace view_manager {
19
20 class ViewTreeState;
21
22 // Describes the state of a particular view.
23 // This object is owned by the ViewRegistry that created it.
24 class ViewState : public base::SupportsWeakPtr<ViewState> {
jamesr 2015/10/27 23:13:11 you should never inherit from base::SupportsWeakPt
jeffbrown 2015/10/28 01:37:29 Done.
25 public:
26 ViewState(mojo::ui::ViewPtr view, uint32_t view_token_value);
27 ~ViewState();
28
29 // Gets the view interface, never null.
30 // Caller does not obtain ownership of the view.
31 mojo::ui::View* view() const { return view_.get(); }
32
33 // Gets the view token value used to refer to this view globally.
34 uint32_t view_token_value() const { return view_token_value_; }
35
36 // Sets the associated host implementation and takes ownership of it.
37 void set_view_host(mojo::ui::ViewHost* host) { view_host_.reset(host); }
38
39 // Sets the connection error handler for the view.
40 void set_view_connection_error_handler(const base::Closure& handler) {
41 view_.set_connection_error_handler(handler);
42 }
43
44 // Gets the view tree to which this view belongs, or null if none.
45 ViewTreeState* tree() const { return tree_; }
46
47 // Gets the parent view state, or null if none.
48 ViewState* parent() const { return parent_; }
49
50 // Gets the key that this child has in its container, or 0 if none.
51 uint32_t key() const { return key_; }
52
53 // Recursively sets the view tree to which this view and all of its
54 // descendents belongs. Must not be null. This method must only be called
55 // on root views.
56 void SetTree(ViewTreeState* tree, uint32_t key);
57
58 // Sets the parent view state pointer, the child's key in its parent,
59 // and set its view tree to that of its parent. Must not be null.
60 void SetParent(ViewState* parent, uint32_t key);
61
62 // Resets the parent view state and tree pointers to null.
63 void ResetContainer();
64
65 // Gets the view's service provider.
66 void GetServiceProvider(
67 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider);
68
69 // The map of children, indexed by child key.
70 // Child view state may be null if the child with the given key has
71 // become unavailable but not yet removed.
72 std::unordered_map<uint32_t, ViewState*> children;
jamesr 2015/10/27 23:13:11 no public members
jeffbrown 2015/10/28 01:37:29 Done.
73
74 // The set of children needing layout.
75 // This set must never contain non-existent or unavailable children.
76 std::set<uint32_t> children_needing_layout;
77
78 // The list of pending layout requests.
79 std::vector<std::unique_ptr<ViewLayoutRequest>> pending_layout_requests;
80
81 // The layout parameters most recently processed by the view,
82 // or null if none. These parameters are preserved across reparenting.
83 mojo::ui::ViewLayoutParamsPtr layout_params;
84
85 // The layout information most recently provided by the view in
86 // response to the value of |layout_params|, or null if none. These
87 // results are preserved across reparenting.
88 mojo::ui::ViewLayoutInfoPtr layout_info;
89
90 // The id of the Surface which the view manager itself created to wrap the
91 // view's own Surface, or null if none. The wrapped Surface is destroyed
92 // when the view is reparented so that the old parent can no longer embed
93 // the view's actual content.
94 mojo::SurfaceIdPtr wrapped_surface;
95
96 private:
97 void SetTreeUnchecked(ViewTreeState* tree);
98
99 mojo::ui::ViewPtr view_;
100 uint32_t view_token_value_;
101 std::unique_ptr<mojo::ui::ViewHost> view_host_;
102
103 ViewTreeState* tree_;
104 ViewState* parent_;
105 uint32_t key_;
106
107 DISALLOW_COPY_AND_ASSIGN(ViewState);
108 };
109
110 } // namespace view_manager
111
112 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698