| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/mus/public/cpp/window.h" | 5 #include "components/mus/public/cpp/window.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 Window* window_; | 140 Window* window_; |
| 141 const gfx::Rect old_bounds_; | 141 const gfx::Rect old_bounds_; |
| 142 const gfx::Rect new_bounds_; | 142 const gfx::Rect new_bounds_; |
| 143 | 143 |
| 144 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); | 144 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // Some operations are only permitted in the connection that created the window. | 147 // Some operations are only permitted in the connection that created the window. |
| 148 bool OwnsWindow(WindowTreeConnection* connection, Window* window) { | 148 bool OwnsWindow(WindowTreeConnection* connection, Window* window) { |
| 149 return !connection || | 149 return !connection || |
| 150 static_cast<WindowTreeClientImpl*>(connection) | 150 static_cast<WindowTreeClientImpl*>(connection)->OwnsWindow(window); |
| 151 ->OwnsWindow(window->id()); | |
| 152 } | 151 } |
| 153 | 152 |
| 154 bool IsConnectionRoot(Window* window) { | 153 bool IsConnectionRoot(Window* window) { |
| 155 return window->connection() && | 154 return window->connection() && |
| 156 window->connection()->GetRoots().count(window) > 0; | 155 window->connection()->GetRoots().count(window) > 0; |
| 157 } | 156 } |
| 158 | 157 |
| 159 bool OwnsWindowOrIsRoot(Window* window) { | 158 bool OwnsWindowOrIsRoot(Window* window) { |
| 160 return OwnsWindow(window->connection(), window) || IsConnectionRoot(window); | 159 return OwnsWindow(window->connection(), window) || IsConnectionRoot(window); |
| 161 } | 160 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 for (const Window* parent = this; parent; parent = parent->parent()) | 266 for (const Window* parent = this; parent; parent = parent->parent()) |
| 268 root = parent; | 267 root = parent; |
| 269 return root; | 268 return root; |
| 270 } | 269 } |
| 271 | 270 |
| 272 void Window::AddChild(Window* child) { | 271 void Window::AddChild(Window* child) { |
| 273 // TODO(beng): not necessarily valid to all connections, but possibly to the | 272 // TODO(beng): not necessarily valid to all connections, but possibly to the |
| 274 // embeddee in an embedder-embeddee relationship. | 273 // embeddee in an embedder-embeddee relationship. |
| 275 if (connection_) | 274 if (connection_) |
| 276 CHECK_EQ(child->connection(), connection_); | 275 CHECK_EQ(child->connection(), connection_); |
| 276 // Roots can not be added as children of other windows. |
| 277 if (tree_client() && tree_client()->IsRoot(child)) |
| 278 return; |
| 277 LocalAddChild(child); | 279 LocalAddChild(child); |
| 278 if (connection_) | 280 if (connection_) |
| 279 tree_client()->AddChild(this, child->id()); | 281 tree_client()->AddChild(this, child->id()); |
| 280 } | 282 } |
| 281 | 283 |
| 282 void Window::RemoveChild(Window* child) { | 284 void Window::RemoveChild(Window* child) { |
| 283 // TODO(beng): not necessarily valid to all connections, but possibly to the | 285 // TODO(beng): not necessarily valid to all connections, but possibly to the |
| 284 // embeddee in an embedder-embeddee relationship. | 286 // embeddee in an embedder-embeddee relationship. |
| 285 if (connection_) | 287 if (connection_) |
| 286 CHECK_EQ(child->connection(), connection_); | 288 CHECK_EQ(child->connection(), connection_); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 notifier->NotifyWindowReordered(); | 805 notifier->NotifyWindowReordered(); |
| 804 | 806 |
| 805 return true; | 807 return true; |
| 806 } | 808 } |
| 807 | 809 |
| 808 // static | 810 // static |
| 809 Window** Window::GetStackingTarget(Window* window) { | 811 Window** Window::GetStackingTarget(Window* window) { |
| 810 return &window->stacking_target_; | 812 return &window->stacking_target_; |
| 811 } | 813 } |
| 812 } // namespace mus | 814 } // namespace mus |
| OLD | NEW |