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

Side by Side Diff: mojo/services/view_manager/view_manager_connection.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/view_manager/view_manager_connection.h" 5 #include "mojo/services/view_manager/view_manager_connection.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "mojo/geometry/geometry_type_converters.h"
8 #include "mojo/public/cpp/bindings/allocation_scope.h" 9 #include "mojo/public/cpp/bindings/allocation_scope.h"
9 #include "mojo/services/view_manager/node.h" 10 #include "mojo/services/view_manager/node.h"
10 #include "mojo/services/view_manager/root_node_manager.h" 11 #include "mojo/services/view_manager/root_node_manager.h"
11 #include "mojo/services/view_manager/view.h" 12 #include "mojo/services/view_manager/view.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 #include "ui/gfx/codec/png_codec.h" 15 #include "ui/gfx/codec/png_codec.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace view_manager { 18 namespace view_manager {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 79 }
79 80
80 View* ViewManagerConnection::GetView(const ViewId& id) { 81 View* ViewManagerConnection::GetView(const ViewId& id) {
81 if (id_ == id.connection_id) { 82 if (id_ == id.connection_id) {
82 ViewMap::const_iterator i = view_map_.find(id.view_id); 83 ViewMap::const_iterator i = view_map_.find(id.view_id);
83 return i == view_map_.end() ? NULL : i->second; 84 return i == view_map_.end() ? NULL : i->second;
84 } 85 }
85 return root_node_manager_->GetView(id); 86 return root_node_manager_->GetView(id);
86 } 87 }
87 88
89 void ViewManagerConnection::ProcessNodeBoundsChanged(
90 const Node* node,
91 const gfx::Rect& old_bounds,
92 const gfx::Rect& new_bounds,
93 bool originated_change) {
94 if (originated_change)
95 return;
96 TransportNodeId node_id = NodeIdToTransportId(node->id());
97 if (known_nodes_.count(node_id) > 0) {
98 AllocationScope scope;
99 client()->OnNodeBoundsChanged(node_id, old_bounds, new_bounds);
100 }
101 }
102
88 void ViewManagerConnection::ProcessNodeHierarchyChanged( 103 void ViewManagerConnection::ProcessNodeHierarchyChanged(
89 const Node* node, 104 const Node* node,
90 const Node* new_parent, 105 const Node* new_parent,
91 const Node* old_parent, 106 const Node* old_parent,
92 TransportChangeId server_change_id, 107 TransportChangeId server_change_id,
93 bool originated_change) { 108 bool originated_change) {
94 if (known_nodes_.count(NodeIdToTransportId(node->id())) > 0) { 109 if (known_nodes_.count(NodeIdToTransportId(node->id())) > 0) {
95 if (originated_change) 110 if (originated_change)
96 return; 111 return;
97 if (node->id().connection_id != id_ && !IsNodeDescendantOfRoots(node)) { 112 if (node->id().connection_id != id_ && !IsNodeDescendantOfRoots(node)) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 void ViewManagerConnection::SetRoots( 519 void ViewManagerConnection::SetRoots(
505 TransportConnectionId connection_id, 520 TransportConnectionId connection_id,
506 const Array<TransportNodeId>& transport_node_ids, 521 const Array<TransportNodeId>& transport_node_ids,
507 const Callback<void(bool)>& callback) { 522 const Callback<void(bool)>& callback) {
508 ViewManagerConnection* connection = 523 ViewManagerConnection* connection =
509 root_node_manager_->GetConnection(connection_id); 524 root_node_manager_->GetConnection(connection_id);
510 callback.Run(connection && 525 callback.Run(connection &&
511 connection->ProcessSetRoots(id_, transport_node_ids)); 526 connection->ProcessSetRoots(id_, transport_node_ids));
512 } 527 }
513 528
529 void ViewManagerConnection::SetNodeBounds(
530 TransportNodeId node_id,
531 const Rect& bounds,
532 const Callback<void(bool)>& callback) {
533 bool success = false;
534 Node* node = GetNode(NodeIdFromTransportId(node_id));
sky 2014/05/21 21:16:35 Only do this if node->id().connection_id == id_.
535 if (node) {
536 RootNodeManager::ScopedChange change(
537 this, root_node_manager_,
538 RootNodeManager::CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, false);
539 gfx::Rect old_bounds = node->window()->bounds();
540 node->window()->SetBounds(bounds);
541 root_node_manager_->ProcessNodeBoundsChanged(node, old_bounds, bounds);
542 success = true;
543 }
544 callback.Run(success);
545 }
546
514 void ViewManagerConnection::OnNodeHierarchyChanged(const Node* node, 547 void ViewManagerConnection::OnNodeHierarchyChanged(const Node* node,
515 const Node* new_parent, 548 const Node* new_parent,
516 const Node* old_parent) { 549 const Node* old_parent) {
517 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); 550 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent);
518 } 551 }
519 552
520 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, 553 void ViewManagerConnection::OnNodeViewReplaced(const Node* node,
521 const View* new_view, 554 const View* new_view,
522 const View* old_view) { 555 const View* old_view) {
523 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); 556 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view);
524 } 557 }
525 558
526 } // namespace service 559 } // namespace service
527 } // namespace view_manager 560 } // namespace view_manager
528 } // namespace mojo 561 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698