Chromium Code Reviews| Index: components/mus/ws/server_window.cc |
| diff --git a/components/mus/ws/server_window.cc b/components/mus/ws/server_window.cc |
| index 518c0640fe0abcbe126f08b9557f6b1ebbbb3ec6..ffe80c75003ce9b276d10f807e3157e007a0f107 100644 |
| --- a/components/mus/ws/server_window.cc |
| +++ b/components/mus/ws/server_window.cc |
| @@ -18,6 +18,28 @@ namespace mus { |
| namespace ws { |
| +namespace { |
| + |
| +const ServerWindow* GetModalChildForWindowAncestor(const ServerWindow* window) { |
| + for (const ServerWindow* ancestor = window; ancestor; |
| + ancestor = ancestor->parent()) { |
| + for (const auto& transient_child : ancestor->transient_children()) { |
| + if (transient_child->is_modal() && transient_child->IsDrawn()) |
| + return transient_child; |
| + } |
| + } |
| + return nullptr; |
| +} |
| + |
| +const ServerWindow* GetModalTargetForWindow(const ServerWindow* window) { |
| + const ServerWindow* modal_window = GetModalChildForWindowAncestor(window); |
| + if (!modal_window) |
| + return window; |
| + return GetModalTargetForWindow(modal_window); |
| +} |
| + |
| +} |
|
sky
2016/03/09 16:33:56
nit: // namespace
mohsen
2016/03/09 18:32:51
Done.
|
| + |
| ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) |
| : ServerWindow(delegate, id, Properties()) {} |
| @@ -29,6 +51,7 @@ ServerWindow::ServerWindow(ServerWindowDelegate* delegate, |
| parent_(nullptr), |
| stacking_target_(nullptr), |
| transient_parent_(nullptr), |
| + is_modal_(false), |
| visible_(false), |
| cursor_id_(mojom::Cursor::CURSOR_NULL), |
| opacity_(1), |
| @@ -241,6 +264,18 @@ void ServerWindow::RemoveTransientWindow(ServerWindow* child) { |
| OnTransientWindowRemoved(this, child)); |
| } |
| +void ServerWindow::SetAsModal() { |
| + is_modal_ = true; |
| +} |
| + |
| +bool ServerWindow::IsBlockedByModalWindow() const { |
| + return !!GetModalChildForWindowAncestor(this); |
| +} |
| + |
| +const ServerWindow* ServerWindow::GetModalTarget() const { |
| + return GetModalTargetForWindow(this); |
| +} |
| + |
| bool ServerWindow::Contains(const ServerWindow* window) const { |
| for (const ServerWindow* parent = window; parent; parent = parent->parent_) { |
| if (parent == this) |