| 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 "view_manager/public/cpp/view.h" | 5 #include "view_manager/public/cpp/view.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/application/service_provider_impl.h" | 10 #include "mojo/public/cpp/application/service_provider_impl.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds); | 213 static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds); |
| 214 LocalSetBounds(bounds_, bounds); | 214 LocalSetBounds(bounds_, bounds); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void View::SetVisible(bool value) { | 217 void View::SetVisible(bool value) { |
| 218 if (visible_ == value) | 218 if (visible_ == value) |
| 219 return; | 219 return; |
| 220 | 220 |
| 221 if (manager_) | 221 if (manager_) |
| 222 static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value); | 222 static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value); |
| 223 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this)); | 223 LocalSetVisible(value); |
| 224 visible_ = value; | |
| 225 NotifyViewVisibilityChanged(this); | |
| 226 } | 224 } |
| 227 | 225 |
| 228 void View::SetSharedProperty(const std::string& name, | 226 void View::SetSharedProperty(const std::string& name, |
| 229 const std::vector<uint8_t>* value) { | 227 const std::vector<uint8_t>* value) { |
| 230 std::vector<uint8_t> old_value; | 228 std::vector<uint8_t> old_value; |
| 231 std::vector<uint8_t>* old_value_ptr = nullptr; | 229 std::vector<uint8_t>* old_value_ptr = nullptr; |
| 232 auto it = properties_.find(name); | 230 auto it = properties_.find(name); |
| 233 if (it != properties_.end()) { | 231 if (it != properties_.end()) { |
| 234 old_value = it->second; | 232 old_value = it->second; |
| 235 old_value_ptr = &old_value; | 233 old_value_ptr = &old_value; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // notification is the value of IsDrawn() is really changing. | 522 // notification is the value of IsDrawn() is really changing. |
| 525 if (IsDrawn() == value) { | 523 if (IsDrawn() == value) { |
| 526 drawn_ = value; | 524 drawn_ = value; |
| 527 return; | 525 return; |
| 528 } | 526 } |
| 529 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this)); | 527 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this)); |
| 530 drawn_ = value; | 528 drawn_ = value; |
| 531 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this)); | 529 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this)); |
| 532 } | 530 } |
| 533 | 531 |
| 532 void View::LocalSetVisible(bool visible) { |
| 533 if (visible_ == visible) |
| 534 return; |
| 535 |
| 536 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this)); |
| 537 visible_ = visible; |
| 538 NotifyViewVisibilityChanged(this); |
| 539 } |
| 540 |
| 534 void View::NotifyViewVisibilityChanged(View* target) { | 541 void View::NotifyViewVisibilityChanged(View* target) { |
| 535 if (!NotifyViewVisibilityChangedDown(target)) { | 542 if (!NotifyViewVisibilityChangedDown(target)) { |
| 536 return; // |this| has been deleted. | 543 return; // |this| has been deleted. |
| 537 } | 544 } |
| 538 NotifyViewVisibilityChangedUp(target); | 545 NotifyViewVisibilityChangedUp(target); |
| 539 } | 546 } |
| 540 | 547 |
| 541 bool View::NotifyViewVisibilityChangedAtReceiver(View* target) { | 548 bool View::NotifyViewVisibilityChangedAtReceiver(View* target) { |
| 542 // |this| may be deleted during a call to OnViewVisibilityChanged() on one | 549 // |this| may be deleted during a call to OnViewVisibilityChanged() on one |
| 543 // of the observers. We create an local observer for that. In that case we | 550 // of the observers. We create an local observer for that. In that case we |
| (...skipping 29 matching lines...) Expand all Loading... |
| 573 void View::NotifyViewVisibilityChangedUp(View* target) { | 580 void View::NotifyViewVisibilityChangedUp(View* target) { |
| 574 // Start with the parent as we already notified |this| | 581 // Start with the parent as we already notified |this| |
| 575 // in NotifyViewVisibilityChangedDown. | 582 // in NotifyViewVisibilityChangedDown. |
| 576 for (View* view = parent(); view; view = view->parent()) { | 583 for (View* view = parent(); view; view = view->parent()) { |
| 577 bool ret = view->NotifyViewVisibilityChangedAtReceiver(target); | 584 bool ret = view->NotifyViewVisibilityChangedAtReceiver(target); |
| 578 DCHECK(ret); | 585 DCHECK(ret); |
| 579 } | 586 } |
| 580 } | 587 } |
| 581 | 588 |
| 582 } // namespace mojo | 589 } // namespace mojo |
| OLD | NEW |