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

Unified Diff: mojo/services/view_manager/node.cc

Issue 250633003: Adds more to viewmanager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: override Created 6 years, 8 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
« no previous file with comments | « mojo/services/view_manager/node.h ('k') | mojo/services/view_manager/node_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/view_manager/node.cc
diff --git a/mojo/services/view_manager/node.cc b/mojo/services/view_manager/node.cc
index 1457a7ee6b6ac1785b983567ecbdd826555312ce..e2436dab5aeb96d5f46149465355e37299d2ac54 100644
--- a/mojo/services/view_manager/node.cc
+++ b/mojo/services/view_manager/node.cc
@@ -5,6 +5,7 @@
#include "mojo/services/view_manager/node.h"
#include "mojo/services/view_manager/node_delegate.h"
+#include "mojo/services/view_manager/view.h"
#include "ui/aura/window_property.h"
DECLARE_WINDOW_PROPERTY_TYPE(mojo::services::view_manager::Node*);
@@ -18,6 +19,7 @@ DEFINE_WINDOW_PROPERTY_KEY(Node*, kNodeKey, NULL);
Node::Node(NodeDelegate* delegate, const NodeId& id)
: delegate_(delegate),
id_(id),
+ view_(NULL),
window_(NULL) {
DCHECK(delegate); // Must provide a delegate.
window_.set_owned_by_parent(false);
@@ -26,6 +28,7 @@ Node::Node(NodeDelegate* delegate, const NodeId& id)
}
Node::~Node() {
+ SetView(NULL);
}
Node* Node::GetParent() {
@@ -42,6 +45,36 @@ void Node::Remove(Node* child) {
window_.RemoveChild(&child->window_);
}
+std::vector<Node*> Node::GetChildren() {
+ std::vector<Node*> children;
+ children.reserve(window_.children().size());
+ for (size_t i = 0; i < window_.children().size(); ++i)
+ children.push_back(window_.children()[i]->GetProperty(kNodeKey));
+ return children;
+}
+
+void Node::SetView(View* view) {
+ if (view == view_)
+ return;
+
+ // Detach view from existing node. This way notifications are sent out.
+ if (view && view->node())
+ view->node()->SetView(NULL);
+
+ ViewId old_view_id;
+ if (view_) {
+ view_->set_node(NULL);
+ old_view_id = view_->id();
+ }
+ view_ = view;
+ ViewId view_id;
+ if (view) {
+ view_id = view->id();
+ view->set_node(this);
+ }
+ delegate_->OnNodeViewReplaced(id_, view_id, old_view_id);
+}
+
void Node::OnWindowHierarchyChanged(
const aura::WindowObserver::HierarchyChangeParams& params) {
if (params.target != &window_ || params.receiver != &window_)
« no previous file with comments | « mojo/services/view_manager/node.h ('k') | mojo/services/view_manager/node_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698