Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / web_contents / aura / overscroll_navigation_overlay.cc
index ac7b20c..1a17d90 100644 (file)
@@ -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(
@@ -156,13 +164,7 @@ void OverscrollNavigationOverlay::SetupForTesting() {
 }
 
 void OverscrollNavigationOverlay::StopObservingIfDone() {
-  // If there is a screenshot displayed in the overlay window, then wait for
-  // the navigated page to complete loading and some paint update before
-  // 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 ((need_paint_update_ && !received_paint_update_) ||
-      (image_delegate_->has_image() && !loading_complete_)) {
+  if ((need_paint_update_ && !received_paint_update_)) {
     return;
   }
 
@@ -171,9 +173,8 @@ void OverscrollNavigationOverlay::StopObservingIfDone() {
     return;
 
   scoped_ptr<ui::Layer> layer;
-  if (window_.get()) {
-    layer.reset(window_->AcquireLayer());
-  }
+  if (window_.get())
+    layer = window_->AcquireLayer();
   Observe(NULL);
   window_slider_.reset();
   window_.reset();
@@ -241,10 +242,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();
@@ -253,12 +250,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() {
@@ -307,21 +301,19 @@ void OverscrollNavigationOverlay::OnWindowSliderDestroyed() {
   }
 }
 
-void OverscrollNavigationOverlay::DocumentOnLoadCompletedInMainFrame(
-    int32 page_id) {
+void OverscrollNavigationOverlay::DocumentOnLoadCompletedInMainFrame() {
   // Use the last committed entry rather than the active one, in case a
   // pending entry has been created.
   int committed_entry_id =
       web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID();
-  // For the purposes of dismissing the overlay - consider the loading completed
-  // once the main frame has loaded.
+  // Consider the loading completed once the main frame has loaded.
   if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) {
     loading_complete_ = true;
     StopObservingIfDone();
   }
 }
 
-void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint(int32 page_id) {
+void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint() {
   int visible_entry_id =
       web_contents_->GetController().GetVisibleEntry()->GetUniqueID();
   if (visible_entry_id == pending_entry_id_ || !pending_entry_id_) {
@@ -337,7 +329,7 @@ void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) {
       web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID();
   if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) {
     loading_complete_ = true;
-    if (!received_paint_update_) {
+    if (!received_paint_update_ && need_paint_update_) {
       // Force a repaint after the page is loaded.
       RenderViewHostImpl* view = static_cast<RenderViewHostImpl*>(host);
       view->ScheduleComposite();