Chromium Code Reviews| Index: content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| index 8c47a7b1ff1b50a50540f896722b3aefcf10ca29..e2d7abb97d61a2d1042907f11ba8e768d5b41d06 100644 |
| --- a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| @@ -9,6 +9,7 @@ |
| #include "content/browser/web_contents/aura/image_window_delegate.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/view_messages.h" |
| +#include "content/public/browser/render_widget_host_view.h" |
| #include "ui/aura/window.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/layer_animation_observer.h" |
| @@ -222,43 +223,33 @@ void OverscrollNavigationOverlay::OnUpdateRect( |
| } |
| } |
| -ui::Layer* OverscrollNavigationOverlay::CreateBackLayer() { |
| +ui::Layer* OverscrollNavigationOverlay::OnSlideBackStartedCreateLayer() { |
| if (!web_contents_->GetController().CanGoBack()) |
| return NULL; |
| slide_direction_ = SLIDE_BACK; |
| return CreateSlideLayer(-1); |
| } |
| -ui::Layer* OverscrollNavigationOverlay::CreateFrontLayer() { |
| +ui::Layer* OverscrollNavigationOverlay::OnSlideForwardStartedCreateLayer() { |
| if (!web_contents_->GetController().CanGoForward()) |
| return NULL; |
| slide_direction_ = SLIDE_FRONT; |
| return CreateSlideLayer(1); |
| } |
| -void OverscrollNavigationOverlay::OnWindowSlideComplete() { |
| +void OverscrollNavigationOverlay::OnWindowFlingStarted() { |
| if (slide_direction_ == SLIDE_UNKNOWN) { |
|
sadrul
2014/03/19 20:21:18
You can remove the braces
mfomitchev
2014/03/20 15:10:06
Done.
|
| - window_slider_.reset(); |
| - StopObservingIfDone(); |
| return; |
| } |
| - // Change the image used for the overlay window. |
| - image_delegate_->SetImage(layer_delegate_->image()); |
| - window_->layer()->SetTransform(gfx::Transform()); |
| - window_->SchedulePaintInRect(gfx::Rect(window_->bounds().size())); |
| - |
| - SlideDirection direction = slide_direction_; |
| - slide_direction_ = SLIDE_UNKNOWN; |
| - |
| // Reset state and wait for the new navigation page to complete |
| // loading/painting. |
| StartObserving(); |
| // Perform the navigation. |
| - if (direction == SLIDE_BACK) |
| + if (slide_direction_ == SLIDE_BACK) |
| web_contents_->GetController().GoBack(); |
| - else if (direction == SLIDE_FRONT) |
| + else if (slide_direction_ == SLIDE_FRONT) |
| web_contents_->GetController().GoForward(); |
| else |
| NOTREACHED(); |
| @@ -271,7 +262,37 @@ void OverscrollNavigationOverlay::OnWindowSlideComplete() { |
| pending_entry_id_ = pending_entry ? pending_entry->GetUniqueID() : 0; |
| } |
| +void OverscrollNavigationOverlay::OnWindowFlingCompleted() { |
| + if (slide_direction_ == SLIDE_UNKNOWN) { |
| + window_slider_.reset(); |
| + StopObservingIfDone(); |
| + return; |
| + } |
| + |
| + // Change the image used for the overlay window. |
| + image_delegate_->SetImage(layer_delegate_->image()); |
| + window_->layer()->SetTransform(gfx::Transform()); |
| + window_->SchedulePaintInRect(gfx::Rect(window_->bounds().size())); |
| + slide_direction_ = SLIDE_UNKNOWN; |
| + |
| + // Make sure the overlay layer is repainted before we dismiss it, otherwise |
| + // OverlayDismissAnimator may end up showing the wrong screenshot during the |
| + // fadeout animation. |
| + if (received_paint_update_ && need_paint_update_) { |
| + received_paint_update_ = false; |
| + RenderWidgetHost* host = |
| + web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(); |
| + RenderViewHostImpl* view_host = |
| + static_cast<RenderViewHostImpl*> (RenderViewHost::From(host)); |
| + view_host->ScheduleComposite(); |
| + } else if (!need_paint_update_) { |
| + StopObservingIfDone(); |
| + } |
| +} |
| + |
| void OverscrollNavigationOverlay::OnWindowSlideAborted() { |
| + // The overlay may have been kept because of an in-progress slide, so check |
| + // if we need to dismiss it. |
|
sadrul
2014/03/19 20:21:18
I am not sure I understand this comment.
mfomitchev
2014/03/20 15:10:06
Yeah, it's poorly worded. Basically I was just try
|
| StopObservingIfDone(); |
| } |