diff options
author | thakis <thakis@chromium.org> | 2015-04-12 17:12:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-13 00:13:14 +0000 |
commit | 67bcbf34229acff21e300e630ee871b0a64871b4 (patch) | |
tree | cf6b7f3584c56f5855beef84ddb317e189e563db /content | |
parent | 668990c3f40b73d9c9a502be655566041a1b621d (diff) | |
download | chromium_src-67bcbf34229acff21e300e630ee871b0a64871b4.zip chromium_src-67bcbf34229acff21e300e630ee871b0a64871b4.tar.gz chromium_src-67bcbf34229acff21e300e630ee871b0a64871b4.tar.bz2 |
Revert of Snap RWHVA and resize the legacy window on Windows whenever the ancestor window's bounds change. (patchset #12 id:220001 of https://codereview.chromium.org/1062273002/)
Reason for revert:
Speculative, possibly caused lots of browsert_tests redness on a bot that runs browser_tests with an official build (and a different compiler, but all the redness we fixed on official builds so far were caused by the builds being official, not because of the compiler): http://build.chromium.org/p/chromium.fyi/builders/CrWinClang%20tester/builds/285 (see http://crbug.com/467929)
Original issue's description:
> Snap RWHVA and resize the legacy window on Windows whenever the ancestor window's bounds change.
>
> The bookmark bar is hidden through the fast resize code path where in the Renderer is informed about
> the actual size minus the bookmar bar before the bookmark bar is hidden. To ensure that the RWHVA is snapped
> to pixel boundaries and the legacy window is resized we observe bounds changed events on the parent of the WCVA
> window which is the NativeViewHost clipping window. Reason for doing this is the layer for the window hosted by WCVA
> verifies if the stored bounds is the same as the one coming in and ignores the change if yes.
>
> For more context and a general discussion of the reason why this bug happens please visit this link
> https://codereview.chromium.org/1009533005/
>
> BUG=469857, 468669
>
> Committed: https://crrev.com/e6a9b7fff4802ac6796250987be4d52204716392
> Cr-Commit-Position: refs/heads/master@{#324743}
TBR=sky@chromium.org,scottmg@chromium.org,cpu@chromium.org,ananta@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=469857, 468669
Review URL: https://codereview.chromium.org/1063083003
Cr-Commit-Position: refs/heads/master@{#324804}
Diffstat (limited to 'content')
3 files changed, 15 insertions, 83 deletions
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 fd85fcc..1463557 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -4,8 +4,6 @@ #include "content/browser/renderer_host/render_widget_host_view_aura.h" -#include <set> - #include "base/auto_reset.h" #include "base/basictypes.h" #include "base/bind.h" @@ -354,64 +352,12 @@ class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { view_->RemovingFromRootWindow(); } - void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override { - view_->ParentHierarchyChanged(); - } - private: RenderWidgetHostViewAura* view_; DISALLOW_COPY_AND_ASSIGN(WindowObserver); }; -// This class provides functionality to observe the ancestors of the RWHVA for -// bounds changes. This is done to snap the RWHVA window to a pixel boundary, -// which could change when the bounds relative to the root changes. -// An example where this happens is below:- -// 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 -// the traditional bounds change notification for the WCV reporting the old -// bounds as the bookmark is still around. Observing all the ancestors of the -// RWHVA window enables us to know when the bounds of the window relative to -// root changes and allows us to snap accordingly. -class RenderWidgetHostViewAura::WindowAncestorObserver - : public aura::WindowObserver { - public: - explicit WindowAncestorObserver(RenderWidgetHostViewAura* view) - : view_(view) { - aura::Window* parent = view_->window_->parent(); - while (parent) { - parent->AddObserver(this); - ancestors_.insert(parent); - parent = parent->parent(); - } - } - - ~WindowAncestorObserver() override { - RemoveAncestorObservers(); - } - - void OnWindowBoundsChanged(aura::Window* window, - const gfx::Rect& old_bounds, - const gfx::Rect& new_bounds) override { - DCHECK(ancestors_.find(window) != ancestors_.end()); - if (new_bounds.origin() != old_bounds.origin()) - view_->HandleParentBoundsChanged(); - } - - private: - void RemoveAncestorObservers() { - for (auto ancestor : ancestors_) - ancestor->RemoveObserver(this); - ancestors_.clear(); - } - - RenderWidgetHostViewAura* view_; - std::set<aura::Window*> ancestors_; - - DISALLOW_COPY_AND_ASSIGN(WindowAncestorObserver); -}; - //////////////////////////////////////////////////////////////////////////////// // RenderWidgetHostViewAura, public: @@ -449,7 +395,6 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, host_->SetView(this); window_observer_.reset(new WindowObserver(this)); - aura::client::SetTooltipText(window_, &tooltip_); aura::client::SetActivationDelegate(window_, this); aura::client::SetFocusChangeObserver(window_, this); @@ -789,22 +734,6 @@ 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::ParentHierarchyChanged() { - ancestor_window_observer_.reset(new WindowAncestorObserver(this)); - // Snap when we receive a hierarchy changed. http://crbug.com/388908. - HandleParentBoundsChanged(); -} - void RenderWidgetHostViewAura::MovePluginWindows( const std::vector<WebPluginGeometry>& plugin_window_moves) { #if defined(OS_WIN) diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index d9e1201..89bead7 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -401,9 +401,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura class WindowObserver; friend class WindowObserver; - class WindowAncestorObserver; - friend class WindowAncestorObserver; - void UpdateCursorIfOverSelf(); // Tracks whether SnapToPhysicalPixelBoundary() has been called. @@ -503,12 +500,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura bool mouse_locked, bool selection_popup); - // Called when the parent window bounds change. - void HandleParentBoundsChanged(); - - // Called when the parent window hierarchy for our window changes. - void ParentHierarchyChanged(); - // The model object. RenderWidgetHostImpl* host_; @@ -518,9 +509,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura scoped_ptr<WindowObserver> window_observer_; - // Tracks the ancestors of the RWHVA window for window location changes. - scoped_ptr<WindowAncestorObserver> ancestor_window_observer_; - // Are we in the process of closing? Tracked so fullscreen views can avoid // sending a second shutdown request to the host when they lose the focus // after requesting shutdown for another reason (e.g. Escape key). diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index f0d20fa..ce104f2 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -429,6 +429,21 @@ class WebContentsViewAura::WindowObserver #endif } + // Overridden from aura::WindowObserver: + void OnWindowHierarchyChanged( + const aura::WindowObserver::HierarchyChangeParams& params) override { + if (params.receiver != view_->window_.get() || + !params.target->Contains(view_->window_.get())) { + return; + } + + // Use the new parent's root window for calculating HiDPI subpixel offset. + RenderWidgetHostViewAura* rwhv = ToRenderWidgetHostViewAura( + view_->web_contents_->GetRenderWidgetHostView()); + if (rwhv) + rwhv->SnapToPhysicalPixelBoundary(); + } + #if defined(OS_WIN) // Constrained windows are added as children of the parent's parent's view // which may overlap with windowed NPAPI plugins. In that case, tell the RWHV |