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..acd0fa418f17beda7e6ac1eb604e2a5e225335d3 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
@@ -4,6 +4,8 @@ |
#include "content/browser/renderer_host/render_widget_host_view_aura.h" |
+#include <map> |
+ |
#include "base/auto_reset.h" |
#include "base/basictypes.h" |
#include "base/bind.h" |
@@ -338,22 +340,58 @@ class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { |
view_->window_->AddObserver(this); |
} |
- ~WindowObserver() override { view_->window_->RemoveObserver(this); } |
+ ~WindowObserver() override { |
+ RemoveAncestorObservers(); |
+ view_->window_->RemoveObserver(this); |
+ } |
// Overridden from aura::WindowObserver: |
void OnWindowAddedToRootWindow(aura::Window* window) override { |
sky
2015/04/09 00:01:14
I don't think you're handling the case of ancestor
ananta
2015/04/09 03:36:05
Done.
|
- if (window == view_->window_) |
+ if (window == view_->window_) { |
+ // We observe the ancestors 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. |
+ aura::Window* parent = window->parent(); |
+ while (parent) { |
+ parent->AddObserver(this); |
+ ancestor_observer_map_[parent] = true; |
+ parent = parent->parent(); |
+ } |
view_->AddedToRootWindow(); |
+ } |
} |
void OnWindowRemovingFromRootWindow(aura::Window* window, |
aura::Window* new_root) override { |
- if (window == view_->window_) |
+ if (window == view_->window_) { |
+ RemoveAncestorObservers(); |
view_->RemovingFromRootWindow(); |
+ } |
+ } |
+ |
+ void OnWindowBoundsChanged(aura::Window* window, |
+ const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) override { |
+ if (ancestor_observer_map_.find(window) != ancestor_observer_map_.end()) |
+ view_->HandleParentBoundsChanged(); |
} |
private: |
+ void RemoveAncestorObservers() { |
+ for (auto ancestor_iterator : ancestor_observer_map_) |
+ ancestor_iterator.first->RemoveObserver(this); |
+ ancestor_observer_map_.clear(); |
+ } |
+ |
RenderWidgetHostViewAura* view_; |
+ std::map<aura::Window*, bool> ancestor_observer_map_; |
sky
2015/04/09 00:01:14
I don't think you need a map, how about a set?
ananta
2015/04/09 03:36:05
Done.
|
DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
}; |
@@ -734,6 +772,16 @@ bool RenderWidgetHostViewAura::CanRendererHandleEvent( |
return true; |
} |
+void RenderWidgetHostViewAura::HandleParentBoundsChanged() { |
+ SnapToPhysicalPixelBoundary(); |
sky
2015/04/09 00:01:14
Does this mean we can remove some calls to SnapToP
ananta
2015/04/09 03:36:05
Removed the call from WCVA.
|
+#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) |