| 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 "ui/aura/desktop.h" | 10 #include "ui/aura/desktop.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 void Window::AddChild(Window* child) { | 200 void Window::AddChild(Window* child) { |
| 201 DCHECK(std::find(children_.begin(), children_.end(), child) == | 201 DCHECK(std::find(children_.begin(), children_.end(), child) == |
| 202 children_.end()); | 202 children_.end()); |
| 203 if (child->parent()) | 203 if (child->parent()) |
| 204 child->parent()->RemoveChild(child); | 204 child->parent()->RemoveChild(child); |
| 205 child->parent_ = this; | 205 child->parent_ = this; |
| 206 layer_->Add(child->layer_.get()); | 206 layer_->Add(child->layer_.get()); |
| 207 children_.push_back(child); | 207 children_.push_back(child); |
| 208 if (GetRoot()) |
| 209 Desktop::GetInstance()->WindowAdded(child); |
| 208 } | 210 } |
| 209 | 211 |
| 210 void Window::RemoveChild(Window* child) { | 212 void Window::RemoveChild(Window* child) { |
| 211 Windows::iterator i = std::find(children_.begin(), children_.end(), child); | 213 Windows::iterator i = std::find(children_.begin(), children_.end(), child); |
| 212 DCHECK(i != children_.end()); | 214 DCHECK(i != children_.end()); |
| 215 if (GetRoot()) |
| 216 Desktop::GetInstance()->WillRemoveWindow(child); |
| 213 child->parent_ = NULL; | 217 child->parent_ = NULL; |
| 214 layer_->Remove(child->layer_.get()); | 218 layer_->Remove(child->layer_.get()); |
| 215 children_.erase(i); | 219 children_.erase(i); |
| 216 } | 220 } |
| 217 | 221 |
| 218 Window* Window::GetChildById(int id) { | 222 Window* Window::GetChildById(int id) { |
| 219 return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id)); | 223 return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id)); |
| 220 } | 224 } |
| 221 | 225 |
| 222 const Window* Window::GetChildById(int id) const { | 226 const Window* Window::GetChildById(int id) const { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 if (restore_bounds_.IsEmpty()) | 393 if (restore_bounds_.IsEmpty()) |
| 390 restore_bounds_ = bounds(); | 394 restore_bounds_ = bounds(); |
| 391 return true; | 395 return true; |
| 392 } | 396 } |
| 393 | 397 |
| 394 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 398 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 395 delegate_->OnPaint(canvas); | 399 delegate_->OnPaint(canvas); |
| 396 } | 400 } |
| 397 | 401 |
| 398 } // namespace aura | 402 } // namespace aura |
| OLD | NEW |