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..a9bbe61ba944f934a4792e389a103fdf949b8b94 |
--- /dev/null |
+++ b/content/browser/web_contents/aura/overscroll_window_animation.h |
@@ -0,0 +1,110 @@ |
+// Copyright 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 "content/browser/renderer_host/overscroll_controller_delegate.h" |
+#include "content/browser/web_contents/aura/slidable_wrapper.h" |
+#include "content/common/content_export.h" |
+#include "ui/compositor/layer_animation_observer.h" |
+ |
+namespace aura { |
+class Window; |
+} |
+ |
+namespace ui { |
+class Layer; |
+class LayerAnimator; |
+} |
+ |
+namespace content { |
+ |
+class SlidableWrapper; |
+class ShadowLayerDelegate; |
+class WebContentsImpl; |
+ |
+// Manages the animations during an overscroll navigation by handling overscroll |
+// events. |
+class CONTENT_EXPORT OverscrollWindowAnimation |
+ : public OverscrollControllerDelegate, |
+ ui::ImplicitAnimationObserver { |
+ public: |
+ enum Direction { SLIDE_FRONT, SLIDE_BACK, SLIDE_NONE }; |
+ |
+ // Delegate class that interfaces with the window animation, responsible for |
+ // navigation. |
+ class Delegate { |
+ public: |
+ virtual ~Delegate() {} |
+ |
+ // The following two functions create a layer wrapper and transfer back its |
+ // ownership. |
+ virtual scoped_ptr<SlidableWrapper> CreateFrontWrapper() = 0; |
+ virtual scoped_ptr<SlidableWrapper> CreateBackWrapper() = 0; |
+ |
+ // Returns the live window that participates in the overscroll gesture. |
+ virtual aura::Window* GetLiveWindow() const = 0; |
mfomitchev
2015/03/16 22:28:02
We should really find another name for this. This
Nina
2015/03/17 14:27:07
GetTargetWindow? As the window is the one being ov
|
+ |
+ // Called when we know the animation is going to complete successfully. |
+ virtual void OnOverscrollCompleting() = 0; |
+ |
+ // Called when the animation has been completed. |
+ virtual void OnOverscrollCompleted( |
+ scoped_ptr<SlidableWrapper> layer_wrapper) = 0; |
+ |
+ // Called when the overscroll gesture has been aborted. |
+ virtual void OnOverscrollAborted() = 0; |
+ }; |
+ |
+ explicit OverscrollWindowAnimation(Delegate* delegate); |
+ |
+ ~OverscrollWindowAnimation() override; |
+ |
+ // Returns true if we are currently handling a slide animation. |
+ bool is_active() const { return !!wrapper_; } |
+ |
+ // Overridden 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: |
+ // Starts the overscroll cancelled animation. |
+ void CancelOverscroll(); |
+ |
+ // Moves the animated window according to the given scroll deltas. Returns |
+ // true if the update moved the window. |
+ bool UpdateForScroll(float delta_x); |
+ |
+ // Returns a translation on the x axis for the given overscroll. |
+ float GetTranslationForOverscroll(float delta_x); |
+ |
+ // Returns the SlidableWrapper that is animated for the overscroll gesture. |
+ ui::Layer* GetFrontLayer() const; |
+ |
+ // ui::ImplicitAnimationObserver: |
+ void OnImplicitAnimationsCompleted() override; |
+ |
+ // Wrapper that owns the new layer created on the overscroll gesture. |
+ scoped_ptr<SlidableWrapper> wrapper_; |
+ |
+ // Shadow shown under the animated layer. |
+ scoped_ptr<ShadowLayerDelegate> shadow_; |
+ |
+ // Delegate that provides the animation target and handles navigation. |
+ Delegate* delegate_; |
+ |
+ // The current overscroll direction. |
+ Direction direction_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |