OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/auto_reset.h" | |
10 #include "base/bind.h" | 9 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
12 #include "base/callback.h" | 11 #include "base/callback.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
15 #include "base/string_util.h" | 14 #include "base/string_util.h" |
16 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
17 #include "ui/aura/client/capture_client.h" | 16 #include "ui/aura/client/capture_client.h" |
18 #include "ui/aura/client/event_client.h" | 17 #include "ui/aura/client/event_client.h" |
19 #include "ui/aura/client/screen_position_client.h" | 18 #include "ui/aura/client/screen_position_client.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 Window::Window(WindowDelegate* delegate) | 56 Window::Window(WindowDelegate* delegate) |
58 : type_(client::WINDOW_TYPE_UNKNOWN), | 57 : type_(client::WINDOW_TYPE_UNKNOWN), |
59 owned_by_parent_(true), | 58 owned_by_parent_(true), |
60 delegate_(delegate), | 59 delegate_(delegate), |
61 parent_(NULL), | 60 parent_(NULL), |
62 transient_parent_(NULL), | 61 transient_parent_(NULL), |
63 visible_(false), | 62 visible_(false), |
64 id_(-1), | 63 id_(-1), |
65 transparent_(false), | 64 transparent_(false), |
66 user_data_(NULL), | 65 user_data_(NULL), |
67 ignore_events_(false), | 66 ignore_events_(false) { |
68 in_set_visible_call_(false) { | |
69 } | 67 } |
70 | 68 |
71 Window::~Window() { | 69 Window::~Window() { |
72 CHECK(!in_set_visible_call_); | |
73 | |
74 // layer_ can be NULL if Init() wasn't invoked, which can happen | 70 // layer_ can be NULL if Init() wasn't invoked, which can happen |
75 // only in tests. | 71 // only in tests. |
76 if (layer_) | 72 if (layer_) |
77 layer_->SuppressPaint(); | 73 layer_->SuppressPaint(); |
78 | 74 |
79 // Let the delegate know we're in the processing of destroying. | 75 // Let the delegate know we're in the processing of destroying. |
80 if (delegate_) | 76 if (delegate_) |
81 delegate_->OnWindowDestroying(); | 77 delegate_->OnWindowDestroying(); |
82 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroying(this)); | 78 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroying(this)); |
83 | 79 |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // changed notification from the layer (this typically happens after animating | 676 // changed notification from the layer (this typically happens after animating |
681 // hidden). We must notify ourselves. | 677 // hidden). We must notify ourselves. |
682 if (layer_->delegate() != this) | 678 if (layer_->delegate() != this) |
683 OnLayerBoundsChanged(old_bounds, ContainsMouse()); | 679 OnLayerBoundsChanged(old_bounds, ContainsMouse()); |
684 } | 680 } |
685 | 681 |
686 void Window::SetVisible(bool visible) { | 682 void Window::SetVisible(bool visible) { |
687 if (visible == layer_->GetTargetVisibility()) | 683 if (visible == layer_->GetTargetVisibility()) |
688 return; // No change. | 684 return; // No change. |
689 | 685 |
690 AutoReset<bool> reseter(&in_set_visible_call_, true); | |
691 | |
692 RootWindow* root_window = GetRootWindow(); | 686 RootWindow* root_window = GetRootWindow(); |
693 if (client::GetVisibilityClient(root_window)) { | 687 if (client::GetVisibilityClient(root_window)) { |
694 client::GetVisibilityClient(root_window)->UpdateLayerVisibility( | 688 client::GetVisibilityClient(root_window)->UpdateLayerVisibility( |
695 this, visible); | 689 this, visible); |
696 } else { | 690 } else { |
697 layer_->SetVisible(visible); | 691 layer_->SetVisible(visible); |
698 } | 692 } |
699 visible_ = visible; | 693 visible_ = visible; |
700 SchedulePaint(); | 694 SchedulePaint(); |
701 if (delegate_) | 695 if (delegate_) |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 for (Windows::const_reverse_iterator it = children_.rbegin(), | 941 for (Windows::const_reverse_iterator it = children_.rbegin(), |
948 rend = children_.rend(); | 942 rend = children_.rend(); |
949 it != rend; ++it) { | 943 it != rend; ++it) { |
950 Window* child = *it; | 944 Window* child = *it; |
951 child->PrintWindowHierarchy(depth + 1); | 945 child->PrintWindowHierarchy(depth + 1); |
952 } | 946 } |
953 } | 947 } |
954 #endif | 948 #endif |
955 | 949 |
956 } // namespace aura | 950 } // namespace aura |
OLD | NEW |