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

Side by Side Diff: ui/android/overscroll_refresh.h

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: rebase Created 3 years, 3 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
« no previous file with comments | « ui/android/overscroll_glow.h ('k') | ui/android/overscroll_refresh.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 UI_ANDROID_OVERSCROLL_REFRESH_H_ 5 #ifndef UI_ANDROID_OVERSCROLL_REFRESH_H_
6 #define UI_ANDROID_OVERSCROLL_REFRESH_H_ 6 #define UI_ANDROID_OVERSCROLL_REFRESH_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/android/ui_android_export.h" 9 #include "ui/android/ui_android_export.h"
10 #include "ui/gfx/geometry/size_f.h" 10 #include "ui/gfx/geometry/size_f.h"
(...skipping 12 matching lines...) Expand all
23 // The actuall pull response, animation and action are delegated to the 23 // The actuall pull response, animation and action are delegated to the
24 // provided refresh handler. 24 // provided refresh handler.
25 class UI_ANDROID_EXPORT OverscrollRefresh { 25 class UI_ANDROID_EXPORT OverscrollRefresh {
26 public: 26 public:
27 // Minmum number of overscrolling pull events required to activate the effect. 27 // Minmum number of overscrolling pull events required to activate the effect.
28 // Useful for avoiding accidental triggering when a scroll janks (is delayed), 28 // Useful for avoiding accidental triggering when a scroll janks (is delayed),
29 // capping the impulse per event. 29 // capping the impulse per event.
30 enum { kMinPullsToActivate = 3 }; 30 enum { kMinPullsToActivate = 3 };
31 31
32 explicit OverscrollRefresh(OverscrollRefreshHandler* handler); 32 explicit OverscrollRefresh(OverscrollRefreshHandler* handler);
33 // This constructor is for mocking only.
34 OverscrollRefresh();
boliu 2017/08/24 02:33:54 protected?
sunyunjia 2017/08/24 16:42:36 Done.
33 ~OverscrollRefresh(); 35 ~OverscrollRefresh();
34 36
35 // Scroll event stream listening methods. 37 // Scroll event stream listening methods.
36 void OnScrollBegin(); 38 void OnScrollBegin();
37 // Returns whether the refresh was activated. 39 // Returns whether the refresh was activated.
38 void OnScrollEnd(const gfx::Vector2dF& velocity); 40 void OnScrollEnd(const gfx::Vector2dF& velocity);
39 41
40 // Scroll ack listener. The effect will only be activated if the initial 42 // Scroll ack listener. The effect will only be activated if |can_navigate|
41 // updates go unconsumed. 43 // is true which happens when the scroll update is not consumed and the
42 void OnScrollUpdateAck(bool was_consumed); 44 // scroll_boundary_behavior on y axis is 'auto'.
45 // This method is made virtual for mocking.
46 virtual void OnOverscrolled();
43 47
44 // Returns true if the effect has consumed the |scroll_delta|. 48 // Returns true if the effect has consumed the |scroll_delta|.
45 bool WillHandleScrollUpdate(const gfx::Vector2dF& scroll_delta); 49 bool WillHandleScrollUpdate(const gfx::Vector2dF& scroll_delta);
46 50
47 // Release the effect (if active), preventing any associated refresh action. 51 // Release the effect (if active), preventing any associated refresh action.
48 void ReleaseWithoutActivation(); 52 void ReleaseWithoutActivation();
49 53
50 // Notify the effect of the latest scroll offset and overflow properties. 54 // Notify the effect of the latest scroll offset and overflow properties.
51 // The effect will be disabled when the offset is non-zero or overflow is 55 // The effect will be disabled when the offset is non-zero or overflow is
52 // hidden. Note: All dimensions are in device pixels. 56 // hidden. Note: All dimensions are in device pixels.
53 void OnFrameUpdated(const gfx::Vector2dF& content_scroll_offset, 57 void OnFrameUpdated(const gfx::Vector2dF& content_scroll_offset,
54 bool root_overflow_y_hidden); 58 bool root_overflow_y_hidden);
55 59
56 // Reset the effect to its inactive state, immediately detaching and 60 // Reset the effect to its inactive state, immediately detaching and
57 // disabling any active effects. 61 // disabling any active effects.
58 void Reset(); 62 // This method is made virtual for mocking.
63 virtual void Reset();
59 64
60 // Returns true if the refresh effect is either being manipulated or animated. 65 // Returns true if the refresh effect is either being manipulated or animated.
61 bool IsActive() const; 66 // This method is made virtual for mocking.
67 virtual bool IsActive() const;
62 68
63 // Returns true if the effect is waiting for an unconsumed scroll to start. 69 // Returns true if the effect is waiting for an unconsumed scroll to start.
64 bool IsAwaitingScrollUpdateAck() const; 70 // This method is made virtual for mocking.
71 virtual bool IsAwaitingScrollUpdateAck() const;
65 72
66 private: 73 private:
67 void Release(bool allow_refresh); 74 void Release(bool allow_refresh);
68 75
69 bool scrolled_to_top_; 76 bool scrolled_to_top_;
70 bool overflow_y_hidden_; 77 bool overflow_y_hidden_;
71 78
72 enum ScrollConsumptionState { 79 enum ScrollConsumptionState {
73 DISABLED, 80 DISABLED,
74 AWAITING_SCROLL_UPDATE_ACK, 81 AWAITING_SCROLL_UPDATE_ACK,
75 ENABLED, 82 ENABLED,
76 } scroll_consumption_state_; 83 } scroll_consumption_state_;
77 84
78 OverscrollRefreshHandler* const handler_; 85 OverscrollRefreshHandler* const handler_;
79 86
80 DISALLOW_COPY_AND_ASSIGN(OverscrollRefresh); 87 DISALLOW_COPY_AND_ASSIGN(OverscrollRefresh);
81 }; 88 };
82 89
83 } // namespace ui 90 } // namespace ui
84 91
85 #endif // UI_ANDROID_OVERSCROLL_REFRESH_H_ 92 #endif // UI_ANDROID_OVERSCROLL_REFRESH_H_
OLDNEW
« no previous file with comments | « ui/android/overscroll_glow.h ('k') | ui/android/overscroll_refresh.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698