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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1062273002: Snap RWHVA and resize the legacy window on Windows whenever the ancestor window's bounds change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 5 years, 8 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 | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 146355707f08f247446929d5c6c0d22d7b5e11e2..f6d1b48bd5f00c74fde472733c38bf6a9fa47f71 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -334,26 +334,59 @@ void RenderWidgetHostViewAura::ApplyEventFilterForPopupExit(
class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
public:
explicit WindowObserver(RenderWidgetHostViewAura* view)
- : view_(view) {
+ : view_(view),
+ view_ancestor_(nullptr) {
view_->window_->AddObserver(this);
}
- ~WindowObserver() override { view_->window_->RemoveObserver(this); }
+ ~WindowObserver() override {
+ if (view_ancestor_)
+ view_ancestor_->RemoveObserver(this);
+ view_->window_->RemoveObserver(this);
+ }
// Overridden from aura::WindowObserver:
void OnWindowAddedToRootWindow(aura::Window* window) override {
- if (window == view_->window_)
+ if (window == view_->window_) {
+ if (window->parent() && window->parent()->parent()) {
+ // We observe the ancestor for bounds changes and snap the RWHVA
+ // instance to pixel boundaries. Reason for doing this is there are
+ // cases like the fast resize code path for bookmarks where in the
+ // parent of RWHVA which is WCV has its bounds changed before the
+ // bookmark is hidden. This results in it reporting the old bounds
+ // which includes the bookmark. Eventually when it does get the correct
+ // bounds after the bar is hidden, the layer ignores the bounds changed
+ // call as the bounds are the same. To work around this we observe the
+ // parent of WCV for bounds changed notifications and snap when we
+ // receive them.
+ view_ancestor_ = window->parent()->parent();
+ view_ancestor_->AddObserver(this);
sky 2015/04/08 20:13:09 Don't you want to know when the bounds of any ance
ananta 2015/04/08 21:08:20 Done.
+ }
view_->AddedToRootWindow();
+ }
}
void OnWindowRemovingFromRootWindow(aura::Window* window,
aura::Window* new_root) override {
- if (window == view_->window_)
+ if (window == view_->window_) {
+ if (view_ancestor_) {
+ view_ancestor_->RemoveObserver(this);
+ view_ancestor_ = nullptr;
+ }
view_->RemovingFromRootWindow();
+ }
+ }
+
+ void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
+ if (window == view_ancestor_)
+ view_->HandleParentBoundsChanged();
}
private:
RenderWidgetHostViewAura* view_;
+ aura::Window* view_ancestor_;
DISALLOW_COPY_AND_ASSIGN(WindowObserver);
};
@@ -734,6 +767,16 @@ bool RenderWidgetHostViewAura::CanRendererHandleEvent(
return true;
}
+void RenderWidgetHostViewAura::HandleParentBoundsChanged() {
+ SnapToPhysicalPixelBoundary();
+#if defined(OS_WIN)
+ if (legacy_render_widget_host_HWND_) {
+ legacy_render_widget_host_HWND_->SetBounds(
+ window_->GetBoundsInRootWindow());
+ }
+#endif
+}
+
void RenderWidgetHostViewAura::MovePluginWindows(
const std::vector<WebPluginGeometry>& plugin_window_moves) {
#if defined(OS_WIN)
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698