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

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

Issue 14703004: Reland "Unifies ScrollView and RenderLayer to use non-shi..." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 7 years, 7 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 | Annotate | Revision Log
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 { 48 {
49 } 49 }
50 50
51 ScrollAnimator::~ScrollAnimator() 51 ScrollAnimator::~ScrollAnimator()
52 { 52 {
53 } 53 }
54 54
55 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier) 55 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier)
56 { 56 {
57 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX : &m_currentPosY; 57 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX : &m_currentPosY;
58 float newPos = std::max(std::min(*currentPos + (step * multiplier), static_c ast<float>(m_scrollableArea->scrollSize(orientation))), 0.0f); 58 float newPos = m_scrollableArea->clampScrollPosition(orientation, *currentPo s + step * multiplier);
59 float delta = *currentPos - newPos; 59 float delta = *currentPos - newPos;
60 if (*currentPos == newPos) 60 if (*currentPos == newPos)
61 return false; 61 return false;
62 *currentPos = newPos; 62 *currentPos = newPos;
63 63
64 notifyPositionChanged(orientation == HorizontalScrollbar ? FloatSize(delta, 0) : FloatSize(0, delta)); 64 notifyPositionChanged(orientation == HorizontalScrollbar ? FloatSize(delta, 0) : FloatSize(0, delta));
65 65
66 return true; 66 return true;
67 } 67 }
68 68
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return FloatPoint(m_currentPosX, m_currentPosY); 134 return FloatPoint(m_currentPosX, m_currentPosY);
135 } 135 }
136 136
137 void ScrollAnimator::notifyPositionChanged(const FloatSize& delta) 137 void ScrollAnimator::notifyPositionChanged(const FloatSize& delta)
138 { 138 {
139 UNUSED_PARAM(delta); 139 UNUSED_PARAM(delta);
140 m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_cur rentPosY)); 140 m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_cur rentPosY));
141 } 141 }
142 142
143 } // namespace WebCore 143 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp ('k') | Source/core/platform/ScrollView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698