| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus/window_port_mus.h" | 5 #include "ui/aura/mus/window_port_mus.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/aura_constants.h" | 7 #include "ui/aura/client/aura_constants.h" |
| 8 #include "ui/aura/client/transient_window_client.h" |
| 8 #include "ui/aura/mus/property_converter.h" | 9 #include "ui/aura/mus/property_converter.h" |
| 9 #include "ui/aura/mus/surface_id_handler.h" | 10 #include "ui/aura/mus/surface_id_handler.h" |
| 10 #include "ui/aura/mus/window_tree_client.h" | 11 #include "ui/aura/mus/window_tree_client.h" |
| 11 #include "ui/aura/mus/window_tree_client_delegate.h" | 12 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 14 #include "ui/aura/window_property.h" | 15 #include "ui/aura/window_property.h" |
| 15 | 16 |
| 16 namespace aura { | 17 namespace aura { |
| 17 | 18 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 78 |
| 78 bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type, | 79 bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type, |
| 79 const ServerChangeData& data) { | 80 const ServerChangeData& data) { |
| 80 for (auto iter = server_changes_.begin(); iter != server_changes_.end(); | 81 for (auto iter = server_changes_.begin(); iter != server_changes_.end(); |
| 81 ++iter) { | 82 ++iter) { |
| 82 if (iter->type != type) | 83 if (iter->type != type) |
| 83 continue; | 84 continue; |
| 84 | 85 |
| 85 switch (type) { | 86 switch (type) { |
| 86 case ServerChangeType::ADD: | 87 case ServerChangeType::ADD: |
| 88 case ServerChangeType::ADD_TRANSIENT: |
| 87 case ServerChangeType::REMOVE: | 89 case ServerChangeType::REMOVE: |
| 90 case ServerChangeType::REMOVE_TRANSIENT: |
| 88 case ServerChangeType::REORDER: | 91 case ServerChangeType::REORDER: |
| 89 if (iter->data.child_id == data.child_id) | 92 if (iter->data.child_id == data.child_id) |
| 90 break; | 93 break; |
| 91 continue; | 94 continue; |
| 92 case ServerChangeType::BOUNDS: | 95 case ServerChangeType::BOUNDS: |
| 93 if (iter->data.bounds == data.bounds) | 96 if (iter->data.bounds == data.bounds) |
| 94 break; | 97 break; |
| 95 continue; | 98 continue; |
| 96 case ServerChangeType::PROPERTY: | 99 case ServerChangeType::PROPERTY: |
| 97 if (iter->data.property_name == data.property_name) | 100 if (iter->data.property_name == data.property_name) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 208 } |
| 206 } | 209 } |
| 207 WindowPortMus* parent = Get(window_->parent()); | 210 WindowPortMus* parent = Get(window_->parent()); |
| 208 if (parent && parent->surface_id_handler_) { | 211 if (parent && parent->surface_id_handler_) { |
| 209 parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_, | 212 parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_, |
| 210 &surface_info); | 213 &surface_info); |
| 211 } | 214 } |
| 212 surface_info_ = std::move(surface_info); | 215 surface_info_ = std::move(surface_info); |
| 213 } | 216 } |
| 214 | 217 |
| 218 void WindowPortMus::AddTransientChildFromServer(WindowMus* child) { |
| 219 DCHECK(has_server_window()); |
| 220 ServerChangeData data; |
| 221 data.child_id = child->server_id(); |
| 222 ScopedServerChange change(this, ServerChangeType::ADD_TRANSIENT, data); |
| 223 client::GetTransientWindowClient()->AddTransientChild(window_, |
| 224 child->GetWindow()); |
| 225 } |
| 226 |
| 227 void WindowPortMus::RemoveTransientChildFromServer(WindowMus* child) { |
| 228 DCHECK(has_server_window()); |
| 229 ServerChangeData data; |
| 230 data.child_id = child->server_id(); |
| 231 ScopedServerChange change(this, ServerChangeType::REMOVE_TRANSIENT, data); |
| 232 client::GetTransientWindowClient()->RemoveTransientChild(window_, |
| 233 child->GetWindow()); |
| 234 } |
| 235 |
| 236 WindowPortMus::ChangeSource WindowPortMus::OnTransientChildAdded( |
| 237 WindowMus* child) { |
| 238 DCHECK(has_server_window()); |
| 239 ServerChangeData change_data; |
| 240 change_data.child_id = child->server_id(); |
| 241 // If there was a change it means we scheduled the change by way of |
| 242 // AddTransientChildFromServer(), which came from the server. |
| 243 return RemoveChangeByTypeAndData(ServerChangeType::ADD_TRANSIENT, change_data) |
| 244 ? ChangeSource::SERVER |
| 245 : ChangeSource::LOCAL; |
| 246 } |
| 247 |
| 248 WindowPortMus::ChangeSource WindowPortMus::OnTransientChildRemoved( |
| 249 WindowMus* child) { |
| 250 DCHECK(has_server_window()); |
| 251 ServerChangeData change_data; |
| 252 change_data.child_id = child->server_id(); |
| 253 // If there was a change it means we scheduled the change by way of |
| 254 // RemoveTransientChildFromServer(), which came from the server. |
| 255 return RemoveChangeByTypeAndData(ServerChangeType::REMOVE_TRANSIENT, |
| 256 change_data) |
| 257 ? ChangeSource::SERVER |
| 258 : ChangeSource::LOCAL; |
| 259 } |
| 260 |
| 215 std::unique_ptr<WindowMusChangeData> | 261 std::unique_ptr<WindowMusChangeData> |
| 216 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) { | 262 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) { |
| 217 std::unique_ptr<WindowMusChangeDataImpl> data( | 263 std::unique_ptr<WindowMusChangeDataImpl> data( |
| 218 base::MakeUnique<WindowMusChangeDataImpl>()); | 264 base::MakeUnique<WindowMusChangeDataImpl>()); |
| 219 ServerChangeData change_data; | 265 ServerChangeData change_data; |
| 220 change_data.bounds = bounds; | 266 change_data.bounds = bounds; |
| 221 data->change = base::MakeUnique<ScopedServerChange>( | 267 data->change = base::MakeUnique<ScopedServerChange>( |
| 222 this, ServerChangeType::BOUNDS, change_data); | 268 this, ServerChangeType::BOUNDS, change_data); |
| 223 return std::move(data); | 269 return std::move(data); |
| 224 } | 270 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 change_data.property_name = | 365 change_data.property_name = |
| 320 GetPropertyConverter()->GetTransportNameForPropertyKey(key); | 366 GetPropertyConverter()->GetTransportNameForPropertyKey(key); |
| 321 // TODO(sky): investigate to see if we need to compare data. In particular do | 367 // TODO(sky): investigate to see if we need to compare data. In particular do |
| 322 // we ever have a case where changing a property cascades into changing the | 368 // we ever have a case where changing a property cascades into changing the |
| 323 // same property? | 369 // same property? |
| 324 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) | 370 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) |
| 325 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data)); | 371 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data)); |
| 326 } | 372 } |
| 327 | 373 |
| 328 } // namespace aura | 374 } // namespace aura |
| OLD | NEW |