| 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 "components/mus/public/cpp/view.h" | 5 #include "components/mus/public/cpp/view.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "components/mus/public/cpp/lib/view_private.h" | 11 #include "components/mus/public/cpp/lib/view_private.h" |
| 12 #include "components/mus/public/cpp/lib/view_tree_client_impl.h" | 12 #include "components/mus/public/cpp/lib/view_tree_client_impl.h" |
| 13 #include "components/mus/public/cpp/view_observer.h" | 13 #include "components/mus/public/cpp/view_observer.h" |
| 14 #include "components/mus/public/cpp/view_surface.h" | 14 #include "components/mus/public/cpp/view_surface.h" |
| 15 #include "components/mus/public/cpp/view_tracker.h" | 15 #include "components/mus/public/cpp/view_tracker.h" |
| 16 #include "mojo/application/public/cpp/service_provider_impl.h" | 16 #include "mojo/application/public/cpp/service_provider_impl.h" |
| 17 | 17 |
| 18 namespace mus { | 18 namespace mojo { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 void NotifyViewTreeChangeAtReceiver( | 22 void NotifyViewTreeChangeAtReceiver( |
| 23 View* receiver, | 23 View* receiver, |
| 24 const ViewObserver::TreeChangeParams& params, | 24 const ViewObserver::TreeChangeParams& params, |
| 25 bool change_applied) { | 25 bool change_applied) { |
| 26 ViewObserver::TreeChangeParams local_params = params; | 26 ViewObserver::TreeChangeParams local_params = params; |
| 27 local_params.receiver = receiver; | 27 local_params.receiver = receiver; |
| 28 if (change_applied) { | 28 if (change_applied) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (it != children->end()) { | 81 if (it != children->end()) { |
| 82 children->erase(it); | 82 children->erase(it); |
| 83 ViewPrivate(child).ClearParent(); | 83 ViewPrivate(child).ClearParent(); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 class ScopedOrderChangedNotifier { | 87 class ScopedOrderChangedNotifier { |
| 88 public: | 88 public: |
| 89 ScopedOrderChangedNotifier(View* view, | 89 ScopedOrderChangedNotifier(View* view, |
| 90 View* relative_view, | 90 View* relative_view, |
| 91 mojo::OrderDirection direction) | 91 OrderDirection direction) |
| 92 : view_(view), relative_view_(relative_view), direction_(direction) { | 92 : view_(view), relative_view_(relative_view), direction_(direction) { |
| 93 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), | 93 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), |
| 94 OnViewReordering(view_, relative_view_, direction_)); | 94 OnViewReordering(view_, relative_view_, direction_)); |
| 95 } | 95 } |
| 96 ~ScopedOrderChangedNotifier() { | 96 ~ScopedOrderChangedNotifier() { |
| 97 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), | 97 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), |
| 98 OnViewReordered(view_, relative_view_, direction_)); | 98 OnViewReordered(view_, relative_view_, direction_)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 View* view_; | 102 View* view_; |
| 103 View* relative_view_; | 103 View* relative_view_; |
| 104 mojo::OrderDirection direction_; | 104 OrderDirection direction_; |
| 105 | 105 |
| 106 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier); | 106 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 // Returns true if the order actually changed. | 109 // Returns true if the order actually changed. |
| 110 bool ReorderImpl(View::Children* children, | 110 bool ReorderImpl(View::Children* children, |
| 111 View* view, | 111 View* view, |
| 112 View* relative, | 112 View* relative, |
| 113 mojo::OrderDirection direction) { | 113 OrderDirection direction) { |
| 114 DCHECK(relative); | 114 DCHECK(relative); |
| 115 DCHECK_NE(view, relative); | 115 DCHECK_NE(view, relative); |
| 116 DCHECK_EQ(view->parent(), relative->parent()); | 116 DCHECK_EQ(view->parent(), relative->parent()); |
| 117 | 117 |
| 118 const size_t child_i = | 118 const size_t child_i = |
| 119 std::find(children->begin(), children->end(), view) - children->begin(); | 119 std::find(children->begin(), children->end(), view) - children->begin(); |
| 120 const size_t target_i = | 120 const size_t target_i = |
| 121 std::find(children->begin(), children->end(), relative) - | 121 std::find(children->begin(), children->end(), relative) - |
| 122 children->begin(); | 122 children->begin(); |
| 123 if ((direction == mojo::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || | 123 if ((direction == ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || |
| 124 (direction == mojo::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { | 124 (direction == ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 | 127 |
| 128 ScopedOrderChangedNotifier notifier(view, relative, direction); | 128 ScopedOrderChangedNotifier notifier(view, relative, direction); |
| 129 | 129 |
| 130 const size_t dest_i = direction == mojo::ORDER_DIRECTION_ABOVE | 130 const size_t dest_i = direction == ORDER_DIRECTION_ABOVE |
| 131 ? (child_i < target_i ? target_i : target_i + 1) | 131 ? (child_i < target_i ? target_i : target_i + 1) |
| 132 : (child_i < target_i ? target_i - 1 : target_i); | 132 : (child_i < target_i ? target_i - 1 : target_i); |
| 133 children->erase(children->begin() + child_i); | 133 children->erase(children->begin() + child_i); |
| 134 children->insert(children->begin() + dest_i, view); | 134 children->insert(children->begin() + dest_i, view); |
| 135 | 135 |
| 136 return true; | 136 return true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 class ScopedSetBoundsNotifier { | 139 class ScopedSetBoundsNotifier { |
| 140 public: | 140 public: |
| 141 ScopedSetBoundsNotifier(View* view, | 141 ScopedSetBoundsNotifier(View* view, |
| 142 const mojo::Rect& old_bounds, | 142 const Rect& old_bounds, |
| 143 const mojo::Rect& new_bounds) | 143 const Rect& new_bounds) |
| 144 : view_(view), old_bounds_(old_bounds), new_bounds_(new_bounds) { | 144 : view_(view), old_bounds_(old_bounds), new_bounds_(new_bounds) { |
| 145 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), | 145 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), |
| 146 OnViewBoundsChanging(view_, old_bounds_, new_bounds_)); | 146 OnViewBoundsChanging(view_, old_bounds_, new_bounds_)); |
| 147 } | 147 } |
| 148 ~ScopedSetBoundsNotifier() { | 148 ~ScopedSetBoundsNotifier() { |
| 149 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), | 149 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), |
| 150 OnViewBoundsChanged(view_, old_bounds_, new_bounds_)); | 150 OnViewBoundsChanged(view_, old_bounds_, new_bounds_)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 View* view_; | 154 View* view_; |
| 155 const mojo::Rect old_bounds_; | 155 const Rect old_bounds_; |
| 156 const mojo::Rect new_bounds_; | 156 const Rect new_bounds_; |
| 157 | 157 |
| 158 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); | 158 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 // Some operations are only permitted in the connection that created the view. | 161 // Some operations are only permitted in the connection that created the view. |
| 162 bool OwnsView(ViewTreeConnection* connection, View* view) { | 162 bool OwnsView(ViewTreeConnection* connection, View* view) { |
| 163 return !connection || | 163 return !connection || |
| 164 static_cast<ViewTreeClientImpl*>(connection)->OwnsView(view->id()); | 164 static_cast<ViewTreeClientImpl*>(connection)->OwnsView(view->id()); |
| 165 } | 165 } |
| 166 | 166 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 184 children_.erase(children_.begin()); | 184 children_.erase(children_.begin()); |
| 185 } else { | 185 } else { |
| 186 child->Destroy(); | 186 child->Destroy(); |
| 187 DCHECK(std::find(children_.begin(), children_.end(), child) == | 187 DCHECK(std::find(children_.begin(), children_.end(), child) == |
| 188 children_.end()); | 188 children_.end()); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 LocalDestroy(); | 191 LocalDestroy(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void View::SetBounds(const mojo::Rect& bounds) { | 194 void View::SetBounds(const Rect& bounds) { |
| 195 if (!OwnsView(connection_, this)) | 195 if (!OwnsView(connection_, this)) |
| 196 return; | 196 return; |
| 197 | 197 |
| 198 if (bounds_.Equals(bounds)) | 198 if (bounds_.Equals(bounds)) |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 if (connection_) | 201 if (connection_) |
| 202 static_cast<ViewTreeClientImpl*>(connection_)->SetBounds(id_, bounds); | 202 static_cast<ViewTreeClientImpl*>(connection_)->SetBounds(id_, bounds); |
| 203 LocalSetBounds(bounds_, bounds); | 203 LocalSetBounds(bounds_, bounds); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void View::SetVisible(bool value) { | 206 void View::SetVisible(bool value) { |
| 207 if (visible_ == value) | 207 if (visible_ == value) |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 if (connection_) | 210 if (connection_) |
| 211 static_cast<ViewTreeClientImpl*>(connection_)->SetVisible(id_, value); | 211 static_cast<ViewTreeClientImpl*>(connection_)->SetVisible(id_, value); |
| 212 LocalSetVisible(value); | 212 LocalSetVisible(value); |
| 213 } | 213 } |
| 214 | 214 |
| 215 scoped_ptr<ViewSurface> View::RequestSurface() { | 215 scoped_ptr<mojo::ViewSurface> View::RequestSurface() { |
| 216 mojo::SurfacePtr surface; | 216 mojo::SurfacePtr surface; |
| 217 mojo::SurfaceClientPtr client; | 217 mojo::SurfaceClientPtr client; |
| 218 mojo::InterfaceRequest<mojo::SurfaceClient> client_request = | 218 mojo::InterfaceRequest<SurfaceClient> client_request = GetProxy(&client); |
| 219 GetProxy(&client); | |
| 220 static_cast<ViewTreeClientImpl*>(connection_) | 219 static_cast<ViewTreeClientImpl*>(connection_) |
| 221 ->RequestSurface(id_, GetProxy(&surface), client.Pass()); | 220 ->RequestSurface(id_, GetProxy(&surface), client.Pass()); |
| 222 return make_scoped_ptr( | 221 return make_scoped_ptr( |
| 223 new ViewSurface(surface.PassInterface(), client_request.Pass())); | 222 new mojo::ViewSurface(surface.PassInterface(), client_request.Pass())); |
| 224 } | 223 } |
| 225 | 224 |
| 226 void View::SetSharedProperty(const std::string& name, | 225 void View::SetSharedProperty(const std::string& name, |
| 227 const std::vector<uint8_t>* value) { | 226 const std::vector<uint8_t>* value) { |
| 228 std::vector<uint8_t> old_value; | 227 std::vector<uint8_t> old_value; |
| 229 std::vector<uint8_t>* old_value_ptr = nullptr; | 228 std::vector<uint8_t>* old_value_ptr = nullptr; |
| 230 auto it = properties_.find(name); | 229 auto it = properties_.find(name); |
| 231 if (it != properties_.end()) { | 230 if (it != properties_.end()) { |
| 232 old_value = it->second; | 231 old_value = it->second; |
| 233 old_value_ptr = &old_value; | 232 old_value_ptr = &old_value; |
| 234 | 233 |
| 235 if (value && old_value == *value) | 234 if (value && old_value == *value) |
| 236 return; | 235 return; |
| 237 } else if (!value) { | 236 } else if (!value) { |
| 238 // This property isn't set in |properties_| and |value| is NULL, so there's | 237 // This property isn't set in |properties_| and |value| is NULL, so there's |
| 239 // no change. | 238 // no change. |
| 240 return; | 239 return; |
| 241 } | 240 } |
| 242 | 241 |
| 243 if (value) { | 242 if (value) { |
| 244 properties_[name] = *value; | 243 properties_[name] = *value; |
| 245 } else if (it != properties_.end()) { | 244 } else if (it != properties_.end()) { |
| 246 properties_.erase(it); | 245 properties_.erase(it); |
| 247 } | 246 } |
| 248 | 247 |
| 249 // TODO: add test coverage of this (450303). | 248 // TODO: add test coverage of this (450303). |
| 250 if (connection_) { | 249 if (connection_) { |
| 251 mojo::Array<uint8_t> transport_value; | 250 Array<uint8_t> transport_value; |
| 252 if (value) { | 251 if (value) { |
| 253 transport_value.resize(value->size()); | 252 transport_value.resize(value->size()); |
| 254 if (value->size()) | 253 if (value->size()) |
| 255 memcpy(&transport_value.front(), &(value->front()), value->size()); | 254 memcpy(&transport_value.front(), &(value->front()), value->size()); |
| 256 } | 255 } |
| 257 static_cast<ViewTreeClientImpl*>(connection_) | 256 static_cast<ViewTreeClientImpl*>(connection_) |
| 258 ->SetProperty(id_, name, transport_value.Pass()); | 257 ->SetProperty(id_, name, transport_value.Pass()); |
| 259 } | 258 } |
| 260 | 259 |
| 261 FOR_EACH_OBSERVER( | 260 FOR_EACH_OBSERVER( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 LocalRemoveChild(child); | 301 LocalRemoveChild(child); |
| 303 if (connection_) { | 302 if (connection_) { |
| 304 static_cast<ViewTreeClientImpl*>(connection_) | 303 static_cast<ViewTreeClientImpl*>(connection_) |
| 305 ->RemoveChild(child->id(), id_); | 304 ->RemoveChild(child->id(), id_); |
| 306 } | 305 } |
| 307 } | 306 } |
| 308 | 307 |
| 309 void View::MoveToFront() { | 308 void View::MoveToFront() { |
| 310 if (!parent_ || parent_->children_.back() == this) | 309 if (!parent_ || parent_->children_.back() == this) |
| 311 return; | 310 return; |
| 312 Reorder(parent_->children_.back(), mojo::ORDER_DIRECTION_ABOVE); | 311 Reorder(parent_->children_.back(), ORDER_DIRECTION_ABOVE); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void View::MoveToBack() { | 314 void View::MoveToBack() { |
| 316 if (!parent_ || parent_->children_.front() == this) | 315 if (!parent_ || parent_->children_.front() == this) |
| 317 return; | 316 return; |
| 318 Reorder(parent_->children_.front(), mojo::ORDER_DIRECTION_BELOW); | 317 Reorder(parent_->children_.front(), ORDER_DIRECTION_BELOW); |
| 319 } | 318 } |
| 320 | 319 |
| 321 void View::Reorder(View* relative, mojo::OrderDirection direction) { | 320 void View::Reorder(View* relative, OrderDirection direction) { |
| 322 if (!LocalReorder(relative, direction)) | 321 if (!LocalReorder(relative, direction)) |
| 323 return; | 322 return; |
| 324 if (connection_) { | 323 if (connection_) { |
| 325 static_cast<ViewTreeClientImpl*>(connection_) | 324 static_cast<ViewTreeClientImpl*>(connection_) |
| 326 ->Reorder(id_, relative->id(), direction); | 325 ->Reorder(id_, relative->id(), direction); |
| 327 } | 326 } |
| 328 } | 327 } |
| 329 | 328 |
| 330 bool View::Contains(View* child) const { | 329 bool View::Contains(View* child) const { |
| 331 if (!child) | 330 if (!child) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 347 // TODO(beng): this could be improved depending on how we decide to own views. | 346 // TODO(beng): this could be improved depending on how we decide to own views. |
| 348 Children::const_iterator it = children_.begin(); | 347 Children::const_iterator it = children_.begin(); |
| 349 for (; it != children_.end(); ++it) { | 348 for (; it != children_.end(); ++it) { |
| 350 View* view = (*it)->GetChildById(id); | 349 View* view = (*it)->GetChildById(id); |
| 351 if (view) | 350 if (view) |
| 352 return view; | 351 return view; |
| 353 } | 352 } |
| 354 return NULL; | 353 return NULL; |
| 355 } | 354 } |
| 356 | 355 |
| 357 void View::SetTextInputState(mojo::TextInputStatePtr state) { | 356 void View::SetTextInputState(TextInputStatePtr state) { |
| 358 if (connection_) { | 357 if (connection_) { |
| 359 static_cast<ViewTreeClientImpl*>(connection_) | 358 static_cast<ViewTreeClientImpl*>(connection_) |
| 360 ->SetViewTextInputState(id_, state.Pass()); | 359 ->SetViewTextInputState(id_, state.Pass()); |
| 361 } | 360 } |
| 362 } | 361 } |
| 363 | 362 |
| 364 void View::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { | 363 void View::SetImeVisibility(bool visible, TextInputStatePtr state) { |
| 365 // SetImeVisibility() shouldn't be used if the view is not editable. | 364 // SetImeVisibility() shouldn't be used if the view is not editable. |
| 366 DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); | 365 DCHECK(state.is_null() || state->type != TEXT_INPUT_TYPE_NONE); |
| 367 if (connection_) { | 366 if (connection_) { |
| 368 static_cast<ViewTreeClientImpl*>(connection_) | 367 static_cast<ViewTreeClientImpl*>(connection_) |
| 369 ->SetImeVisibility(id_, visible, state.Pass()); | 368 ->SetImeVisibility(id_, visible, state.Pass()); |
| 370 } | 369 } |
| 371 } | 370 } |
| 372 | 371 |
| 373 void View::SetFocus() { | 372 void View::SetFocus() { |
| 374 if (connection_) | 373 if (connection_) |
| 375 static_cast<ViewTreeClientImpl*>(connection_)->SetFocus(id_); | 374 static_cast<ViewTreeClientImpl*>(connection_)->SetFocus(id_); |
| 376 } | 375 } |
| 377 | 376 |
| 378 bool View::HasFocus() const { | 377 bool View::HasFocus() const { |
| 379 return connection_ && connection_->GetFocusedView() == this; | 378 return connection_ && connection_->GetFocusedView() == this; |
| 380 } | 379 } |
| 381 | 380 |
| 382 void View::Embed(mojo::ViewTreeClientPtr client) { | 381 void View::Embed(ViewTreeClientPtr client) { |
| 383 Embed(client.Pass(), mojo::ViewTree::ACCESS_POLICY_DEFAULT, | 382 Embed(client.Pass(), ViewTree::ACCESS_POLICY_DEFAULT, |
| 384 base::Bind(&EmptyEmbedCallback)); | 383 base::Bind(&EmptyEmbedCallback)); |
| 385 } | 384 } |
| 386 | 385 |
| 387 void View::Embed(mojo::ViewTreeClientPtr client, | 386 void View::Embed(ViewTreeClientPtr client, |
| 388 uint32_t policy_bitmask, | 387 uint32_t policy_bitmask, |
| 389 const EmbedCallback& callback) { | 388 const EmbedCallback& callback) { |
| 390 if (PrepareForEmbed()) { | 389 if (PrepareForEmbed()) { |
| 391 static_cast<ViewTreeClientImpl*>(connection_) | 390 static_cast<ViewTreeClientImpl*>(connection_) |
| 392 ->Embed(id_, client.Pass(), policy_bitmask, callback); | 391 ->Embed(id_, client.Pass(), policy_bitmask, callback); |
| 393 } else { | 392 } else { |
| 394 callback.Run(false, 0); | 393 callback.Run(false, 0); |
| 395 } | 394 } |
| 396 } | 395 } |
| 397 | 396 |
| 398 //////////////////////////////////////////////////////////////////////////////// | 397 //////////////////////////////////////////////////////////////////////////////// |
| 399 // View, protected: | 398 // View, protected: |
| 400 | 399 |
| 401 namespace { | 400 namespace { |
| 402 | 401 |
| 403 mojo::ViewportMetricsPtr CreateEmptyViewportMetrics() { | 402 ViewportMetricsPtr CreateEmptyViewportMetrics() { |
| 404 mojo::ViewportMetricsPtr metrics = mojo::ViewportMetrics::New(); | 403 ViewportMetricsPtr metrics = ViewportMetrics::New(); |
| 405 metrics->size_in_pixels = mojo::Size::New(); | 404 metrics->size_in_pixels = Size::New(); |
| 406 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it | 405 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it |
| 407 // once that's fixed. | 406 // once that's fixed. |
| 408 return metrics.Pass(); | 407 return metrics.Pass(); |
| 409 } | 408 } |
| 410 | 409 |
| 411 } // namespace | 410 } // namespace |
| 412 | 411 |
| 413 View::View() | 412 View::View() |
| 414 : connection_(NULL), | 413 : connection_(NULL), |
| 415 id_(static_cast<Id>(-1)), | 414 id_(static_cast<Id>(-1)), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 children_.push_back(child); | 498 children_.push_back(child); |
| 500 child->parent_ = this; | 499 child->parent_ = this; |
| 501 } | 500 } |
| 502 | 501 |
| 503 void View::LocalRemoveChild(View* child) { | 502 void View::LocalRemoveChild(View* child) { |
| 504 DCHECK_EQ(this, child->parent()); | 503 DCHECK_EQ(this, child->parent()); |
| 505 ScopedTreeNotifier notifier(child, this, NULL); | 504 ScopedTreeNotifier notifier(child, this, NULL); |
| 506 RemoveChildImpl(child, &children_); | 505 RemoveChildImpl(child, &children_); |
| 507 } | 506 } |
| 508 | 507 |
| 509 bool View::LocalReorder(View* relative, mojo::OrderDirection direction) { | 508 bool View::LocalReorder(View* relative, OrderDirection direction) { |
| 510 return ReorderImpl(&parent_->children_, this, relative, direction); | 509 return ReorderImpl(&parent_->children_, this, relative, direction); |
| 511 } | 510 } |
| 512 | 511 |
| 513 void View::LocalSetBounds(const mojo::Rect& old_bounds, | 512 void View::LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds) { |
| 514 const mojo::Rect& new_bounds) { | |
| 515 DCHECK(old_bounds.x == bounds_.x); | 513 DCHECK(old_bounds.x == bounds_.x); |
| 516 DCHECK(old_bounds.y == bounds_.y); | 514 DCHECK(old_bounds.y == bounds_.y); |
| 517 DCHECK(old_bounds.width == bounds_.width); | 515 DCHECK(old_bounds.width == bounds_.width); |
| 518 DCHECK(old_bounds.height == bounds_.height); | 516 DCHECK(old_bounds.height == bounds_.height); |
| 519 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); | 517 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); |
| 520 bounds_ = new_bounds; | 518 bounds_ = new_bounds; |
| 521 } | 519 } |
| 522 | 520 |
| 523 void View::LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics, | 521 void View::LocalSetViewportMetrics(const ViewportMetrics& old_metrics, |
| 524 const mojo::ViewportMetrics& new_metrics) { | 522 const ViewportMetrics& new_metrics) { |
| 525 // TODO(eseidel): We could check old_metrics against viewport_metrics_. | 523 // TODO(eseidel): We could check old_metrics against viewport_metrics_. |
| 526 viewport_metrics_ = new_metrics.Clone(); | 524 viewport_metrics_ = new_metrics.Clone(); |
| 527 FOR_EACH_OBSERVER( | 525 FOR_EACH_OBSERVER( |
| 528 ViewObserver, observers_, | 526 ViewObserver, observers_, |
| 529 OnViewViewportMetricsChanged(this, old_metrics, new_metrics)); | 527 OnViewViewportMetricsChanged(this, old_metrics, new_metrics)); |
| 530 } | 528 } |
| 531 | 529 |
| 532 void View::LocalSetDrawn(bool value) { | 530 void View::LocalSetDrawn(bool value) { |
| 533 if (drawn_ == value) | 531 if (drawn_ == value) |
| 534 return; | 532 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 if (!OwnsView(connection_, this) && | 603 if (!OwnsView(connection_, this) && |
| 606 !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) { | 604 !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) { |
| 607 return false; | 605 return false; |
| 608 } | 606 } |
| 609 | 607 |
| 610 while (!children_.empty()) | 608 while (!children_.empty()) |
| 611 RemoveChild(children_[0]); | 609 RemoveChild(children_[0]); |
| 612 return true; | 610 return true; |
| 613 } | 611 } |
| 614 | 612 |
| 615 } // namespace mus | 613 } // namespace mojo |
| OLD | NEW |