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

Unified Diff: third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Created 4 years, 2 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
Index: third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
diff --git a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
index 7594133e1035d813da590caaa2392b546cf945e8..47f815a1872c6443fb2be4ac52f30fec8a6a5cfa 100644
--- a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
+++ b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
@@ -122,14 +122,15 @@ static NSSize abs(NSSize size) {
if (!_animator)
return NSZeroRect;
- blink::FloatPoint currentPosition = _animator->currentPosition();
- return NSMakeRect(currentPosition.x(), currentPosition.y(), 0, 0);
+ blink::ScrollOffset currentOffset = _animator->currentOffset();
+ return NSMakeRect(currentOffset.width(), currentOffset.height(), 0, 0);
}
- (void)_immediateScrollToPoint:(NSPoint)newPosition {
if (!_animator)
return;
- _animator->immediateScrollToPointForScrollAnimation(newPosition);
+ _animator->immediateScrollToOffsetForScrollAnimation(
+ toScrollOffset(newPosition));
}
- (NSPoint)_pixelAlignProposedScrollPosition:(NSPoint)newOrigin {
@@ -725,7 +726,7 @@ void ScrollAnimatorMac::dispose() {
}
ScrollResult ScrollAnimatorMac::userScroll(ScrollGranularity granularity,
- const FloatSize& delta) {
+ const ScrollOffset& delta) {
m_haveScrolledSincePageLoad = true;
if (!m_scrollableArea->scrollAnimatorEnabled())
@@ -734,21 +735,21 @@ ScrollResult ScrollAnimatorMac::userScroll(ScrollGranularity granularity,
if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel)
return ScrollAnimatorBase::userScroll(granularity, delta);
- FloatSize consumedDelta = computeDeltaToConsume(delta);
- FloatPoint newPos = m_currentPos + consumedDelta;
- if (m_currentPos == newPos)
+ ScrollOffset consumedDelta = computeDeltaToConsume(delta);
+ ScrollOffset newOffset = m_currentOffset + consumedDelta;
+ if (m_currentOffset == newOffset)
return ScrollResult();
// Prevent clobbering an existing animation on an unscrolled axis.
if ([m_scrollAnimationHelper.get() _isAnimating]) {
NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin];
if (!delta.width())
- newPos.setX(targetOrigin.x);
+ newOffset.setWidth(targetOrigin.x);
if (!delta.height())
- newPos.setY(targetOrigin.y);
+ newOffset.setHeight(targetOrigin.y);
}
- NSPoint newPoint = NSMakePoint(newPos.x(), newPos.y());
+ NSPoint newPoint = NSMakePoint(newOffset.width(), newOffset.height());
[m_scrollAnimationHelper.get() scrollToPoint:newPoint];
// TODO(bokan): This has different semantics on ScrollResult than ScrollAnimator,
@@ -759,40 +760,42 @@ ScrollResult ScrollAnimatorMac::userScroll(ScrollGranularity granularity,
}
void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(
- const FloatPoint& offset) {
+ const ScrollOffset& offset) {
[m_scrollAnimationHelper.get() _stopRun];
immediateScrollTo(offset);
}
-FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(
- const FloatPoint& position) const {
- IntPoint minPos = m_scrollableArea->minimumScrollPosition();
- IntPoint maxPos = m_scrollableArea->maximumScrollPosition();
+ScrollOffset ScrollAnimatorMac::adjustScrollOffsetIfNecessary(
+ const ScrollOffset& offset) const {
+ ScrollOffset minOffset = m_scrollableArea->minimumScrollOffset();
+ ScrollOffset maxOffset = m_scrollableArea->maximumScrollOffset();
- float newX = clampTo<float, float>(position.x(), minPos.x(), maxPos.x());
- float newY = clampTo<float, float>(position.y(), minPos.y(), maxPos.y());
+ float newX = clampTo<float, float>(offset.width(), minOffset.width(),
+ maxOffset.width());
+ float newY = clampTo<float, float>(offset.height(), minOffset.height(),
+ maxOffset.height());
- return FloatPoint(newX, newY);
+ return ScrollOffset(newX, newY);
}
-void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) {
- FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
+void ScrollAnimatorMac::immediateScrollTo(const ScrollOffset& newOffset) {
+ ScrollOffset adjustedOffset = adjustScrollOffsetIfNecessary(newOffset);
- bool positionChanged = adjustedPosition != m_currentPos;
- if (!positionChanged && !getScrollableArea()->scrollOriginChanged())
+ bool offsetChanged = adjustedOffset != m_currentOffset;
+ if (!offsetChanged && !getScrollableArea()->scrollOriginChanged())
return;
- FloatSize delta = adjustedPosition - m_currentPos;
+ ScrollOffset delta = adjustedOffset - m_currentOffset;
- m_currentPos = adjustedPosition;
+ m_currentOffset = adjustedOffset;
notifyContentAreaScrolled(delta);
- notifyPositionChanged();
+ notifyOffsetChanged();
}
-void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(
- const FloatPoint& newPosition) {
+void ScrollAnimatorMac::immediateScrollToOffsetForScrollAnimation(
+ const ScrollOffset& newOffset) {
ASSERT(m_scrollAnimationHelper);
- immediateScrollTo(newPosition);
+ immediateScrollTo(newOffset);
}
void ScrollAnimatorMac::contentAreaWillPaint() const {
@@ -945,7 +948,7 @@ bool ScrollAnimatorMac::shouldScrollbarParticipateInHitTesting(
return [painter knobAlpha] > 0;
}
-void ScrollAnimatorMac::notifyContentAreaScrolled(const FloatSize& delta) {
+void ScrollAnimatorMac::notifyContentAreaScrolled(const ScrollOffset& delta) {
// This function is called when a page is going into the page cache, but the page
// isn't really scrolling in that case. We should only pass the message on to the
// ScrollbarPainterController when we're really scrolling on an active page.
@@ -1012,7 +1015,7 @@ void ScrollAnimatorMac::updateScrollerStyle() {
macTheme->setNewPainterForScrollbar(*verticalScrollbar, newVerticalPainter);
// The different scrollbar styles have different thicknesses, so we must re-set the
- // frameRect to the new thickness, and the re-layout below will ensure the position
+ // frameRect to the new thickness, and the re-layout below will ensure the offset
// and length are properly updated.
int thickness =
macTheme->scrollbarThickness(verticalScrollbar->controlSize());
@@ -1036,7 +1039,7 @@ void ScrollAnimatorMac::updateScrollerStyle() {
newHorizontalPainter);
// The different scrollbar styles have different thicknesses, so we must re-set the
- // frameRect to the new thickness, and the re-layout below will ensure the position
+ // frameRect to the new thickness, and the re-layout below will ensure the offset
// and length are properly updated.
int thickness =
macTheme->scrollbarThickness(horizontalScrollbar->controlSize());
@@ -1072,7 +1075,7 @@ void ScrollAnimatorMac::initialScrollbarPaintTask() {
[m_scrollbarPainterController.get() flashScrollers];
}
-void ScrollAnimatorMac::sendContentAreaScrolledSoon(const FloatSize& delta) {
+void ScrollAnimatorMac::sendContentAreaScrolledSoon(const ScrollOffset& delta) {
m_contentAreaScrolledTimerScrollDelta = delta;
if (!m_sendContentAreaScrolledTaskFactory->isPending())
@@ -1089,7 +1092,7 @@ void ScrollAnimatorMac::sendContentAreaScrolledTask() {
.width(),
m_contentAreaScrolledTimerScrollDelta
.height())];
- m_contentAreaScrolledTimerScrollDelta = FloatSize();
+ m_contentAreaScrolledTimerScrollDelta = ScrollOffset();
} else
[m_scrollbarPainterController.get() contentAreaScrolled];
}

Powered by Google App Engine
This is Rietveld 408576698