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

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

Issue 2500973002: Converts test_wm to use aura (Closed)
Patch Set: fix bad remove Created 4 years, 1 month 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 16 matching lines...) Expand all
27 } 27 }
28 28
29 WindowPortMus::WindowPortMus(WindowTreeClient* client, 29 WindowPortMus::WindowPortMus(WindowTreeClient* client,
30 WindowMusType window_mus_type) 30 WindowMusType window_mus_type)
31 : WindowMus(window_mus_type), window_tree_client_(client) {} 31 : WindowMus(window_mus_type), window_tree_client_(client) {}
32 32
33 WindowPortMus::~WindowPortMus() { 33 WindowPortMus::~WindowPortMus() {
34 if (surface_info_) 34 if (surface_info_)
35 SetSurfaceIdFromServer(nullptr); 35 SetSurfaceIdFromServer(nullptr);
36 36
37 window_tree_client_->OnWindowMusDestroyed(this); 37 const WindowTreeClient::Origin origin =
msw 2016/11/17 21:26:15 nit: maybe comment here since this is slightly sub
sky 2016/11/17 22:25:54 I added a comment indicating why DESTROY means it
38 RemoveChangeByTypeAndData(ServerChangeType::DELETE, ServerChangeData())
39 ? WindowTreeClient::Origin::SERVER
40 : WindowTreeClient::Origin::CLIENT;
41 window_tree_client_->OnWindowMusDestroyed(this, origin);
38 } 42 }
39 43
40 // static 44 // static
41 WindowPortMus* WindowPortMus::Get(Window* window) { 45 WindowPortMus* WindowPortMus::Get(Window* window) {
42 return static_cast<WindowPortMus*>(WindowPort::Get(window)); 46 return static_cast<WindowPortMus*>(WindowPort::Get(window));
43 } 47 }
44 48
45 void WindowPortMus::SetTextInputState(mojo::TextInputStatePtr state) { 49 void WindowPortMus::SetTextInputState(mojo::TextInputStatePtr state) {
46 window_tree_client_->SetWindowTextInputState(this, std::move(state)); 50 window_tree_client_->SetWindowTextInputState(this, std::move(state));
47 } 51 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 case ServerChangeType::REMOVE: 120 case ServerChangeType::REMOVE:
117 case ServerChangeType::REMOVE_TRANSIENT: 121 case ServerChangeType::REMOVE_TRANSIENT:
118 case ServerChangeType::REORDER: 122 case ServerChangeType::REORDER:
119 if (iter->data.child_id == data.child_id) 123 if (iter->data.child_id == data.child_id)
120 break; 124 break;
121 continue; 125 continue;
122 case ServerChangeType::BOUNDS: 126 case ServerChangeType::BOUNDS:
123 if (iter->data.bounds == data.bounds) 127 if (iter->data.bounds == data.bounds)
124 break; 128 break;
125 continue; 129 continue;
130 case ServerChangeType::DELETE:
131 // No extra data for delete.
132 break;
126 case ServerChangeType::PROPERTY: 133 case ServerChangeType::PROPERTY:
127 if (iter->data.property_name == data.property_name) 134 if (iter->data.property_name == data.property_name)
128 break; 135 break;
129 continue; 136 continue;
130 case ServerChangeType::VISIBLE: 137 case ServerChangeType::VISIBLE:
131 if (iter->data.visible == data.visible) 138 if (iter->data.visible == data.visible)
132 break; 139 break;
133 continue; 140 continue;
134 } 141 }
135 server_changes_.erase(iter); 142 server_changes_.erase(iter);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 234 }
228 } 235 }
229 WindowPortMus* parent = Get(window_->parent()); 236 WindowPortMus* parent = Get(window_->parent());
230 if (parent && parent->surface_id_handler_) { 237 if (parent && parent->surface_id_handler_) {
231 parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_, 238 parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_,
232 &surface_info); 239 &surface_info);
233 } 240 }
234 surface_info_ = std::move(surface_info); 241 surface_info_ = std::move(surface_info);
235 } 242 }
236 243
244 void WindowPortMus::DestroyFromServer() {
245 std::unique_ptr<ScopedServerChange> remove_from_parent_change;
246 if (window_->parent()) {
247 ServerChangeData data;
248 data.child_id = server_id();
249 WindowPortMus* parent = Get(window_->parent());
250 remove_from_parent_change = base::MakeUnique<ScopedServerChange>(
251 parent, ServerChangeType::REMOVE, data);
252 }
253 // NOTE: this can't use ScopedServerChange as |this| is destroyed before the
254 // function returns (ScopedServerChange would attempt to access |this| after
255 // destruction).
256 ScheduleChange(ServerChangeType::DELETE, ServerChangeData());
257 delete window_;
258 }
259
237 void WindowPortMus::AddTransientChildFromServer(WindowMus* child) { 260 void WindowPortMus::AddTransientChildFromServer(WindowMus* child) {
238 ServerChangeData data; 261 ServerChangeData data;
239 data.child_id = child->server_id(); 262 data.child_id = child->server_id();
240 ScopedServerChange change(this, ServerChangeType::ADD_TRANSIENT, data); 263 ScopedServerChange change(this, ServerChangeType::ADD_TRANSIENT, data);
241 client::GetTransientWindowClient()->AddTransientChild(window_, 264 client::GetTransientWindowClient()->AddTransientChild(window_,
242 child->GetWindow()); 265 child->GetWindow());
243 } 266 }
244 267
245 void WindowPortMus::RemoveTransientChildFromServer(WindowMus* child) { 268 void WindowPortMus::RemoveTransientChildFromServer(WindowMus* child) {
246 ServerChangeData data; 269 ServerChangeData data;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 change_data.property_name = 381 change_data.property_name =
359 GetPropertyConverter()->GetTransportNameForPropertyKey(key); 382 GetPropertyConverter()->GetTransportNameForPropertyKey(key);
360 // TODO(sky): investigate to see if we need to compare data. In particular do 383 // TODO(sky): investigate to see if we need to compare data. In particular do
361 // we ever have a case where changing a property cascades into changing the 384 // we ever have a case where changing a property cascades into changing the
362 // same property? 385 // same property?
363 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) 386 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data))
364 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data)); 387 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data));
365 } 388 }
366 389
367 } // namespace aura 390 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698