OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ScrollState_h |
| 6 #define ScrollState_h |
| 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/Element.h" |
| 11 #include "wtf/Vector.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class ScrollState final : public GarbageCollectedFinalized<ScrollState>, public
ScriptWrappable { |
| 16 DEFINE_WRAPPERTYPEINFO(); |
| 17 |
| 18 public: |
| 19 static ScrollState* create( |
| 20 double deltaX, double deltaY, double deltaGranularity, double velocityX, |
| 21 double velocityY, bool inInertialPhase, bool isEnding, bool fromUserInpu
t = false, |
| 22 bool shouldPropagate = true); |
| 23 |
| 24 virtual ~ScrollState(); |
| 25 |
| 26 void consumeDelta(double x, double y, ExceptionState&); |
| 27 void distributeToScrollChainDescendant(); |
| 28 |
| 29 // Positive when scrolling left. |
| 30 double deltaX() const { return m_deltaX; } |
| 31 // Positive when scrolling up. |
| 32 double deltaY() const { return m_deltaY; } |
| 33 // Indicates the smallest delta the input device can produce. 0 for unquanti
zed inputs. |
| 34 double deltaGranularity() const { return m_deltaGranularity; } |
| 35 // Positive if moving right. |
| 36 double velocityX() const { return m_velocityX; } |
| 37 // Positive if moving down. |
| 38 double velocityY() const { return m_velocityY; } |
| 39 // True for events dispatched after the users's gesture has finished. |
| 40 bool inInertialPhase() const { return m_inInertialPhase; } |
| 41 // True if this is the last event for this scroll. |
| 42 bool isEnding() const { return m_isEnding; } |
| 43 // True if this scroll is the direct result of user input. |
| 44 bool fromUserInput() const { return m_fromUserInput; } |
| 45 // True if this scroll is allowed to bubble upwards. |
| 46 bool shouldPropagate() const { return m_shouldPropagate; } |
| 47 |
| 48 // FIXME - indicate which of these are exposed. |
| 49 void consumeDeltaNative(double x, double y); |
| 50 |
| 51 void setScrollChain(WillBeHeapVector<RefPtrWillBeMember<Element>> scrollChai
n) |
| 52 { |
| 53 m_scrollChain = scrollChain; |
| 54 } |
| 55 |
| 56 void setCurrentNativeScrollingElement(Element* element) |
| 57 { |
| 58 m_currentNativeScrollingElement = element; |
| 59 } |
| 60 |
| 61 Element* currentNativeScrollingElement() const |
| 62 { |
| 63 return m_currentNativeScrollingElement; |
| 64 } |
| 65 |
| 66 void setScrollLockedToElement(bool scrollLockedToElement) |
| 67 { |
| 68 m_scrollLockedToElement = scrollLockedToElement; |
| 69 } |
| 70 |
| 71 bool scrollLockedToElement() const { return m_scrollLockedToElement; } |
| 72 |
| 73 bool fullyConsumed() const |
| 74 { |
| 75 return !m_deltaX && !m_deltaY && !m_isEnding; |
| 76 } |
| 77 |
| 78 void trace(Visitor* visitor) |
| 79 { |
| 80 visitor->trace(m_scrollChain); |
| 81 } |
| 82 |
| 83 private: |
| 84 ScrollState(); |
| 85 ScrollState(double deltaX, double deltaY, double deltaGranularity, |
| 86 double velocityX, double velocityY, bool inInertialPhase, bool isEnding,
bool fromUserInput, bool shouldPropagate); |
| 87 |
| 88 double m_deltaX; |
| 89 double m_deltaY; |
| 90 double m_deltaGranularity; |
| 91 double m_velocityX; |
| 92 double m_velocityY; |
| 93 bool m_inInertialPhase; |
| 94 bool m_isEnding; |
| 95 bool m_fromUserInput; |
| 96 |
| 97 WillBeHeapVector<RefPtrWillBeMember<Element>> m_scrollChain; |
| 98 |
| 99 // The last element to respond to a scroll, or null if none exists. |
| 100 Element* m_currentNativeScrollingElement; |
| 101 bool m_scrollLockedToElement; |
| 102 bool m_shouldPropagate; |
| 103 }; |
| 104 |
| 105 } // namespace blink |
| 106 |
| 107 #endif // ScrollState_h |
OLD | NEW |