Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: content/browser/web_contents/aura/overscroll_window_animation.h

Issue 895543005: Refactor GestureNavigation to eliminate code redundancy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Following suggestions by Mikhail, rewritten OWA to use a delegate interface (to be implemented) Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
7
8 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
9 #include "content/common/content_export.h"
10 #include "ui/compositor/layer_animation_observer.h"
11
12 namespace ui {
13 class LayerAnimator;
14 }
15
16 namespace content {
17
18 // Manages the animations during an overscroll navigation by handling overscroll
19 // events.
20 class CONTENT_EXPORT OverscrollWindowAnimation : ui::ImplicitAnimationObserver,
21 OverscrollControllerDelegate {
22 public:
23 enum Direction { FORWARD, BACKWARD, NONE };
24
25 // Delegate class that interfaces with the window animation, responsible for
26 // navigation.
27 class Delegate {
28 public:
29 virtual ~Delegate() {}
30
31 // Creates an OverscrollWindow if it does not exist, or adds a new layer if
32 // it does. Returns the navigation direction.
33 virtual Direction StartNavigation(OverscrollMode mode) = 0;
34
35 // Sets the transform on the OverscrollWindow, which can set it in the
36 // active layer or the overscroll window.
37 virtual void SetTransform(const gfx::Transform& transform) = 0;
38
39 // Returns the active layer animator.
40 virtual ui::LayerAnimator* GetAnimator() = 0;
41
42 // Returns the bounds of the contents window.
43 virtual gfx::Rect GetContentsBounds() const = 0;
44
45 // Called when the animation has been completed. The delagate can then
46 // dismiss the overlay window, or wait for the page to load first.
47 virtual void OnAnimationCompleted() = 0;
mfomitchev 2015/02/19 19:04:59 OnOverscrollCompleted Maybe OnOverscrollCompleted(
Nina 2015/02/27 19:32:51 I think passing the layer instead of the wrapper m
48
49 // Called when we know the animation is going to complete. This should start
50 // the navigation.
51 virtual void OnAnimationCompleting() = 0;
52 };
53
54 OverscrollWindowAnimation(Delegate* delegate);
55
56 ~OverscrollWindowAnimation() override;
57
58 // Aborts all current running animations.
59 void AbortAllAnimations();
60
61 // Returns true if there is a slide animation currently in progress.
62 bool IsSlideInProgress() const;
63
64 // Overridden from OverscrollControllerDelegate:
65 gfx::Rect GetVisibleBounds() const override;
66
67 bool OnOverscrollUpdate(float delta_x, float delta_y) override;
68
69 void OnOverscrollComplete(OverscrollMode overscroll_mode) override;
70
71 void OnOverscrollModeChange(OverscrollMode old_mode,
72 OverscrollMode new_mode) override;
73
74 private:
75 // Prepares the overscroll window to begin animating.
76 void StartAnimating();
77
78 // Starts the overscroll cancelled animation.
79 void CancelOverscroll();
80
81 // Moves the animated window according to the given scroll deltas. Returns
82 // true if the update moved the window.
83 bool UpdateForScroll(float delta_x);
84
85 // Returns a translation for the given overscroll.
86 gfx::Vector2dF GetTranslationForOverscroll(float delta_x);
87
88 // Overridden from ui::ImplicitAnimationObserver:
89 void OnImplicitAnimationsCompleted() override;
90
91 // Delegate that provides images and handles navigation.
92 Delegate* delegate_;
93
94 // The current overscroll direction.
95 Direction direction_;
96
97 // True if the overscroll gesture has been cancelled.
98 bool overscroll_cancelled_;
mfomitchev 2015/02/19 19:04:59 DOesn't seem like you need this
Nina 2015/02/27 19:32:51 Removed.
99
100 // True if the overscroll animation has been completed.
101 bool animation_completed_;
102 };
103
104 } // namespace content
105
106 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698