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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 { | 659 { |
660 m_haveScrolledSincePageLoad = true; | 660 m_haveScrolledSincePageLoad = true; |
661 | 661 |
662 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea->scrollAnimatorE
nabled()) | 662 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea->scrollAnimatorE
nabled()) |
663 return ScrollAnimator::scroll(orientation, granularity, step, multiplier
); | 663 return ScrollAnimator::scroll(orientation, granularity, step, multiplier
); |
664 | 664 |
665 if (granularity == ScrollByPixel) | 665 if (granularity == ScrollByPixel) |
666 return ScrollAnimator::scroll(orientation, granularity, step, multiplier
); | 666 return ScrollAnimator::scroll(orientation, granularity, step, multiplier
); |
667 | 667 |
668 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu
rrentPosY; | 668 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu
rrentPosY; |
669 float newPos = std::max<float>(std::min<float>(currentPos + (step * multipli
er), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0); | 669 float newPos = std::max<float>(std::min<float>(currentPos + (step * multipli
er), m_scrollableArea->maximumScrollPosition(orientation)), m_scrollableArea->mi
nimumScrollPosition(orientation)); |
670 if (currentPos == newPos) | 670 if (currentPos == newPos) |
671 return false; | 671 return false; |
672 | 672 |
673 NSPoint newPoint; | 673 NSPoint newPoint; |
674 if ([m_scrollAnimationHelper.get() _isAnimating]) { | 674 if ([m_scrollAnimationHelper.get() _isAnimating]) { |
675 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin]; | 675 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin]; |
676 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ
etOrigin.y) : NSMakePoint(targetOrigin.x, newPos); | 676 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ
etOrigin.y) : NSMakePoint(targetOrigin.x, newPos); |
677 } else | 677 } else |
678 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu
rrentPosY) : NSMakePoint(m_currentPosX, newPos); | 678 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu
rrentPosY) : NSMakePoint(m_currentPosX, newPos); |
679 | 679 |
680 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; | 680 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; |
681 return true; | 681 return true; |
682 } | 682 } |
683 | 683 |
684 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) | 684 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) |
685 { | 685 { |
686 [m_scrollAnimationHelper.get() _stopRun]; | 686 [m_scrollAnimationHelper.get() _stopRun]; |
687 immediateScrollTo(offset); | 687 immediateScrollTo(offset); |
688 } | 688 } |
689 | 689 |
690 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint&
position) const | 690 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint&
position) const |
691 { | 691 { |
692 if (!m_scrollableArea->constrainsScrollingToContentEdge()) | 692 if (!m_scrollableArea->constrainsScrollingToContentEdge()) |
693 return position; | 693 return position; |
694 | 694 |
695 float newX = max<float>(min<float>(position.x(), m_scrollableArea->contentsS
ize().width() - m_scrollableArea->visibleWidth()), 0); | 695 IntPoint minPos = m_scrollableArea->minimumScrollPosition(); |
696 float newY = max<float>(min<float>(position.y(), m_scrollableArea->contentsS
ize().height() - m_scrollableArea->visibleHeight()), 0); | 696 IntPoint maxPos = m_scrollableArea->maximumScrollPosition(); |
| 697 |
| 698 float newX = max<float>(min<float>(position.x(), maxPos.x()), minPos.x()); |
| 699 float newY = max<float>(min<float>(position.y(), maxPos.y()), minPos.y()); |
697 | 700 |
698 return FloatPoint(newX, newY); | 701 return FloatPoint(newX, newY); |
699 } | 702 } |
700 | 703 |
701 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) | 704 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) |
702 { | 705 { |
703 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); | 706 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); |
704 | 707 |
705 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi
tion.y() != m_currentPosY; | 708 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi
tion.y() != m_currentPosY; |
706 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) | 709 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) | 1286 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) |
1284 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol
lerThumb); | 1287 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol
lerThumb); |
1285 | 1288 |
1286 if (rectInViewCoordinates == m_visibleScrollerThumbRect) | 1289 if (rectInViewCoordinates == m_visibleScrollerThumbRect) |
1287 return; | 1290 return; |
1288 | 1291 |
1289 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1292 m_visibleScrollerThumbRect = rectInViewCoordinates; |
1290 } | 1293 } |
1291 | 1294 |
1292 } // namespace WebCore | 1295 } // namespace WebCore |
OLD | NEW |