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

Side by Side 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, 9 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "config.h"
6 #include "core/page/scrolling/ScrollState.h"
7
8 #include "core/dom/Element.h"
9 #include "core/dom/ExceptionCode.h"
10
11 namespace blink {
12
13 ScrollState* ScrollState::create(double deltaX, double deltaY, double deltaGranu larity,
14 double velocityX, double velocityY, bool inInertialPhase, bool isEnding,
15 bool fromUserInput, bool shouldPropagate)
16 {
17 return new ScrollState(
18 deltaX, deltaY, deltaGranularity, velocityX, velocityY,
19 inInertialPhase, isEnding, fromUserInput, shouldPropagate);
20 }
21
22 ScrollState::ScrollState(double deltaX, double deltaY, double deltaGranularity,
23 double velocityX, double velocityY, bool inInertialPhase, bool isEnding,
24 bool fromUserInput, bool shouldPropagate)
25 : m_deltaX(deltaX)
26 , m_deltaY(deltaY)
27 , m_deltaGranularity(deltaGranularity)
28 , m_velocityX(velocityX)
29 , m_velocityY(velocityY)
30 , m_inInertialPhase(inInertialPhase)
31 , m_isEnding(isEnding)
32 , m_fromUserInput(fromUserInput)
33 , m_shouldPropagate(shouldPropagate)
34 {
35 }
36
37 ScrollState::~ScrollState()
38 {
39 }
40
41 void ScrollState::consumeDelta(double x, double y, ExceptionState& exceptionStat e)
42 {
43 if ((m_deltaX > 0 && 0 > x) || (m_deltaX < 0 && 0 < x) || (m_deltaY > 0 && 0 > y) || (m_deltaY < 0 && 0 < y)) {
44 exceptionState.throwDOMException(InvalidModificationError, "Can't increa se delta using consumeDelta");
45 } else if (fabs(x) > fabs(m_deltaX) || fabs(y) > fabs(m_deltaY)) {
46 exceptionState.throwDOMException(InvalidModificationError, "Can't change direction of delta using consumeDelta");
47 }
48 consumeDeltaNative(x, y);
49 }
50
51 void ScrollState::distributeToScrollChainDescendant()
52 {
53 if (m_scrollChain.isEmpty())
54 return;
55 Element* element = m_scrollChain[0].get();
56 m_scrollChain.remove(0);
57 element->callDistributeScroll(this);
58 }
59
60 void ScrollState::consumeDeltaNative(double x, double y)
61 {
62 m_deltaX -= x;
63 m_deltaY -= y;
64
65 if (x || y)
66 m_scrollLockedToElement = true;
67 }
68
69 } // namespace blink
OLDNEW
« 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