OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ | 5 #ifndef CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
6 #define CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ | 6 #define CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
7 | 7 |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "ui/gfx/geometry/vector2d_f.h" | 10 #include "ui/gfx/geometry/vector2d_f.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
40 * THE POSSIBILITY OF SUCH DAMAGE. | 40 * THE POSSIBILITY OF SUCH DAMAGE. |
41 */ | 41 */ |
42 | 42 |
43 // Interface between a LayerTreeHostImpl and the ScrollElasticityController. It | 43 // Interface between a LayerTreeHostImpl and the ScrollElasticityController. It |
44 // would be possible, in principle, for LayerTreeHostImpl to implement this | 44 // would be possible, in principle, for LayerTreeHostImpl to implement this |
45 // interface itself. This artificial boundary is introduced to reduce the amount | 45 // interface itself. This artificial boundary is introduced to reduce the amount |
46 // of logic and state held directly inside LayerTreeHostImpl. | 46 // of logic and state held directly inside LayerTreeHostImpl. |
47 class CC_EXPORT ScrollElasticityHelper { | 47 class CC_EXPORT ScrollElasticityHelper { |
48 public: | 48 public: |
49 explicit ScrollElasticityHelper(LayerTreeHostImpl* layer_tree); | 49 static ScrollElasticityHelper* CreateForLayerTreeHostImpl( |
50 ~ScrollElasticityHelper(); | 50 LayerTreeHostImpl* layer_tree_host_impl); |
51 | 51 |
52 bool AllowsHorizontalStretching(); | 52 virtual ~ScrollElasticityHelper() {} |
53 bool AllowsVerticalStretching(); | 53 |
54 // The amount that the view is stretched past the normal allowable bounds. | 54 // The amount that the view is stretched past the normal allowable bounds. |
55 // The "overhang" amount. | 55 virtual gfx::Vector2dF StretchAmount() = 0; |
56 gfx::Vector2dF StretchAmount(); | 56 virtual void SetStretchAmount(const gfx::Vector2dF& stretch_amount) = 0; |
57 bool PinnedInDirection(const gfx::Vector2dF& direction); | 57 // Returns true if either component of |direction| is pointing in a direction |
58 bool CanScrollHorizontally(); | 58 // in which it is not possible to scroll any farther. It is only in this |
59 bool CanScrollVertically(); | 59 // circumstance that an overscroll in that direction may begin. |
60 | 60 // TODO(ccameron): Note that it is possible for a scroll to occur against a |
61 // Return the absolute scroll position, not relative to the scroll origin. | 61 // previous over-scroll. Such a scroll needs to first cancel out the |
62 gfx::Vector2dF AbsoluteScrollPosition(); | 62 // over-scroll, and only then may it start scrolling away from the edge. |
63 | 63 virtual bool PinnedInDirection(const gfx::Vector2dF& direction) = 0; |
64 void ImmediateScrollBy(const gfx::Vector2dF& scroll); | 64 // Whether or not the content of the page is scrollable in each direction. |
65 void ImmediateScrollByWithoutContentEdgeConstraints( | 65 virtual bool CanScrollHorizontally() = 0; |
66 const gfx::Vector2dF& scroll); | 66 virtual bool CanScrollVertically() = 0; |
67 void StartSnapRubberbandTimer(); | 67 // Request that the controller have its Animate method called for the next |
68 void StopSnapRubberbandTimer(); | 68 // frame. |
69 void SnapRubberbandTimerFired(); | 69 virtual void RequestAnimate() = 0; |
70 | |
71 // If the current scroll position is within the overhang area, this function | |
72 // will cause | |
73 // the page to scroll to the nearest boundary point. | |
74 void AdjustScrollPositionToBoundsIfNecessary(); | |
75 | |
76 private: | |
77 LayerTreeHostImpl* layer_tree_host_impl_; | |
78 gfx::Vector2dF stretch_offset_; | |
79 bool timer_active_; | |
80 }; | 70 }; |
81 | 71 |
82 } // namespace cc | 72 } // namespace cc |
83 | 73 |
84 #endif // CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ | 74 #endif // CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
OLD | NEW |