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

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

Issue 8574033: Beginnings of Window Modality support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 delete child; 49 delete child;
50 // Deleting the child so remove it from out children_ list. 50 // Deleting the child so remove it from out children_ list.
51 DCHECK(std::find(children_.begin(), children_.end(), child) == 51 DCHECK(std::find(children_.begin(), children_.end(), child) ==
52 children_.end()); 52 children_.end());
53 } 53 }
54 54
55 // Removes ourselves from our transient parent. 55 // Removes ourselves from our transient parent.
56 if (transient_parent_) 56 if (transient_parent_)
57 transient_parent_->RemoveTransientChild(this); 57 transient_parent_->RemoveTransientChild(this);
58 58
59 // Destroy transient children.
60 Windows transient_children(transient_children_);
61 STLDeleteElements(&transient_children);
62 DCHECK(transient_children_.empty());
63
64 // And let the delegate do any post cleanup. 59 // And let the delegate do any post cleanup.
65 if (delegate_) 60 if (delegate_)
66 delegate_->OnWindowDestroyed(); 61 delegate_->OnWindowDestroyed();
67 if (parent_) 62 if (parent_)
68 parent_->RemoveChild(this); 63 parent_->RemoveChild(this);
69 64
65 // Destroy transient children, only after we've removed ourselves from our
66 // parent, as destroying an active transient child may otherwise attempt to
67 // refocus us.
68 Windows transient_children(transient_children_);
69 STLDeleteElements(&transient_children);
70 DCHECK(transient_children_.empty());
71
70 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); 72 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this));
71 } 73 }
72 74
73 void Window::Init(ui::Layer::LayerType layer_type) { 75 void Window::Init(ui::Layer::LayerType layer_type) {
74 layer_.reset(new ui::Layer(layer_type)); 76 layer_.reset(new ui::Layer(layer_type));
75 layer_->SetVisible(false); 77 layer_->SetVisible(false);
76 layer_->set_delegate(this); 78 layer_->set_delegate(this);
77 } 79 }
78 80
79 void Window::SetType(WindowType type) { 81 void Window::SetType(WindowType type) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 else 388 else
387 prop_map_.erase(name); 389 prop_map_.erase(name);
388 FOR_EACH_OBSERVER(WindowObserver, observers_, 390 FOR_EACH_OBSERVER(WindowObserver, observers_,
389 OnPropertyChanged(this, name, old)); 391 OnPropertyChanged(this, name, old));
390 } 392 }
391 393
392 void Window::SetIntProperty(const char* name, int value) { 394 void Window::SetIntProperty(const char* name, int value) {
393 SetProperty(name, reinterpret_cast<void*>(value)); 395 SetProperty(name, reinterpret_cast<void*>(value));
394 } 396 }
395 397
398 void Window::SetBoolProperty(const char* name, bool value) {
399 SetProperty(name, reinterpret_cast<void*>(value));
400 }
401
396 void* Window::GetProperty(const char* name) const { 402 void* Window::GetProperty(const char* name) const {
397 std::map<const char*, void*>::const_iterator iter = prop_map_.find(name); 403 std::map<const char*, void*>::const_iterator iter = prop_map_.find(name);
398 if (iter == prop_map_.end()) 404 if (iter == prop_map_.end())
399 return NULL; 405 return NULL;
400 return iter->second; 406 return iter->second;
401 } 407 }
402 408
403 int Window::GetIntProperty(const char* name) const { 409 int Window::GetIntProperty(const char* name) const {
404 return static_cast<int>(reinterpret_cast<intptr_t>( 410 return static_cast<int>(reinterpret_cast<intptr_t>(
405 GetProperty(name))); 411 GetProperty(name)));
406 } 412 }
407 413
414 bool Window::GetBoolProperty(const char* name) const {
415 return reinterpret_cast<bool>(GetProperty(name));
416 }
417
408 Desktop* Window::GetDesktop() { 418 Desktop* Window::GetDesktop() {
409 return parent_ ? parent_->GetDesktop() : NULL; 419 return parent_ ? parent_->GetDesktop() : NULL;
410 } 420 }
411 421
412 void Window::WindowDetachedFromDesktop(aura::Window* window) { 422 void Window::WindowDetachedFromDesktop(aura::Window* window) {
413 } 423 }
414 424
415 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { 425 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) {
416 const gfx::Rect old_bounds = layer_->GetTargetBounds(); 426 const gfx::Rect old_bounds = layer_->GetTargetBounds();
417 427
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 499
490 return delegate_ ? this : NULL; 500 return delegate_ ? this : NULL;
491 } 501 }
492 502
493 void Window::OnPaintLayer(gfx::Canvas* canvas) { 503 void Window::OnPaintLayer(gfx::Canvas* canvas) {
494 if (delegate_) 504 if (delegate_)
495 delegate_->OnPaint(canvas); 505 delegate_->OnPaint(canvas);
496 } 506 }
497 507
498 } // namespace aura 508 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698