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

Side by Side Diff: ui/aura/window.cc

Issue 8700013: Release aura::Desktop event handler windows on detaching an ancestor window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use parent_ to access parent. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_) {
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
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
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698