| 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 "services/ui/ws/server_window.h" | 5 #include "services/ui/ws/server_window.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 properties_(properties), | 39 properties_(properties), |
| 40 // Don't notify newly added observers during notification. This causes | 40 // Don't notify newly added observers during notification. This causes |
| 41 // problems for code that adds an observer as part of an observer | 41 // problems for code that adds an observer as part of an observer |
| 42 // notification (such as ServerWindowDrawTracker). | 42 // notification (such as ServerWindowDrawTracker). |
| 43 observers_( | 43 observers_( |
| 44 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { | 44 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 45 DCHECK(delegate); // Must provide a delegate. | 45 DCHECK(delegate); // Must provide a delegate. |
| 46 } | 46 } |
| 47 | 47 |
| 48 ServerWindow::~ServerWindow() { | 48 ServerWindow::~ServerWindow() { |
| 49 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, OnWindowDestroying(this)); | 49 for (auto& observer : observers_) |
| 50 observer.OnWindowDestroying(this); |
| 50 | 51 |
| 51 if (transient_parent_) | 52 if (transient_parent_) |
| 52 transient_parent_->RemoveTransientWindow(this); | 53 transient_parent_->RemoveTransientWindow(this); |
| 53 | 54 |
| 54 // Destroy transient children, only after we've removed ourselves from our | 55 // Destroy transient children, only after we've removed ourselves from our |
| 55 // parent, as destroying an active transient child may otherwise attempt to | 56 // parent, as destroying an active transient child may otherwise attempt to |
| 56 // refocus us. | 57 // refocus us. |
| 57 Windows transient_children(transient_children_); | 58 Windows transient_children(transient_children_); |
| 58 for (auto window : transient_children) | 59 for (auto window : transient_children) |
| 59 delete window; | 60 delete window; |
| 60 DCHECK(transient_children_.empty()); | 61 DCHECK(transient_children_.empty()); |
| 61 | 62 |
| 62 while (!children_.empty()) | 63 while (!children_.empty()) |
| 63 children_.front()->parent()->Remove(children_.front()); | 64 children_.front()->parent()->Remove(children_.front()); |
| 64 | 65 |
| 65 if (parent_) | 66 if (parent_) |
| 66 parent_->Remove(this); | 67 parent_->Remove(this); |
| 67 | 68 |
| 68 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, OnWindowDestroyed(this)); | 69 for (auto& observer : observers_) |
| 70 observer.OnWindowDestroyed(this); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void ServerWindow::AddObserver(ServerWindowObserver* observer) { | 73 void ServerWindow::AddObserver(ServerWindowObserver* observer) { |
| 72 observers_.AddObserver(observer); | 74 observers_.AddObserver(observer); |
| 73 } | 75 } |
| 74 | 76 |
| 75 void ServerWindow::RemoveObserver(ServerWindowObserver* observer) { | 77 void ServerWindow::RemoveObserver(ServerWindowObserver* observer) { |
| 76 DCHECK(observers_.HasObserver(observer)); | 78 DCHECK(observers_.HasObserver(observer)); |
| 77 observers_.RemoveObserver(observer); | 79 observers_.RemoveObserver(observer); |
| 78 } | 80 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 94 DCHECK(child != this); | 96 DCHECK(child != this); |
| 95 DCHECK(!child->Contains(this)); | 97 DCHECK(!child->Contains(this)); |
| 96 if (child->parent() == this) { | 98 if (child->parent() == this) { |
| 97 if (children_.size() == 1) | 99 if (children_.size() == 1) |
| 98 return; // Already in the right position. | 100 return; // Already in the right position. |
| 99 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); | 101 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); |
| 100 return; | 102 return; |
| 101 } | 103 } |
| 102 | 104 |
| 103 ServerWindow* old_parent = child->parent(); | 105 ServerWindow* old_parent = child->parent(); |
| 104 FOR_EACH_OBSERVER(ServerWindowObserver, child->observers_, | 106 for (auto& observer : child->observers_) |
| 105 OnWillChangeWindowHierarchy(child, this, old_parent)); | 107 observer.OnWillChangeWindowHierarchy(child, this, old_parent); |
| 106 | 108 |
| 107 if (child->parent()) | 109 if (child->parent()) |
| 108 child->parent()->RemoveImpl(child); | 110 child->parent()->RemoveImpl(child); |
| 109 | 111 |
| 110 child->parent_ = this; | 112 child->parent_ = this; |
| 111 children_.push_back(child); | 113 children_.push_back(child); |
| 112 | 114 |
| 113 // Stack the child properly if it is a transient child of a sibling. | 115 // Stack the child properly if it is a transient child of a sibling. |
| 114 if (child->transient_parent_ && child->transient_parent_->parent() == this) | 116 if (child->transient_parent_ && child->transient_parent_->parent() == this) |
| 115 RestackTransientDescendants(child->transient_parent_, &GetStackingTarget, | 117 RestackTransientDescendants(child->transient_parent_, &GetStackingTarget, |
| 116 &ReorderImpl); | 118 &ReorderImpl); |
| 117 | 119 |
| 118 FOR_EACH_OBSERVER(ServerWindowObserver, child->observers_, | 120 for (auto& observer : child->observers_) |
| 119 OnWindowHierarchyChanged(child, this, old_parent)); | 121 observer.OnWindowHierarchyChanged(child, this, old_parent); |
| 120 } | 122 } |
| 121 | 123 |
| 122 void ServerWindow::Remove(ServerWindow* child) { | 124 void ServerWindow::Remove(ServerWindow* child) { |
| 123 // We assume validation checks happened else where. | 125 // We assume validation checks happened else where. |
| 124 DCHECK(child); | 126 DCHECK(child); |
| 125 DCHECK(child != this); | 127 DCHECK(child != this); |
| 126 DCHECK(child->parent() == this); | 128 DCHECK(child->parent() == this); |
| 127 | 129 |
| 128 FOR_EACH_OBSERVER(ServerWindowObserver, child->observers_, | 130 for (auto& observer : child->observers_) |
| 129 OnWillChangeWindowHierarchy(child, nullptr, this)); | 131 observer.OnWillChangeWindowHierarchy(child, nullptr, this); |
| 130 RemoveImpl(child); | 132 RemoveImpl(child); |
| 131 | 133 |
| 132 // Stack the child properly if it is a transient child of a sibling. | 134 // Stack the child properly if it is a transient child of a sibling. |
| 133 if (child->transient_parent_ && child->transient_parent_->parent() == this) | 135 if (child->transient_parent_ && child->transient_parent_->parent() == this) |
| 134 RestackTransientDescendants(child->transient_parent_, &GetStackingTarget, | 136 RestackTransientDescendants(child->transient_parent_, &GetStackingTarget, |
| 135 &ReorderImpl); | 137 &ReorderImpl); |
| 136 | 138 |
| 137 FOR_EACH_OBSERVER(ServerWindowObserver, child->observers_, | 139 for (auto& observer : child->observers_) |
| 138 OnWindowHierarchyChanged(child, nullptr, this)); | 140 observer.OnWindowHierarchyChanged(child, nullptr, this); |
| 139 } | 141 } |
| 140 | 142 |
| 141 void ServerWindow::Reorder(ServerWindow* relative, | 143 void ServerWindow::Reorder(ServerWindow* relative, |
| 142 mojom::OrderDirection direction) { | 144 mojom::OrderDirection direction) { |
| 143 ReorderImpl(this, relative, direction); | 145 ReorderImpl(this, relative, direction); |
| 144 } | 146 } |
| 145 | 147 |
| 146 void ServerWindow::StackChildAtBottom(ServerWindow* child) { | 148 void ServerWindow::StackChildAtBottom(ServerWindow* child) { |
| 147 // There's nothing to do if the child is already at the bottom. | 149 // There's nothing to do if the child is already at the bottom. |
| 148 if (children_.size() <= 1 || child == children_.front()) | 150 if (children_.size() <= 1 || child == children_.front()) |
| 149 return; | 151 return; |
| 150 child->Reorder(children_.front(), mojom::OrderDirection::BELOW); | 152 child->Reorder(children_.front(), mojom::OrderDirection::BELOW); |
| 151 } | 153 } |
| 152 | 154 |
| 153 void ServerWindow::StackChildAtTop(ServerWindow* child) { | 155 void ServerWindow::StackChildAtTop(ServerWindow* child) { |
| 154 // There's nothing to do if the child is already at the top. | 156 // There's nothing to do if the child is already at the top. |
| 155 if (children_.size() <= 1 || child == children_.back()) | 157 if (children_.size() <= 1 || child == children_.back()) |
| 156 return; | 158 return; |
| 157 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); | 159 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); |
| 158 } | 160 } |
| 159 | 161 |
| 160 void ServerWindow::SetBounds(const gfx::Rect& bounds) { | 162 void ServerWindow::SetBounds(const gfx::Rect& bounds) { |
| 161 if (bounds_ == bounds) | 163 if (bounds_ == bounds) |
| 162 return; | 164 return; |
| 163 | 165 |
| 164 // TODO(fsamuel): figure out how will this work with CompositorFrames. | 166 // TODO(fsamuel): figure out how will this work with CompositorFrames. |
| 165 | 167 |
| 166 const gfx::Rect old_bounds = bounds_; | 168 const gfx::Rect old_bounds = bounds_; |
| 167 bounds_ = bounds; | 169 bounds_ = bounds; |
| 168 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 170 for (auto& observer : observers_) |
| 169 OnWindowBoundsChanged(this, old_bounds, bounds)); | 171 observer.OnWindowBoundsChanged(this, old_bounds, bounds); |
| 170 } | 172 } |
| 171 | 173 |
| 172 void ServerWindow::SetClientArea( | 174 void ServerWindow::SetClientArea( |
| 173 const gfx::Insets& insets, | 175 const gfx::Insets& insets, |
| 174 const std::vector<gfx::Rect>& additional_client_areas) { | 176 const std::vector<gfx::Rect>& additional_client_areas) { |
| 175 if (client_area_ == insets && | 177 if (client_area_ == insets && |
| 176 additional_client_areas == additional_client_areas_) { | 178 additional_client_areas == additional_client_areas_) { |
| 177 return; | 179 return; |
| 178 } | 180 } |
| 179 | 181 |
| 180 additional_client_areas_ = additional_client_areas; | 182 additional_client_areas_ = additional_client_areas; |
| 181 client_area_ = insets; | 183 client_area_ = insets; |
| 182 FOR_EACH_OBSERVER( | 184 for (auto& observer : observers_) |
| 183 ServerWindowObserver, observers_, | 185 observer.OnWindowClientAreaChanged(this, insets, additional_client_areas); |
| 184 OnWindowClientAreaChanged(this, insets, additional_client_areas)); | |
| 185 } | 186 } |
| 186 | 187 |
| 187 void ServerWindow::SetHitTestMask(const gfx::Rect& mask) { | 188 void ServerWindow::SetHitTestMask(const gfx::Rect& mask) { |
| 188 hit_test_mask_ = base::MakeUnique<gfx::Rect>(mask); | 189 hit_test_mask_ = base::MakeUnique<gfx::Rect>(mask); |
| 189 } | 190 } |
| 190 | 191 |
| 191 void ServerWindow::ClearHitTestMask() { | 192 void ServerWindow::ClearHitTestMask() { |
| 192 hit_test_mask_.reset(); | 193 hit_test_mask_.reset(); |
| 193 } | 194 } |
| 194 | 195 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 224 DCHECK(std::find(transient_children_.begin(), transient_children_.end(), | 225 DCHECK(std::find(transient_children_.begin(), transient_children_.end(), |
| 225 child) == transient_children_.end()); | 226 child) == transient_children_.end()); |
| 226 transient_children_.push_back(child); | 227 transient_children_.push_back(child); |
| 227 child->transient_parent_ = this; | 228 child->transient_parent_ = this; |
| 228 | 229 |
| 229 // Restack |child| properly above its transient parent, if they share the same | 230 // Restack |child| properly above its transient parent, if they share the same |
| 230 // parent. | 231 // parent. |
| 231 if (child->parent() == parent()) | 232 if (child->parent() == parent()) |
| 232 RestackTransientDescendants(this, &GetStackingTarget, &ReorderImpl); | 233 RestackTransientDescendants(this, &GetStackingTarget, &ReorderImpl); |
| 233 | 234 |
| 234 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 235 for (auto& observer : observers_) |
| 235 OnTransientWindowAdded(this, child)); | 236 observer.OnTransientWindowAdded(this, child); |
| 236 return true; | 237 return true; |
| 237 } | 238 } |
| 238 | 239 |
| 239 void ServerWindow::RemoveTransientWindow(ServerWindow* child) { | 240 void ServerWindow::RemoveTransientWindow(ServerWindow* child) { |
| 240 Windows::iterator i = | 241 Windows::iterator i = |
| 241 std::find(transient_children_.begin(), transient_children_.end(), child); | 242 std::find(transient_children_.begin(), transient_children_.end(), child); |
| 242 DCHECK(i != transient_children_.end()); | 243 DCHECK(i != transient_children_.end()); |
| 243 transient_children_.erase(i); | 244 transient_children_.erase(i); |
| 244 DCHECK_EQ(this, child->transient_parent()); | 245 DCHECK_EQ(this, child->transient_parent()); |
| 245 child->transient_parent_ = nullptr; | 246 child->transient_parent_ = nullptr; |
| 246 | 247 |
| 247 // If |child| and its former transient parent share the same parent, |child| | 248 // If |child| and its former transient parent share the same parent, |child| |
| 248 // should be restacked properly so it is not among transient children of its | 249 // should be restacked properly so it is not among transient children of its |
| 249 // former parent, anymore. | 250 // former parent, anymore. |
| 250 if (parent() == child->parent()) | 251 if (parent() == child->parent()) |
| 251 RestackTransientDescendants(this, &GetStackingTarget, &ReorderImpl); | 252 RestackTransientDescendants(this, &GetStackingTarget, &ReorderImpl); |
| 252 | 253 |
| 253 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 254 for (auto& observer : observers_) |
| 254 OnTransientWindowRemoved(this, child)); | 255 observer.OnTransientWindowRemoved(this, child); |
| 255 } | 256 } |
| 256 | 257 |
| 257 void ServerWindow::SetModal() { | 258 void ServerWindow::SetModal() { |
| 258 is_modal_ = true; | 259 is_modal_ = true; |
| 259 } | 260 } |
| 260 | 261 |
| 261 bool ServerWindow::Contains(const ServerWindow* window) const { | 262 bool ServerWindow::Contains(const ServerWindow* window) const { |
| 262 for (const ServerWindow* parent = window; parent; parent = parent->parent_) { | 263 for (const ServerWindow* parent = window; parent; parent = parent->parent_) { |
| 263 if (parent == this) | 264 if (parent == this) |
| 264 return true; | 265 return true; |
| 265 } | 266 } |
| 266 return false; | 267 return false; |
| 267 } | 268 } |
| 268 | 269 |
| 269 void ServerWindow::SetVisible(bool value) { | 270 void ServerWindow::SetVisible(bool value) { |
| 270 if (visible_ == value) | 271 if (visible_ == value) |
| 271 return; | 272 return; |
| 272 | 273 |
| 273 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 274 for (auto& observer : observers_) |
| 274 OnWillChangeWindowVisibility(this)); | 275 observer.OnWillChangeWindowVisibility(this); |
| 275 visible_ = value; | 276 visible_ = value; |
| 276 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 277 for (auto& observer : observers_) |
| 277 OnWindowVisibilityChanged(this)); | 278 observer.OnWindowVisibilityChanged(this); |
| 278 } | 279 } |
| 279 | 280 |
| 280 void ServerWindow::SetOpacity(float value) { | 281 void ServerWindow::SetOpacity(float value) { |
| 281 if (value == opacity_) | 282 if (value == opacity_) |
| 282 return; | 283 return; |
| 283 float old_opacity = opacity_; | 284 float old_opacity = opacity_; |
| 284 opacity_ = value; | 285 opacity_ = value; |
| 285 delegate_->OnScheduleWindowPaint(this); | 286 delegate_->OnScheduleWindowPaint(this); |
| 286 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 287 for (auto& observer : observers_) |
| 287 OnWindowOpacityChanged(this, old_opacity, opacity_)); | 288 observer.OnWindowOpacityChanged(this, old_opacity, opacity_); |
| 288 } | 289 } |
| 289 | 290 |
| 290 void ServerWindow::SetPredefinedCursor(ui::mojom::Cursor value) { | 291 void ServerWindow::SetPredefinedCursor(ui::mojom::Cursor value) { |
| 291 if (value == cursor_id_) | 292 if (value == cursor_id_) |
| 292 return; | 293 return; |
| 293 cursor_id_ = value; | 294 cursor_id_ = value; |
| 294 FOR_EACH_OBSERVER( | 295 for (auto& observer : observers_) |
| 295 ServerWindowObserver, observers_, | 296 observer.OnWindowPredefinedCursorChanged(this, value); |
| 296 OnWindowPredefinedCursorChanged(this, value)); | |
| 297 } | 297 } |
| 298 | 298 |
| 299 void ServerWindow::SetNonClientCursor(ui::mojom::Cursor value) { | 299 void ServerWindow::SetNonClientCursor(ui::mojom::Cursor value) { |
| 300 if (value == non_client_cursor_id_) | 300 if (value == non_client_cursor_id_) |
| 301 return; | 301 return; |
| 302 non_client_cursor_id_ = value; | 302 non_client_cursor_id_ = value; |
| 303 FOR_EACH_OBSERVER( | 303 for (auto& observer : observers_) |
| 304 ServerWindowObserver, observers_, | 304 observer.OnWindowNonClientCursorChanged(this, value); |
| 305 OnWindowNonClientCursorChanged(this, value)); | |
| 306 } | 305 } |
| 307 | 306 |
| 308 void ServerWindow::SetTransform(const gfx::Transform& transform) { | 307 void ServerWindow::SetTransform(const gfx::Transform& transform) { |
| 309 if (transform_ == transform) | 308 if (transform_ == transform) |
| 310 return; | 309 return; |
| 311 | 310 |
| 312 transform_ = transform; | 311 transform_ = transform; |
| 313 delegate_->OnScheduleWindowPaint(this); | 312 delegate_->OnScheduleWindowPaint(this); |
| 314 } | 313 } |
| 315 | 314 |
| 316 void ServerWindow::SetProperty(const std::string& name, | 315 void ServerWindow::SetProperty(const std::string& name, |
| 317 const std::vector<uint8_t>* value) { | 316 const std::vector<uint8_t>* value) { |
| 318 auto it = properties_.find(name); | 317 auto it = properties_.find(name); |
| 319 if (it != properties_.end()) { | 318 if (it != properties_.end()) { |
| 320 if (value && it->second == *value) | 319 if (value && it->second == *value) |
| 321 return; | 320 return; |
| 322 } else if (!value) { | 321 } else if (!value) { |
| 323 // This property isn't set in |properties_| and |value| is nullptr, so | 322 // This property isn't set in |properties_| and |value| is nullptr, so |
| 324 // there's | 323 // there's |
| 325 // no change. | 324 // no change. |
| 326 return; | 325 return; |
| 327 } | 326 } |
| 328 | 327 |
| 329 if (value) { | 328 if (value) { |
| 330 properties_[name] = *value; | 329 properties_[name] = *value; |
| 331 } else if (it != properties_.end()) { | 330 } else if (it != properties_.end()) { |
| 332 properties_.erase(it); | 331 properties_.erase(it); |
| 333 } | 332 } |
| 334 | 333 |
| 335 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 334 for (auto& observer : observers_) |
| 336 OnWindowSharedPropertyChanged(this, name, value)); | 335 observer.OnWindowSharedPropertyChanged(this, name, value); |
| 337 } | 336 } |
| 338 | 337 |
| 339 std::string ServerWindow::GetName() const { | 338 std::string ServerWindow::GetName() const { |
| 340 auto it = properties_.find(mojom::WindowManager::kName_Property); | 339 auto it = properties_.find(mojom::WindowManager::kName_Property); |
| 341 if (it == properties_.end()) | 340 if (it == properties_.end()) |
| 342 return std::string(); | 341 return std::string(); |
| 343 return std::string(it->second.begin(), it->second.end()); | 342 return std::string(it->second.begin(), it->second.end()); |
| 344 } | 343 } |
| 345 | 344 |
| 346 void ServerWindow::SetTextInputState(const ui::TextInputState& state) { | 345 void ServerWindow::SetTextInputState(const ui::TextInputState& state) { |
| 347 const bool changed = !(text_input_state_ == state); | 346 const bool changed = !(text_input_state_ == state); |
| 348 if (changed) { | 347 if (changed) { |
| 349 text_input_state_ = state; | 348 text_input_state_ = state; |
| 350 // keyboard even if the state is not changed. So we have to notify | 349 // keyboard even if the state is not changed. So we have to notify |
| 351 // |observers_|. | 350 // |observers_|. |
| 352 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 351 for (auto& observer : observers_) |
| 353 OnWindowTextInputStateChanged(this, state)); | 352 observer.OnWindowTextInputStateChanged(this, state); |
| 354 } | 353 } |
| 355 } | 354 } |
| 356 | 355 |
| 357 bool ServerWindow::IsDrawn() const { | 356 bool ServerWindow::IsDrawn() const { |
| 358 const ServerWindow* root = delegate_->GetRootWindow(this); | 357 const ServerWindow* root = delegate_->GetRootWindow(this); |
| 359 if (!root || !root->visible()) | 358 if (!root || !root->visible()) |
| 360 return false; | 359 return false; |
| 361 const ServerWindow* window = this; | 360 const ServerWindow* window = this; |
| 362 while (window && window != root && window->visible()) | 361 while (window && window != root && window->visible()) |
| 363 window = window->parent(); | 362 window = window->parent(); |
| 364 return root == window; | 363 return root == window; |
| 365 } | 364 } |
| 366 | 365 |
| 367 ServerWindowSurfaceManager* ServerWindow::GetOrCreateSurfaceManager() { | 366 ServerWindowSurfaceManager* ServerWindow::GetOrCreateSurfaceManager() { |
| 368 if (!surface_manager_.get()) | 367 if (!surface_manager_.get()) |
| 369 surface_manager_ = base::MakeUnique<ServerWindowSurfaceManager>(this); | 368 surface_manager_ = base::MakeUnique<ServerWindowSurfaceManager>(this); |
| 370 return surface_manager_.get(); | 369 return surface_manager_.get(); |
| 371 } | 370 } |
| 372 | 371 |
| 373 void ServerWindow::SetUnderlayOffset(const gfx::Vector2d& offset) { | 372 void ServerWindow::SetUnderlayOffset(const gfx::Vector2d& offset) { |
| 374 if (offset == underlay_offset_) | 373 if (offset == underlay_offset_) |
| 375 return; | 374 return; |
| 376 | 375 |
| 377 underlay_offset_ = offset; | 376 underlay_offset_ = offset; |
| 378 delegate_->OnScheduleWindowPaint(this); | 377 delegate_->OnScheduleWindowPaint(this); |
| 379 } | 378 } |
| 380 | 379 |
| 381 void ServerWindow::OnEmbeddedAppDisconnected() { | 380 void ServerWindow::OnEmbeddedAppDisconnected() { |
| 382 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 381 for (auto& observer : observers_) |
| 383 OnWindowEmbeddedAppDisconnected(this)); | 382 observer.OnWindowEmbeddedAppDisconnected(this); |
| 384 } | 383 } |
| 385 | 384 |
| 386 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 385 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 387 std::string ServerWindow::GetDebugWindowHierarchy() const { | 386 std::string ServerWindow::GetDebugWindowHierarchy() const { |
| 388 std::string result; | 387 std::string result; |
| 389 BuildDebugInfo(std::string(), &result); | 388 BuildDebugInfo(std::string(), &result); |
| 390 return result; | 389 return result; |
| 391 } | 390 } |
| 392 | 391 |
| 393 std::string ServerWindow::GetDebugWindowInfo() const { | 392 std::string ServerWindow::GetDebugWindowInfo() const { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 window)); | 441 window)); |
| 443 Windows::iterator i = std::find(window->parent_->children_.begin(), | 442 Windows::iterator i = std::find(window->parent_->children_.begin(), |
| 444 window->parent_->children_.end(), relative); | 443 window->parent_->children_.end(), relative); |
| 445 if (direction == mojom::OrderDirection::ABOVE) { | 444 if (direction == mojom::OrderDirection::ABOVE) { |
| 446 DCHECK(i != window->parent_->children_.end()); | 445 DCHECK(i != window->parent_->children_.end()); |
| 447 window->parent_->children_.insert(++i, window); | 446 window->parent_->children_.insert(++i, window); |
| 448 } else if (direction == mojom::OrderDirection::BELOW) { | 447 } else if (direction == mojom::OrderDirection::BELOW) { |
| 449 DCHECK(i != window->parent_->children_.end()); | 448 DCHECK(i != window->parent_->children_.end()); |
| 450 window->parent_->children_.insert(i, window); | 449 window->parent_->children_.insert(i, window); |
| 451 } | 450 } |
| 452 FOR_EACH_OBSERVER(ServerWindowObserver, window->observers_, | 451 for (auto& observer : window->observers_) |
| 453 OnWindowReordered(window, relative, direction)); | 452 observer.OnWindowReordered(window, relative, direction); |
| 454 window->OnStackingChanged(); | 453 window->OnStackingChanged(); |
| 455 } | 454 } |
| 456 | 455 |
| 457 // static | 456 // static |
| 458 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 457 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
| 459 return &window->stacking_target_; | 458 return &window->stacking_target_; |
| 460 } | 459 } |
| 461 | 460 |
| 462 } // namespace ws | 461 } // namespace ws |
| 463 | 462 |
| 464 } // namespace ui | 463 } // namespace ui |
| OLD | NEW |