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 mojo { | 18 namespace mus { |
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 OrderDirection direction) | 91 mojo::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 OrderDirection direction_; | 104 mojo::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 OrderDirection direction) { | 113 mojo::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 == ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || | 123 if ((direction == mojo::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || |
124 (direction == ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { | 124 (direction == mojo::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 == ORDER_DIRECTION_ABOVE | 130 const size_t dest_i = direction == mojo::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 Rect& old_bounds, | 142 const mojo::Rect& old_bounds, |
143 const Rect& new_bounds) | 143 const mojo::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 Rect old_bounds_; | 155 const mojo::Rect old_bounds_; |
156 const Rect new_bounds_; | 156 const mojo::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 Rect& bounds) { | 194 void View::SetBounds(const mojo::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<mojo::ViewSurface> View::RequestSurface() { | 215 scoped_ptr<ViewSurface> View::RequestSurface() { |
216 mojo::SurfacePtr surface; | 216 mojo::SurfacePtr surface; |
217 mojo::SurfaceClientPtr client; | 217 mojo::SurfaceClientPtr client; |
218 mojo::InterfaceRequest<SurfaceClient> client_request = GetProxy(&client); | 218 mojo::InterfaceRequest<mojo::SurfaceClient> client_request = |
| 219 GetProxy(&client); |
219 static_cast<ViewTreeClientImpl*>(connection_) | 220 static_cast<ViewTreeClientImpl*>(connection_) |
220 ->RequestSurface(id_, GetProxy(&surface), client.Pass()); | 221 ->RequestSurface(id_, GetProxy(&surface), client.Pass()); |
221 return make_scoped_ptr( | 222 return make_scoped_ptr( |
222 new mojo::ViewSurface(surface.PassInterface(), client_request.Pass())); | 223 new ViewSurface(surface.PassInterface(), client_request.Pass())); |
223 } | 224 } |
224 | 225 |
225 void View::SetSharedProperty(const std::string& name, | 226 void View::SetSharedProperty(const std::string& name, |
226 const std::vector<uint8_t>* value) { | 227 const std::vector<uint8_t>* value) { |
227 std::vector<uint8_t> old_value; | 228 std::vector<uint8_t> old_value; |
228 std::vector<uint8_t>* old_value_ptr = nullptr; | 229 std::vector<uint8_t>* old_value_ptr = nullptr; |
229 auto it = properties_.find(name); | 230 auto it = properties_.find(name); |
230 if (it != properties_.end()) { | 231 if (it != properties_.end()) { |
231 old_value = it->second; | 232 old_value = it->second; |
232 old_value_ptr = &old_value; | 233 old_value_ptr = &old_value; |
233 | 234 |
234 if (value && old_value == *value) | 235 if (value && old_value == *value) |
235 return; | 236 return; |
236 } else if (!value) { | 237 } else if (!value) { |
237 // This property isn't set in |properties_| and |value| is NULL, so there's | 238 // This property isn't set in |properties_| and |value| is NULL, so there's |
238 // no change. | 239 // no change. |
239 return; | 240 return; |
240 } | 241 } |
241 | 242 |
242 if (value) { | 243 if (value) { |
243 properties_[name] = *value; | 244 properties_[name] = *value; |
244 } else if (it != properties_.end()) { | 245 } else if (it != properties_.end()) { |
245 properties_.erase(it); | 246 properties_.erase(it); |
246 } | 247 } |
247 | 248 |
248 // TODO: add test coverage of this (450303). | 249 // TODO: add test coverage of this (450303). |
249 if (connection_) { | 250 if (connection_) { |
250 Array<uint8_t> transport_value; | 251 mojo::Array<uint8_t> transport_value; |
251 if (value) { | 252 if (value) { |
252 transport_value.resize(value->size()); | 253 transport_value.resize(value->size()); |
253 if (value->size()) | 254 if (value->size()) |
254 memcpy(&transport_value.front(), &(value->front()), value->size()); | 255 memcpy(&transport_value.front(), &(value->front()), value->size()); |
255 } | 256 } |
256 static_cast<ViewTreeClientImpl*>(connection_) | 257 static_cast<ViewTreeClientImpl*>(connection_) |
257 ->SetProperty(id_, name, transport_value.Pass()); | 258 ->SetProperty(id_, name, transport_value.Pass()); |
258 } | 259 } |
259 | 260 |
260 FOR_EACH_OBSERVER( | 261 FOR_EACH_OBSERVER( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 LocalRemoveChild(child); | 302 LocalRemoveChild(child); |
302 if (connection_) { | 303 if (connection_) { |
303 static_cast<ViewTreeClientImpl*>(connection_) | 304 static_cast<ViewTreeClientImpl*>(connection_) |
304 ->RemoveChild(child->id(), id_); | 305 ->RemoveChild(child->id(), id_); |
305 } | 306 } |
306 } | 307 } |
307 | 308 |
308 void View::MoveToFront() { | 309 void View::MoveToFront() { |
309 if (!parent_ || parent_->children_.back() == this) | 310 if (!parent_ || parent_->children_.back() == this) |
310 return; | 311 return; |
311 Reorder(parent_->children_.back(), ORDER_DIRECTION_ABOVE); | 312 Reorder(parent_->children_.back(), mojo::ORDER_DIRECTION_ABOVE); |
312 } | 313 } |
313 | 314 |
314 void View::MoveToBack() { | 315 void View::MoveToBack() { |
315 if (!parent_ || parent_->children_.front() == this) | 316 if (!parent_ || parent_->children_.front() == this) |
316 return; | 317 return; |
317 Reorder(parent_->children_.front(), ORDER_DIRECTION_BELOW); | 318 Reorder(parent_->children_.front(), mojo::ORDER_DIRECTION_BELOW); |
318 } | 319 } |
319 | 320 |
320 void View::Reorder(View* relative, OrderDirection direction) { | 321 void View::Reorder(View* relative, mojo::OrderDirection direction) { |
321 if (!LocalReorder(relative, direction)) | 322 if (!LocalReorder(relative, direction)) |
322 return; | 323 return; |
323 if (connection_) { | 324 if (connection_) { |
324 static_cast<ViewTreeClientImpl*>(connection_) | 325 static_cast<ViewTreeClientImpl*>(connection_) |
325 ->Reorder(id_, relative->id(), direction); | 326 ->Reorder(id_, relative->id(), direction); |
326 } | 327 } |
327 } | 328 } |
328 | 329 |
329 bool View::Contains(View* child) const { | 330 bool View::Contains(View* child) const { |
330 if (!child) | 331 if (!child) |
(...skipping 15 matching lines...) Expand all Loading... |
346 // TODO(beng): this could be improved depending on how we decide to own views. | 347 // TODO(beng): this could be improved depending on how we decide to own views. |
347 Children::const_iterator it = children_.begin(); | 348 Children::const_iterator it = children_.begin(); |
348 for (; it != children_.end(); ++it) { | 349 for (; it != children_.end(); ++it) { |
349 View* view = (*it)->GetChildById(id); | 350 View* view = (*it)->GetChildById(id); |
350 if (view) | 351 if (view) |
351 return view; | 352 return view; |
352 } | 353 } |
353 return NULL; | 354 return NULL; |
354 } | 355 } |
355 | 356 |
356 void View::SetTextInputState(TextInputStatePtr state) { | 357 void View::SetTextInputState(mojo::TextInputStatePtr state) { |
357 if (connection_) { | 358 if (connection_) { |
358 static_cast<ViewTreeClientImpl*>(connection_) | 359 static_cast<ViewTreeClientImpl*>(connection_) |
359 ->SetViewTextInputState(id_, state.Pass()); | 360 ->SetViewTextInputState(id_, state.Pass()); |
360 } | 361 } |
361 } | 362 } |
362 | 363 |
363 void View::SetImeVisibility(bool visible, TextInputStatePtr state) { | 364 void View::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { |
364 // SetImeVisibility() shouldn't be used if the view is not editable. | 365 // SetImeVisibility() shouldn't be used if the view is not editable. |
365 DCHECK(state.is_null() || state->type != TEXT_INPUT_TYPE_NONE); | 366 DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); |
366 if (connection_) { | 367 if (connection_) { |
367 static_cast<ViewTreeClientImpl*>(connection_) | 368 static_cast<ViewTreeClientImpl*>(connection_) |
368 ->SetImeVisibility(id_, visible, state.Pass()); | 369 ->SetImeVisibility(id_, visible, state.Pass()); |
369 } | 370 } |
370 } | 371 } |
371 | 372 |
372 void View::SetFocus() { | 373 void View::SetFocus() { |
373 if (connection_) | 374 if (connection_) |
374 static_cast<ViewTreeClientImpl*>(connection_)->SetFocus(id_); | 375 static_cast<ViewTreeClientImpl*>(connection_)->SetFocus(id_); |
375 } | 376 } |
376 | 377 |
377 bool View::HasFocus() const { | 378 bool View::HasFocus() const { |
378 return connection_ && connection_->GetFocusedView() == this; | 379 return connection_ && connection_->GetFocusedView() == this; |
379 } | 380 } |
380 | 381 |
381 void View::Embed(ViewTreeClientPtr client) { | 382 void View::Embed(mojo::ViewTreeClientPtr client) { |
382 Embed(client.Pass(), ViewTree::ACCESS_POLICY_DEFAULT, | 383 Embed(client.Pass(), mojo::ViewTree::ACCESS_POLICY_DEFAULT, |
383 base::Bind(&EmptyEmbedCallback)); | 384 base::Bind(&EmptyEmbedCallback)); |
384 } | 385 } |
385 | 386 |
386 void View::Embed(ViewTreeClientPtr client, | 387 void View::Embed(mojo::ViewTreeClientPtr client, |
387 uint32_t policy_bitmask, | 388 uint32_t policy_bitmask, |
388 const EmbedCallback& callback) { | 389 const EmbedCallback& callback) { |
389 if (PrepareForEmbed()) { | 390 if (PrepareForEmbed()) { |
390 static_cast<ViewTreeClientImpl*>(connection_) | 391 static_cast<ViewTreeClientImpl*>(connection_) |
391 ->Embed(id_, client.Pass(), policy_bitmask, callback); | 392 ->Embed(id_, client.Pass(), policy_bitmask, callback); |
392 } else { | 393 } else { |
393 callback.Run(false, 0); | 394 callback.Run(false, 0); |
394 } | 395 } |
395 } | 396 } |
396 | 397 |
397 //////////////////////////////////////////////////////////////////////////////// | 398 //////////////////////////////////////////////////////////////////////////////// |
398 // View, protected: | 399 // View, protected: |
399 | 400 |
400 namespace { | 401 namespace { |
401 | 402 |
402 ViewportMetricsPtr CreateEmptyViewportMetrics() { | 403 mojo::ViewportMetricsPtr CreateEmptyViewportMetrics() { |
403 ViewportMetricsPtr metrics = ViewportMetrics::New(); | 404 mojo::ViewportMetricsPtr metrics = mojo::ViewportMetrics::New(); |
404 metrics->size_in_pixels = Size::New(); | 405 metrics->size_in_pixels = mojo::Size::New(); |
405 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it | 406 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it |
406 // once that's fixed. | 407 // once that's fixed. |
407 return metrics.Pass(); | 408 return metrics.Pass(); |
408 } | 409 } |
409 | 410 |
410 } // namespace | 411 } // namespace |
411 | 412 |
412 View::View() | 413 View::View() |
413 : connection_(NULL), | 414 : connection_(NULL), |
414 id_(static_cast<Id>(-1)), | 415 id_(static_cast<Id>(-1)), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 children_.push_back(child); | 499 children_.push_back(child); |
499 child->parent_ = this; | 500 child->parent_ = this; |
500 } | 501 } |
501 | 502 |
502 void View::LocalRemoveChild(View* child) { | 503 void View::LocalRemoveChild(View* child) { |
503 DCHECK_EQ(this, child->parent()); | 504 DCHECK_EQ(this, child->parent()); |
504 ScopedTreeNotifier notifier(child, this, NULL); | 505 ScopedTreeNotifier notifier(child, this, NULL); |
505 RemoveChildImpl(child, &children_); | 506 RemoveChildImpl(child, &children_); |
506 } | 507 } |
507 | 508 |
508 bool View::LocalReorder(View* relative, OrderDirection direction) { | 509 bool View::LocalReorder(View* relative, mojo::OrderDirection direction) { |
509 return ReorderImpl(&parent_->children_, this, relative, direction); | 510 return ReorderImpl(&parent_->children_, this, relative, direction); |
510 } | 511 } |
511 | 512 |
512 void View::LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds) { | 513 void View::LocalSetBounds(const mojo::Rect& old_bounds, |
| 514 const mojo::Rect& new_bounds) { |
513 DCHECK(old_bounds.x == bounds_.x); | 515 DCHECK(old_bounds.x == bounds_.x); |
514 DCHECK(old_bounds.y == bounds_.y); | 516 DCHECK(old_bounds.y == bounds_.y); |
515 DCHECK(old_bounds.width == bounds_.width); | 517 DCHECK(old_bounds.width == bounds_.width); |
516 DCHECK(old_bounds.height == bounds_.height); | 518 DCHECK(old_bounds.height == bounds_.height); |
517 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); | 519 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); |
518 bounds_ = new_bounds; | 520 bounds_ = new_bounds; |
519 } | 521 } |
520 | 522 |
521 void View::LocalSetViewportMetrics(const ViewportMetrics& old_metrics, | 523 void View::LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics, |
522 const ViewportMetrics& new_metrics) { | 524 const mojo::ViewportMetrics& new_metrics) { |
523 // TODO(eseidel): We could check old_metrics against viewport_metrics_. | 525 // TODO(eseidel): We could check old_metrics against viewport_metrics_. |
524 viewport_metrics_ = new_metrics.Clone(); | 526 viewport_metrics_ = new_metrics.Clone(); |
525 FOR_EACH_OBSERVER( | 527 FOR_EACH_OBSERVER( |
526 ViewObserver, observers_, | 528 ViewObserver, observers_, |
527 OnViewViewportMetricsChanged(this, old_metrics, new_metrics)); | 529 OnViewViewportMetricsChanged(this, old_metrics, new_metrics)); |
528 } | 530 } |
529 | 531 |
530 void View::LocalSetDrawn(bool value) { | 532 void View::LocalSetDrawn(bool value) { |
531 if (drawn_ == value) | 533 if (drawn_ == value) |
532 return; | 534 return; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 if (!OwnsView(connection_, this) && | 605 if (!OwnsView(connection_, this) && |
604 !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) { | 606 !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) { |
605 return false; | 607 return false; |
606 } | 608 } |
607 | 609 |
608 while (!children_.empty()) | 610 while (!children_.empty()) |
609 RemoveChild(children_[0]); | 611 RemoveChild(children_[0]); |
610 return true; | 612 return true; |
611 } | 613 } |
612 | 614 |
613 } // namespace mojo | 615 } // namespace mus |
OLD | NEW |