| 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..cac0efc6474133572dc61873cd5a67e9fa1d3ed7
|
| --- /dev/null
|
| +++ b/content/browser/web_contents/aura/overscroll_window_animation.h
|
| @@ -0,0 +1,117 @@
|
| +// 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/common/content_export.h"
|
| +#include "ui/compositor/layer_animation_observer.h"
|
| +
|
| +namespace aura {
|
| +class Window;
|
| +}
|
| +
|
| +namespace ui {
|
| +class Layer;
|
| +class LayerAnimator;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +class OverscrollLayerWrapper;
|
| +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<OverscrollLayerWrapper> CreateFrontLayerWrapper() = 0;
|
| + virtual scoped_ptr<OverscrollLayerWrapper> CreateBackLayerWrapper() = 0;
|
| +
|
| + // 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<OverscrollLayerWrapper> layer_wrapper) = 0;
|
| +
|
| + // Called when the overscroll gesture has been aborted.
|
| + virtual void OnOverscrollAborted() = 0;
|
| + };
|
| +
|
| + OverscrollWindowAnimation(Delegate* delegate, WebContentsImpl* web_contents);
|
| +
|
| + ~OverscrollWindowAnimation() override;
|
| +
|
| + // Returns true if we are currently handling a slide animation.
|
| + bool is_active() const { return !!layer_wrapper_; }
|
| +
|
| + void set_overlay_window(aura::Window* overlay_window) {
|
| + DCHECK(overlay_window);
|
| + overlay_window_ = overlay_window;
|
| + }
|
| +
|
| + // 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 layer that is animated for the overscroll gesture.
|
| + ui::Layer* GetFrontLayer() const;
|
| +
|
| + // ui::ImplicitAnimationObserver:
|
| + void OnImplicitAnimationsCompleted() override;
|
| +
|
| + // Wrapper that owns the overscroll window.
|
| + scoped_ptr<OverscrollLayerWrapper> layer_wrapper_;
|
| +
|
| + // Shadow shown under the animated layer.
|
| + scoped_ptr<ShadowLayerDelegate> shadow_;
|
| +
|
| + // The window shown on top of the web contents.
|
| + aura::Window* overlay_window_;
|
| +
|
| + // Web contents being handled.
|
| + WebContentsImpl* web_contents_;
|
| +
|
| + // 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_
|
|
|