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

Unified Diff: ui/wm/core/transient_window_manager.cc

Issue 628413002: Show transient child when the transient parent is shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix check Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/wm/core/transient_window_manager.cc
diff --git a/ui/wm/core/transient_window_manager.cc b/ui/wm/core/transient_window_manager.cc
index 120af84786c5b98a717491d7b4ff263d8facef53..6fb33d87bb41f04bb59876321034fc40693c326c 100644
--- a/ui/wm/core/transient_window_manager.cc
+++ b/ui/wm/core/transient_window_manager.cc
@@ -18,9 +18,12 @@
using aura::Window;
namespace wm {
+namespace {
DEFINE_OWNED_WINDOW_PROPERTY_KEY(TransientWindowManager, kPropertyKey, NULL);
+} // namespace
+
TransientWindowManager::~TransientWindowManager() {
}
@@ -97,7 +100,10 @@ bool TransientWindowManager::IsStackingTransient(
TransientWindowManager::TransientWindowManager(Window* window)
: window_(window),
transient_parent_(NULL),
- stacking_target_(NULL) {
+ stacking_target_(NULL),
+ parent_control_visibility_(false),
+ show_on_parent_visible_(false),
+ ignore_visibility_changed_event_(false) {
window_->AddObserver(this);
}
@@ -134,18 +140,45 @@ void TransientWindowManager::OnWindowParentChanged(aura::Window* window,
}
}
+void TransientWindowManager::UpdateTransientChildVisibility(
+ bool parent_visible) {
+ base::AutoReset<bool> reset(&ignore_visibility_changed_event_, true);
+ if (!parent_visible) {
+ show_on_parent_visible_ = window_->TargetVisibility();
+ window_->Hide();
+ } else {
+ if (show_on_parent_visible_ && parent_control_visibility_)
+ window_->Show();
+ show_on_parent_visible_ = false;
+ }
+}
+
void TransientWindowManager::OnWindowVisibilityChanging(Window* window,
bool visible) {
- // TODO(sky): move handling of becoming visible here.
- if (!visible) {
- std::for_each(transient_children_.begin(), transient_children_.end(),
- std::mem_fun(&Window::Hide));
+ if (window_ != window)
sky 2014/10/07 15:19:14 Why the if, at best this should be a DCHECK
oshima 2014/10/07 17:41:14 Done. I was confused by the difference between Cha
oshima 2014/10/07 17:41:56 oops, I meant "Changed (called in hierarchy chain)
+ return;
+
+ for (auto* child : transient_children_)
sky 2014/10/07 15:19:14 From the style guide: "auto is permitted, for loca
oshima 2014/10/07 17:41:14 Where is it? I was looking at http://chromium-cpp
oshima 2014/10/07 17:46:25 I guess you meant the description in https://googl
sky 2014/10/07 19:34:21 Yes, you are right. My mistake.
+ Get(child)->UpdateTransientChildVisibility(visible);
+}
+
+void TransientWindowManager::OnWindowVisibilityChanged(Window* window,
sky 2014/10/07 15:19:14 Why do you need to do something in both changed an
oshima 2014/10/07 17:41:14 I tried and had problem because OnWindowVisibiltyC
sky 2014/10/07 19:34:21 That seems wrong. It should only be called once.
+ bool visible) {
+ if (window_ != window || ignore_visibility_changed_event_ ||
sky 2014/10/07 15:19:14 You shouldn't need the window_ != window. Add a DC
oshima 2014/10/07 17:41:14 I needed this because OnWindowVisibilityChanged is
sky 2014/10/07 19:34:21 Ah, ok.
+ !transient_parent_ || !parent_control_visibility_) {
+ return;
+ }
+ if (!transient_parent_->TargetVisibility() && visible) {
+ base::AutoReset<bool> reset(&ignore_visibility_changed_event_, true);
+ show_on_parent_visible_ = true;
+ window_->Hide();
+ } else if (!visible) {
+ DCHECK(!show_on_parent_visible_);
}
}
void TransientWindowManager::OnWindowStackingChanged(Window* window) {
DCHECK_EQ(window_, window);
-
// Do nothing if we initiated the stacking change.
const TransientWindowManager* transient_manager =
Get(static_cast<const Window*>(window));

Powered by Google App Engine
This is Rietveld 408576698