| 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 22 matching lines...) Expand all Loading... |
| 33 #include "platform/animation/TimingFunction.h" | 33 #include "platform/animation/TimingFunction.h" |
| 34 #include "platform/geometry/FloatRect.h" | 34 #include "platform/geometry/FloatRect.h" |
| 35 #include "platform/geometry/IntRect.h" | 35 #include "platform/geometry/IntRect.h" |
| 36 #include "platform/mac/BlockExceptions.h" | 36 #include "platform/mac/BlockExceptions.h" |
| 37 #include "platform/mac/NSScrollerImpDetails.h" | 37 #include "platform/mac/NSScrollerImpDetails.h" |
| 38 #include "platform/scroll/ScrollableArea.h" | 38 #include "platform/scroll/ScrollableArea.h" |
| 39 #include "platform/scroll/ScrollbarTheme.h" | 39 #include "platform/scroll/ScrollbarTheme.h" |
| 40 #include "platform/scroll/ScrollbarThemeMacCommon.h" | 40 #include "platform/scroll/ScrollbarThemeMacCommon.h" |
| 41 #include "platform/scroll/ScrollbarThemeMacOverlayAPI.h" | 41 #include "platform/scroll/ScrollbarThemeMacOverlayAPI.h" |
| 42 #include "wtf/MainThread.h" | 42 #include "wtf/MainThread.h" |
| 43 #include "wtf/MathExtras.h" |
| 43 #include "wtf/PassOwnPtr.h" | 44 #include "wtf/PassOwnPtr.h" |
| 44 | 45 |
| 45 using namespace blink; | 46 using namespace blink; |
| 46 | 47 |
| 47 static bool supportsUIStateTransitionProgress() | 48 static bool supportsUIStateTransitionProgress() |
| 48 { | 49 { |
| 49 // FIXME: This is temporary until all platforms that support ScrollbarPainte
r support this part of the API. | 50 // FIXME: This is temporary until all platforms that support ScrollbarPainte
r support this part of the API. |
| 50 static bool globalSupportsUIStateTransitionProgress = [NSClassFromString(@"N
SScrollerImp") instancesRespondToSelector:@selector(mouseEnteredScroller)]; | 51 static bool globalSupportsUIStateTransitionProgress = [NSClassFromString(@"N
SScrollerImp") instancesRespondToSelector:@selector(mouseEnteredScroller)]; |
| 51 return globalSupportsUIStateTransitionProgress; | 52 return globalSupportsUIStateTransitionProgress; |
| 52 } | 53 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 private: | 337 private: |
| 337 void timerFired(Timer<WebScrollbarPartAnimationTimer>*) | 338 void timerFired(Timer<WebScrollbarPartAnimationTimer>*) |
| 338 { | 339 { |
| 339 double currentTime = WTF::currentTime(); | 340 double currentTime = WTF::currentTime(); |
| 340 double delta = currentTime - m_startTime; | 341 double delta = currentTime - m_startTime; |
| 341 | 342 |
| 342 if (delta >= m_duration) | 343 if (delta >= m_duration) |
| 343 m_timer.stop(); | 344 m_timer.stop(); |
| 344 | 345 |
| 345 double fraction = delta / m_duration; | 346 double fraction = delta / m_duration; |
| 346 fraction = std::min(1.0, fraction); | 347 fraction = clampTo(fraction, 0.0, 1.0); |
| 347 fraction = std::max(0.0, fraction); | |
| 348 double progress = m_timingFunction->evaluate(fraction, 0.001); | 348 double progress = m_timingFunction->evaluate(fraction, 0.001); |
| 349 [m_animation setCurrentProgress:progress]; | 349 [m_animation setCurrentProgress:progress]; |
| 350 } | 350 } |
| 351 | 351 |
| 352 Timer<WebScrollbarPartAnimationTimer> m_timer; | 352 Timer<WebScrollbarPartAnimationTimer> m_timer; |
| 353 double m_startTime; // In seconds. | 353 double m_startTime; // In seconds. |
| 354 double m_duration; // In seconds. | 354 double m_duration; // In seconds. |
| 355 WebScrollbarPartAnimation* m_animation; // Weak, owns this. | 355 WebScrollbarPartAnimation* m_animation; // Weak, owns this. |
| 356 RefPtr<CubicBezierTimingFunction> m_timingFunction; | 356 RefPtr<CubicBezierTimingFunction> m_timingFunction; |
| 357 }; | 357 }; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 { | 763 { |
| 764 [m_scrollAnimationHelper.get() _stopRun]; | 764 [m_scrollAnimationHelper.get() _stopRun]; |
| 765 immediateScrollTo(offset); | 765 immediateScrollTo(offset); |
| 766 } | 766 } |
| 767 | 767 |
| 768 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint&
position) const | 768 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint&
position) const |
| 769 { | 769 { |
| 770 IntPoint minPos = m_scrollableArea->minimumScrollPosition(); | 770 IntPoint minPos = m_scrollableArea->minimumScrollPosition(); |
| 771 IntPoint maxPos = m_scrollableArea->maximumScrollPosition(); | 771 IntPoint maxPos = m_scrollableArea->maximumScrollPosition(); |
| 772 | 772 |
| 773 float newX = std::max<float>(std::min<float>(position.x(), maxPos.x()), minP
os.x()); | 773 float newX = clampTo<float, float>(position.x(), minPos.x(), maxPos.x()); |
| 774 float newY = std::max<float>(std::min<float>(position.y(), maxPos.y()), minP
os.y()); | 774 float newY = clampTo<float, float>(position.y(), minPos.y(), maxPos.y()); |
| 775 | 775 |
| 776 return FloatPoint(newX, newY); | 776 return FloatPoint(newX, newY); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) | 779 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) |
| 780 { | 780 { |
| 781 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); | 781 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); |
| 782 | 782 |
| 783 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi
tion.y() != m_currentPosY; | 783 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi
tion.y() != m_currentPosY; |
| 784 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) | 784 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 return; | 1198 return; |
| 1199 | 1199 |
| 1200 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1200 m_visibleScrollerThumbRect = rectInViewCoordinates; |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { | 1203 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { |
| 1204 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); | 1204 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 } // namespace blink | 1207 } // namespace blink |
| OLD | NEW |