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

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

Issue 383763003: Trigger Node destruction notifications from Node's dtor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | « no previous file | 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 6351ac406cfdff10758c78e29d1cb7f09a1f821e..37da7b822ef60a2c5b8e982681f6559c46080bb1 100644
--- a/mojo/services/view_manager/node.cc
+++ b/mojo/services/view_manager/node.cc
@@ -37,11 +37,17 @@ Node::Node(NodeDelegate* delegate, const NodeId& id)
}
Node::~Node() {
- SetView(NULL);
// This is implicitly done during deletion of the window, but we do it here so
// that we're in a known state.
if (window_.parent())
window_.parent()->RemoveChild(&window_);
+
+ // This must be done *after* updating the hierarchy since the hierarchy change
+ // will remove the node from the connections that know about it, preventing
+ // this notification from being sent after the destruction notification.
+ SetView(NULL);
+
+ delegate_->OnNodeDestroyed(this);
}
// static
@@ -133,7 +139,12 @@ void Node::OnWindowHierarchyChanged(
params.new_parent->GetProperty(kNodeKey) : NULL;
const Node* old_parent = params.old_parent ?
params.old_parent->GetProperty(kNodeKey) : NULL;
- delegate_->OnNodeHierarchyChanged(this, new_parent, old_parent);
+ // This check is needed because even the root Node's aura::Window has a
+ // parent, but the Node itself has no parent (so it's possible for us to
+ // receive this notification from aura when no logical Node hierarchy change
+ // has actually ocurred).
+ if (new_parent != old_parent)
+ delegate_->OnNodeHierarchyChanged(this, new_parent, old_parent);
}
gfx::Size Node::GetMinimumSize() const {
« no previous file with comments | « no previous file | mojo/services/view_manager/node_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698