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

Side by Side Diff: third_party/mojo_services/src/view_manager/public/cpp/lib/view.cc

Issue 954643002: Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use run_renderer_in_process() Created 5 years, 9 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 "view_manager/public/cpp/view.h" 5 #include "view_manager/public/cpp/view.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/public/cpp/application/service_provider_impl.h" 10 #include "mojo/public/cpp/application/service_provider_impl.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 params_.new_parent = new_parent; 70 params_.new_parent = new_parent;
71 NotifyViewTreeChange(params_, false); 71 NotifyViewTreeChange(params_, false);
72 } 72 }
73 ~ScopedTreeNotifier() { 73 ~ScopedTreeNotifier() {
74 NotifyViewTreeChange(params_, true); 74 NotifyViewTreeChange(params_, true);
75 } 75 }
76 76
77 private: 77 private:
78 ViewObserver::TreeChangeParams params_; 78 ViewObserver::TreeChangeParams params_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(ScopedTreeNotifier); 80 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedTreeNotifier);
81 }; 81 };
82 82
83 void RemoveChildImpl(View* child, View::Children* children) { 83 void RemoveChildImpl(View* child, View::Children* children) {
84 View::Children::iterator it = 84 View::Children::iterator it =
85 std::find(children->begin(), children->end(), child); 85 std::find(children->begin(), children->end(), child);
86 if (it != children->end()) { 86 if (it != children->end()) {
87 children->erase(it); 87 children->erase(it);
88 ViewPrivate(child).ClearParent(); 88 ViewPrivate(child).ClearParent();
89 } 89 }
90 } 90 }
(...skipping 14 matching lines...) Expand all
105 FOR_EACH_OBSERVER(ViewObserver, 105 FOR_EACH_OBSERVER(ViewObserver,
106 *ViewPrivate(view_).observers(), 106 *ViewPrivate(view_).observers(),
107 OnViewReordered(view_, relative_view_, direction_)); 107 OnViewReordered(view_, relative_view_, direction_));
108 } 108 }
109 109
110 private: 110 private:
111 View* view_; 111 View* view_;
112 View* relative_view_; 112 View* relative_view_;
113 OrderDirection direction_; 113 OrderDirection direction_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier); 115 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier);
116 }; 116 };
117 117
118 // Returns true if the order actually changed. 118 // Returns true if the order actually changed.
119 bool ReorderImpl(View::Children* children, 119 bool ReorderImpl(View::Children* children,
120 View* view, 120 View* view,
121 View* relative, 121 View* relative,
122 OrderDirection direction) { 122 OrderDirection direction) {
123 DCHECK(relative); 123 DCHECK(relative);
124 DCHECK_NE(view, relative); 124 DCHECK_NE(view, relative);
125 DCHECK_EQ(view->parent(), relative->parent()); 125 DCHECK_EQ(view->parent(), relative->parent());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 FOR_EACH_OBSERVER(ViewObserver, 161 FOR_EACH_OBSERVER(ViewObserver,
162 *ViewPrivate(view_).observers(), 162 *ViewPrivate(view_).observers(),
163 OnViewBoundsChanged(view_, old_bounds_, new_bounds_)); 163 OnViewBoundsChanged(view_, old_bounds_, new_bounds_));
164 } 164 }
165 165
166 private: 166 private:
167 View* view_; 167 View* view_;
168 const Rect old_bounds_; 168 const Rect old_bounds_;
169 const Rect new_bounds_; 169 const Rect new_bounds_;
170 170
171 DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); 171 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier);
172 }; 172 };
173 173
174 // Some operations are only permitted in the connection that created the view. 174 // Some operations are only permitted in the connection that created the view.
175 bool OwnsView(ViewManager* manager, View* view) { 175 bool OwnsView(ViewManager* manager, View* view) {
176 return !manager || 176 return !manager ||
177 static_cast<ViewManagerClientImpl*>(manager)->OwnsView(view->id()); 177 static_cast<ViewManagerClientImpl*>(manager)->OwnsView(view->id());
178 } 178 }
179 179
180 } // namespace 180 } // namespace
181 181
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds); 213 static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds);
214 LocalSetBounds(bounds_, bounds); 214 LocalSetBounds(bounds_, bounds);
215 } 215 }
216 216
217 void View::SetVisible(bool value) { 217 void View::SetVisible(bool value) {
218 if (visible_ == value) 218 if (visible_ == value)
219 return; 219 return;
220 220
221 if (manager_) 221 if (manager_)
222 static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value); 222 static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value);
223 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this)); 223 LocalSetVisible(value);
224 visible_ = value;
225 NotifyViewVisibilityChanged(this);
226 } 224 }
227 225
228 void View::SetSharedProperty(const std::string& name, 226 void View::SetSharedProperty(const std::string& name,
229 const std::vector<uint8_t>* value) { 227 const std::vector<uint8_t>* value) {
230 std::vector<uint8_t> old_value; 228 std::vector<uint8_t> old_value;
231 std::vector<uint8_t>* old_value_ptr = nullptr; 229 std::vector<uint8_t>* old_value_ptr = nullptr;
232 auto it = properties_.find(name); 230 auto it = properties_.find(name);
233 if (it != properties_.end()) { 231 if (it != properties_.end()) {
234 old_value = it->second; 232 old_value = it->second;
235 old_value_ptr = &old_value; 233 old_value_ptr = &old_value;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // notification is the value of IsDrawn() is really changing. 522 // notification is the value of IsDrawn() is really changing.
525 if (IsDrawn() == value) { 523 if (IsDrawn() == value) {
526 drawn_ = value; 524 drawn_ = value;
527 return; 525 return;
528 } 526 }
529 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this)); 527 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this));
530 drawn_ = value; 528 drawn_ = value;
531 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this)); 529 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this));
532 } 530 }
533 531
532 void View::LocalSetVisible(bool visible) {
533 if (visible_ == visible)
534 return;
535
536 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this));
537 visible_ = visible;
538 NotifyViewVisibilityChanged(this);
539 }
540
534 void View::NotifyViewVisibilityChanged(View* target) { 541 void View::NotifyViewVisibilityChanged(View* target) {
535 if (!NotifyViewVisibilityChangedDown(target)) { 542 if (!NotifyViewVisibilityChangedDown(target)) {
536 return; // |this| has been deleted. 543 return; // |this| has been deleted.
537 } 544 }
538 NotifyViewVisibilityChangedUp(target); 545 NotifyViewVisibilityChangedUp(target);
539 } 546 }
540 547
541 bool View::NotifyViewVisibilityChangedAtReceiver(View* target) { 548 bool View::NotifyViewVisibilityChangedAtReceiver(View* target) {
542 // |this| may be deleted during a call to OnViewVisibilityChanged() on one 549 // |this| may be deleted during a call to OnViewVisibilityChanged() on one
543 // of the observers. We create an local observer for that. In that case we 550 // of the observers. We create an local observer for that. In that case we
(...skipping 29 matching lines...) Expand all
573 void View::NotifyViewVisibilityChangedUp(View* target) { 580 void View::NotifyViewVisibilityChangedUp(View* target) {
574 // Start with the parent as we already notified |this| 581 // Start with the parent as we already notified |this|
575 // in NotifyViewVisibilityChangedDown. 582 // in NotifyViewVisibilityChangedDown.
576 for (View* view = parent(); view; view = view->parent()) { 583 for (View* view = parent(); view; view = view->parent()) {
577 bool ret = view->NotifyViewVisibilityChangedAtReceiver(target); 584 bool ret = view->NotifyViewVisibilityChangedAtReceiver(target);
578 DCHECK(ret); 585 DCHECK(ret);
579 } 586 }
580 } 587 }
581 588
582 } // namespace mojo 589 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698