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

Unified Diff: Source/core/page/scrolling/ScrollState.cpp

Issue 850443002: Scroll Customization Prototype (Not for review, WIP) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase / cleanup / minor bug fixes Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/scrolling/ScrollState.h ('k') | Source/core/page/scrolling/ScrollState.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/scrolling/ScrollState.cpp
diff --git a/Source/core/page/scrolling/ScrollState.cpp b/Source/core/page/scrolling/ScrollState.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a9f319bc84db49af2684f118f47c848108f4949b
--- /dev/null
+++ b/Source/core/page/scrolling/ScrollState.cpp
@@ -0,0 +1,69 @@
+// 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.
+
+#include "config.h"
+#include "core/page/scrolling/ScrollState.h"
+
+#include "core/dom/Element.h"
+#include "core/dom/ExceptionCode.h"
+
+namespace blink {
+
+ScrollState* ScrollState::create(double deltaX, double deltaY, double deltaGranularity,
+ double velocityX, double velocityY, bool inInertialPhase, bool isEnding,
+ bool fromUserInput, bool shouldPropagate)
+{
+ return new ScrollState(
+ deltaX, deltaY, deltaGranularity, velocityX, velocityY,
+ inInertialPhase, isEnding, fromUserInput, shouldPropagate);
+}
+
+ScrollState::ScrollState(double deltaX, double deltaY, double deltaGranularity,
+ double velocityX, double velocityY, bool inInertialPhase, bool isEnding,
+ bool fromUserInput, bool shouldPropagate)
+ : m_deltaX(deltaX)
+ , m_deltaY(deltaY)
+ , m_deltaGranularity(deltaGranularity)
+ , m_velocityX(velocityX)
+ , m_velocityY(velocityY)
+ , m_inInertialPhase(inInertialPhase)
+ , m_isEnding(isEnding)
+ , m_fromUserInput(fromUserInput)
+ , m_shouldPropagate(shouldPropagate)
+{
+}
+
+ScrollState::~ScrollState()
+{
+}
+
+void ScrollState::consumeDelta(double x, double y, ExceptionState& exceptionState)
+{
+ if ((m_deltaX > 0 && 0 > x) || (m_deltaX < 0 && 0 < x) || (m_deltaY > 0 && 0 > y) || (m_deltaY < 0 && 0 < y)) {
+ exceptionState.throwDOMException(InvalidModificationError, "Can't increase delta using consumeDelta");
+ } else if (fabs(x) > fabs(m_deltaX) || fabs(y) > fabs(m_deltaY)) {
+ exceptionState.throwDOMException(InvalidModificationError, "Can't change direction of delta using consumeDelta");
+ }
+ consumeDeltaNative(x, y);
+}
+
+void ScrollState::distributeToScrollChainDescendant()
+{
+ if (m_scrollChain.isEmpty())
+ return;
+ Element* element = m_scrollChain[0].get();
+ m_scrollChain.remove(0);
+ element->callDistributeScroll(this);
+}
+
+void ScrollState::consumeDeltaNative(double x, double y)
+{
+ m_deltaX -= x;
+ m_deltaY -= y;
+
+ if (x || y)
+ m_scrollLockedToElement = true;
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/page/scrolling/ScrollState.h ('k') | Source/core/page/scrolling/ScrollState.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698