Chromium Code Reviews| 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 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
| 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 namespace services { | 14 namespace services { |
| 15 namespace view_manager { | 15 namespace view_manager { |
| 16 | 16 |
| 17 class ViewManager; | |
| 17 class ViewTreeNodeObserver; | 18 class ViewTreeNodeObserver; |
| 18 | 19 |
| 19 class ViewTreeNode { | 20 class ViewTreeNode { |
| 20 public: | 21 public: |
| 21 typedef std::vector<ViewTreeNode*> Children; | 22 typedef std::vector<ViewTreeNode*> Children; |
| 22 | 23 |
| 23 ViewTreeNode(); | 24 explicit ViewTreeNode(ViewManager* manager); |
| 25 ViewTreeNode(); // Used for tests. | |
| 24 ~ViewTreeNode(); | 26 ~ViewTreeNode(); |
| 25 | 27 |
| 26 // Configuration. | 28 // Configuration. |
| 29 int id() const { return id_; } | |
| 27 void set_owned_by_parent(bool owned_by_parent) { | 30 void set_owned_by_parent(bool owned_by_parent) { |
| 28 owned_by_parent_ = owned_by_parent; | 31 owned_by_parent_ = owned_by_parent; |
| 29 } | 32 } |
| 30 | 33 |
| 31 // Observation. | 34 // Observation. |
| 32 void AddObserver(ViewTreeNodeObserver* observer); | 35 void AddObserver(ViewTreeNodeObserver* observer); |
| 33 void RemoveObserver(ViewTreeNodeObserver* observer); | 36 void RemoveObserver(ViewTreeNodeObserver* observer); |
| 34 | 37 |
| 35 // Tree. | 38 // Tree. |
| 36 ViewTreeNode* parent() { return parent_; } | 39 ViewTreeNode* parent() { return parent_; } |
| 37 const ViewTreeNode* parent() const { return parent_; } | 40 const ViewTreeNode* parent() const { return parent_; } |
| 38 const Children& children() const { return children_; } | 41 const Children& children() const { return children_; } |
| 39 | 42 |
| 40 void AddChild(ViewTreeNode* child); | 43 void AddChild(ViewTreeNode* child); |
| 41 void RemoveChild(ViewTreeNode* child); | 44 void RemoveChild(ViewTreeNode* child); |
| 42 | 45 |
| 43 bool Contains(ViewTreeNode* child) const; | 46 bool Contains(ViewTreeNode* child) const; |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 friend class ViewTreeNodePrivate; | 49 friend class ViewTreeNodePrivate; |
| 47 | 50 |
| 51 ViewManager* manager_; | |
| 52 int id_; | |
|
sky
2014/04/28 23:04:19
uint16_t Same for id() above.
| |
| 48 bool owned_by_parent_; | 53 bool owned_by_parent_; |
| 49 ViewTreeNode* parent_; | 54 ViewTreeNode* parent_; |
| 50 Children children_; | 55 Children children_; |
| 51 | 56 |
| 52 ObserverList<ViewTreeNodeObserver> observers_; | 57 ObserverList<ViewTreeNodeObserver> observers_; |
| 53 | 58 |
| 54 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); | 59 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); |
| 55 }; | 60 }; |
| 56 | 61 |
| 57 } // namespace view_manager | 62 } // namespace view_manager |
| 58 } // namespace services | 63 } // namespace services |
| 59 } // namespace mojo | 64 } // namespace mojo |
| 60 | 65 |
| 61 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 66 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
| OLD | NEW |