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

Side by Side Diff: ui/events/blink/input_scroll_elasticity_controller.h

Issue 2194833002: Overscroll and Elasticity for views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-RouteThroughInputHandler
Patch Set: Restore functionality and fix bugs \o/ Created 4 years, 1 month 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
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_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_ 5 #ifndef UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
6 #define UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_ 6 #define UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "cc/input/scroll_elasticity_helper.h" 10 #include "cc/input/scroll_elasticity_helper.h"
(...skipping 27 matching lines...) Expand all
38 */ 38 */
39 39
40 namespace cc { 40 namespace cc {
41 struct InputHandlerScrollResult; 41 struct InputHandlerScrollResult;
42 } // namespace cc 42 } // namespace cc
43 43
44 namespace ui { 44 namespace ui {
45 45
46 class InputScrollElasticityController { 46 class InputScrollElasticityController {
47 public: 47 public:
48 explicit InputScrollElasticityController(cc::ScrollElasticityHelper* helper); 48 InputScrollElasticityController();
49 virtual ~InputScrollElasticityController(); 49 virtual ~InputScrollElasticityController();
50 50
51 base::WeakPtr<InputScrollElasticityController> GetWeakPtr(); 51 base::WeakPtr<InputScrollElasticityController> GetWeakPtr();
52 52
53 void SetActiveHelper(const base::WeakPtr<cc::ScrollElasticityHelper>& helper);
54
55 void ObserveRealScrollBegin(bool enter_momentum, bool leave_momentum);
56 void ObserveScrollUpdate(const gfx::Vector2dF& event_delta,
57 const gfx::Vector2dF& unused_scroll_delta,
58 const base::TimeTicks& event_timestamp,
59 bool has_momentum);
60 void ObserveRealScrollEnd(const base::TimeTicks& event_timestamp);
61
53 // Update the overscroll state based a gesture event that has been processed. 62 // Update the overscroll state based a gesture event that has been processed.
54 // Note that this assumes that all events are coming from a single input 63 // Note that this assumes that all events are coming from a single input
55 // device. If the user simultaneously uses multiple input devices, Cocoa may 64 // device. If the user simultaneously uses multiple input devices, Cocoa may
56 // not correctly pass all the gesture begin and end events. In this case, 65 // not correctly pass all the gesture begin and end events. In this case,
57 // this class may disregard some scrolls that come in at unexpected times. 66 // this class may disregard some scrolls that come in at unexpected times.
58 void ObserveGestureEventAndResult( 67 void ObserveGestureEventAndResult(
59 const blink::WebGestureEvent& gesture_event, 68 const blink::WebGestureEvent& gesture_event,
60 const cc::InputHandlerScrollResult& scroll_result); 69 const cc::InputHandlerScrollResult& scroll_result);
61 70
62 void Animate(base::TimeTicks time); 71 void Animate(base::TimeTicks time);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Returns true if |direction| is pointing in a direction in which it is not 108 // Returns true if |direction| is pointing in a direction in which it is not
100 // possible to scroll any farther horizontally (or vertically). It is only in 109 // possible to scroll any farther horizontally (or vertically). It is only in
101 // this circumstance that an overscroll in that direction may begin. 110 // this circumstance that an overscroll in that direction may begin.
102 bool PinnedHorizontally(float direction) const; 111 bool PinnedHorizontally(float direction) const;
103 bool PinnedVertically(float direction) const; 112 bool PinnedVertically(float direction) const;
104 // Whether or not the content of the page is scrollable horizontaly (or 113 // Whether or not the content of the page is scrollable horizontaly (or
105 // vertically). 114 // vertically).
106 bool CanScrollHorizontally() const; 115 bool CanScrollHorizontally() const;
107 bool CanScrollVertically() const; 116 bool CanScrollVertically() const;
108 117
109 cc::ScrollElasticityHelper* helper_; 118 base::WeakPtr<cc::ScrollElasticityHelper> helper_;
110 State state_; 119 State state_;
111 120
112 // If there is no overscroll, require a minimum overscroll delta before 121 // If there is no overscroll, require a minimum overscroll delta before
113 // starting the rubber-band effect. Track the amount of scrolling that has 122 // starting the rubber-band effect. Track the amount of scrolling that has
114 // has occurred but has not yet caused rubber-band stretching in 123 // has occurred but has not yet caused rubber-band stretching in
115 // |pending_overscroll_delta_|. 124 // |pending_overscroll_delta_|.
116 gfx::Vector2dF pending_overscroll_delta_; 125 gfx::Vector2dF pending_overscroll_delta_;
117 126
118 // Maintain a calculation of the velocity of the scroll, based on the input 127 // Maintain a calculation of the velocity of the scroll, based on the input
119 // scroll delta divide by the time between input events. Track this velocity 128 // scroll delta divide by the time between input events. Track this velocity
(...skipping 19 matching lines...) Expand all
139 // behavior as would happen if the scroll were caused by an active scroll). 148 // behavior as would happen if the scroll were caused by an active scroll).
140 bool momentum_animation_reset_at_next_frame_; 149 bool momentum_animation_reset_at_next_frame_;
141 150
142 base::WeakPtrFactory<InputScrollElasticityController> weak_factory_; 151 base::WeakPtrFactory<InputScrollElasticityController> weak_factory_;
143 DISALLOW_COPY_AND_ASSIGN(InputScrollElasticityController); 152 DISALLOW_COPY_AND_ASSIGN(InputScrollElasticityController);
144 }; 153 };
145 154
146 } // namespace ui 155 } // namespace ui
147 156
148 #endif // UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_ 157 #endif // UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/events/blink/input_handler_proxy_unittest.cc ('k') | ui/events/blink/input_scroll_elasticity_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698