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

Side by Side Diff: mojo/services/view_manager/server_view.cc

Issue 557573002: Changes view manager to report visibility and drawn state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk 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
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/server_view.h" 5 #include "mojo/services/view_manager/server_view.h"
6 6
7 #include "mojo/services/view_manager/server_view_delegate.h" 7 #include "mojo/services/view_manager/server_view_delegate.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace service { 10 namespace service {
(...skipping 19 matching lines...) Expand all
30 DCHECK(child != this); 30 DCHECK(child != this);
31 DCHECK(!child->Contains(this)); 31 DCHECK(!child->Contains(this));
32 if (child->parent() == this) { 32 if (child->parent() == this) {
33 if (children_.size() == 1) 33 if (children_.size() == 1)
34 return; // Already in the right position. 34 return; // Already in the right position.
35 Reorder(child, children_.back(), ORDER_DIRECTION_ABOVE); 35 Reorder(child, children_.back(), ORDER_DIRECTION_ABOVE);
36 return; 36 return;
37 } 37 }
38 38
39 const ServerView* old_parent = child->parent(); 39 const ServerView* old_parent = child->parent();
40 child->delegate_->OnWillChangeViewHierarchy(child, this, old_parent);
40 if (child->parent()) 41 if (child->parent())
41 child->parent()->RemoveImpl(child); 42 child->parent()->RemoveImpl(child);
42 43
43 child->parent_ = this; 44 child->parent_ = this;
44 children_.push_back(child); 45 children_.push_back(child);
45 child->delegate_->OnViewHierarchyChanged(child, this, old_parent); 46 child->delegate_->OnViewHierarchyChanged(child, this, old_parent);
46 } 47 }
47 48
48 void ServerView::Remove(ServerView* child) { 49 void ServerView::Remove(ServerView* child) {
49 // We assume validation checks happened else where. 50 // We assume validation checks happened else where.
50 DCHECK(child); 51 DCHECK(child);
51 DCHECK(child != this); 52 DCHECK(child != this);
52 DCHECK(child->parent() == this); 53 DCHECK(child->parent() == this);
53 54
55 child->delegate_->OnWillChangeViewHierarchy(child, NULL, this);
54 RemoveImpl(child); 56 RemoveImpl(child);
55 child->delegate_->OnViewHierarchyChanged(child, NULL, this); 57 child->delegate_->OnViewHierarchyChanged(child, NULL, this);
56 } 58 }
57 59
58 void ServerView::Reorder(ServerView* child, 60 void ServerView::Reorder(ServerView* child,
59 ServerView* relative, 61 ServerView* relative,
60 OrderDirection direction) { 62 OrderDirection direction) {
61 // We assume validation checks happened else where. 63 // We assume validation checks happened else where.
62 DCHECK(child); 64 DCHECK(child);
63 DCHECK(child->parent() == this); 65 DCHECK(child->parent() == this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (parent == this) 109 if (parent == this)
108 return true; 110 return true;
109 } 111 }
110 return false; 112 return false;
111 } 113 }
112 114
113 void ServerView::SetVisible(bool value) { 115 void ServerView::SetVisible(bool value) {
114 if (visible_ == value) 116 if (visible_ == value)
115 return; 117 return;
116 118
119 delegate_->OnWillChangeViewVisibility(this);
117 visible_ = value; 120 visible_ = value;
118 // TODO(sky): notification, including repaint. 121 }
122
123 bool ServerView::IsDrawn(const ServerView* root) const {
124 if (!root->visible_)
125 return false;
126 const ServerView* view = this;
127 while (view && view != root && view->visible_)
128 view = view->parent_;
129 return view == root;
119 } 130 }
120 131
121 void ServerView::SetBitmap(const SkBitmap& bitmap) { 132 void ServerView::SetBitmap(const SkBitmap& bitmap) {
122 bitmap_ = bitmap; 133 bitmap_ = bitmap;
123 delegate_->OnViewBitmapChanged(this); 134 delegate_->OnViewBitmapChanged(this);
124 } 135 }
125 136
126 void ServerView::RemoveImpl(ServerView* view) { 137 void ServerView::RemoveImpl(ServerView* view) {
127 view->parent_ = NULL; 138 view->parent_ = NULL;
128 children_.erase(std::find(children_.begin(), children_.end(), view)); 139 children_.erase(std::find(children_.begin(), children_.end(), view));
129 } 140 }
130 141
131 } // namespace service 142 } // namespace service
132 } // namespace mojo 143 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/server_view.h ('k') | mojo/services/view_manager/server_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698