| 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 21 matching lines...) Expand all Loading... |
| 32 #include "platform/geometry/FloatRect.h" | 32 #include "platform/geometry/FloatRect.h" |
| 33 #include "platform/geometry/IntRect.h" | 33 #include "platform/geometry/IntRect.h" |
| 34 #include "platform/mac/BlockExceptions.h" | 34 #include "platform/mac/BlockExceptions.h" |
| 35 #include "platform/mac/NSScrollerImpDetails.h" | 35 #include "platform/mac/NSScrollerImpDetails.h" |
| 36 #include "platform/scroll/ScrollableArea.h" | 36 #include "platform/scroll/ScrollableArea.h" |
| 37 #include "platform/scroll/ScrollbarTheme.h" | 37 #include "platform/scroll/ScrollbarTheme.h" |
| 38 #include "platform/scroll/ScrollbarThemeMac.h" | 38 #include "platform/scroll/ScrollbarThemeMac.h" |
| 39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebScheduler.h" | 40 #include "public/platform/WebScheduler.h" |
| 41 #include "wtf/MathExtras.h" | 41 #include "wtf/MathExtras.h" |
| 42 #include "wtf/PtrUtil.h" | 42 #include "wtf/PassOwnPtr.h" |
| 43 #include <memory> | |
| 44 | 43 |
| 45 using namespace blink; | 44 using namespace blink; |
| 46 | 45 |
| 47 static bool supportsUIStateTransitionProgress() | 46 static bool supportsUIStateTransitionProgress() |
| 48 { | 47 { |
| 49 // FIXME: This is temporary until all platforms that support ScrollbarPainte
r support this part of the API. | 48 // 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)]; | 49 static bool globalSupportsUIStateTransitionProgress = [NSClassFromString(@"N
SScrollerImp") instancesRespondToSelector:@selector(mouseEnteredScroller)]; |
| 51 return globalSupportsUIStateTransitionProgress; | 50 return globalSupportsUIStateTransitionProgress; |
| 52 } | 51 } |
| 53 | 52 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 double m_startTime; // In seconds. | 347 double m_startTime; // In seconds. |
| 349 double m_duration; // In seconds. | 348 double m_duration; // In seconds. |
| 350 BlinkScrollbarPartAnimation* m_animation; // Weak, owns this. | 349 BlinkScrollbarPartAnimation* m_animation; // Weak, owns this. |
| 351 RefPtr<CubicBezierTimingFunction> m_timingFunction; | 350 RefPtr<CubicBezierTimingFunction> m_timingFunction; |
| 352 }; | 351 }; |
| 353 | 352 |
| 354 } // namespace blink | 353 } // namespace blink |
| 355 | 354 |
| 356 @interface BlinkScrollbarPartAnimation : NSObject { | 355 @interface BlinkScrollbarPartAnimation : NSObject { |
| 357 Scrollbar* _scrollbar; | 356 Scrollbar* _scrollbar; |
| 358 std::unique_ptr<BlinkScrollbarPartAnimationTimer> _timer; | 357 OwnPtr<BlinkScrollbarPartAnimationTimer> _timer; |
| 359 RetainPtr<ScrollbarPainter> _scrollbarPainter; | 358 RetainPtr<ScrollbarPainter> _scrollbarPainter; |
| 360 FeatureToAnimate _featureToAnimate; | 359 FeatureToAnimate _featureToAnimate; |
| 361 CGFloat _startValue; | 360 CGFloat _startValue; |
| 362 CGFloat _endValue; | 361 CGFloat _endValue; |
| 363 } | 362 } |
| 364 - (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate
)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue du
ration:(NSTimeInterval)duration; | 363 - (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate
)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue du
ration:(NSTimeInterval)duration; |
| 365 @end | 364 @end |
| 366 | 365 |
| 367 @implementation BlinkScrollbarPartAnimation | 366 @implementation BlinkScrollbarPartAnimation |
| 368 | 367 |
| 369 - (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate
)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue du
ration:(NSTimeInterval)duration | 368 - (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate
)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue du
ration:(NSTimeInterval)duration |
| 370 { | 369 { |
| 371 self = [super init]; | 370 self = [super init]; |
| 372 if (!self) | 371 if (!self) |
| 373 return nil; | 372 return nil; |
| 374 | 373 |
| 375 _timer = wrapUnique(new BlinkScrollbarPartAnimationTimer(self, duration)); | 374 _timer = adoptPtr(new BlinkScrollbarPartAnimationTimer(self, duration)); |
| 376 _scrollbar = scrollbar; | 375 _scrollbar = scrollbar; |
| 377 _featureToAnimate = featureToAnimate; | 376 _featureToAnimate = featureToAnimate; |
| 378 _startValue = startValue; | 377 _startValue = startValue; |
| 379 _endValue = endValue; | 378 _endValue = endValue; |
| 380 | 379 |
| 381 return self; | 380 return self; |
| 382 } | 381 } |
| 383 | 382 |
| 384 - (void)startAnimation | 383 - (void)startAnimation |
| 385 { | 384 { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 675 |
| 677 ScrollAnimatorBase* ScrollAnimatorBase::create(ScrollableArea* scrollableArea) | 676 ScrollAnimatorBase* ScrollAnimatorBase::create(ScrollableArea* scrollableArea) |
| 678 { | 677 { |
| 679 return new ScrollAnimatorMac(scrollableArea); | 678 return new ScrollAnimatorMac(scrollableArea); |
| 680 } | 679 } |
| 681 | 680 |
| 682 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) | 681 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) |
| 683 : ScrollAnimatorBase(scrollableArea) | 682 : ScrollAnimatorBase(scrollableArea) |
| 684 , m_initialScrollbarPaintTaskFactory(CancellableTaskFactory::create(this, &S
crollAnimatorMac::initialScrollbarPaintTask)) | 683 , m_initialScrollbarPaintTaskFactory(CancellableTaskFactory::create(this, &S
crollAnimatorMac::initialScrollbarPaintTask)) |
| 685 , m_sendContentAreaScrolledTaskFactory(CancellableTaskFactory::create(this,
&ScrollAnimatorMac::sendContentAreaScrolledTask)) | 684 , m_sendContentAreaScrolledTaskFactory(CancellableTaskFactory::create(this,
&ScrollAnimatorMac::sendContentAreaScrolledTask)) |
| 686 , m_taskRunner(wrapUnique(Platform::current()->currentThread()->scheduler()-
>timerTaskRunner()->clone())) | 685 , m_taskRunner(adoptPtr(Platform::current()->currentThread()->scheduler()->t
imerTaskRunner()->clone())) |
| 687 , m_haveScrolledSincePageLoad(false) | 686 , m_haveScrolledSincePageLoad(false) |
| 688 , m_needsScrollerStyleUpdate(false) | 687 , m_needsScrollerStyleUpdate(false) |
| 689 { | 688 { |
| 690 ThreadState::current()->registerPreFinalizer(this); | 689 ThreadState::current()->registerPreFinalizer(this); |
| 691 | 690 |
| 692 m_scrollAnimationHelperDelegate.adoptNS([[BlinkScrollAnimationHelperDelegate
alloc] initWithScrollAnimator:this]); | 691 m_scrollAnimationHelperDelegate.adoptNS([[BlinkScrollAnimationHelperDelegate
alloc] initWithScrollAnimator:this]); |
| 693 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelpe
r") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); | 692 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelpe
r") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); |
| 694 | 693 |
| 695 m_scrollbarPainterControllerDelegate.adoptNS([[BlinkScrollbarPainterControll
erDelegate alloc] initWithScrollableArea:scrollableArea]); | 694 m_scrollbarPainterControllerDelegate.adoptNS([[BlinkScrollbarPainterControll
erDelegate alloc] initWithScrollableArea:scrollableArea]); |
| 696 m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair") al
loc] init] autorelease]; | 695 m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair") al
loc] init] autorelease]; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) | 1100 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) |
| 1102 rectInViewCoordinates = verticalScrollbar->convertToContainingWidget(scr
ollerThumb); | 1101 rectInViewCoordinates = verticalScrollbar->convertToContainingWidget(scr
ollerThumb); |
| 1103 | 1102 |
| 1104 if (rectInViewCoordinates == m_visibleScrollerThumbRect) | 1103 if (rectInViewCoordinates == m_visibleScrollerThumbRect) |
| 1105 return; | 1104 return; |
| 1106 | 1105 |
| 1107 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1106 m_visibleScrollerThumbRect = rectInViewCoordinates; |
| 1108 } | 1107 } |
| 1109 | 1108 |
| 1110 } // namespace blink | 1109 } // namespace blink |
| OLD | NEW |