Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010, 2011 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 { | 660 { |
| 661 m_haveScrolledSincePageLoad = true; | 661 m_haveScrolledSincePageLoad = true; |
| 662 | 662 |
| 663 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea->scrollAnimatorE nabled()) | 663 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea->scrollAnimatorE nabled()) |
| 664 return ScrollAnimator::scroll(orientation, granularity, step, multiplier ); | 664 return ScrollAnimator::scroll(orientation, granularity, step, multiplier ); |
| 665 | 665 |
| 666 if (granularity == ScrollByPixel) | 666 if (granularity == ScrollByPixel) |
| 667 return ScrollAnimator::scroll(orientation, granularity, step, multiplier ); | 667 return ScrollAnimator::scroll(orientation, granularity, step, multiplier ); |
| 668 | 668 |
| 669 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu rrentPosY; | 669 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu rrentPosY; |
| 670 float newPos = std::max<float>(std::min<float>(currentPos + (step * multipli er), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0); | 670 float newPos = std::max<float>(std::min<float>(currentPos + (step * multipli er), m_scrollableArea->maximumScrollPosition(orientation)), m_scrollableArea->mi nimumScrollPosition(orientation)); |
|
trchen
2013/05/03 23:19:12
Should we add a float version of ScrollableArea::c
| |
| 671 if (currentPos == newPos) | 671 if (currentPos == newPos) |
| 672 return false; | 672 return false; |
| 673 | 673 |
| 674 NSPoint newPoint; | 674 NSPoint newPoint; |
| 675 if ([m_scrollAnimationHelper.get() _isAnimating]) { | 675 if ([m_scrollAnimationHelper.get() _isAnimating]) { |
| 676 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin]; | 676 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin]; |
| 677 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ etOrigin.y) : NSMakePoint(targetOrigin.x, newPos); | 677 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ etOrigin.y) : NSMakePoint(targetOrigin.x, newPos); |
| 678 } else | 678 } else |
| 679 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu rrentPosY) : NSMakePoint(m_currentPosX, newPos); | 679 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu rrentPosY) : NSMakePoint(m_currentPosX, newPos); |
| 680 | 680 |
| 681 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; | 681 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; |
| 682 return true; | 682 return true; |
| 683 } | 683 } |
| 684 | 684 |
| 685 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) | 685 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) |
| 686 { | 686 { |
| 687 [m_scrollAnimationHelper.get() _stopRun]; | 687 [m_scrollAnimationHelper.get() _stopRun]; |
| 688 immediateScrollTo(offset); | 688 immediateScrollTo(offset); |
| 689 } | 689 } |
| 690 | 690 |
| 691 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const | 691 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const |
| 692 { | 692 { |
| 693 if (!m_scrollableArea->constrainsScrollingToContentEdge()) | 693 if (!m_scrollableArea->constrainsScrollingToContentEdge()) |
| 694 return position; | 694 return position; |
| 695 | 695 |
| 696 float newX = max<float>(min<float>(position.x(), m_scrollableArea->contentsS ize().width() - m_scrollableArea->visibleWidth()), 0); | 696 IntPoint minPos = m_scrollableArea->minimumScrollPosition(); |
| 697 float newY = max<float>(min<float>(position.y(), m_scrollableArea->contentsS ize().height() - m_scrollableArea->visibleHeight()), 0); | 697 IntPoint maxPos = m_scrollableArea->maximumScrollPosition(); |
| 698 | |
| 699 float newX = max<float>(min<float>(position.x(), maxPos.x()), minPos.x()); | |
| 700 float newY = max<float>(min<float>(position.y(), maxPos.y()), minPos.y()); | |
|
trchen
2013/05/03 23:19:12
ditto
| |
| 698 | 701 |
| 699 return FloatPoint(newX, newY); | 702 return FloatPoint(newX, newY); |
| 700 } | 703 } |
| 701 | 704 |
| 702 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) | 705 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) |
| 703 { | 706 { |
| 704 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); | 707 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); |
| 705 | 708 |
| 706 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi tion.y() != m_currentPosY; | 709 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi tion.y() != m_currentPosY; |
| 707 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) | 710 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1285 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol lerThumb); | 1288 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol lerThumb); |
| 1286 | 1289 |
| 1287 if (rectInViewCoordinates == m_visibleScrollerThumbRect) | 1290 if (rectInViewCoordinates == m_visibleScrollerThumbRect) |
| 1288 return; | 1291 return; |
| 1289 | 1292 |
| 1290 m_scrollableArea->setVisibleScrollerThumbRect(rectInViewCoordinates); | 1293 m_scrollableArea->setVisibleScrollerThumbRect(rectInViewCoordinates); |
| 1291 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1294 m_visibleScrollerThumbRect = rectInViewCoordinates; |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 } // namespace WebCore | 1297 } // namespace WebCore |
| OLD | NEW |