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

Side by Side Diff: Source/platform/scroll/ScrollAnimator.cpp

Issue 1161713004: Rename ScrollableArea::scroll to userScroll (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed comment Created 5 years, 6 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/platform/scroll/ScrollAnimator.h ('k') | Source/platform/scroll/ScrollAnimatorNone.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 : m_scrollableArea(scrollableArea) 43 : m_scrollableArea(scrollableArea)
44 , m_currentPosX(0) 44 , m_currentPosX(0)
45 , m_currentPosY(0) 45 , m_currentPosY(0)
46 { 46 {
47 } 47 }
48 48
49 ScrollAnimator::~ScrollAnimator() 49 ScrollAnimator::~ScrollAnimator()
50 { 50 {
51 } 51 }
52 52
53 ScrollResultOneDimensional ScrollAnimator::scroll(ScrollbarOrientation orientati on, ScrollGranularity, float step, float delta) 53 ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orien tation, ScrollGranularity, float step, float delta)
54 { 54 {
55 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m _currentPosY; 55 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m _currentPosY;
56 float newPos = clampScrollPosition(orientation, currentPos + step * delta); 56 float newPos = clampScrollPosition(orientation, currentPos + step * delta);
57 if (currentPos == newPos) 57 if (currentPos == newPos)
58 return ScrollResultOneDimensional(false); 58 return ScrollResultOneDimensional(false);
59 59
60 float usedDelta = (newPos - currentPos) / step; 60 float usedDelta = (newPos - currentPos) / step;
61 currentPos = newPos; 61 currentPos = newPos;
62 62
63 notifyPositionChanged(); 63 notifyPositionChanged();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 result.didScroll = true; 101 result.didScroll = true;
102 102
103 if (deltaY) { 103 if (deltaY) {
104 if (e.granularity() == ScrollByPageWheelEvent) { 104 if (e.granularity() == ScrollByPageWheelEvent) {
105 bool negative = deltaY < 0; 105 bool negative = deltaY < 0;
106 deltaY = m_scrollableArea->pageStep(VerticalScrollbar); 106 deltaY = m_scrollableArea->pageStep(VerticalScrollbar);
107 if (negative) 107 if (negative)
108 deltaY = -deltaY; 108 deltaY = -deltaY;
109 } 109 }
110 110
111 ScrollResultOneDimensional resultY = scroll( 111 ScrollResultOneDimensional resultY = userScroll(
112 VerticalScrollbar, granularity, m_scrollableArea->pixelStep(Vert icalScrollbar), -deltaY); 112 VerticalScrollbar, granularity, m_scrollableArea->pixelStep(Vert icalScrollbar), -deltaY);
113 113
114 if (e.granularity() != ScrollByPageWheelEvent) { 114 if (e.granularity() != ScrollByPageWheelEvent) {
115 if (resultY.didScroll) 115 if (resultY.didScroll)
116 result.unusedScrollDeltaY = -resultY.unusedScrollDelta; 116 result.unusedScrollDeltaY = -resultY.unusedScrollDelta;
117 else 117 else
118 result.unusedScrollDeltaY = deltaY; 118 result.unusedScrollDeltaY = deltaY;
119 } 119 }
120 } 120 }
121 121
122 if (deltaX) { 122 if (deltaX) {
123 if (e.granularity() == ScrollByPageWheelEvent) { 123 if (e.granularity() == ScrollByPageWheelEvent) {
124 bool negative = deltaX < 0; 124 bool negative = deltaX < 0;
125 deltaX = m_scrollableArea->pageStep(HorizontalScrollbar); 125 deltaX = m_scrollableArea->pageStep(HorizontalScrollbar);
126 if (negative) 126 if (negative)
127 deltaX = -deltaX; 127 deltaX = -deltaX;
128 } 128 }
129 129
130 ScrollResultOneDimensional resultX = scroll( 130 ScrollResultOneDimensional resultX = userScroll(
131 HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(Ho rizontalScrollbar), -deltaX); 131 HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(Ho rizontalScrollbar), -deltaX);
132 132
133 if (e.granularity() != ScrollByPageWheelEvent) { 133 if (e.granularity() != ScrollByPageWheelEvent) {
134 if (resultX.didScroll) 134 if (resultX.didScroll)
135 result.unusedScrollDeltaX = -resultX.unusedScrollDelta; 135 result.unusedScrollDeltaX = -resultX.unusedScrollDelta;
136 else 136 else
137 result.unusedScrollDeltaX = deltaX; 137 result.unusedScrollDeltaX = deltaX;
138 } 138 }
139 } 139 }
140 } 140 }
(...skipping 21 matching lines...) Expand all
162 } 162 }
163 163
164 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa t pos) 164 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa t pos)
165 { 165 {
166 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); 166 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation);
167 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); 167 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation);
168 return std::max(std::min(pos, maxScrollPos), minScrollPos); 168 return std::max(std::min(pos, maxScrollPos), minScrollPos);
169 } 169 }
170 170
171 } // namespace blink 171 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/ScrollAnimator.h ('k') | Source/platform/scroll/ScrollAnimatorNone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698