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

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: Brought back gesture cancellation by mouse and linted code. Created 5 years, 9 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 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 "base/gtest_prod_util.h"
9 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
10 #include "content/common/content_export.h"
11 #include "ui/compositor/layer_animation_observer.h"
12
13 namespace aura {
14 class Window;
15 }
16
17 namespace ui {
18 class Layer;
19 class LayerAnimator;
20 }
21
22 namespace content {
23
24 class ShadowLayerDelegate;
25 class WebContentsImpl;
26
27 // Manages the animations during an overscroll navigation by handling overscroll
mfomitchev 2015/03/26 15:36:00 We probably shouldn't be talking about "navigation
Nina 2015/03/27 17:52:36 Changed the comment completely. Check it out.
28 // events.
29 class CONTENT_EXPORT OverscrollWindowAnimation
30 : public OverscrollControllerDelegate,
31 ui::ImplicitAnimationObserver {
32 public:
33 enum Direction { SLIDE_FRONT, SLIDE_BACK, SLIDE_NONE };
34
35 // Delegate class that interfaces with the window animation, responsible for
36 // navigation.
37 class Delegate {
38 public:
39 virtual ~Delegate() {}
40
41 // The following two functions create a slide window and transfer back its
42 // ownership.
43 virtual scoped_ptr<aura::Window> CreateFrontWindow() = 0;
44 virtual scoped_ptr<aura::Window> CreateBackWindow() = 0;
45
46 // Returns the live window that participates in the overscroll gesture.
47 virtual aura::Window* GetTargetWindow() const = 0;
mfomitchev 2015/03/26 02:41:39 "Target window" doesn't really explain what this w
Nina 2015/03/27 17:52:36 Changed to GetMainWindow.
48
49 // Called when we know the animation is going to complete successfully.
50 virtual void OnOverscrollCompleting() = 0;
51
52 // Called when the animation has been completed.
53 virtual void OnOverscrollCompleted(scoped_ptr<aura::Window> window) = 0;
54
55 // Called when the overscroll gesture has been aborted.
56 virtual void OnOverscrollAborted() = 0;
57 };
58
59 explicit OverscrollWindowAnimation(Delegate* delegate);
60
61 ~OverscrollWindowAnimation() override;
62
63 // Returns true if we are currently handling a slide animation.
64 bool is_active() const { return !!window_; }
65
66 // Overridden from OverscrollControllerDelegate:
67 gfx::Rect GetVisibleBounds() const override;
68
69 bool OnOverscrollUpdate(float delta_x, float delta_y) override;
70
71 void OnOverscrollComplete(OverscrollMode overscroll_mode) override;
72
73 void OnOverscrollModeChange(OverscrollMode old_mode,
74 OverscrollMode new_mode) override;
75
76 private:
77 /*friend class OverscrollWindowAnimationTest;
78 FRIEND_TEST_ALL_PREFIXES(OverscrollWindowAnimationTest,
79 BasicOverscroll);*/
80
81 // Starts the overscroll cancelled animation.
82 void CancelOverscroll();
83
84 // Moves the animated window according to the given scroll deltas. Returns
85 // true if the update moved the window.
86 bool UpdateForScroll(float delta_x);
87
88 // Returns a translation on the x axis for the given overscroll.
89 float GetTranslationForOverscroll(float delta_x);
90
91 // Returns the layer that is animated for the overscroll gesture.
92 ui::Layer* GetFrontLayer() const;
93
94 // ui::ImplicitAnimationObserver:
95 void OnImplicitAnimationsCompleted() override;
96
97 // Owns the new window created on the overscroll gesture.
98 scoped_ptr<aura::Window> window_;
99
100 // Shadow shown under the animated layer.
101 scoped_ptr<ShadowLayerDelegate> shadow_;
102
103 // Delegate that provides the animation target and handles navigation.
104 Delegate* delegate_;
105
106 // The current overscroll direction.
107 Direction direction_;
108
109 // Indicates if the current overscroll gesture has been cancelled.
110 bool overscroll_cancelled_;
111 };
112
113 } // namespace content
114
115 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698