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

Unified Diff: services/ui/view_manager/view_state.cc

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.cc
diff --git a/services/ui/view_manager/view_state.cc b/services/ui/view_manager/view_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2af2e0cbf0029c26dcbca66bc22e1284b2f35a70
--- /dev/null
+++ b/services/ui/view_manager/view_state.cc
@@ -0,0 +1,54 @@
+// 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.
+
+#include "base/logging.h"
+#include "services/ui/view_manager/view_state.h"
+#include "services/ui/view_manager/view_tree_state.h"
+
+namespace view_manager {
+
+ViewState::ViewState(mojo::ui::ViewPtr view, uint32_t view_token_value)
+ : view_(view.Pass()),
+ view_token_value_(view_token_value),
+ tree_(nullptr),
+ parent_(nullptr),
+ key_(0) {
+ DCHECK(view_);
+}
+
+ViewState::~ViewState() {}
+
+void ViewState::SetTree(ViewTreeState* tree, uint32_t key) {
+ DCHECK(tree);
+ DCHECK(!parent_); // must be the root
+ if (tree_ != tree) {
+ SetTreeUnchecked(tree);
+ }
+ key_ = key;
+}
+
+void ViewState::SetTreeUnchecked(ViewTreeState* tree) {
+ tree_ = tree;
+ for (auto it = children.begin(); it != children.end(); ++it) {
+ it->second->SetTreeUnchecked(tree);
+ }
+}
+
+void ViewState::SetParent(ViewState* parent, uint32_t key) {
+ DCHECK(parent);
+ parent_ = parent;
+ key_ = key;
+ SetTreeUnchecked(parent->tree_);
+}
+
+void ViewState::ResetContainer() {
+ parent_ = nullptr;
+ key_ = 0;
+ SetTreeUnchecked(nullptr);
+}
+
+void ViewState::GetServiceProvider(
+ mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) {}
+
+} // namespace view_manager

Powered by Google App Engine
This is Rietveld 408576698