| 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" |
| 11 #include "ui/aura/desktop.h" | 11 #include "ui/aura/desktop.h" |
| 12 #include "ui/aura/desktop_delegate.h" | 12 #include "ui/aura/desktop_delegate.h" |
| 13 #include "ui/aura/event.h" | 13 #include "ui/aura/event.h" |
| 14 #include "ui/aura/event_filter.h" | 14 #include "ui/aura/event_filter.h" |
| 15 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
| 16 #include "ui/aura/window_delegate.h" | 16 #include "ui/aura/window_delegate.h" |
| 17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
| 18 #include "ui/aura/window_types.h" | 18 #include "ui/aura/window_types.h" |
| 19 #include "ui/base/animation/multi_animation.h" | 19 #include "ui/base/animation/multi_animation.h" |
| 20 #include "ui/base/view_prop.h" | |
| 21 #include "ui/gfx/canvas_skia.h" | 20 #include "ui/gfx/canvas_skia.h" |
| 22 #include "ui/gfx/compositor/compositor.h" | 21 #include "ui/gfx/compositor/compositor.h" |
| 23 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
| 24 | 23 |
| 25 namespace aura { | 24 namespace aura { |
| 26 | 25 |
| 27 Window::Window(WindowDelegate* delegate) | 26 Window::Window(WindowDelegate* delegate) |
| 28 : type_(WINDOW_TYPE_UNKNOWN), | 27 : type_(WINDOW_TYPE_UNKNOWN), |
| 29 delegate_(delegate), | 28 delegate_(delegate), |
| 30 show_state_(ui::SHOW_STATE_NORMAL), | 29 show_state_(ui::SHOW_STATE_NORMAL), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 STLDeleteElements(&transient_children); | 62 STLDeleteElements(&transient_children); |
| 64 DCHECK(transient_children_.empty()); | 63 DCHECK(transient_children_.empty()); |
| 65 | 64 |
| 66 // And let the delegate do any post cleanup. | 65 // And let the delegate do any post cleanup. |
| 67 if (delegate_) | 66 if (delegate_) |
| 68 delegate_->OnWindowDestroyed(); | 67 delegate_->OnWindowDestroyed(); |
| 69 if (parent_) | 68 if (parent_) |
| 70 parent_->RemoveChild(this); | 69 parent_->RemoveChild(this); |
| 71 | 70 |
| 72 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); | 71 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); |
| 73 | |
| 74 STLDeleteValues(&prop_map_); | |
| 75 } | 72 } |
| 76 | 73 |
| 77 void Window::Init(ui::Layer::LayerType layer_type) { | 74 void Window::Init(ui::Layer::LayerType layer_type) { |
| 78 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); | 75 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); |
| 79 layer_->SetVisible(false); | 76 layer_->SetVisible(false); |
| 80 layer_->set_delegate(this); | 77 layer_->set_delegate(this); |
| 81 } | 78 } |
| 82 | 79 |
| 83 void Window::SetType(WindowType type) { | 80 void Window::SetType(WindowType type) { |
| 84 // Cannot change type after the window is initialized. | 81 // Cannot change type after the window is initialized. |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 412 |
| 416 for (Windows::const_iterator it = children_.begin(); | 413 for (Windows::const_iterator it = children_.begin(); |
| 417 it != children_.end(); ++it) { | 414 it != children_.end(); ++it) { |
| 418 if ((*it)->IsOrContainsFullscreenWindow()) | 415 if ((*it)->IsOrContainsFullscreenWindow()) |
| 419 return true; | 416 return true; |
| 420 } | 417 } |
| 421 return false; | 418 return false; |
| 422 } | 419 } |
| 423 | 420 |
| 424 void Window::SetProperty(const char* name, void* value) { | 421 void Window::SetProperty(const char* name, void* value) { |
| 425 ui::ViewProp* prop = prop_map_[name]; | |
| 426 delete prop; | |
| 427 if (value) | 422 if (value) |
| 428 prop_map_[name] = new ui::ViewProp(this, name, value); | 423 prop_map_[name] = value; |
| 429 else | 424 else |
| 430 prop_map_.erase(name); | 425 prop_map_.erase(name); |
| 431 } | 426 } |
| 432 | 427 |
| 433 void* Window::GetProperty(const char* name) const { | 428 void* Window::GetProperty(const char* name) const { |
| 434 return ui::ViewProp::GetValue(const_cast<gfx::NativeView>(this), name); | 429 std::map<const char*, void*>::const_iterator iter = prop_map_.find(name); |
| 430 if (iter == prop_map_.end()) |
| 431 return NULL; |
| 432 return iter->second; |
| 435 } | 433 } |
| 436 | 434 |
| 437 Desktop* Window::GetDesktop() { | 435 Desktop* Window::GetDesktop() { |
| 438 return parent_ ? parent_->GetDesktop() : NULL; | 436 return parent_ ? parent_->GetDesktop() : NULL; |
| 439 } | 437 } |
| 440 | 438 |
| 441 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { | 439 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { |
| 442 const gfx::Rect old_bounds = bounds(); | 440 const gfx::Rect old_bounds = bounds(); |
| 443 if (old_bounds == new_bounds) | 441 if (old_bounds == new_bounds) |
| 444 return; | 442 return; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 528 |
| 531 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 529 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 532 delegate_->OnPaint(canvas); | 530 delegate_->OnPaint(canvas); |
| 533 } | 531 } |
| 534 | 532 |
| 535 void Window::OnLayerAnimationEnded( | 533 void Window::OnLayerAnimationEnded( |
| 536 const ui::LayerAnimationSequence* animation) { | 534 const ui::LayerAnimationSequence* animation) { |
| 537 } | 535 } |
| 538 | 536 |
| 539 } // namespace aura | 537 } // namespace aura |
| OLD | NEW |