| OLD | NEW |
| 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/node.h" | 5 #include "mojo/services/public/cpp/view_manager/node.h" |
| 6 | 6 |
| 7 #include "mojo/services/public/cpp/view_manager/lib/node_private.h" | 7 #include "mojo/services/public/cpp/view_manager/lib/node_private.h" |
| 8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" | 8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.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/node_observer.h" | 10 #include "mojo/services/public/cpp/view_manager/node_observer.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 static_cast<ViewManagerClientImpl*>(view_manager)->AddNode(node); | 209 static_cast<ViewManagerClientImpl*>(view_manager)->AddNode(node); |
| 210 return node; | 210 return node; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void Node::Destroy() { | 213 void Node::Destroy() { |
| 214 if (!OwnsNode(manager_, this)) | 214 if (!OwnsNode(manager_, this)) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 if (manager_) | 217 if (manager_) |
| 218 static_cast<ViewManagerClientImpl*>(manager_)->DestroyNode(id_); | 218 static_cast<ViewManagerClientImpl*>(manager_)->DestroyNode(id_); |
| 219 while (!children_.empty()) | 219 while (!children_.empty()) { |
| 220 children_.front()->Destroy(); | 220 Node* child = children_.front(); |
| 221 if (!OwnsNode(manager_, child)) { |
| 222 NodePrivate(child).ClearParent(); |
| 223 children_.erase(children_.begin()); |
| 224 } else { |
| 225 child->Destroy(); |
| 226 DCHECK(std::find(children_.begin(), children_.end(), child) == |
| 227 children_.end()); |
| 228 } |
| 229 } |
| 221 LocalDestroy(); | 230 LocalDestroy(); |
| 222 } | 231 } |
| 223 | 232 |
| 224 void Node::SetBounds(const gfx::Rect& bounds) { | 233 void Node::SetBounds(const gfx::Rect& bounds) { |
| 225 if (!OwnsNode(manager_, this)) | 234 if (!OwnsNode(manager_, this)) |
| 226 return; | 235 return; |
| 227 | 236 |
| 228 if (manager_) | 237 if (manager_) |
| 229 static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds); | 238 static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds); |
| 230 LocalSetBounds(bounds_, bounds); | 239 LocalSetBounds(bounds_, bounds); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 397 } |
| 389 | 398 |
| 390 void Node::LocalSetBounds(const gfx::Rect& old_bounds, | 399 void Node::LocalSetBounds(const gfx::Rect& old_bounds, |
| 391 const gfx::Rect& new_bounds) { | 400 const gfx::Rect& new_bounds) { |
| 392 DCHECK(old_bounds == bounds_); | 401 DCHECK(old_bounds == bounds_); |
| 393 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); | 402 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); |
| 394 bounds_ = new_bounds; | 403 bounds_ = new_bounds; |
| 395 } | 404 } |
| 396 | 405 |
| 397 } // namespace mojo | 406 } // namespace mojo |
| OLD | NEW |