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

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: New design with window|wrapper in OWA 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 "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 aura {
13 class Window;
14 }
15
16 namespace ui {
17 class Layer;
18 class LayerAnimator;
19 }
20
21 namespace content {
22
23 class OverscrollLayerWrapper;
24 class ShadowLayerDelegate;
25
26 // Manages the animations during an overscroll navigation by handling overscroll
27 // events.
28 class CONTENT_EXPORT OverscrollWindowAnimation
29 : public OverscrollControllerDelegate,
30 ui::ImplicitAnimationObserver {
31 public:
32 enum Direction { FORWARD, BACKWARD, NONE };
mfomitchev 2015/03/05 23:37:06 In WindowSlider Direction was SLIDE_UNKNOWN, SLID
Nina 2015/03/09 15:54:53 In this case, FORWARD == FRONT and BACKWARD == BAC
33
34 // Delegate class that interfaces with the window animation, responsible for
35 // navigation.
36 class Delegate {
37 public:
38 virtual ~Delegate() {}
39
40 // The following two functions create a layer wrapper and transfer back its
41 // ownership.
42 virtual scoped_ptr<OverscrollLayerWrapper> CreateFrontLayer() = 0;
43 virtual scoped_ptr<OverscrollLayerWrapper> CreateBackLayer() = 0;
44
45 // Called when the animation has been completed. The delagate can then
46 // dismiss the overlay layer, or wait for the page to load first.
mfomitchev 2015/03/06 01:36:43 We shouldn't reference page load in OWA's comments
Nina 2015/03/09 15:54:53 Done.
47 virtual void OnOverscrollCompleted(
mfomitchev 2015/03/05 23:37:06 Don't fire Completed() on failures - add another m
Nina 2015/03/09 15:54:53 Done.
48 scoped_ptr<OverscrollLayerWrapper> layer_wrapper) = 0;
49
50 // Called when we know the animation is going to complete. This should start
51 // the navigation.
52 virtual void OnOverscrollCompleting() = 0;
mfomitchev 2015/03/06 01:36:43 Completing() should be declared before Completed()
Nina 2015/03/09 15:54:53 Done.
53 };
54
55 OverscrollWindowAnimation();
56
57 ~OverscrollWindowAnimation() override;
58
59 // Returns true if we are currently handling a slide animation.
60 bool is_active() const { return !!layer_wrapper_; }
61
62 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
63
64 void set_live_window(aura::Window* live_window) {
65 live_window_ = live_window;
mfomitchev 2015/03/05 23:37:06 DCHECK(live_window)
Nina 2015/03/09 15:54:53 Done.
66 }
67
68 // Overridden from OverscrollControllerDelegate:
69 gfx::Rect GetVisibleBounds() const override;
70
71 bool OnOverscrollUpdate(float delta_x, float delta_y) override;
72
73 void OnOverscrollComplete(OverscrollMode overscroll_mode) override;
74
75 void OnOverscrollModeChange(OverscrollMode old_mode,
76 OverscrollMode new_mode) override;
77
78 private:
79 // Starts the overscroll cancelled animation.
80 void CancelOverscroll();
81
82 // Moves the animated window according to the given scroll deltas. Returns
83 // true if the update moved the window.
84 bool UpdateForScroll(float delta_x);
85
86 // Returns a translation on the x axis for the given overscroll.
87 float GetTranslationForOverscroll(float delta_x);
88
89 // Returns the layer that is animated for the overscroll gesture.
90 ui::Layer* GetAnimatedLayer();
91
92 // ui::ImplicitAnimationObserver:
93 void OnImplicitAnimationsCompleted() override;
94
95 // Wrapper that owns the overscroll window.
96 scoped_ptr<OverscrollLayerWrapper> layer_wrapper_;
97
98 // Shadow shown under the animated layer.
99 scoped_ptr<ShadowLayerDelegate> shadow_;
100
101 // Live window holding the currently active web contents.
mfomitchev 2015/03/05 23:37:06 not web contents for slider case
Nina 2015/03/09 15:54:53 Done.
102 aura::Window* live_window_;
103
104 // Delegate that provides the animation target and handles navigation.
105 Delegate* delegate_;
106
107 // The current overscroll direction.
108 Direction direction_;
109 };
110
111 } // namespace content
112
113 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698