Fixing the flicker issue with fast dismissing GestureNav overlay.

The flicker was introduced in https://codereview.chromium.org/217373003/
Sometimes the overlay would get dismissed based on the paint event from the
previous page which happens just before the navigation.
This CL addressed the problem by ensuring
 a. The navigation is initiated before the overlay starts listening to events.
 b. We keep track of the pending id of the loading page and the paiting page.

BUG=357751

Review URL: https://codereview.chromium.org/224253002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262822 0039d316-1c4b-4281-b951-d872f2087c98
parent c980bdcb
......@@ -131,6 +131,14 @@ void OverscrollNavigationOverlay::StartObserving() {
// Make sure the overlay window is on top.
if (window_.get() && window_->parent())
window_->parent()->StackChildAtTop(window_.get());
// Assumes the navigation has been initiated.
NavigationEntry* pending_entry =
web_contents_->GetController().GetPendingEntry();
// Save id of the pending entry to identify when it loads and paints later.
// Under some circumstances navigation can leave a null pending entry -
// see comments in NavigationControllerImpl::NavigateToPendingEntry().
pending_entry_id_ = pending_entry ? pending_entry->GetUniqueID() : 0;
}
void OverscrollNavigationOverlay::SetOverlayWindow(
......@@ -235,10 +243,6 @@ void OverscrollNavigationOverlay::OnWindowSlideCompleting() {
if (slide_direction_ == SLIDE_UNKNOWN)
return;
// Reset state and wait for the new navigation page to complete
// loading/painting.
StartObserving();
// Perform the navigation.
if (slide_direction_ == SLIDE_BACK)
web_contents_->GetController().GoBack();
......@@ -247,12 +251,9 @@ void OverscrollNavigationOverlay::OnWindowSlideCompleting() {
else
NOTREACHED();
NavigationEntry* pending_entry =
web_contents_->GetController().GetPendingEntry();
// Save id of the pending entry to identify when it loads and paints later.
// Under some circumstances navigation can leave a null pending entry -
// see comments in NavigationControllerImpl::NavigateToPendingEntry().
pending_entry_id_ = pending_entry ? pending_entry->GetUniqueID() : 0;
// Reset state and wait for the new navigation page to complete
// loading/painting.
StartObserving();
}
void OverscrollNavigationOverlay::OnWindowSlideCompleted() {
......
......@@ -37,6 +37,8 @@ class CONTENT_EXPORT OverscrollNavigationOverlay
// updates. This function makes sure that the screenshot window is stacked
// on top, so that it hides the content window behind it, and destroys the
// screenshot window when the page is done loading/painting.
// This should be called immediately after initiating the navigation,
// otherwise the overlay may be dismissed prematurely.
void StartObserving();
// Sets the screenshot window and the delegate. This takes ownership of
......
......@@ -1273,12 +1273,12 @@ void WebContentsViewAura::OnImplicitAnimationsCompleted() {
if (ShouldNavigateForward(web_contents_->GetController(),
completed_overscroll_gesture_)) {
PrepareOverscrollNavigationOverlay();
web_contents_->GetController().GoForward();
PrepareOverscrollNavigationOverlay();
} else if (ShouldNavigateBack(web_contents_->GetController(),
completed_overscroll_gesture_)) {
PrepareOverscrollNavigationOverlay();
web_contents_->GetController().GoBack();
PrepareOverscrollNavigationOverlay();
} else {
if (touch_editable_)
touch_editable_->OverscrollCompleted();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment