| 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/client/transient_window_client.h" |
| 9 #include "ui/aura/mus/property_converter.h" | 9 #include "ui/aura/mus/property_converter.h" |
| 10 #include "ui/aura/mus/surface_id_handler.h" | 10 #include "ui/aura/mus/surface_id_handler.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ++iter) { | 104 ++iter) { |
| 105 if (iter->server_change_id == change_id) { | 105 if (iter->server_change_id == change_id) { |
| 106 server_changes_.erase(--(iter.base())); | 106 server_changes_.erase(--(iter.base())); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type, | 112 bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type, |
| 113 const ServerChangeData& data) { | 113 const ServerChangeData& data) { |
| 114 for (auto iter = server_changes_.begin(); iter != server_changes_.end(); | 114 auto iter = FindChangeByTypeAndData(type, data); |
| 115 ++iter) { | 115 if (iter == server_changes_.end()) |
| 116 return false; |
| 117 server_changes_.erase(iter); |
| 118 return true; |
| 119 } |
| 120 |
| 121 WindowPortMus::ServerChanges::iterator WindowPortMus::FindChangeByTypeAndData( |
| 122 const ServerChangeType type, |
| 123 const ServerChangeData& data) { |
| 124 auto iter = server_changes_.begin(); |
| 125 for (; iter != server_changes_.end(); ++iter) { |
| 116 if (iter->type != type) | 126 if (iter->type != type) |
| 117 continue; | 127 continue; |
| 118 | 128 |
| 119 switch (type) { | 129 switch (type) { |
| 120 case ServerChangeType::ADD: | 130 case ServerChangeType::ADD: |
| 121 case ServerChangeType::ADD_TRANSIENT: | 131 case ServerChangeType::ADD_TRANSIENT: |
| 122 case ServerChangeType::REMOVE: | 132 case ServerChangeType::REMOVE: |
| 123 case ServerChangeType::REMOVE_TRANSIENT: | 133 case ServerChangeType::REMOVE_TRANSIENT: |
| 124 case ServerChangeType::REORDER: | 134 case ServerChangeType::REORDER: |
| 135 case ServerChangeType::TRANSIENT_REORDER: |
| 125 if (iter->data.child_id == data.child_id) | 136 if (iter->data.child_id == data.child_id) |
| 126 break; | 137 return iter; |
| 127 continue; | 138 break; |
| 128 case ServerChangeType::BOUNDS: | 139 case ServerChangeType::BOUNDS: |
| 129 if (iter->data.bounds == data.bounds) | 140 if (iter->data.bounds == data.bounds) |
| 130 break; | 141 return iter; |
| 131 continue; | 142 break; |
| 132 case ServerChangeType::DESTROY: | 143 case ServerChangeType::DESTROY: |
| 133 // No extra data for delete. | 144 // No extra data for delete. |
| 134 break; | 145 return iter; |
| 135 case ServerChangeType::PROPERTY: | 146 case ServerChangeType::PROPERTY: |
| 136 if (iter->data.property_name == data.property_name) | 147 if (iter->data.property_name == data.property_name) |
| 137 break; | 148 return iter; |
| 138 continue; | 149 break; |
| 139 case ServerChangeType::VISIBLE: | 150 case ServerChangeType::VISIBLE: |
| 140 if (iter->data.visible == data.visible) | 151 if (iter->data.visible == data.visible) |
| 141 break; | 152 return iter; |
| 142 continue; | 153 break; |
| 143 } | 154 } |
| 144 server_changes_.erase(iter); | |
| 145 return true; | |
| 146 } | 155 } |
| 147 return false; | 156 return iter; |
| 148 } | 157 } |
| 149 | 158 |
| 150 PropertyConverter* WindowPortMus::GetPropertyConverter() { | 159 PropertyConverter* WindowPortMus::GetPropertyConverter() { |
| 151 return window_tree_client_->delegate_->GetPropertyConverter(); | 160 return window_tree_client_->delegate_->GetPropertyConverter(); |
| 152 } | 161 } |
| 153 | 162 |
| 154 Window* WindowPortMus::GetWindow() { | 163 Window* WindowPortMus::GetWindow() { |
| 155 return window_; | 164 return window_; |
| 156 } | 165 } |
| 157 | 166 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 WindowPortMus::PrepareForServerVisibilityChange(bool value) { | 322 WindowPortMus::PrepareForServerVisibilityChange(bool value) { |
| 314 std::unique_ptr<WindowMusChangeDataImpl> data( | 323 std::unique_ptr<WindowMusChangeDataImpl> data( |
| 315 base::MakeUnique<WindowMusChangeDataImpl>()); | 324 base::MakeUnique<WindowMusChangeDataImpl>()); |
| 316 ServerChangeData change_data; | 325 ServerChangeData change_data; |
| 317 change_data.visible = value; | 326 change_data.visible = value; |
| 318 data->change = base::MakeUnique<ScopedServerChange>( | 327 data->change = base::MakeUnique<ScopedServerChange>( |
| 319 this, ServerChangeType::VISIBLE, change_data); | 328 this, ServerChangeType::VISIBLE, change_data); |
| 320 return std::move(data); | 329 return std::move(data); |
| 321 } | 330 } |
| 322 | 331 |
| 332 void WindowPortMus::PrepareForTransientRestack(WindowMus* window) { |
| 333 ServerChangeData change_data; |
| 334 change_data.child_id = window->server_id(); |
| 335 ScheduleChange(ServerChangeType::TRANSIENT_REORDER, change_data); |
| 336 } |
| 337 |
| 338 void WindowPortMus::OnTransientRestackDone(WindowMus* window) { |
| 339 ServerChangeData change_data; |
| 340 change_data.child_id = window->server_id(); |
| 341 const bool removed = RemoveChangeByTypeAndData( |
| 342 ServerChangeType::TRANSIENT_REORDER, change_data); |
| 343 DCHECK(removed); |
| 344 } |
| 345 |
| 323 void WindowPortMus::NotifyEmbeddedAppDisconnected() { | 346 void WindowPortMus::NotifyEmbeddedAppDisconnected() { |
| 324 for (WindowObserver& observer : *GetObservers(window_)) | 347 for (WindowObserver& observer : *GetObservers(window_)) |
| 325 observer.OnEmbeddedAppDisconnected(window_); | 348 observer.OnEmbeddedAppDisconnected(window_); |
| 326 } | 349 } |
| 327 | 350 |
| 328 void WindowPortMus::OnPreInit(Window* window) { | 351 void WindowPortMus::OnPreInit(Window* window) { |
| 329 window_ = window; | 352 window_ = window; |
| 330 window_tree_client_->OnWindowMusCreated(this); | 353 window_tree_client_->OnWindowMusCreated(this); |
| 331 } | 354 } |
| 332 | 355 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 345 void WindowPortMus::OnWillRemoveChild(Window* child) { | 368 void WindowPortMus::OnWillRemoveChild(Window* child) { |
| 346 ServerChangeData change_data; | 369 ServerChangeData change_data; |
| 347 change_data.child_id = Get(child)->server_id(); | 370 change_data.child_id = Get(child)->server_id(); |
| 348 if (!RemoveChangeByTypeAndData(ServerChangeType::REMOVE, change_data)) | 371 if (!RemoveChangeByTypeAndData(ServerChangeType::REMOVE, change_data)) |
| 349 window_tree_client_->OnWindowMusRemoveChild(this, Get(child)); | 372 window_tree_client_->OnWindowMusRemoveChild(this, Get(child)); |
| 350 } | 373 } |
| 351 | 374 |
| 352 void WindowPortMus::OnWillMoveChild(size_t current_index, size_t dest_index) { | 375 void WindowPortMus::OnWillMoveChild(size_t current_index, size_t dest_index) { |
| 353 ServerChangeData change_data; | 376 ServerChangeData change_data; |
| 354 change_data.child_id = Get(window_->children()[current_index])->server_id(); | 377 change_data.child_id = Get(window_->children()[current_index])->server_id(); |
| 355 if (!RemoveChangeByTypeAndData(ServerChangeType::REORDER, change_data)) | 378 // See description of TRANSIENT_REORDER for details on why it isn't removed |
| 379 // here. |
| 380 if (!RemoveChangeByTypeAndData(ServerChangeType::REORDER, change_data) && |
| 381 FindChangeByTypeAndData(ServerChangeType::TRANSIENT_REORDER, |
| 382 change_data) == server_changes_.end()) { |
| 356 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); | 383 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); |
| 384 } |
| 357 } | 385 } |
| 358 | 386 |
| 359 void WindowPortMus::OnVisibilityChanged(bool visible) { | 387 void WindowPortMus::OnVisibilityChanged(bool visible) { |
| 360 ServerChangeData change_data; | 388 ServerChangeData change_data; |
| 361 change_data.visible = visible; | 389 change_data.visible = visible; |
| 362 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) | 390 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) |
| 363 window_tree_client_->OnWindowMusSetVisible(this, visible); | 391 window_tree_client_->OnWindowMusSetVisible(this, visible); |
| 364 } | 392 } |
| 365 | 393 |
| 366 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, | 394 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 383 change_data.property_name = | 411 change_data.property_name = |
| 384 GetPropertyConverter()->GetTransportNameForPropertyKey(key); | 412 GetPropertyConverter()->GetTransportNameForPropertyKey(key); |
| 385 // TODO(sky): investigate to see if we need to compare data. In particular do | 413 // TODO(sky): investigate to see if we need to compare data. In particular do |
| 386 // we ever have a case where changing a property cascades into changing the | 414 // we ever have a case where changing a property cascades into changing the |
| 387 // same property? | 415 // same property? |
| 388 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) | 416 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) |
| 389 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data)); | 417 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data)); |
| 390 } | 418 } |
| 391 | 419 |
| 392 } // namespace aura | 420 } // namespace aura |
| OLD | NEW |