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

Side by Side Diff: ui/aura/mus/window_port_mus.cc

Issue 2517853002: Fixes bug in handling restacking because of transients (Closed)
Patch Set: merge 2 trunk Created 4 years 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 unified diff | Download patch
OLDNEW
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
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 = FindServerChangeByTypeAndData(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
122 WindowPortMus::FindServerChangeByTypeAndData(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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) { 311 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) {
303 std::unique_ptr<WindowMusChangeDataImpl> data( 312 std::unique_ptr<WindowMusChangeDataImpl> data(
304 base::MakeUnique<WindowMusChangeDataImpl>()); 313 base::MakeUnique<WindowMusChangeDataImpl>());
305 ServerChangeData change_data; 314 ServerChangeData change_data;
306 change_data.bounds = bounds; 315 change_data.bounds = bounds;
307 data->change = base::MakeUnique<ScopedServerChange>( 316 data->change = base::MakeUnique<ScopedServerChange>(
308 this, ServerChangeType::BOUNDS, change_data); 317 this, ServerChangeType::BOUNDS, change_data);
309 return std::move(data); 318 return std::move(data);
310 } 319 }
311 320
321 void WindowPortMus::PrepareForTransientRestack(WindowMus* window) {
322 ServerChangeData change_data;
323 change_data.child_id = window->server_id();
324 ScheduleChange(ServerChangeType::TRANSIENT_REORDER, change_data);
325 }
326
327 void WindowPortMus::OnTransientRestackDone(WindowMus* window) {
328 ServerChangeData change_data;
329 change_data.child_id = window->server_id();
330 const bool removed = RemoveChangeByTypeAndData(
331 ServerChangeType::TRANSIENT_REORDER, change_data);
332 DCHECK(removed);
msw 2016/11/21 19:56:34 Just so I understand: is OnTransientRestackDone on
sky 2016/11/21 21:31:43 OnTransientRestackDone is always called.
msw 2016/11/21 22:34:49 Okay, so the transient reordering step sometimes d
sky 2016/11/21 22:41:10 You got it.
333 }
334
312 std::unique_ptr<WindowMusChangeData> 335 std::unique_ptr<WindowMusChangeData>
313 WindowPortMus::PrepareForServerVisibilityChange(bool value) { 336 WindowPortMus::PrepareForServerVisibilityChange(bool value) {
314 std::unique_ptr<WindowMusChangeDataImpl> data( 337 std::unique_ptr<WindowMusChangeDataImpl> data(
315 base::MakeUnique<WindowMusChangeDataImpl>()); 338 base::MakeUnique<WindowMusChangeDataImpl>());
316 ServerChangeData change_data; 339 ServerChangeData change_data;
317 change_data.visible = value; 340 change_data.visible = value;
318 data->change = base::MakeUnique<ScopedServerChange>( 341 data->change = base::MakeUnique<ScopedServerChange>(
319 this, ServerChangeType::VISIBLE, change_data); 342 this, ServerChangeType::VISIBLE, change_data);
320 return std::move(data); 343 return std::move(data);
321 } 344 }
(...skipping 23 matching lines...) Expand all
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 FindServerChangeByTypeAndData(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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698