Index: mojo/services/public/cpp/view_manager/lib/view_tree_node.cc |
diff --git a/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc b/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc |
index e501ea67038ed1b99c4657df2894cb0d6613d410..66331a72c39ff33bf4d7c1c0a339fe8383e42678 100644 |
--- a/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc |
+++ b/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc |
@@ -124,6 +124,40 @@ class ScopedSetActiveViewNotifier { |
DISALLOW_COPY_AND_ASSIGN(ScopedSetActiveViewNotifier); |
}; |
+class ScopedSetBoundsNotifier { |
+ public: |
+ ScopedSetBoundsNotifier(ViewTreeNode* node, |
+ const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) |
+ : node_(node), |
+ old_bounds_(old_bounds), |
+ new_bounds_(new_bounds) { |
+ FOR_EACH_OBSERVER( |
+ ViewTreeNodeObserver, |
+ *ViewTreeNodePrivate(node_).observers(), |
+ OnNodeBoundsChange(node_, |
+ old_bounds_, |
+ new_bounds_, |
+ ViewTreeNodeObserver::DISPOSITION_CHANGING)); |
+ } |
+ ~ScopedSetBoundsNotifier() { |
+ FOR_EACH_OBSERVER( |
+ ViewTreeNodeObserver, |
+ *ViewTreeNodePrivate(node_).observers(), |
+ OnNodeBoundsChange(node_, |
+ old_bounds_, |
+ new_bounds_, |
+ ViewTreeNodeObserver::DISPOSITION_CHANGED)); |
+ } |
+ |
+ private: |
+ ViewTreeNode* node_; |
+ const gfx::Rect old_bounds_; |
+ const gfx::Rect new_bounds_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); |
+}; |
+ |
class ScopedDestructionNotifier { |
public: |
explicit ScopedDestructionNotifier(ViewTreeNode* node) |
@@ -159,6 +193,7 @@ ViewTreeNode* ViewTreeNode::Create(ViewManager* view_manager) { |
} |
void ViewTreeNode::Destroy() { |
+ // TODO(beng): only proceed if |manager_| OwnsNode(this). |
if (manager_) |
ViewManagerPrivate(manager_).synchronizer()->DestroyViewTreeNode(id_); |
while (!children_.empty()) |
@@ -166,6 +201,13 @@ void ViewTreeNode::Destroy() { |
LocalDestroy(); |
} |
+void ViewTreeNode::SetBounds(const gfx::Rect& bounds) { |
+ // TODO(beng): only proceed if |manager_| OwnsNode(this). |
+ if (manager_) |
+ ViewManagerPrivate(manager_).synchronizer()->SetBounds(id_, bounds); |
+ LocalSetBounds(bounds_, bounds); |
+} |
+ |
void ViewTreeNode::AddObserver(ViewTreeNodeObserver* observer) { |
observers_.AddObserver(observer); |
} |
@@ -276,6 +318,13 @@ void ViewTreeNode::LocalSetActiveView(View* view) { |
ViewPrivate(active_view_).set_node(this); |
} |
+void ViewTreeNode::LocalSetBounds(const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) { |
+ DCHECK(old_bounds == bounds_); |
+ ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); |
+ bounds_ = new_bounds; |
+} |
+ |
} // namespace view_manager |
} // namespace mojo |