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) |