OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 class PlatformWheelEvent; | 38 class PlatformWheelEvent; |
39 | 39 |
40 class ScrollElasticityControllerClient { | 40 class ScrollElasticityControllerClient { |
41 protected: | 41 protected: |
42 virtual ~ScrollElasticityControllerClient() { } | 42 virtual ~ScrollElasticityControllerClient() { } |
43 | 43 |
44 public: | 44 public: |
45 virtual bool allowsHorizontalStretching() = 0; | 45 virtual bool allowsHorizontalStretching() = 0; |
46 virtual bool allowsVerticalStretching() = 0; | 46 virtual bool allowsVerticalStretching() = 0; |
47 // The amount that the view is stretched past the normal allowable bounds. | |
48 // The "overhang" amount. | |
47 virtual IntSize stretchAmount() = 0; | 49 virtual IntSize stretchAmount() = 0; |
48 virtual bool pinnedInDirection(const FloatSize&) = 0; | 50 virtual bool pinnedInDirection(const FloatSize&) = 0; |
49 virtual bool canScrollHorizontally() = 0; | 51 virtual bool canScrollHorizontally() = 0; |
50 virtual bool canScrollVertically() = 0; | 52 virtual bool canScrollVertically() = 0; |
53 // TODO(erikchen): This method is no longer used. Remove all references. | |
erikchen
2014/03/24 22:12:05
I left this as a TODO to try to keep this CL small
Alexei Svitkine (slow)
2014/03/25 15:25:40
SGTM.
| |
51 virtual bool shouldRubberBandInDirection(ScrollDirection) = 0; | 54 virtual bool shouldRubberBandInDirection(ScrollDirection) = 0; |
52 | 55 |
53 // Return the absolute scroll position, not relative to the scroll origin. | 56 // Return the absolute scroll position, not relative to the scroll origin. |
54 virtual WebCore::IntPoint absoluteScrollPosition() = 0; | 57 virtual WebCore::IntPoint absoluteScrollPosition() = 0; |
55 | 58 |
56 virtual void immediateScrollBy(const FloatSize&) = 0; | 59 virtual void immediateScrollBy(const FloatSize&) = 0; |
57 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize& ) = 0; | 60 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize& ) = 0; |
58 virtual void startSnapRubberbandTimer() = 0; | 61 virtual void startSnapRubberbandTimer() = 0; |
59 virtual void stopSnapRubberbandTimer() = 0; | 62 virtual void stopSnapRubberbandTimer() = 0; |
60 }; | 63 }; |
61 | 64 |
62 class ScrollElasticityController { | 65 class ScrollElasticityController { |
63 WTF_MAKE_NONCOPYABLE(ScrollElasticityController); | 66 WTF_MAKE_NONCOPYABLE(ScrollElasticityController); |
64 | 67 |
65 public: | 68 public: |
66 explicit ScrollElasticityController(ScrollElasticityControllerClient*); | 69 explicit ScrollElasticityController(ScrollElasticityControllerClient*); |
67 | 70 |
71 // This method is responsible for both scrolling and rubber-banding. | |
72 // | |
73 // Events are passed by IPC from the embedder. Events on mac are grouped | |
Alexei Svitkine (slow)
2014/03/25 15:25:40
Nit: Mac
erikchen
2014/03/26 18:24:30
Done.
| |
74 // into "gestures". If this method returns 'true', then this object has | |
75 // handled the event. It expects the embedder to continue to forward events | |
76 // from the gesture. | |
77 // | |
78 // This method makes the assumption that there is only 1 input device being | |
79 // used at a time. If the user simultaneously uses multiple input devices, | |
80 // Cocoa does not correctly pass all the gestureBegin/End events. The state | |
81 // of this class is guaranteed to become eventually consistent, once the | |
82 // user stops using multiple input devices. | |
68 bool handleWheelEvent(const PlatformWheelEvent&); | 83 bool handleWheelEvent(const PlatformWheelEvent&); |
69 void snapRubberBandTimerFired(); | 84 void snapRubberBandTimerFired(); |
70 | 85 |
71 bool isRubberBandInProgress() const; | 86 bool isRubberBandInProgress() const; |
72 | 87 |
73 private: | 88 private: |
74 void stopSnapRubberbandTimer(); | 89 void stopSnapRubberbandTimer(); |
75 void snapRubberBand(); | 90 void snapRubberBand(); |
76 | 91 |
77 bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent&); | 92 // This method determines whether a given event should be handled. The |
93 // logic for control events of gestures (PhaseBegan, PhaseEnded) is handled | |
94 // elsewhere. | |
95 // | |
96 // This class handles almost all wheel events. All of the following | |
97 // conditions must be met for this class to ignore an event: | |
98 // + No previous events in this gesture have caused any scrolling or rubber | |
99 // banding. | |
100 // + The event contains a horizontal component. | |
101 // + The client's view is pinned in the horizontal direction of the event. | |
102 // + The wheel event disallows rubber banding in the horizontal direction | |
103 // of the event. | |
104 bool shouldHandleEvent(const PlatformWheelEvent&); | |
78 | 105 |
79 ScrollElasticityControllerClient* m_client; | 106 ScrollElasticityControllerClient* m_client; |
80 | 107 |
108 // There is an active scroll gesture event. This parameter only gets set to | |
109 // false after the rubber band has been snapped, and before a new gesture | |
110 // has begun. A careful audit of the code may deprecate the need for this pa rameter. | |
Alexei Svitkine (slow)
2014/03/25 15:25:40
Nit: Wrap the end of this comment since everything
erikchen
2014/03/26 18:24:30
Done.
| |
81 bool m_inScrollGesture; | 111 bool m_inScrollGesture; |
112 // At least one event in the current gesture has been consumed and has | |
113 // caused the view to scroll or rubber band. All future events in this | |
114 // gesture will be consumed and overscrolls will cause rubberbanding. | |
115 bool m_hasScrolled; | |
82 bool m_momentumScrollInProgress; | 116 bool m_momentumScrollInProgress; |
83 bool m_ignoreMomentumScrolls; | 117 bool m_ignoreMomentumScrolls; |
84 | 118 |
85 CFTimeInterval m_lastMomentumScrollTimestamp; | 119 CFTimeInterval m_lastMomentumScrollTimestamp; |
86 FloatSize m_overflowScrollDelta; | 120 FloatSize m_overflowScrollDelta; |
87 FloatSize m_stretchScrollForce; | 121 FloatSize m_stretchScrollForce; |
88 FloatSize m_momentumVelocity; | 122 FloatSize m_momentumVelocity; |
89 | 123 |
90 // Rubber band state. | 124 // Rubber band state. |
91 CFTimeInterval m_startTime; | 125 CFTimeInterval m_startTime; |
92 FloatSize m_startStretch; | 126 FloatSize m_startStretch; |
93 FloatPoint m_origOrigin; | 127 FloatPoint m_origOrigin; |
94 FloatSize m_origVelocity; | 128 FloatSize m_origVelocity; |
95 | 129 |
96 bool m_snapRubberbandTimerIsActive; | 130 bool m_snapRubberbandTimerIsActive; |
97 }; | 131 }; |
98 | 132 |
99 } // namespace WebCore | 133 } // namespace WebCore |
100 | 134 |
101 #endif // USE(RUBBER_BANDING) | 135 #endif // USE(RUBBER_BANDING) |
102 | 136 |
103 #endif // ScrollElasticityController_h | 137 #endif // ScrollElasticityController_h |
OLD | NEW |