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 89aa4975f81a12b870ddd544c3dff67a96bc2561..b11afc7441b750762da9c2dca38635ff3ee1d486 100644 |
--- a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
+++ b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
@@ -6,6 +6,8 @@ |
#include "content/browser/frame_host/navigation_entry_impl.h" |
#include "content/browser/renderer_host/render_view_host_impl.h" |
+#include "content/browser/web_contents/aura/overscroll_window_delegate.h" |
+#include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
#include "content/browser/web_contents/web_contents_impl.h" |
#include "content/common/view_messages.h" |
#include "content/public/browser/browser_thread.h" |
@@ -18,7 +20,6 @@ |
#include "ui/compositor/scoped_layer_animation_settings.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/image/image_png_rep.h" |
-#include "ui/gfx/image/image_skia.h" |
namespace content { |
namespace { |
@@ -130,26 +131,31 @@ class OverlayDismissAnimator |
}; |
OverscrollNavigationOverlay::OverscrollNavigationOverlay( |
- WebContentsImpl* web_contents) |
- : web_contents_(web_contents), |
+ WebContentsImpl* web_contents, |
+ WebContentsViewAura* wcva, |
+ aura::Window* web_contents_window) |
+ : direction_(OverscrollWindowAnimation::NONE), |
+ web_contents_(web_contents), |
image_delegate_(NULL), |
loading_complete_(false), |
received_paint_update_(false), |
- slide_direction_(SLIDE_UNKNOWN) { |
+ wcva_(wcva), |
+ web_contents_window_(web_contents_window) { |
} |
OverscrollNavigationOverlay::~OverscrollNavigationOverlay() { |
} |
void OverscrollNavigationOverlay::StartObserving() { |
- loading_complete_ = false; |
+ LOG(ERROR) << "Starting to observe"; |
+ /*loading_complete_ = false; |
received_paint_update_ = false; |
- overlay_dismiss_layer_.reset(); |
+ overlay_dismiss_layer_.reset();*/ |
Observe(web_contents_); |
- // Make sure the overlay window is on top. |
+ /*// Make sure the overlay window is on top. |
if (window_.get() && window_->parent()) |
- window_->parent()->StackChildAtTop(window_.get()); |
+ window_->parent()->StackChildAtTop(window_.get());*/ |
// Assumes the navigation has been initiated. |
NavigationEntry* pending_entry = |
@@ -158,12 +164,14 @@ void OverscrollNavigationOverlay::StartObserving() { |
// Under some circumstances navigation can leave a null pending entry - |
// see comments in NavigationControllerImpl::NavigateToPendingEntry(). |
pending_entry_url_ = pending_entry ? pending_entry->GetURL() : GURL(); |
+ LOG(ERROR) << "URL: " << pending_entry_url_.GetContent(); |
} |
void OverscrollNavigationOverlay::SetOverlayWindow( |
scoped_ptr<aura::Window> window, |
aura_extra::ImageWindowDelegate* delegate) { |
- window_ = window.Pass(); |
+ LOG(ERROR) << "Setting overlay window"; |
+ /*window_ = window.Pass(); |
if (window_.get() && window_->parent()) |
window_->parent()->StackChildAtTop(window_.get()); |
image_delegate_ = delegate; |
@@ -175,18 +183,80 @@ void OverscrollNavigationOverlay::SetOverlayWindow( |
slide_direction_ = SLIDE_UNKNOWN; |
} else { |
window_slider_.reset(); |
+ }*/ |
+} |
+ |
+const gfx::Image OverscrollNavigationOverlay::GetImageForDirection( |
+ OverscrollWindowAnimation::Direction direction) { |
+ const NavigationControllerImpl& controller = web_contents_->GetController(); |
+ const NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
+ controller.GetEntryAtOffset( |
+ direction == OverscrollWindowAnimation::FORWARD ? 1 : -1)); |
+ |
+ if (entry && entry->screenshot().get()) { |
+ std::vector<gfx::ImagePNGRep> image_reps; |
+ image_reps.push_back(gfx::ImagePNGRep(entry->screenshot(), 1.0f)); |
+ return gfx::Image(image_reps); |
+ } |
+ return gfx::Image(); |
+} |
+ |
+OverscrollWindowAnimation::Direction |
+OverscrollNavigationOverlay::StartNavigation(OverscrollMode mode) { |
+ return OverscrollWindowAnimation::NONE; |
+} |
+ |
+void OverscrollNavigationOverlay::SetTransform( |
+ const gfx::Transform& transform) { |
+ |
+} |
+ |
+ui::LayerAnimator* OverscrollNavigationOverlay::GetAnimator() { |
+ return nullptr; |
+} |
+ |
+gfx::Rect OverscrollNavigationOverlay::GetContentsBounds() const { |
+ return gfx::Rect(); |
+} |
+ |
+void OverscrollNavigationOverlay::OnAnimationCompleted() { |
+ |
+} |
+ |
+void OverscrollNavigationOverlay::OnAnimationCompleting() { |
+ |
+} |
+ |
+void OverscrollNavigationOverlay::FadeOutOverscrollWindow() { |
+ LOG(ERROR) << "FadeOutOverscrollWindow"; |
+ // TODO maybe we do not need this check. |
+ if (!window_) |
+ return; |
+ aura::Window* contents = web_contents_->GetContentNativeView(); |
+ contents->layer()->SetLayerBrightness(1.f); |
+ { |
+ ui::ScopedLayerAnimationSettings settings(contents->layer()->GetAnimator()); |
+ settings.SetPreemptionStrategy( |
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ settings.SetTweenType(gfx::Tween::EASE_OUT); |
+ contents->layer()->SetLayerBrightness(0.f); |
} |
+ scoped_ptr<ui::Layer> dismiss_layer = window_->AcquireLayer(); |
+ window_.reset(); |
+ (new OverlayDismissAnimator(dismiss_layer.Pass()))->Animate(); |
+ // TODO delete shadow when the dismiss animation finishes? |
+ shadow_.reset(); |
} |
void OverscrollNavigationOverlay::StopObservingIfDone() { |
+ LOG(ERROR) << "Stop observing if done"; |
// Normally we dismiss the overlay once we receive a paint update, however |
// for in-page navigations DidFirstVisuallyNonEmptyPaint() does not get |
// called, and we rely on loading_complete_ for those cases. |
if (!received_paint_update_ && !loading_complete_) |
return; |
- // If a slide is in progress, then do not destroy the window or the slide. |
- if (window_slider_.get() && window_slider_->IsSlideInProgress()) |
+ if (owa_->IsSlideInProgress()) |
return; |
// The layer to be animated by OverlayDismissAnimator |
@@ -195,38 +265,30 @@ void OverscrollNavigationOverlay::StopObservingIfDone() { |
overlay_dismiss_layer = overlay_dismiss_layer_.Pass(); |
else if (window_.get()) |
overlay_dismiss_layer = window_->AcquireLayer(); |
+ LOG(ERROR) << "Resetting window slider"; |
Observe(NULL); |
- window_slider_.reset(); |
- window_.reset(); |
- image_delegate_ = NULL; |
- if (overlay_dismiss_layer.get()) { |
- // OverlayDismissAnimator deletes overlay_dismiss_layer and itself when the |
- // animation completes. |
- (new OverlayDismissAnimator(overlay_dismiss_layer.Pass()))->Animate(); |
- } |
} |
+// TODO delete these *Layer functions. |
ui::Layer* OverscrollNavigationOverlay::CreateSlideLayer(int offset) { |
- const NavigationControllerImpl& controller = web_contents_->GetController(); |
- const NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
- controller.GetEntryAtOffset(offset)); |
- |
- gfx::Image image; |
- if (entry && entry->screenshot().get()) { |
- std::vector<gfx::ImagePNGRep> image_reps; |
- image_reps.push_back(gfx::ImagePNGRep(entry->screenshot(), 1.0f)); |
- image = gfx::Image(image_reps); |
- } |
if (!layer_delegate_) |
layer_delegate_.reset(new ImageLayerDelegate()); |
- layer_delegate_->SetImage(image); |
+ // TODO fixme. |
+ layer_delegate_->SetImage( |
+ GetImageForDirection(offset == -1 ? OverscrollWindowAnimation::BACKWARD |
+ : OverscrollWindowAnimation::FORWARD)); |
ui::Layer* layer = new ui::Layer(ui::LAYER_TEXTURED); |
layer->set_delegate(layer_delegate_.get()); |
return layer; |
} |
-ui::Layer* OverscrollNavigationOverlay::CreateBackLayer() { |
+OverscrollWindowAnimation::Direction |
+OverscrollNavigationOverlay::GetNavigationDirection() { |
+ return direction_; |
+} |
+ |
+/*ui::Layer* OverscrollNavigationOverlay::CreateBackLayer() { |
if (!web_contents_->GetController().CanGoBack()) |
return NULL; |
slide_direction_ = SLIDE_BACK; |
@@ -255,29 +317,9 @@ void OverscrollNavigationOverlay::OnWindowSlideCompleting() { |
// Reset state and wait for the new navigation page to complete |
// loading/painting. |
StartObserving(); |
-} |
+}*/ |
-void OverscrollNavigationOverlay::OnWindowSlideCompleted( |
- scoped_ptr<ui::Layer> layer) { |
- 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; |
- // We may end up dismissing the overlay before it has a chance to repaint, so |
- // set the slider layer to be the one animated by OverlayDismissAnimator. |
- if (layer.get()) |
- overlay_dismiss_layer_ = layer.Pass(); |
- StopObservingIfDone(); |
-} |
- |
-void OverscrollNavigationOverlay::OnWindowSlideAborted() { |
+/*void OverscrollNavigationOverlay::OnWindowSlideAborted() { |
StopObservingIfDone(); |
} |
@@ -293,9 +335,10 @@ void OverscrollNavigationOverlay::OnWindowSliderDestroyed() { |
ignore_result(window_slider_.release()); |
StopObservingIfDone(); |
} |
-} |
+}*/ |
void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint() { |
+ LOG(ERROR) << "Did first visually non empty paint"; |
NavigationEntry* visible_entry = |
web_contents_->GetController().GetVisibleEntry(); |
if (pending_entry_url_.is_empty() || |
@@ -306,6 +349,7 @@ void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint() { |
} |
void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { |
+ LOG(ERROR) << "Did stop loading"; |
// Don't compare URLs in this case - it's possible they won't match if |
// a gesture-nav initiated navigation was interrupted by some other in-site |
// navigation ((e.g., from a script, or from a bookmark). |
@@ -313,4 +357,22 @@ void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { |
StopObservingIfDone(); |
} |
+/*aura::Window* OverscrollNavigationOverlay::GetWindowToAnimateForOverscroll() |
+ const { |
+ return direction_ == OverscrollNavigationOverlay::FORWARD |
+ ? window_.get() |
+ : web_contents_->GetContentNativeView(); |
+} |
+ |
+gfx::Rect OverscrollNavigationOverlay::GetStarterBounds() const { |
+ gfx::Rect bounds = gfx::Rect(web_contents_window_->bounds().size()); |
+ if (direction_ == OverscrollNavigationOverlay::FORWARD) { |
+ // The overlay will be sliding in from the right edge towards the left in |
+ // non-RTL, or sliding in from the left edge towards the right in RTL. |
+ // So position the overlay window accordingly. |
+ bounds.Offset(base::i18n::IsRTL() ? -bounds.width() : bounds.width(), 0); |
+ } |
+ return bounds; |
+}*/ |
+ |
} // namespace content |