OLD | NEW |
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/public/cpp/view_manager/view.h" | 5 #include "mojo/services/public/cpp/view_manager/view.h" |
6 | 6 |
7 #include "mojo/public/cpp/application/service_provider_impl.h" | 7 #include "mojo/public/cpp/application/service_provider_impl.h" |
8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" | 8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" |
9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" | 9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" |
10 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 10 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 | 264 |
265 void View::AddObserver(ViewObserver* observer) { | 265 void View::AddObserver(ViewObserver* observer) { |
266 observers_.AddObserver(observer); | 266 observers_.AddObserver(observer); |
267 } | 267 } |
268 | 268 |
269 void View::RemoveObserver(ViewObserver* observer) { | 269 void View::RemoveObserver(ViewObserver* observer) { |
270 observers_.RemoveObserver(observer); | 270 observers_.RemoveObserver(observer); |
271 } | 271 } |
272 | 272 |
| 273 const View* View::GetRoot() const { |
| 274 const View* root = this; |
| 275 for (const View* parent = this; parent; parent = parent->parent()) |
| 276 root = parent; |
| 277 return root; |
| 278 } |
| 279 |
273 void View::AddChild(View* child) { | 280 void View::AddChild(View* child) { |
274 // TODO(beng): not necessarily valid to all connections, but possibly to the | 281 // TODO(beng): not necessarily valid to all connections, but possibly to the |
275 // embeddee in an embedder-embeddee relationship. | 282 // embeddee in an embedder-embeddee relationship. |
276 if (manager_) | 283 if (manager_) |
277 CHECK_EQ(ViewPrivate(child).view_manager(), manager_); | 284 CHECK_EQ(ViewPrivate(child).view_manager(), manager_); |
278 LocalAddChild(child); | 285 LocalAddChild(child); |
279 if (manager_) | 286 if (manager_) |
280 static_cast<ViewManagerClientImpl*>(manager_)->AddChild(child->id(), id_); | 287 static_cast<ViewManagerClientImpl*>(manager_)->AddChild(child->id(), id_); |
281 } | 288 } |
282 | 289 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (IsDrawn() == value) { | 488 if (IsDrawn() == value) { |
482 drawn_ = value; | 489 drawn_ = value; |
483 return; | 490 return; |
484 } | 491 } |
485 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this)); | 492 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this)); |
486 drawn_ = value; | 493 drawn_ = value; |
487 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this)); | 494 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this)); |
488 } | 495 } |
489 | 496 |
490 } // namespace mojo | 497 } // namespace mojo |
OLD | NEW |