Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | |
|
mohsen
2017/02/21 20:47:58
Is this needed?
mfomitchev
2017/02/23 02:59:42
Done.
| |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 12 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
| 14 | 15 |
| 15 namespace aura { | 16 namespace aura { |
| 16 class Window; | 17 class Window; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 virtual void OnOverscrollCancelled() = 0; | 71 virtual void OnOverscrollCancelled() = 0; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 explicit OverscrollWindowAnimation(Delegate* delegate); | 74 explicit OverscrollWindowAnimation(Delegate* delegate); |
| 74 | 75 |
| 75 ~OverscrollWindowAnimation() override; | 76 ~OverscrollWindowAnimation() override; |
| 76 | 77 |
| 77 // Returns true if we are currently animating. | 78 // Returns true if we are currently animating. |
| 78 bool is_active() const { return !!slide_window_; } | 79 bool is_active() const { return !!slide_window_; } |
| 79 | 80 |
| 81 OverscrollSource overscroll_source() { return overscroll_source_; } | |
| 82 | |
| 83 void SetOverscrollSourceForTesting(OverscrollSource source) { | |
| 84 overscroll_source_ = source; | |
| 85 } | |
| 86 | |
| 80 // OverscrollControllerDelegate: | 87 // OverscrollControllerDelegate: |
| 81 gfx::Rect GetVisibleBounds() const override; | 88 gfx::Rect GetVisibleBounds() const override; |
| 82 bool OnOverscrollUpdate(float delta_x, float delta_y) override; | 89 bool OnOverscrollUpdate(float delta_x, float delta_y) override; |
| 83 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; | 90 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; |
| 84 void OnOverscrollModeChange(OverscrollMode old_mode, | 91 void OnOverscrollModeChange(OverscrollMode old_mode, |
| 85 OverscrollMode new_mode) override; | 92 OverscrollMode new_mode, |
| 93 OverscrollSource source) override; | |
| 86 | 94 |
| 87 private: | 95 private: |
| 88 // Cancels the slide, animating the front and back window to their original | 96 // Cancels the slide, animating the front and back window to their original |
| 89 // positions. | 97 // positions. |
| 90 void CancelSlide(); | 98 void CancelSlide(); |
| 91 | 99 |
| 92 // Returns a translation on the x axis for the given overscroll. | 100 // Returns a translation on the x axis for the given overscroll. |
| 93 float GetTranslationForOverscroll(float delta_x); | 101 float GetTranslationForOverscroll(float delta_x); |
| 94 | 102 |
| 95 // Animates a translation of the given |layer|. If |listen_for_completion| is | 103 // Animates a translation of the given |layer|. If |listen_for_completion| is |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 112 // Shadow shown under the animated layer. | 120 // Shadow shown under the animated layer. |
| 113 std::unique_ptr<ShadowLayerDelegate> shadow_; | 121 std::unique_ptr<ShadowLayerDelegate> shadow_; |
| 114 | 122 |
| 115 // Delegate that provides the animation target and is notified of the | 123 // Delegate that provides the animation target and is notified of the |
| 116 // animation state. | 124 // animation state. |
| 117 Delegate* delegate_; | 125 Delegate* delegate_; |
| 118 | 126 |
| 119 // The current animation direction. | 127 // The current animation direction. |
| 120 Direction direction_; | 128 Direction direction_; |
| 121 | 129 |
| 130 // OverscrollSource of the current overscroll gesture. Updated when the new | |
| 131 // overscroll gesture starts, before CreateFront/BackWindow callback is called | |
| 132 // on the delegate. | |
| 133 OverscrollSource overscroll_source_ = OVERSCROLL_SOURCE_NONE; | |
| 134 | |
| 122 // Indicates if the current slide has been cancelled. True while the cancel | 135 // Indicates if the current slide has been cancelled. True while the cancel |
| 123 // animation is in progress. | 136 // animation is in progress. |
| 124 bool overscroll_cancelled_; | 137 bool overscroll_cancelled_; |
| 125 | 138 |
| 126 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimation); | 139 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimation); |
| 127 }; | 140 }; |
| 128 | 141 |
| 129 } // namespace content | 142 } // namespace content |
| 130 | 143 |
| 131 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | 144 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
| OLD | NEW |