OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child)); | 270 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child)); |
271 aura::Window* desktop = child->GetDesktop(); | 271 aura::Window* desktop = child->GetDesktop(); |
272 child->parent_ = NULL; | 272 child->parent_ = NULL; |
273 if (desktop) | 273 if (desktop) |
274 desktop->WindowDetachedFromDesktop(child); | 274 desktop->WindowDetachedFromDesktop(child); |
275 layer_->Remove(child->layer_.get()); | 275 layer_->Remove(child->layer_.get()); |
276 children_.erase(i); | 276 children_.erase(i); |
277 child->OnParentChanged(); | 277 child->OnParentChanged(); |
278 } | 278 } |
279 | 279 |
280 bool Window::Contains(const Window* other) const { | |
281 for (const Window* parent = other; parent; parent = parent->parent()) { | |
sky
2011/11/28 21:55:25
nit: use parent->parent_ here.
flackr
2011/11/29 14:54:14
Done.
| |
282 if (parent == this) | |
283 return true; | |
284 } | |
285 return false; | |
286 } | |
287 | |
280 Window* Window::GetChildById(int id) { | 288 Window* Window::GetChildById(int id) { |
281 return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id)); | 289 return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id)); |
282 } | 290 } |
283 | 291 |
284 const Window* Window::GetChildById(int id) const { | 292 const Window* Window::GetChildById(int id) const { |
285 Windows::const_iterator i; | 293 Windows::const_iterator i; |
286 for (i = children_.begin(); i != children_.end(); ++i) { | 294 for (i = children_.begin(); i != children_.end(); ++i) { |
287 if ((*i)->id() == id) | 295 if ((*i)->id() == id) |
288 return *i; | 296 return *i; |
289 const Window* result = (*i)->GetChildById(id); | 297 const Window* result = (*i)->GetChildById(id); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 void Window::OnStackingChanged() { | 545 void Window::OnStackingChanged() { |
538 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); | 546 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); |
539 } | 547 } |
540 | 548 |
541 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 549 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
542 if (delegate_) | 550 if (delegate_) |
543 delegate_->OnPaint(canvas); | 551 delegate_->OnPaint(canvas); |
544 } | 552 } |
545 | 553 |
546 } // namespace aura | 554 } // namespace aura |
OLD | NEW |