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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_tree_node.cc

Issue 310223002: Get most of the View Manager client lib tests to pass again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" 5 #include "mojo/services/public/cpp/view_manager/view_tree_node.h"
6 6
7 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" 7 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" 8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" 9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h"
10 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" 10 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h"
(...skipping 27 matching lines...) Expand all
38 const ViewTreeNodeObserver::TreeChangeParams& params) { 38 const ViewTreeNodeObserver::TreeChangeParams& params) {
39 NotifyViewTreeChangeAtReceiver(start_at, params); 39 NotifyViewTreeChangeAtReceiver(start_at, params);
40 ViewTreeNode::Children::const_iterator it = start_at->children().begin(); 40 ViewTreeNode::Children::const_iterator it = start_at->children().begin();
41 for (; it != start_at->children().end(); ++it) 41 for (; it != start_at->children().end(); ++it)
42 NotifyViewTreeChangeDown(*it, params); 42 NotifyViewTreeChangeDown(*it, params);
43 } 43 }
44 44
45 void NotifyViewTreeChange( 45 void NotifyViewTreeChange(
46 const ViewTreeNodeObserver::TreeChangeParams& params) { 46 const ViewTreeNodeObserver::TreeChangeParams& params) {
47 NotifyViewTreeChangeDown(params.target, params); 47 NotifyViewTreeChangeDown(params.target, params);
48 switch (params.phase) { 48 if (params.old_parent)
49 case ViewTreeNodeObserver::DISPOSITION_CHANGING: 49 NotifyViewTreeChangeUp(params.old_parent, params);
50 if (params.old_parent) 50 if (params.new_parent)
51 NotifyViewTreeChangeUp(params.old_parent, params); 51 NotifyViewTreeChangeUp(params.new_parent, params);
52 break;
53 case ViewTreeNodeObserver::DISPOSITION_CHANGED:
54 if (params.new_parent)
55 NotifyViewTreeChangeUp(params.new_parent, params);
56 break;
57 default:
58 NOTREACHED();
59 break;
60 }
61 } 52 }
62 53
63 class ScopedTreeNotifier { 54 class ScopedTreeNotifier {
64 public: 55 public:
65 ScopedTreeNotifier(ViewTreeNode* target, 56 ScopedTreeNotifier(ViewTreeNode* target,
66 ViewTreeNode* old_parent, 57 ViewTreeNode* old_parent,
67 ViewTreeNode* new_parent) { 58 ViewTreeNode* new_parent) {
68 params_.target = target; 59 params_.target = target;
69 params_.old_parent = old_parent; 60 params_.old_parent = old_parent;
70 params_.new_parent = new_parent; 61 params_.new_parent = new_parent;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 void ViewTreeNode::LocalAddChild(ViewTreeNode* child) { 305 void ViewTreeNode::LocalAddChild(ViewTreeNode* child) {
315 ScopedTreeNotifier notifier(child, child->parent(), this); 306 ScopedTreeNotifier notifier(child, child->parent(), this);
316 if (child->parent()) 307 if (child->parent())
317 RemoveChildImpl(child, &child->parent_->children_); 308 RemoveChildImpl(child, &child->parent_->children_);
318 children_.push_back(child); 309 children_.push_back(child);
319 child->parent_ = this; 310 child->parent_ = this;
320 } 311 }
321 312
322 void ViewTreeNode::LocalRemoveChild(ViewTreeNode* child) { 313 void ViewTreeNode::LocalRemoveChild(ViewTreeNode* child) {
323 DCHECK_EQ(this, child->parent()); 314 DCHECK_EQ(this, child->parent());
324 ScopedTreeNotifier(child, this, NULL); 315 ScopedTreeNotifier notifier(child, this, NULL);
325 RemoveChildImpl(child, &children_); 316 RemoveChildImpl(child, &children_);
326 } 317 }
327 318
328 void ViewTreeNode::LocalSetActiveView(View* view) { 319 void ViewTreeNode::LocalSetActiveView(View* view) {
329 ScopedSetActiveViewNotifier notifier(this, active_view_, view); 320 ScopedSetActiveViewNotifier notifier(this, active_view_, view);
330 if (active_view_) 321 if (active_view_)
331 ViewPrivate(active_view_).set_node(NULL); 322 ViewPrivate(active_view_).set_node(NULL);
332 active_view_ = view; 323 active_view_ = view;
333 if (active_view_) 324 if (active_view_)
334 ViewPrivate(active_view_).set_node(this); 325 ViewPrivate(active_view_).set_node(this);
335 } 326 }
336 327
337 void ViewTreeNode::LocalSetBounds(const gfx::Rect& old_bounds, 328 void ViewTreeNode::LocalSetBounds(const gfx::Rect& old_bounds,
338 const gfx::Rect& new_bounds) { 329 const gfx::Rect& new_bounds) {
339 DCHECK(old_bounds == bounds_); 330 DCHECK(old_bounds == bounds_);
340 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); 331 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds);
341 bounds_ = new_bounds; 332 bounds_ = new_bounds;
342 } 333 }
343 334
344 } // namespace view_manager 335 } // namespace view_manager
345 } // namespace mojo 336 } // namespace mojo
346 337
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698