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

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

Issue 287053004: SetBounds for ViewTreeNode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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_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

Powered by Google App Engine
This is Rietveld 408576698