diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-26 16:16:25 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-26 16:16:25 +0000 |
commit | 250756bf45cf796af847512aa0f38132f17c282f (patch) | |
tree | 8d8ac5df458dd45fd536b6b48ebd0ebb905853ca /content | |
parent | c603afb9cd6af6496f22fbcdc38ff2b6326326a9 (diff) | |
download | chromium_src-250756bf45cf796af847512aa0f38132f17c282f.zip chromium_src-250756bf45cf796af847512aa0f38132f17c282f.tar.gz chromium_src-250756bf45cf796af847512aa0f38132f17c282f.tar.bz2 |
overscroll: Fix an issue where the overscroll window could get stuck.
While the content page is still loading after a gesture navigation, the overlay
that shows the preview of the history page should not forward input events to
the content page. Forwarding events during this time can get the overscroll
controller into an inconsistent state (because the overscroll controller does
not receive the whole stream of events after the overlay window is destroyed).
BUG=174186
Review URL: https://codereview.chromium.org/12346002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
3 files changed, 41 insertions, 6 deletions
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index c4505c1..4ca716d 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -100,7 +100,8 @@ class OverscrollWindowDelegate : public aura::WindowDelegate { OverscrollWindowDelegate(WebContentsImpl* web_contents, OverscrollMode overscroll_mode) : web_contents_(web_contents), - show_shadow_(false) { + show_shadow_(false), + forward_events_(true) { const NavigationControllerImpl& controller = web_contents->GetController(); const NavigationEntryImpl* entry = NULL; if (ShouldNavigateForward(controller, overscroll_mode)) { @@ -127,6 +128,8 @@ class OverscrollWindowDelegate : public aura::WindowDelegate { show_shadow_ = show; } + void stop_forwarding_events() { forward_events_ = false; } + private: virtual ~OverscrollWindowDelegate() {} @@ -224,12 +227,12 @@ class OverscrollWindowDelegate : public aura::WindowDelegate { // Overridden from ui::EventHandler. virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { - if (web_contents_window()) + if (forward_events_ && web_contents_window()) web_contents_window()->delegate()->OnScrollEvent(event); } virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { - if (web_contents_window()) + if (forward_events_ && web_contents_window()) web_contents_window()->delegate()->OnGestureEvent(event); } @@ -237,6 +240,14 @@ class OverscrollWindowDelegate : public aura::WindowDelegate { gfx::Image image_; bool show_shadow_; + // The window is displayed both during the gesture, and after the gesture + // while the navigation is in progress. During the gesture, it is necessary to + // forward input events to the content page (e.g. when the overscroll window + // slides under the cursor and starts receiving scroll events). However, once + // the gesture is complete, and the window is being displayed as an overlay + // window during navigation, events should not be forwarded anymore. + bool forward_events_; + DISALLOW_COPY_AND_ASSIGN(OverscrollWindowDelegate); }; @@ -597,7 +608,8 @@ class OverscrollNavigationOverlay : loading_complete_(false), received_paint_update_(false), compositor_updated_(false), - has_screenshot_(false) { + has_screenshot_(false), + need_paint_update_(true) { } virtual ~OverscrollNavigationOverlay() { @@ -629,6 +641,10 @@ class OverscrollNavigationOverlay : has_screenshot_ = has_screenshot; } + void SetupForTesting() { + need_paint_update_ = false; + } + private: // Stop observing the page if the page-load has completed and the page has // been painted. @@ -638,8 +654,10 @@ class OverscrollNavigationOverlay : // hiding the overlay. // If there is no screenshot in the overlay window, then hide this view // as soon as there is any new painting notification. - if (!received_paint_update_ || (has_screenshot_ && !loading_complete_)) + if ((need_paint_update_ && !received_paint_update_) || + (has_screenshot_ && !loading_complete_)) { return; + } window_.reset(); if (view_) { @@ -681,6 +699,11 @@ class OverscrollNavigationOverlay : bool compositor_updated_; bool has_screenshot_; + // During tests, the aura windows don't get any paint updates. So the overlay + // container keeps waiting for a paint update it never receives, causing a + // timeout. So during tests, disable the wait for paint updates. + bool need_paint_update_; + DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); }; @@ -858,6 +881,11 @@ WebContentsViewAura::~WebContentsViewAura() { window_.reset(); } +void WebContentsViewAura::SetupOverlayWindowForTesting() { + if (navigation_overlay_.get()) + navigation_overlay_->SetupForTesting(); +} + void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { if (web_contents_->GetInterstitialPage()) web_contents_->GetInterstitialPage()->SetSize(size); @@ -1051,6 +1079,7 @@ void WebContentsViewAura::PrepareOverscrollNavigationOverlay() { OverscrollWindowDelegate* delegate = static_cast<OverscrollWindowDelegate*>( overscroll_window_->delegate()); delegate->set_show_shadow(false); + delegate->stop_forwarding_events(); overscroll_window_->SchedulePaintInRect( gfx::Rect(overscroll_window_->bounds().size())); navigation_overlay_->SetOverlayWindow(overscroll_window_.Pass(), @@ -1379,7 +1408,8 @@ void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, // Reset any in-progress overscroll animation first. ResetOverscrollTransform(); - if (new_mode == OVERSCROLL_NONE) { + if (new_mode == OVERSCROLL_NONE || + (navigation_overlay_.get() && navigation_overlay_->has_window())) { current_overscroll_gesture_ = OVERSCROLL_NONE; } else { // Cleanup state of the content window first, because that can reset the diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 1b8269d..64b1b5f 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -43,6 +43,8 @@ class CONTENT_EXPORT WebContentsViewAura WebContentsViewAura(WebContentsImpl* web_contents, WebContentsViewDelegate* delegate); + void SetupOverlayWindowForTesting(); + private: class WindowObserver; #if defined(OS_WIN) diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index 3a278f3..5811b73 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -98,6 +98,9 @@ class WebContentsViewAuraTest : public ContentBrowserTest { NavigationController& controller = web_contents->GetController(); RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( web_contents->GetRenderViewHost()); + WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( + web_contents->GetView()); + view_aura->SetupOverlayWindowForTesting(); EXPECT_FALSE(controller.CanGoBack()); EXPECT_FALSE(controller.CanGoForward()); |