Index: Source/core/page/scrolling/ScrollState.h |
diff --git a/Source/core/page/scrolling/ScrollState.h b/Source/core/page/scrolling/ScrollState.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3a84e1d6211b03ae936458f4d407abbe8cf36c28 |
--- /dev/null |
+++ b/Source/core/page/scrolling/ScrollState.h |
@@ -0,0 +1,107 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ScrollState_h |
+#define ScrollState_h |
+ |
+#include "bindings/core/v8/ExceptionState.h" |
+#include "bindings/core/v8/ScriptWrappable.h" |
+#include "core/dom/Element.h" |
+#include "wtf/Vector.h" |
+ |
+namespace blink { |
+ |
+class ScrollState final : public GarbageCollectedFinalized<ScrollState>, public ScriptWrappable { |
+ DEFINE_WRAPPERTYPEINFO(); |
+ |
+public: |
+ static ScrollState* create( |
+ double deltaX, double deltaY, double deltaGranularity, double velocityX, |
+ double velocityY, bool inInertialPhase, bool isEnding, bool fromUserInput = false, |
+ bool shouldPropagate = true); |
+ |
+ virtual ~ScrollState(); |
+ |
+ void consumeDelta(double x, double y, ExceptionState&); |
+ void distributeToScrollChainDescendant(); |
+ |
+ // Positive when scrolling left. |
+ double deltaX() const { return m_deltaX; } |
+ // Positive when scrolling up. |
+ double deltaY() const { return m_deltaY; } |
+ // Indicates the smallest delta the input device can produce. 0 for unquantized inputs. |
+ double deltaGranularity() const { return m_deltaGranularity; } |
+ // Positive if moving right. |
+ double velocityX() const { return m_velocityX; } |
+ // Positive if moving down. |
+ double velocityY() const { return m_velocityY; } |
+ // True for events dispatched after the users's gesture has finished. |
+ bool inInertialPhase() const { return m_inInertialPhase; } |
+ // True if this is the last event for this scroll. |
+ bool isEnding() const { return m_isEnding; } |
+ // True if this scroll is the direct result of user input. |
+ bool fromUserInput() const { return m_fromUserInput; } |
+ // True if this scroll is allowed to bubble upwards. |
+ bool shouldPropagate() const { return m_shouldPropagate; } |
+ |
+ // FIXME - indicate which of these are exposed. |
+ void consumeDeltaNative(double x, double y); |
+ |
+ void setScrollChain(WillBeHeapVector<RefPtrWillBeMember<Element>> scrollChain) |
+ { |
+ m_scrollChain = scrollChain; |
+ } |
+ |
+ void setCurrentNativeScrollingElement(Element* element) |
+ { |
+ m_currentNativeScrollingElement = element; |
+ } |
+ |
+ Element* currentNativeScrollingElement() const |
+ { |
+ return m_currentNativeScrollingElement; |
+ } |
+ |
+ void setScrollLockedToElement(bool scrollLockedToElement) |
+ { |
+ m_scrollLockedToElement = scrollLockedToElement; |
+ } |
+ |
+ bool scrollLockedToElement() const { return m_scrollLockedToElement; } |
+ |
+ bool fullyConsumed() const |
+ { |
+ return !m_deltaX && !m_deltaY && !m_isEnding; |
+ } |
+ |
+ void trace(Visitor* visitor) |
+ { |
+ visitor->trace(m_scrollChain); |
+ } |
+ |
+private: |
+ ScrollState(); |
+ ScrollState(double deltaX, double deltaY, double deltaGranularity, |
+ double velocityX, double velocityY, bool inInertialPhase, bool isEnding, bool fromUserInput, bool shouldPropagate); |
+ |
+ double m_deltaX; |
+ double m_deltaY; |
+ double m_deltaGranularity; |
+ double m_velocityX; |
+ double m_velocityY; |
+ bool m_inInertialPhase; |
+ bool m_isEnding; |
+ bool m_fromUserInput; |
+ |
+ WillBeHeapVector<RefPtrWillBeMember<Element>> m_scrollChain; |
+ |
+ // The last element to respond to a scroll, or null if none exists. |
+ Element* m_currentNativeScrollingElement; |
+ bool m_scrollLockedToElement; |
+ bool m_shouldPropagate; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // ScrollState_h |