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

Side by Side Diff: trunk/src/mojo/services/view_manager/node.cc

Issue 286973009: Revert 270925 "Tweaks to ViewManager:" (Closed) Base URL: svn://svn.chromium.org/chrome/
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/node.h" 5 #include "mojo/services/view_manager/node.h"
6 6
7 #include "mojo/services/view_manager/node_delegate.h" 7 #include "mojo/services/view_manager/node_delegate.h"
8 #include "mojo/services/view_manager/view.h" 8 #include "mojo/services/view_manager/view.h"
9 #include "ui/aura/window_property.h" 9 #include "ui/aura/window_property.h"
10 #include "ui/base/cursor/cursor.h" 10 #include "ui/base/cursor/cursor.h"
(...skipping 22 matching lines...) Expand all
33 window_.Init(aura::WINDOW_LAYER_TEXTURED); 33 window_.Init(aura::WINDOW_LAYER_TEXTURED);
34 34
35 // TODO(sky): this likely needs to be false and add a visibility API. 35 // TODO(sky): this likely needs to be false and add a visibility API.
36 window_.Show(); 36 window_.Show();
37 } 37 }
38 38
39 Node::~Node() { 39 Node::~Node() {
40 SetView(NULL); 40 SetView(NULL);
41 } 41 }
42 42
43 const Node* Node::GetParent() const { 43 Node* Node::GetParent() {
44 if (!window_.parent()) 44 if (!window_.parent())
45 return NULL; 45 return NULL;
46 return window_.parent()->GetProperty(kNodeKey); 46 return window_.parent()->GetProperty(kNodeKey);
47 } 47 }
48 48
49 void Node::Add(Node* child) { 49 void Node::Add(Node* child) {
50 window_.AddChild(&child->window_); 50 window_.AddChild(&child->window_);
51 } 51 }
52 52
53 void Node::Remove(Node* child) { 53 void Node::Remove(Node* child) {
54 window_.RemoveChild(&child->window_); 54 window_.RemoveChild(&child->window_);
55 } 55 }
56 56
57 const Node* Node::GetRoot() const {
58 const aura::Window* window = &window_;
59 while (window && window->parent())
60 window = window->parent();
61 return window->GetProperty(kNodeKey);
62 }
63
64 std::vector<Node*> Node::GetChildren() { 57 std::vector<Node*> Node::GetChildren() {
65 std::vector<Node*> children; 58 std::vector<Node*> children;
66 children.reserve(window_.children().size()); 59 children.reserve(window_.children().size());
67 for (size_t i = 0; i < window_.children().size(); ++i) 60 for (size_t i = 0; i < window_.children().size(); ++i)
68 children.push_back(window_.children()[i]->GetProperty(kNodeKey)); 61 children.push_back(window_.children()[i]->GetProperty(kNodeKey));
69 return children; 62 return children;
70 } 63 }
71 64
72 bool Node::Contains(const Node* node) const {
73 return node && window_.Contains(&(node->window_));
74 }
75
76 void Node::SetView(View* view) { 65 void Node::SetView(View* view) {
77 if (view == view_) 66 if (view == view_)
78 return; 67 return;
79 68
80 // Detach view from existing node. This way notifications are sent out. 69 // Detach view from existing node. This way notifications are sent out.
81 if (view && view->node()) 70 if (view && view->node())
82 view->node()->SetView(NULL); 71 view->node()->SetView(NULL);
83 72
84 ViewId old_view_id; 73 ViewId old_view_id;
85 if (view_) { 74 if (view_) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 bool Node::HasHitTestMask() const { 152 bool Node::HasHitTestMask() const {
164 return false; 153 return false;
165 } 154 }
166 155
167 void Node::GetHitTestMask(gfx::Path* mask) const { 156 void Node::GetHitTestMask(gfx::Path* mask) const {
168 } 157 }
169 158
170 } // namespace service 159 } // namespace service
171 } // namespace view_manager 160 } // namespace view_manager
172 } // namespace mojo 161 } // namespace mojo
OLDNEW
« no previous file with comments | « trunk/src/mojo/services/view_manager/node.h ('k') | trunk/src/mojo/services/view_manager/root_node_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698