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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: services/ui/view_manager/view_state.h
diff --git a/services/ui/view_manager/view_state.h b/services/ui/view_manager/view_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..0bb52ff1282c93ac04c163e54fb1df8177c9145a
--- /dev/null
+++ b/services/ui/view_manager/view_state.h
@@ -0,0 +1,112 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_UI_VIEW_MANAGER_VIEW_STATE_H_
+#define SERVICES_UI_VIEW_MANAGER_VIEW_STATE_H_
+
+#include <memory>
+#include <set>
+#include <unordered_map>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "mojo/services/ui/views/interfaces/views.mojom.h"
+#include "services/ui/view_manager/view_layout_request.h"
+
+namespace view_manager {
+
+class ViewTreeState;
+
+// Describes the state of a particular view.
+// This object is owned by the ViewRegistry that created it.
+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.
+ public:
+ ViewState(mojo::ui::ViewPtr view, uint32_t view_token_value);
+ ~ViewState();
+
+ // Gets the view interface, never null.
+ // Caller does not obtain ownership of the view.
+ mojo::ui::View* view() const { return view_.get(); }
+
+ // Gets the view token value used to refer to this view globally.
+ uint32_t view_token_value() const { return view_token_value_; }
+
+ // Sets the associated host implementation and takes ownership of it.
+ void set_view_host(mojo::ui::ViewHost* host) { view_host_.reset(host); }
+
+ // Sets the connection error handler for the view.
+ void set_view_connection_error_handler(const base::Closure& handler) {
+ view_.set_connection_error_handler(handler);
+ }
+
+ // Gets the view tree to which this view belongs, or null if none.
+ ViewTreeState* tree() const { return tree_; }
+
+ // Gets the parent view state, or null if none.
+ ViewState* parent() const { return parent_; }
+
+ // Gets the key that this child has in its container, or 0 if none.
+ uint32_t key() const { return key_; }
+
+ // Recursively sets the view tree to which this view and all of its
+ // descendents belongs. Must not be null. This method must only be called
+ // on root views.
+ void SetTree(ViewTreeState* tree, uint32_t key);
+
+ // Sets the parent view state pointer, the child's key in its parent,
+ // and set its view tree to that of its parent. Must not be null.
+ void SetParent(ViewState* parent, uint32_t key);
+
+ // Resets the parent view state and tree pointers to null.
+ void ResetContainer();
+
+ // Gets the view's service provider.
+ void GetServiceProvider(
+ mojo::InterfaceRequest<mojo::ServiceProvider> service_provider);
+
+ // The map of children, indexed by child key.
+ // Child view state may be null if the child with the given key has
+ // become unavailable but not yet removed.
+ 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.
+
+ // The set of children needing layout.
+ // This set must never contain non-existent or unavailable children.
+ std::set<uint32_t> children_needing_layout;
+
+ // The list of pending layout requests.
+ std::vector<std::unique_ptr<ViewLayoutRequest>> pending_layout_requests;
+
+ // The layout parameters most recently processed by the view,
+ // or null if none. These parameters are preserved across reparenting.
+ mojo::ui::ViewLayoutParamsPtr layout_params;
+
+ // The layout information most recently provided by the view in
+ // response to the value of |layout_params|, or null if none. These
+ // results are preserved across reparenting.
+ mojo::ui::ViewLayoutInfoPtr layout_info;
+
+ // The id of the Surface which the view manager itself created to wrap the
+ // view's own Surface, or null if none. The wrapped Surface is destroyed
+ // when the view is reparented so that the old parent can no longer embed
+ // the view's actual content.
+ mojo::SurfaceIdPtr wrapped_surface;
+
+ private:
+ void SetTreeUnchecked(ViewTreeState* tree);
+
+ mojo::ui::ViewPtr view_;
+ uint32_t view_token_value_;
+ std::unique_ptr<mojo::ui::ViewHost> view_host_;
+
+ ViewTreeState* tree_;
+ ViewState* parent_;
+ uint32_t key_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewState);
+};
+
+} // namespace view_manager
+
+#endif // SERVICES_UI_VIEW_MANAGER_VIEW_STATE_H_

Powered by Google App Engine
This is Rietveld 408576698