Index: content/browser/web_contents/aura/overscroll_window_animation.h |
diff --git a/content/browser/web_contents/aura/overscroll_window_animation.h b/content/browser/web_contents/aura/overscroll_window_animation.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4599fa41f756d72d69e74d068addd0afac28fba7 |
--- /dev/null |
+++ b/content/browser/web_contents/aura/overscroll_window_animation.h |
@@ -0,0 +1,117 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
+#define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "content/browser/renderer_host/overscroll_controller.h" |
+#include "content/browser/renderer_host/overscroll_controller_delegate.h" |
+#include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
+#include "ui/aura/window.h" |
+#include "ui/aura_extra/image_window_delegate.h" |
+#include "ui/compositor/layer_animation_observer.h" |
+ |
+namespace content { |
+ |
+class ShadowLayerDelegate; |
+class WebContentsImpl; |
+ |
+// Manages the animations during an overscroll navigation. |
+// TODO write doc and nice comment explaining how overscroll navigation works. |
+class OverscrollWindowAnimation : ui::ImplicitAnimationObserver, |
+ OverscrollControllerDelegate { |
+ public: |
+ OverscrollWindowAnimation(WebContentsImpl* web_contents, |
+ OverscrollNavigationOverlay* ono, |
+ aura::Window* web_contents_window); |
+ |
+ ~OverscrollWindowAnimation() override; |
+ |
+ // Cancels the current animation. |
+ void CancelAnimation(); |
+ |
+ // Moves the animated window according to the given scroll deltas. Returns |
+ // true if the update moved the window. |
+ bool UpdateForScroll(float delta_x); |
+ |
+ // Aborts all current running animations. |
+ void AbortAllAnimations(); |
+ |
+ // Dismisses the overlay. |
+ void DismissOverlay(); |
+ |
+ // Returns the overscroll window delegate as an ImageWindowDelegate. |
+ aura_extra::ImageWindowDelegate* delegate() { |
+ return static_cast<aura_extra::ImageWindowDelegate*>( |
+ overscroll_window_->delegate()); |
+ } |
+ |
+ // Overridden from ui::ImplicitAnimationObserver: |
+ void OnImplicitAnimationsCompleted() override; |
+ |
+ // Overridn from OverscrollControllerDelegate: |
+ gfx::Rect GetVisibleBounds() const override; |
+ |
+ bool OnOverscrollUpdate(float delta_x, float delta_y) override; |
+ |
+ void OnOverscrollComplete(OverscrollMode overscroll_mode) override; |
+ |
+ void OnOverscrollModeChange(OverscrollMode old_mode, |
+ OverscrollMode new_mode) override; |
+ |
+ private: |
+ // Prepares the overscroll window to begin animating. |
+ void StartAnimating(); |
+ |
+ // Adds a new layer on top of the overscroll window. |
+ void AddNewLayer(); |
+ |
+ // Stops the animation, dismissing the overscroll window. |
+ void FadeOutOverscrollWindow(); |
+ |
+ // Returns the bounds for the overscroll current direction and RTL status. |
+ gfx::Rect GetStarterBounds() const; |
+ |
+ // Returns the window that should be animated for the overscroll navigation. |
+ aura::Window* GetWindowToAnimateForOverscroll() const; |
+ |
+ gfx::Vector2dF GetTranslationForOverscroll(float delta_x); |
+ |
+ // The window shown on top of the live window for the animations. |
+ scoped_ptr<aura::Window> overscroll_window_; |
+ |
+ // Shadow shown under the animated window. |
+ scoped_ptr<ShadowLayerDelegate> overscroll_shadow_; |
+ |
+ // Web contents that this instance refers to. |
+ WebContentsImpl* web_contents_; |
+ |
+ // Reference to the navigation overlay. |
+ OverscrollNavigationOverlay* ono_; |
+ |
+ // The current overscroll direction. |
+ OverscrollNavigationOverlay::Direction direction_; |
+ |
+ // Window that hosts the web contents. |
+ aura::Window* web_contents_window_; |
+ |
+ // Sliding layer used during second stage overscroll navigation. |
+ // TODO it is very likely that we don't need to own this layer. |
+ scoped_ptr<ui::Layer> slide_layer_; |
+ |
+ // TODO rename and make the following fields behave better. |
+ // Indicates if we should fade out the overlay prior to destroying it. |
+ bool fade_out_; |
+ |
+ // Indicates if the overscroll gesture has been cancelled. |
+ bool animation_cancelled_; |
+ |
+ // Indicates if the overscroll gesture has been completed. |
+ bool gesture_completed_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |