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

Unified Diff: mojo/services/public/cpp/view_manager/lib/view.cc

Issue 621903004: Adds View::visible() and IsDrawn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/public/cpp/view_manager/lib/view.cc
diff --git a/mojo/services/public/cpp/view_manager/lib/view.cc b/mojo/services/public/cpp/view_manager/lib/view.cc
index 82b6d11e9e98118479041cc35436092bcd373eef..fe45ffc4a663b4eb2719038b9cc6d6f13cd9171e 100644
--- a/mojo/services/public/cpp/view_manager/lib/view.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view.cc
@@ -221,8 +221,20 @@ void View::SetBounds(const gfx::Rect& bounds) {
}
void View::SetVisible(bool value) {
+ if (visible_ == value)
+ return;
+
if (manager_)
static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value);
+ FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this));
+ visible_ = value;
+ FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanged(this));
+}
+
+bool View::IsDrawn() const {
+ if (!visible_)
+ return false;
+ return parent_ ? parent_->IsDrawn() : drawn_;
}
void View::AddObserver(ViewObserver* observer) {
@@ -354,7 +366,10 @@ scoped_ptr<ServiceProvider>
View::View()
: manager_(NULL),
id_(static_cast<Id>(-1)),
- parent_(NULL) {}
+ parent_(NULL),
+ visible_(true),
+ drawn_(false) {
+}
View::~View() {
FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroying(this));
@@ -373,7 +388,10 @@ View::~View() {
View::View(ViewManager* manager)
: manager_(manager),
id_(static_cast<ViewManagerClientImpl*>(manager_)->CreateView()),
- parent_(NULL) {}
+ parent_(NULL),
+ visible_(true),
+ drawn_(false) {
+}
void View::LocalDestroy() {
delete this;
@@ -404,6 +422,21 @@ void View::LocalSetBounds(const gfx::Rect& old_bounds,
bounds_ = new_bounds;
}
+void View::LocalSetDrawn(bool value) {
+ if (drawn_ == value)
+ return;
+
+ // As IsDrawn() is derived from |visible_| and |drawn_|, only send drawn
+ // notification is the value of IsDrawn() is really changing.
+ if (IsDrawn() == value) {
+ drawn_ = value;
+ return;
+ }
+ FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this));
+ drawn_ = value;
+ FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this));
+}
+
void View::CreateBitmapUploader() {
ViewManagerClientImpl* vmci = static_cast<ViewManagerClientImpl*>(manager_);
SurfacesServicePtr surfaces_service;
« no previous file with comments | « no previous file | mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698