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

Unified Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 54623007: Make code path for bounds changes getting to renderer less brittle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_view_aura.cc
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index bc7ee3ada1c36fdf0dde2e5d033d022ab7f566f8..e54e082b5e19530578dba17834560846254ee7d8 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -653,7 +653,7 @@ class WebContentsViewAura::WindowObserver
public:
explicit WindowObserver(WebContentsViewAura* view)
: view_(view),
- parent_(NULL) {
+ top_level_(NULL) {
view_->window_->AddObserver(this);
}
@@ -661,20 +661,25 @@ class WebContentsViewAura::WindowObserver
view_->window_->RemoveObserver(this);
if (view_->window_->GetDispatcher())
view_->window_->GetDispatcher()->RemoveRootWindowObserver(this);
- if (parent_)
- parent_->RemoveObserver(this);
+ if (top_level_)
+ top_level_->RemoveObserver(this);
}
// Overridden from aura::WindowObserver:
virtual void OnWindowParentChanged(aura::Window* window,
aura::Window* parent) OVERRIDE {
- if (window == parent_)
+ if (window == top_level_)
return;
- if (parent_)
- parent_->RemoveObserver(this);
- parent_ = parent;
- if (parent)
- parent->AddObserver(this);
+
+ if (top_level_) {
+ top_level_->RemoveObserver(this);
+ top_level_ = NULL;
+ }
+
+ if (window && window != window->GetToplevelWindow())
+ top_level_ = window->GetToplevelWindow();
+ if (top_level_)
+ top_level_->AddObserver(this);
}
virtual void OnWindowBoundsChanged(aura::Window* window,
@@ -686,12 +691,12 @@ class WebContentsViewAura::WindowObserver
}
virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE {
- if (window != parent_)
+ if (window != top_level_)
window->GetDispatcher()->AddRootWindowObserver(this);
}
virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE {
- if (window != parent_)
+ if (window != top_level_)
window->GetDispatcher()->RemoveRootWindowObserver(this);
}
@@ -710,9 +715,9 @@ class WebContentsViewAura::WindowObserver
WebContentsViewAura* view_;
- // We cache the old parent so that we can unregister when it's not the parent
- // anymore.
- aura::Window* parent_;
+ // We cache the old value so that we can unregister the observer when it
+ // changes. This also allows for filtering the events seen by the observer.
+ aura::Window* top_level_;
DISALLOW_COPY_AND_ASSIGN(WindowObserver);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698