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

Side by Side Diff: mojo/services/view_manager/node.h

Issue 507563002: Removes usage of aura::Window from Node (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: conditional Created 6 years, 3 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 #ifndef MOJO_SERVICES_VIEW_MANAGER_NODE_H_ 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_NODE_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_ 6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 11 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
12 #include "mojo/services/view_manager/ids.h" 12 #include "mojo/services/view_manager/ids.h"
13 #include "mojo/services/view_manager/view_manager_export.h" 13 #include "mojo/services/view_manager/view_manager_export.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/aura/window.h" 15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/aura/window_delegate.h"
17 #include "ui/aura/window_observer.h"
18 16
19 namespace mojo { 17 namespace mojo {
20 namespace service { 18 namespace service {
21 19
22 class NodeDelegate; 20 class NodeDelegate;
23 21
24 // Represents a node in the graph. Delegate is informed of interesting events. 22 // Represents a node in the graph. Delegate is informed of interesting events.
25 class MOJO_VIEW_MANAGER_EXPORT Node 23 //
26 : public aura::WindowObserver, 24 // It is assumed that all functions that mutate the node tree have validated the
27 public aura::WindowDelegate { 25 // value. For example, Reorder() assumes the supplied node is a child and not
26 // already in position.
27 class MOJO_VIEW_MANAGER_EXPORT Node {
28 public: 28 public:
29 Node(NodeDelegate* delegate, const NodeId& id); 29 Node(NodeDelegate* delegate, const NodeId& id);
30 virtual ~Node(); 30 virtual ~Node();
31 31
32 static Node* NodeForWindow(aura::Window* window);
33
34 const NodeId& id() const { return id_; } 32 const NodeId& id() const { return id_; }
35 33
36 void Add(Node* child); 34 void Add(Node* child);
37 void Remove(Node* child); 35 void Remove(Node* child);
38
39 void Reorder(Node* child, Node* relative, OrderDirection direction); 36 void Reorder(Node* child, Node* relative, OrderDirection direction);
40 37
41 aura::Window* window() { return &window_; } 38 const gfx::Rect& bounds() const { return bounds_; }
39 void SetBounds(const gfx::Rect& bounds);
42 40
43 const gfx::Rect& bounds() const { return window_.bounds(); } 41 const Node* parent() const { return parent_; }
44 42 Node* parent() { return parent_; }
45 const Node* GetParent() const;
46 Node* GetParent() {
47 return const_cast<Node*>(const_cast<const Node*>(this)->GetParent());
48 }
49 43
50 const Node* GetRoot() const; 44 const Node* GetRoot() const;
51 Node* GetRoot() { 45 Node* GetRoot() {
52 return const_cast<Node*>(const_cast<const Node*>(this)->GetRoot()); 46 return const_cast<Node*>(const_cast<const Node*>(this)->GetRoot());
53 } 47 }
54 48
55 std::vector<const Node*> GetChildren() const; 49 std::vector<const Node*> GetChildren() const;
56 std::vector<Node*> GetChildren(); 50 std::vector<Node*> GetChildren();
57 51
58 bool Contains(const Node* node) const; 52 bool Contains(const Node* node) const;
59 53
60 // Returns true if the window is visible. This does not consider visibility 54 // Returns true if the window is visible. This does not consider visibility
61 // of any ancestors. 55 // of any ancestors.
62 bool IsVisible() const; 56 bool visible() const { return visible_; }
63 void SetVisible(bool value); 57 void SetVisible(bool value);
64 58
65 void SetBitmap(const SkBitmap& contents); 59 void SetBitmap(const SkBitmap& contents);
66 const SkBitmap& bitmap() const { return bitmap_; } 60 const SkBitmap& bitmap() const { return bitmap_; }
67 61
68 private: 62 private:
69 // WindowObserver overrides: 63 typedef std::vector<Node*> Nodes;
70 virtual void OnWindowHierarchyChanged(
71 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE;
72 64
73 // WindowDelegate overrides: 65 // Implementation of removing a node. Doesn't send any notification.
74 virtual gfx::Size GetMinimumSize() const OVERRIDE; 66 void RemoveImpl(Node* node);
75 virtual gfx::Size GetMaximumSize() const OVERRIDE;
76 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
77 const gfx::Rect& new_bounds) OVERRIDE;
78 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
79 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
80 virtual bool ShouldDescendIntoChildForEventHandling(
81 aura::Window* child,
82 const gfx::Point& location) OVERRIDE;
83 virtual bool CanFocus() OVERRIDE;
84 virtual void OnCaptureLost() OVERRIDE;
85 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
86 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
87 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
88 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
89 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
90 virtual bool HasHitTestMask() const OVERRIDE;
91 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
92 67
93 NodeDelegate* delegate_; 68 NodeDelegate* delegate_;
94 const NodeId id_; 69 const NodeId id_;
95 70 Node* parent_;
96 aura::Window window_; 71 Nodes children_;
72 bool visible_;
73 gfx::Rect bounds_;
97 SkBitmap bitmap_; 74 SkBitmap bitmap_;
98 75
99 DISALLOW_COPY_AND_ASSIGN(Node); 76 DISALLOW_COPY_AND_ASSIGN(Node);
100 }; 77 };
101 78
102 } // namespace service 79 } // namespace service
103 } // namespace mojo 80 } // namespace mojo
104 81
105 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ 82 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698