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

Unified Diff: mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.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_manager_synchronizer.cc
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
index 8eea829d0dffffc6c39c4aa397b199f5e429dcc3..76a6b52f9f190419c6438144f3372b0afd399cc5 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
@@ -99,7 +99,9 @@ class ViewManagerTransaction {
// parent.)
TYPE_HIERARCHY,
// View replacement.
- TYPE_SET_ACTIVE_VIEW
+ TYPE_SET_ACTIVE_VIEW,
+ // Node bounds.
+ TYPE_SET_BOUNDS
};
ViewManagerTransaction(TransactionType transaction_type,
@@ -305,6 +307,32 @@ class SetActiveViewTransaction : public ViewManagerTransaction {
DISALLOW_COPY_AND_ASSIGN(SetActiveViewTransaction);
};
+class SetBoundsTransaction : public ViewManagerTransaction {
+ public:
+ SetBoundsTransaction(TransportNodeId node_id,
+ const gfx::Rect& bounds,
+ ViewManagerSynchronizer* synchronizer)
+ : ViewManagerTransaction(TYPE_SET_BOUNDS, synchronizer),
+ node_id_(node_id),
+ bounds_(bounds) {}
+ virtual ~SetBoundsTransaction() {}
+
+ private:
+ // Overridden from ViewManagerTransaction:
+ virtual void DoCommit() OVERRIDE {
+ AllocationScope scope;
+ service()->SetNodeBounds(node_id_, bounds_, ActionCompletedCallback());
+ }
+ virtual void DoActionCompleted(bool success) OVERRIDE {
+ // TODO(beng): recovery?
+ }
+
+ const TransportNodeId node_id_;
+ const gfx::Rect bounds_;
+
+ DISALLOW_COPY_AND_ASSIGN(SetBoundsTransaction);
+};
+
ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager)
: view_manager_(view_manager),
connected_(false),
@@ -399,6 +427,14 @@ void ViewManagerSynchronizer::SetActiveView(TransportNodeId node_id,
Sync();
}
+void ViewManagerSynchronizer::SetBounds(TransportNodeId node_id,
+ const gfx::Rect& bounds) {
+ DCHECK(connected_);
+ pending_transactions_.push_back(
+ new SetBoundsTransaction(node_id, bounds, this));
+ Sync();
+}
+
////////////////////////////////////////////////////////////////////////////////
// ViewManagerSynchronizer, IViewManagerClient implementation:
@@ -423,6 +459,13 @@ void ViewManagerSynchronizer::OnServerChangeIdAdvanced(
next_server_change_id_ = next_server_change_id;
}
+void ViewManagerSynchronizer::OnNodeBoundsChanged(uint32 node_id,
+ const Rect& old_bounds,
+ const Rect& new_bounds) {
+ ViewTreeNode* node = view_manager_->GetNodeById(node_id);
+ ViewTreeNodePrivate(node).LocalSetBounds(old_bounds, new_bounds);
+}
+
void ViewManagerSynchronizer::OnNodeHierarchyChanged(
uint32_t node_id,
uint32_t new_parent_id,

Powered by Google App Engine
This is Rietveld 408576698