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 ScrollState_h | 5 #ifndef ScrollState_h |
6 #define ScrollState_h | 6 #define ScrollState_h |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
11 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class ScrollState final : public RefCountedWillBeGarbageCollected<ScrollState>, public ScriptWrappable { | 15 class ScrollState final : public RefCountedWillBeGarbageCollected<ScrollState>, public ScriptWrappable { |
16 DEFINE_WRAPPERTYPEINFO(); | 16 DEFINE_WRAPPERTYPEINFO(); |
17 | 17 |
18 public: | 18 public: |
19 static PassRefPtrWillBeRawPtr<ScrollState> create( | 19 static PassRefPtrWillBeRawPtr<ScrollState> create( |
20 double deltaX, double deltaY, double deltaGranularity, double velocityX, | 20 double deltaX, double deltaY, double deltaGranularity, double velocityX, |
21 double velocityY, bool inInertialPhase, bool isEnding, bool fromUserInpu t = false, | 21 double velocityY, bool inInertialPhase, |
22 bool shouldPropagate = true, bool deltaConsumedForScrollSequence = false ); | 22 bool isBeginning = false, bool isEnding = false, |
tdresser
2015/03/06 20:38:11
This needs to be updated in the layout tests.
tdresser
2015/03/09 17:02:56
Done.
| |
23 bool fromUserInput = false, bool shouldPropagate = true, | |
24 bool deltaConsumedForScrollSequence = false); | |
23 | 25 |
24 // Web exposed methods. | 26 // Web exposed methods. |
25 | 27 |
26 // Reduce deltas by x, y. | 28 // Reduce deltas by x, y. |
27 void consumeDelta(double x, double y, ExceptionState&); | 29 void consumeDelta(double x, double y, ExceptionState&); |
30 // Pops the first element off of |m_scrollChain| and calls | |
31 // |distributeScroll| on it. | |
32 void distributeToScrollChainDescendant(); | |
28 // Positive when scrolling left. | 33 // Positive when scrolling left. |
29 double deltaX() const { return m_deltaX; } | 34 double deltaX() const { return m_deltaX; } |
30 // Positive when scrolling up. | 35 // Positive when scrolling up. |
31 double deltaY() const { return m_deltaY; } | 36 double deltaY() const { return m_deltaY; } |
32 // Indicates the smallest delta the input device can produce. 0 for unquanti zed inputs. | 37 // Indicates the smallest delta the input device can produce. 0 for unquanti zed inputs. |
33 double deltaGranularity() const { return m_deltaGranularity; } | 38 double deltaGranularity() const { return m_deltaGranularity; } |
34 // Positive if moving right. | 39 // Positive if moving right. |
35 double velocityX() const { return m_velocityX; } | 40 double velocityX() const { return m_velocityX; } |
36 // Positive if moving down. | 41 // Positive if moving down. |
37 double velocityY() const { return m_velocityY; } | 42 double velocityY() const { return m_velocityY; } |
38 // True for events dispatched after the users's gesture has finished. | 43 // True for events dispatched after the users's gesture has finished. |
39 bool inInertialPhase() const { return m_inInertialPhase; } | 44 bool inInertialPhase() const { return m_inInertialPhase; } |
45 // True if this is the first event for this scroll. | |
46 bool isBeginning() const { return m_isBeginning; } | |
40 // True if this is the last event for this scroll. | 47 // True if this is the last event for this scroll. |
41 bool isEnding() const { return m_isEnding; } | 48 bool isEnding() const { return m_isEnding; } |
42 // True if this scroll is the direct result of user input. | 49 // True if this scroll is the direct result of user input. |
43 bool fromUserInput() const { return m_fromUserInput; } | 50 bool fromUserInput() const { return m_fromUserInput; } |
44 // True if this scroll is allowed to bubble upwards. | 51 // True if this scroll is allowed to bubble upwards. |
45 bool shouldPropagate() const { return m_shouldPropagate; } | 52 bool shouldPropagate() const { return m_shouldPropagate; } |
46 | 53 |
47 // Non web exposed methods. | 54 // Non web exposed methods. |
48 void consumeDeltaNative(double x, double y); | 55 void consumeDeltaNative(double x, double y); |
49 | 56 |
57 void setScrollChain(WillBeHeapDeque<RefPtrWillBeMember<Element>> scrollChain ) | |
58 { | |
59 m_scrollChain = scrollChain; | |
60 } | |
61 | |
50 void setCurrentNativeScrollingElement(Element* element) | 62 void setCurrentNativeScrollingElement(Element* element) |
51 { | 63 { |
52 m_currentNativeScrollingElement = element; | 64 m_currentNativeScrollingElement = element; |
53 } | 65 } |
54 | 66 |
55 Element* currentNativeScrollingElement() const | 67 Element* currentNativeScrollingElement() const |
56 { | 68 { |
57 return m_currentNativeScrollingElement.get(); | 69 return m_currentNativeScrollingElement.get(); |
58 } | 70 } |
59 | 71 |
60 void setDeltaConsumedForScrollSequence(bool deltaConsumedForScrollSequence) | |
61 { | |
62 m_deltaConsumedForScrollSequence = deltaConsumedForScrollSequence; | |
63 } | |
64 | |
65 bool deltaConsumedForScrollSequence() const | 72 bool deltaConsumedForScrollSequence() const |
66 { | 73 { |
67 return m_deltaConsumedForScrollSequence; | 74 return m_deltaConsumedForScrollSequence; |
68 } | 75 } |
69 | 76 |
70 bool fullyConsumed() const | 77 bool fullyConsumed() const |
71 { | 78 { |
72 return !m_deltaX && !m_deltaY && !m_isEnding; | 79 return !m_deltaX && !m_deltaY && !m_isEnding && !m_isBeginning; |
73 } | 80 } |
74 | 81 |
75 DEFINE_INLINE_TRACE() | 82 DEFINE_INLINE_TRACE() |
76 { | 83 { |
77 visitor->trace(m_currentNativeScrollingElement); | 84 visitor->trace(m_currentNativeScrollingElement); |
85 visitor->trace(m_scrollChain); | |
78 }; | 86 }; |
79 | 87 |
80 private: | 88 private: |
81 ScrollState(); | 89 ScrollState(); |
82 ScrollState(double deltaX, double deltaY, double deltaGranularity, | 90 ScrollState(double deltaX, double deltaY, double deltaGranularity, |
83 double velocityX, double velocityY, bool inInertialPhase, bool isEnding, | 91 double velocityX, double velocityY, bool inInertialPhase, bool isBeginni ng, |
84 bool fromUserInput, bool shouldPropagate, bool deltaConsumedForScrollSeq uence); | 92 bool isEnding, bool fromUserInput, bool shouldPropagate, |
93 bool deltaConsumedForScrollSequence); | |
85 | 94 |
86 double m_deltaX; | 95 double m_deltaX; |
87 double m_deltaY; | 96 double m_deltaY; |
88 double m_deltaGranularity; | 97 double m_deltaGranularity; |
89 double m_velocityX; | 98 double m_velocityX; |
90 double m_velocityY; | 99 double m_velocityY; |
91 bool m_inInertialPhase; | 100 bool m_inInertialPhase; |
101 bool m_isBeginning; | |
92 bool m_isEnding; | 102 bool m_isEnding; |
93 | 103 |
94 bool m_fromUserInput; | 104 bool m_fromUserInput; |
95 bool m_shouldPropagate; | 105 bool m_shouldPropagate; |
96 // The last native element to respond to a scroll, or null if none exists. | 106 // The last native element to respond to a scroll, or null if none exists. |
97 RefPtrWillBeMember<Element> m_currentNativeScrollingElement; | 107 RefPtrWillBeMember<Element> m_currentNativeScrollingElement; |
98 // Whether the scroll sequence has had any delta consumed. | 108 // Whether the scroll sequence has had any delta consumed. |
99 bool m_deltaConsumedForScrollSequence; | 109 bool m_deltaConsumedForScrollSequence; |
110 | |
111 WillBeHeapDeque<RefPtrWillBeMember<Element>> m_scrollChain; | |
100 }; | 112 }; |
101 | 113 |
102 } // namespace blink | 114 } // namespace blink |
103 | 115 |
104 #endif // ScrollState_h | 116 #endif // ScrollState_h |
OLD | NEW |