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

Unified Diff: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc

Issue 424533002: Cleans up usage of ViewManagerServiceImpl::roots_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: delete 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
Index: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
index a9bb119b762150cb905d4247fef97fbbbe076331..d4dbfe427e4133327e67835b1e848b9aea9a94fe 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
@@ -59,10 +59,13 @@ Node* AddNodeToViewManager(ViewManagerClientImpl* client,
}
Node* BuildNodeTree(ViewManagerClientImpl* client,
- const Array<NodeDataPtr>& nodes) {
+ const Array<NodeDataPtr>& nodes,
+ Node* initial_parent) {
std::vector<Node*> parents;
Node* root = NULL;
Node* last_node = NULL;
+ if (initial_parent)
+ parents.push_back(initial_parent);
for (size_t i = 0; i < nodes.size(); ++i) {
if (last_node && nodes[i]->parent_id == last_node->id()) {
parents.push_back(last_node);
@@ -324,11 +327,11 @@ void ViewManagerClientImpl::OnViewManagerConnectionEstablished(
connected_ = true;
connection_id_ = connection_id;
creator_url_ = TypeConverter<String, std::string>::ConvertFrom(creator_url);
- AddRoot(BuildNodeTree(this, nodes));
+ AddRoot(BuildNodeTree(this, nodes, NULL));
}
void ViewManagerClientImpl::OnRootAdded(Array<NodeDataPtr> nodes) {
- AddRoot(BuildNodeTree(this, nodes));
+ AddRoot(BuildNodeTree(this, nodes, NULL));
}
void ViewManagerClientImpl::OnNodeBoundsChanged(Id node_id,
@@ -344,7 +347,10 @@ void ViewManagerClientImpl::OnNodeHierarchyChanged(
Id new_parent_id,
Id old_parent_id,
mojo::Array<NodeDataPtr> nodes) {
- BuildNodeTree(this, nodes);
+ Node* initial_parent = nodes.size() ?
+ GetNodeById(nodes[0]->parent_id) : NULL;
+
+ BuildNodeTree(this, nodes, initial_parent);
Node* new_parent = GetNodeById(new_parent_id);
Node* old_parent = GetNodeById(old_parent_id);

Powered by Google App Engine
This is Rietveld 408576698