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

Side by Side Diff: Source/core/page/scrolling/ScrollState.cpp

Issue 988823003: Use scroll customization primitives for touch scrolling (behind REF). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address rbyers' nit. Created 5 years, 8 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
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 #include "config.h" 5 #include "config.h"
6 #include "core/page/scrolling/ScrollState.h" 6 #include "core/page/scrolling/ScrollState.h"
7 7
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/ExceptionCode.h" 9 #include "core/dom/ExceptionCode.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 PassRefPtrWillBeRawPtr<ScrollState> ScrollState::create(double deltaX, double de ltaY, 13 PassRefPtrWillBeRawPtr<ScrollState> ScrollState::create(double deltaX, double de ltaY,
14 double deltaGranularity, double velocityX, double velocityY, bool inInertial Phase, 14 double deltaGranularity, double velocityX, double velocityY, bool inInertial Phase,
15 bool isEnding, bool fromUserInput, bool shouldPropagate, 15 bool isBeginning, bool isEnding, bool fromUserInput, bool shouldPropagate,
16 bool deltaConsumedForScrollSequence) 16 bool deltaConsumedForScrollSequence)
17 { 17 {
18 return adoptRefWillBeNoop(new ScrollState( 18 return adoptRefWillBeNoop(new ScrollState(
19 deltaX, deltaY, deltaGranularity, velocityX, velocityY, 19 deltaX, deltaY, deltaGranularity, velocityX, velocityY,
20 inInertialPhase, isEnding, fromUserInput, shouldPropagate, 20 inInertialPhase, isBeginning, isEnding, fromUserInput, shouldPropagate,
21 deltaConsumedForScrollSequence)); 21 deltaConsumedForScrollSequence));
22 } 22 }
23 23
24 ScrollState::ScrollState(double deltaX, double deltaY, double deltaGranularity, 24 ScrollState::ScrollState(double deltaX, double deltaY, double deltaGranularity,
25 double velocityX, double velocityY, bool inInertialPhase, bool isEnding, 25 double velocityX, double velocityY, bool inInertialPhase, bool isBeginning,
26 bool fromUserInput, bool shouldPropagate, bool deltaConsumedForScrollSequenc e) 26 bool isEnding, bool fromUserInput, bool shouldPropagate,
27 bool deltaConsumedForScrollSequence)
27 : m_deltaX(deltaX) 28 : m_deltaX(deltaX)
28 , m_deltaY(deltaY) 29 , m_deltaY(deltaY)
29 , m_deltaGranularity(deltaGranularity) 30 , m_deltaGranularity(deltaGranularity)
30 , m_velocityX(velocityX) 31 , m_velocityX(velocityX)
31 , m_velocityY(velocityY) 32 , m_velocityY(velocityY)
32 , m_inInertialPhase(inInertialPhase) 33 , m_inInertialPhase(inInertialPhase)
34 , m_isBeginning(isBeginning)
33 , m_isEnding(isEnding) 35 , m_isEnding(isEnding)
34 , m_fromUserInput(fromUserInput) 36 , m_fromUserInput(fromUserInput)
35 , m_shouldPropagate(shouldPropagate) 37 , m_shouldPropagate(shouldPropagate)
36 , m_deltaConsumedForScrollSequence(deltaConsumedForScrollSequence) 38 , m_deltaConsumedForScrollSequence(deltaConsumedForScrollSequence)
37 { 39 {
38 } 40 }
39 41
40 void ScrollState::consumeDelta(double x, double y, ExceptionState& exceptionStat e) 42 void ScrollState::consumeDelta(double x, double y, ExceptionState& exceptionStat e)
41 { 43 {
42 if ((m_deltaX > 0 && 0 > x) || (m_deltaX < 0 && 0 < x) || (m_deltaY > 0 && 0 > y) || (m_deltaY < 0 && 0 < y)) { 44 if ((m_deltaX > 0 && 0 > x) || (m_deltaX < 0 && 0 < x) || (m_deltaY > 0 && 0 > y) || (m_deltaY < 0 && 0 < y)) {
43 exceptionState.throwDOMException(InvalidModificationError, "Can't increa se delta using consumeDelta"); 45 exceptionState.throwDOMException(InvalidModificationError, "Can't increa se delta using consumeDelta");
44 return; 46 return;
45 } 47 }
46 if (fabs(x) > fabs(m_deltaX) || fabs(y) > fabs(m_deltaY)) { 48 if (fabs(x) > fabs(m_deltaX) || fabs(y) > fabs(m_deltaY)) {
47 exceptionState.throwDOMException(InvalidModificationError, "Can't change direction of delta using consumeDelta"); 49 exceptionState.throwDOMException(InvalidModificationError, "Can't change direction of delta using consumeDelta");
48 return; 50 return;
49 } 51 }
50 consumeDeltaNative(x, y); 52 consumeDeltaNative(x, y);
51 } 53 }
52 54
55 void ScrollState::distributeToScrollChainDescendant()
56 {
57 if (!m_scrollChain.isEmpty())
58 m_scrollChain.takeFirst()->distributeScroll(*this);
59 }
60
53 void ScrollState::consumeDeltaNative(double x, double y) 61 void ScrollState::consumeDeltaNative(double x, double y)
54 { 62 {
55 m_deltaX -= x; 63 m_deltaX -= x;
56 m_deltaY -= y; 64 m_deltaY -= y;
57 65
58 if (x || y) 66 if (x || y)
59 m_deltaConsumedForScrollSequence = true; 67 m_deltaConsumedForScrollSequence = true;
60 } 68 }
61 69
62 } // namespace blink 70 } // 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