| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 - (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator; | 93 - (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator; |
| 94 @end | 94 @end |
| 95 | 95 |
| 96 static NSSize abs(NSSize size) | 96 static NSSize abs(NSSize size) |
| 97 { | 97 { |
| 98 NSSize finalSize = size; | 98 NSSize finalSize = size; |
| 99 if (finalSize.width < 0) | 99 if (finalSize.width < 0) |
| 100 finalSize.width = -finalSize.width; | 100 finalSize.width = -finalSize.width; |
| 101 if (finalSize.height < 0) | 101 if (finalSize.height < 0) |
| 102 finalSize.height = -finalSize.height; | 102 finalSize.height = -finalSize.height; |
| 103 return finalSize; | 103 return finalSize; |
| 104 } | 104 } |
| 105 | 105 |
| 106 @implementation WebScrollAnimationHelperDelegate | 106 @implementation WebScrollAnimationHelperDelegate |
| 107 | 107 |
| 108 - (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator | 108 - (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator |
| 109 { | 109 { |
| 110 self = [super init]; | 110 self = [super init]; |
| 111 if (!self) | 111 if (!self) |
| 112 return nil; | 112 return nil; |
| 113 | 113 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 - (id)initWithScrollableArea:(ScrollableArea*)scrollableArea; | 189 - (id)initWithScrollableArea:(ScrollableArea*)scrollableArea; |
| 190 @end | 190 @end |
| 191 | 191 |
| 192 @implementation WebScrollbarPainterControllerDelegate | 192 @implementation WebScrollbarPainterControllerDelegate |
| 193 | 193 |
| 194 - (id)initWithScrollableArea:(ScrollableArea*)scrollableArea | 194 - (id)initWithScrollableArea:(ScrollableArea*)scrollableArea |
| 195 { | 195 { |
| 196 self = [super init]; | 196 self = [super init]; |
| 197 if (!self) | 197 if (!self) |
| 198 return nil; | 198 return nil; |
| 199 | 199 |
| 200 _scrollableArea = scrollableArea; | 200 _scrollableArea = scrollableArea; |
| 201 return self; | 201 return self; |
| 202 } | 202 } |
| 203 | 203 |
| 204 - (void)invalidate | 204 - (void)invalidate |
| 205 { | 205 { |
| 206 _scrollableArea = 0; | 206 _scrollableArea = 0; |
| 207 } | 207 } |
| 208 | 208 |
| 209 - (NSRect)contentAreaRectForScrollerImpPair:(id)scrollerImpPair | 209 - (NSRect)contentAreaRectForScrollerImpPair:(id)scrollerImpPair |
| (...skipping 23 matching lines...) Expand all Loading... |
| 233 | 233 |
| 234 - (NSPoint)scrollerImpPair:(id)scrollerImpPair convertContentPoint:(NSPoint)poin
tInContentArea toScrollerImp:(id)scrollerImp | 234 - (NSPoint)scrollerImpPair:(id)scrollerImpPair convertContentPoint:(NSPoint)poin
tInContentArea toScrollerImp:(id)scrollerImp |
| 235 { | 235 { |
| 236 | 236 |
| 237 if (!_scrollableArea || !scrollerImp) | 237 if (!_scrollableArea || !scrollerImp) |
| 238 return NSZeroPoint; | 238 return NSZeroPoint; |
| 239 | 239 |
| 240 WebCore::Scrollbar* scrollbar = 0; | 240 WebCore::Scrollbar* scrollbar = 0; |
| 241 if ([scrollerImp isHorizontal]) | 241 if ([scrollerImp isHorizontal]) |
| 242 scrollbar = _scrollableArea->horizontalScrollbar(); | 242 scrollbar = _scrollableArea->horizontalScrollbar(); |
| 243 else | 243 else |
| 244 scrollbar = _scrollableArea->verticalScrollbar(); | 244 scrollbar = _scrollableArea->verticalScrollbar(); |
| 245 | 245 |
| 246 // It is possible to have a null scrollbar here since it is possible for thi
s delegate | 246 // It is possible to have a null scrollbar here since it is possible for thi
s delegate |
| 247 // method to be called between the moment when a scrollbar has been set to 0
and the | 247 // method to be called between the moment when a scrollbar has been set to 0
and the |
| 248 // moment when its destructor has been called. We should probably de-couple
some | 248 // moment when its destructor has been called. We should probably de-couple
some |
| 249 // of the clean-up work in ScrollbarThemeMac::unregisterScrollbar() to avoid
this | 249 // of the clean-up work in ScrollbarThemeMac::unregisterScrollbar() to avoid
this |
| 250 // issue. | 250 // issue. |
| 251 if (!scrollbar) | 251 if (!scrollbar) |
| 252 return NSZeroPoint; | 252 return NSZeroPoint; |
| 253 | 253 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 - (void)cancelAnimations; | 394 - (void)cancelAnimations; |
| 395 @end | 395 @end |
| 396 | 396 |
| 397 @implementation WebScrollbarPainterDelegate | 397 @implementation WebScrollbarPainterDelegate |
| 398 | 398 |
| 399 - (id)initWithScrollbar:(WebCore::Scrollbar*)scrollbar | 399 - (id)initWithScrollbar:(WebCore::Scrollbar*)scrollbar |
| 400 { | 400 { |
| 401 self = [super init]; | 401 self = [super init]; |
| 402 if (!self) | 402 if (!self) |
| 403 return nil; | 403 return nil; |
| 404 | 404 |
| 405 _scrollbar = scrollbar; | 405 _scrollbar = scrollbar; |
| 406 return self; | 406 return self; |
| 407 } | 407 } |
| 408 | 408 |
| 409 - (void)cancelAnimations | 409 - (void)cancelAnimations |
| 410 { | 410 { |
| 411 BEGIN_BLOCK_OBJC_EXCEPTIONS; | 411 BEGIN_BLOCK_OBJC_EXCEPTIONS; |
| 412 [_knobAlphaAnimation.get() stopAnimation]; | 412 [_knobAlphaAnimation.get() stopAnimation]; |
| 413 [_trackAlphaAnimation.get() stopAnimation]; | 413 [_trackAlphaAnimation.get() stopAnimation]; |
| 414 [_uiStateTransitionAnimation.get() stopAnimation]; | 414 [_uiStateTransitionAnimation.get() stopAnimation]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 436 if (!_scrollbar) | 436 if (!_scrollbar) |
| 437 return NSZeroPoint; | 437 return NSZeroPoint; |
| 438 | 438 |
| 439 ASSERT_UNUSED(scrollerImp, scrollerImp == scrollbarPainterForScrollbar(_scro
llbar)); | 439 ASSERT_UNUSED(scrollerImp, scrollerImp == scrollbarPainterForScrollbar(_scro
llbar)); |
| 440 | 440 |
| 441 return _scrollbar->convertFromContainingView(_scrollbar->scrollableArea()->l
astKnownMousePosition()); | 441 return _scrollbar->convertFromContainingView(_scrollbar->scrollableArea()->l
astKnownMousePosition()); |
| 442 } | 442 } |
| 443 | 443 |
| 444 - (void)setUpAlphaAnimation:(RetainPtr<WebScrollbarPartAnimation>&)scrollbarPart
Animation scrollerPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::Scrol
lbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration | 444 - (void)setUpAlphaAnimation:(RetainPtr<WebScrollbarPartAnimation>&)scrollbarPart
Animation scrollerPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::Scrol
lbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration |
| 445 { | 445 { |
| 446 // If the user has scrolled the page, then the scrollbars must be animated h
ere. | 446 // If the user has scrolled the page, then the scrollbars must be animated h
ere. |
| 447 // This overrides the early returns. | 447 // This overrides the early returns. |
| 448 bool mustAnimate = [self scrollAnimator]->haveScrolledSincePageLoad(); | 448 bool mustAnimate = [self scrollAnimator]->haveScrolledSincePageLoad(); |
| 449 | 449 |
| 450 if ([self scrollAnimator]->scrollbarPaintTimerIsActive() && !mustAnimate) | 450 if ([self scrollAnimator]->scrollbarPaintTimerIsActive() && !mustAnimate) |
| 451 return; | 451 return; |
| 452 | 452 |
| 453 if (_scrollbar->scrollableArea()->shouldSuspendScrollAnimations() && !mustAn
imate) { | 453 if (_scrollbar->scrollableArea()->shouldSuspendScrollAnimations() && !mustAn
imate) { |
| 454 [self scrollAnimator]->startScrollbarPaintTimer(); | 454 [self scrollAnimator]->startScrollbarPaintTimer(); |
| 455 return; | 455 return; |
| 456 } | 456 } |
| 457 | 457 |
| 458 // At this point, we are definitely going to animate now, so stop the timer. | 458 // At this point, we are definitely going to animate now, so stop the timer. |
| 459 [self scrollAnimator]->stopScrollbarPaintTimer(); | 459 [self scrollAnimator]->stopScrollbarPaintTimer(); |
| 460 | 460 |
| 461 // If we are currently animating, stop | 461 // If we are currently animating, stop |
| 462 if (scrollbarPartAnimation) { | 462 if (scrollbarPartAnimation) { |
| 463 [scrollbarPartAnimation.get() stopAnimation]; | 463 [scrollbarPartAnimation.get() stopAnimation]; |
| 464 scrollbarPartAnimation = nil; | 464 scrollbarPartAnimation = nil; |
| 465 } | 465 } |
| 466 | 466 |
| 467 if (part == WebCore::ThumbPart && _scrollbar->orientation() == VerticalScrol
lbar) { | 467 if (part == WebCore::ThumbPart && _scrollbar->orientation() == VerticalScrol
lbar) { |
| 468 if (newAlpha == 1) { | 468 if (newAlpha == 1) { |
| 469 IntRect thumbRect = IntRect([scrollerPainter rectForPart:NSScrollerK
nob]); | 469 IntRect thumbRect = IntRect([scrollerPainter rectForPart:NSScrollerK
nob]); |
| 470 [self scrollAnimator]->setVisibleScrollerThumbRect(thumbRect); | 470 [self scrollAnimator]->setVisibleScrollerThumbRect(thumbRect); |
| 471 } else | 471 } else |
| 472 [self scrollAnimator]->setVisibleScrollerThumbRect(IntRect()); | 472 [self scrollAnimator]->setVisibleScrollerThumbRect(IntRect()); |
| 473 } | 473 } |
| 474 | 474 |
| 475 scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithSc
rollbar:_scrollbar | 475 scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithSc
rollbar:_scrollbar |
| 476 featureTo
Animate:part == ThumbPart ? ThumbAlpha : TrackAlpha | 476 featureTo
Animate:part == ThumbPart ? ThumbAlpha : TrackAlpha |
| 477 anim
ateFrom:part == ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter track
Alpha] | 477 anim
ateFrom:part == ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter track
Alpha] |
| 478 an
imateTo:newAlpha | 478 an
imateTo:newAlpha |
| 479 d
uration:duration]); | 479 d
uration:duration]); |
| 480 [scrollbarPartAnimation.get() startAnimation]; | 480 [scrollbarPartAnimation.get() startAnimation]; |
| 481 } | 481 } |
| 482 | 482 |
| 483 - (void)scrollerImp:(id)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha dur
ation:(NSTimeInterval)duration | 483 - (void)scrollerImp:(id)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha dur
ation:(NSTimeInterval)duration |
| 484 { | 484 { |
| 485 if (!_scrollbar) | 485 if (!_scrollbar) |
| 486 return; | 486 return; |
| 487 | 487 |
| 488 ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); | 488 ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); |
| 489 | 489 |
| 490 ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp; | 490 ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp; |
| 491 [self setUpAlphaAnimation:_knobAlphaAnimation scrollerPainter:scrollerPainte
r part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration]; | 491 [self setUpAlphaAnimation:_knobAlphaAnimation scrollerPainter:scrollerPainte
r part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration]; |
| 492 } | 492 } |
| 493 | 493 |
| 494 - (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha d
uration:(NSTimeInterval)duration | 494 - (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha d
uration:(NSTimeInterval)duration |
| 495 { | 495 { |
| 496 if (!_scrollbar) | 496 if (!_scrollbar) |
| 497 return; | 497 return; |
| 498 | 498 |
| 499 ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); | 499 ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); |
| 500 | 500 |
| 501 ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp; | 501 ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp; |
| 502 [self setUpAlphaAnimation:_trackAlphaAnimation scrollerPainter:scrollerPaint
er part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration]; | 502 [self setUpAlphaAnimation:_trackAlphaAnimation scrollerPainter:scrollerPaint
er part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration]; |
| 503 } | 503 } |
| 504 | 504 |
| 505 - (void)scrollerImp:(id)scrollerImp animateUIStateTransitionWithDuration:(NSTime
Interval)duration | 505 - (void)scrollerImp:(id)scrollerImp animateUIStateTransitionWithDuration:(NSTime
Interval)duration |
| 506 { | 506 { |
| 507 if (!_scrollbar) | 507 if (!_scrollbar) |
| 508 return; | 508 return; |
| 509 | 509 |
| 510 if (!supportsUIStateTransitionProgress()) | 510 if (!supportsUIStateTransitionProgress()) |
| 511 return; | 511 return; |
| 512 | 512 |
| 513 ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); | 513 ASSERT(scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); |
| 514 | 514 |
| 515 ScrollbarPainter scrollbarPainter = (ScrollbarPainter)scrollerImp; | 515 ScrollbarPainter scrollbarPainter = (ScrollbarPainter)scrollerImp; |
| 516 | 516 |
| 517 // UIStateTransition always animates to 1. In case an animation is in progre
ss this avoids a hard transition. | 517 // UIStateTransition always animates to 1. In case an animation is in progre
ss this avoids a hard transition. |
| 518 [scrollbarPainter setUiStateTransitionProgress:1 - [scrollerImp uiStateTrans
itionProgress]]; | 518 [scrollbarPainter setUiStateTransitionProgress:1 - [scrollerImp uiStateTrans
itionProgress]]; |
| 519 | 519 |
| 520 if (!_uiStateTransitionAnimation) | 520 if (!_uiStateTransitionAnimation) |
| 521 _uiStateTransitionAnimation.adoptNS([[WebScrollbarPartAnimation alloc] i
nitWithScrollbar:_scrollbar | 521 _uiStateTransitionAnimation.adoptNS([[WebScrollbarPartAnimation alloc] i
nitWithScrollbar:_scrollbar |
| 522
featureToAnimate:UIStateTransition | 522
featureToAnimate:UIStateTransition |
| 523
animateFrom:[scrollbarPainter uiStateTransitionProgress] | 523
animateFrom:[scrollbarPainter uiStateTransitionProgress] |
| 524
animateTo:1.0 | 524
animateTo:1.0 |
| 525
duration:duration]); | 525
duration:duration]); |
| 526 else { | 526 else { |
| 527 // If we don't need to initialize the animation, just reset the values i
n case they have changed. | 527 // If we don't need to initialize the animation, just reset the values i
n case they have changed. |
| 528 [_uiStateTransitionAnimation.get() setStartValue:[scrollbarPainter uiSta
teTransitionProgress]]; | 528 [_uiStateTransitionAnimation.get() setStartValue:[scrollbarPainter uiSta
teTransitionProgress]]; |
| 529 [_uiStateTransitionAnimation.get() setEndValue:1.0]; | 529 [_uiStateTransitionAnimation.get() setEndValue:1.0]; |
| 530 [_uiStateTransitionAnimation.get() setDuration:duration]; | 530 [_uiStateTransitionAnimation.get() setDuration:duration]; |
| 531 } | 531 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 [m_scrollbarPainterController.get() setDelegate:nil]; | 616 [m_scrollbarPainterController.get() setDelegate:nil]; |
| 617 [m_horizontalScrollbarPainterDelegate.get() invalidate]; | 617 [m_horizontalScrollbarPainterDelegate.get() invalidate]; |
| 618 [m_verticalScrollbarPainterDelegate.get() invalidate]; | 618 [m_verticalScrollbarPainterDelegate.get() invalidate]; |
| 619 [m_scrollAnimationHelperDelegate.get() invalidate]; | 619 [m_scrollAnimationHelperDelegate.get() invalidate]; |
| 620 END_BLOCK_OBJC_EXCEPTIONS; | 620 END_BLOCK_OBJC_EXCEPTIONS; |
| 621 } | 621 } |
| 622 } | 622 } |
| 623 | 623 |
| 624 static bool scrollAnimationEnabledForSystem() | 624 static bool scrollAnimationEnabledForSystem() |
| 625 { | 625 { |
| 626 NSString* scrollAnimationDefaultsKey = | 626 NSString* scrollAnimationDefaultsKey = |
| 627 @"AppleScrollAnimationEnabled"; | 627 @"AppleScrollAnimationEnabled"; |
| 628 static bool enabled = [[NSUserDefaults standardUserDefaults] boolForKey:scro
llAnimationDefaultsKey]; | 628 static bool enabled = [[NSUserDefaults standardUserDefaults] boolForKey:scro
llAnimationDefaultsKey]; |
| 629 return enabled; | 629 return enabled; |
| 630 } | 630 } |
| 631 | 631 |
| 632 #if USE(RUBBER_BANDING) | 632 #if USE(RUBBER_BANDING) |
| 633 static bool rubberBandingEnabledForSystem() | 633 static bool rubberBandingEnabledForSystem() |
| 634 { | 634 { |
| 635 static bool initialized = false; | 635 static bool initialized = false; |
| 636 static bool enabled = true; | 636 static bool enabled = true; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 float newX = max<float>(min<float>(position.x(), maxPos.x()), minPos.x()); | 690 float newX = max<float>(min<float>(position.x(), maxPos.x()), minPos.x()); |
| 691 float newY = max<float>(min<float>(position.y(), maxPos.y()), minPos.y()); | 691 float newY = max<float>(min<float>(position.y(), maxPos.y()), minPos.y()); |
| 692 | 692 |
| 693 return FloatPoint(newX, newY); | 693 return FloatPoint(newX, newY); |
| 694 } | 694 } |
| 695 | 695 |
| 696 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) | 696 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) |
| 697 { | 697 { |
| 698 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); | 698 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); |
| 699 | 699 |
| 700 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi
tion.y() != m_currentPosY; | 700 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi
tion.y() != m_currentPosY; |
| 701 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) | 701 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) |
| 702 return; | 702 return; |
| 703 | 703 |
| 704 FloatSize delta = FloatSize(adjustedPosition.x() - m_currentPosX, adjustedPo
sition.y() - m_currentPosY); | 704 FloatSize delta = FloatSize(adjustedPosition.x() - m_currentPosX, adjustedPo
sition.y() - m_currentPosY); |
| 705 | 705 |
| 706 m_currentPosX = adjustedPosition.x(); | 706 m_currentPosX = adjustedPosition.x(); |
| 707 m_currentPosY = adjustedPosition.y(); | 707 m_currentPosY = adjustedPosition.y(); |
| 708 notifyPositionChanged(delta); | 708 notifyPositionChanged(delta); |
| 709 } | 709 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 if (!painter) | 956 if (!painter) |
| 957 return false; | 957 return false; |
| 958 return [painter knobAlpha] > 0; | 958 return [painter knobAlpha] > 0; |
| 959 } | 959 } |
| 960 | 960 |
| 961 void ScrollAnimatorMac::notifyContentAreaScrolled(const FloatSize& delta) | 961 void ScrollAnimatorMac::notifyContentAreaScrolled(const FloatSize& delta) |
| 962 { | 962 { |
| 963 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable()) | 963 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable()) |
| 964 return; | 964 return; |
| 965 | 965 |
| 966 // This function is called when a page is going into the page cache, but the
page | 966 // This function is called when a page is going into the page cache, but the
page |
| 967 // isn't really scrolling in that case. We should only pass the message on t
o the | 967 // isn't really scrolling in that case. We should only pass the message on t
o the |
| 968 // ScrollbarPainterController when we're really scrolling on an active page. | 968 // ScrollbarPainterController when we're really scrolling on an active page. |
| 969 if (scrollableArea()->scrollbarsCanBeActive()) | 969 if (scrollableArea()->scrollbarsCanBeActive()) |
| 970 sendContentAreaScrolledSoon(delta); | 970 sendContentAreaScrolledSoon(delta); |
| 971 } | 971 } |
| 972 | 972 |
| 973 void ScrollAnimatorMac::cancelAnimations() | 973 void ScrollAnimatorMac::cancelAnimations() |
| 974 { | 974 { |
| 975 m_haveScrolledSincePageLoad = false; | 975 m_haveScrolledSincePageLoad = false; |
| 976 | 976 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 } | 1039 } |
| 1040 } else if (deltaX != 0) { | 1040 } else if (deltaX != 0) { |
| 1041 if (deltaX < 0) { | 1041 if (deltaX < 0) { |
| 1042 // We are trying to scroll left. Make sure we are not pinned to the
left | 1042 // We are trying to scroll left. Make sure we are not pinned to the
left |
| 1043 limitDelta.setWidth(m_scrollableArea->visibleContentRect().x() + m_s
crollableArea->scrollOrigin().x()); | 1043 limitDelta.setWidth(m_scrollableArea->visibleContentRect().x() + m_s
crollableArea->scrollOrigin().x()); |
| 1044 } else { | 1044 } else { |
| 1045 // We are trying to scroll right. Make sure we are not pinned to th
e right | 1045 // We are trying to scroll right. Make sure we are not pinned to th
e right |
| 1046 limitDelta.setWidth(m_scrollableArea->contentsSize().width() - (m_sc
rollableArea->visibleContentRect().maxX() + m_scrollableArea->scrollOrigin().x()
)); | 1046 limitDelta.setWidth(m_scrollableArea->contentsSize().width() - (m_sc
rollableArea->visibleContentRect().maxX() + m_scrollableArea->scrollOrigin().x()
)); |
| 1047 } | 1047 } |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 if ((deltaX != 0 || deltaY != 0) && (limitDelta.width() < 1 && limitDelta.he
ight() < 1)) | 1050 if ((deltaX != 0 || deltaY != 0) && (limitDelta.width() < 1 && limitDelta.he
ight() < 1)) |
| 1051 return true; | 1051 return true; |
| 1052 return false; | 1052 return false; |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 bool ScrollAnimatorMac::allowsVerticalStretching() | 1055 bool ScrollAnimatorMac::allowsVerticalStretching() |
| 1056 { | 1056 { |
| 1057 switch (m_scrollableArea->verticalScrollElasticity()) { | 1057 switch (m_scrollableArea->verticalScrollElasticity()) { |
| 1058 case ScrollElasticityAutomatic: { | 1058 case ScrollElasticityAutomatic: { |
| 1059 Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar(); | 1059 Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1139 |
| 1140 FloatSize adjustedDelta = FloatSize(newPos.x() - m_currentPosX, newPos.y() -
m_currentPosY); | 1140 FloatSize adjustedDelta = FloatSize(newPos.x() - m_currentPosX, newPos.y() -
m_currentPosY); |
| 1141 | 1141 |
| 1142 m_currentPosX = newPos.x(); | 1142 m_currentPosX = newPos.x(); |
| 1143 m_currentPosY = newPos.y(); | 1143 m_currentPosY = newPos.y(); |
| 1144 notifyPositionChanged(adjustedDelta); | 1144 notifyPositionChanged(adjustedDelta); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 void ScrollAnimatorMac::startSnapRubberbandTimer() | 1147 void ScrollAnimatorMac::startSnapRubberbandTimer() |
| 1148 { | 1148 { |
| 1149 m_snapRubberBandTimer.startRepeating(1.0 / 60.0); | 1149 m_snapRubberBandTimer.startRepeating(1.0 / 60.0, FROM_HERE); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 void ScrollAnimatorMac::stopSnapRubberbandTimer() | 1152 void ScrollAnimatorMac::stopSnapRubberbandTimer() |
| 1153 { | 1153 { |
| 1154 m_snapRubberBandTimer.stop(); | 1154 m_snapRubberBandTimer.stop(); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*) | 1157 void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*) |
| 1158 { | 1158 { |
| 1159 m_scrollElasticityController.snapRubberBandTimerFired(); | 1159 m_scrollElasticityController.snapRubberBandTimerFired(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1186 m_needsScrollerStyleUpdate = false; | 1186 m_needsScrollerStyleUpdate = false; |
| 1187 return; | 1187 return; |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle
]; | 1190 NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle
]; |
| 1191 | 1191 |
| 1192 if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) { | 1192 if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) { |
| 1193 verticalScrollbar->invalidate(); | 1193 verticalScrollbar->invalidate(); |
| 1194 | 1194 |
| 1195 ScrollbarPainter oldVerticalPainter = [m_scrollbarPainterController.get(
) verticalScrollerImp]; | 1195 ScrollbarPainter oldVerticalPainter = [m_scrollbarPainterController.get(
) verticalScrollerImp]; |
| 1196 ScrollbarPainter newVerticalPainter = [NSClassFromString(@"NSScrollerImp
") scrollerImpWithStyle:newStyle | 1196 ScrollbarPainter newVerticalPainter = [NSClassFromString(@"NSScrollerImp
") scrollerImpWithStyle:newStyle |
| 1197
controlSize:(NSControlSize)verticalScrollbar->controlSize() | 1197
controlSize:(NSControlSize)verticalScrollbar->controlSize() |
| 1198
horizontal:NO | 1198
horizontal:NO |
| 1199
replacingScrollerImp:oldVerticalPainter]; | 1199
replacingScrollerImp:oldVerticalPainter]; |
| 1200 [m_scrollbarPainterController.get() setVerticalScrollerImp:newVerticalPa
inter]; | 1200 [m_scrollbarPainterController.get() setVerticalScrollerImp:newVerticalPa
inter]; |
| 1201 macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainte
r); | 1201 macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainte
r); |
| 1202 | 1202 |
| 1203 // The different scrollbar styles have different thicknesses, so we must
re-set the | 1203 // The different scrollbar styles have different thicknesses, so we must
re-set the |
| 1204 // frameRect to the new thickness, and the re-layout below will ensure t
he position | 1204 // frameRect to the new thickness, and the re-layout below will ensure t
he position |
| 1205 // and length are properly updated. | 1205 // and length are properly updated. |
| 1206 int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlS
ize()); | 1206 int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlS
ize()); |
| 1207 verticalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); | 1207 verticalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()
) { | 1210 if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()
) { |
| 1211 horizontalScrollbar->invalidate(); | 1211 horizontalScrollbar->invalidate(); |
| 1212 | 1212 |
| 1213 ScrollbarPainter oldHorizontalPainter = [m_scrollbarPainterController.ge
t() horizontalScrollerImp]; | 1213 ScrollbarPainter oldHorizontalPainter = [m_scrollbarPainterController.ge
t() horizontalScrollerImp]; |
| 1214 ScrollbarPainter newHorizontalPainter = [NSClassFromString(@"NSScrollerI
mp") scrollerImpWithStyle:newStyle | 1214 ScrollbarPainter newHorizontalPainter = [NSClassFromString(@"NSScrollerI
mp") scrollerImpWithStyle:newStyle |
| 1215
controlSize:(NSControlSize)horizontalScrollbar->controlSize() | 1215
controlSize:(NSControlSize)horizontalScrollbar->controlSize() |
| 1216
horizontal:YES | 1216
horizontal:YES |
| 1217
replacingScrollerImp:oldHorizontalPainter]; | 1217
replacingScrollerImp:oldHorizontalPainter]; |
| 1218 [m_scrollbarPainterController.get() setHorizontalScrollerImp:newHorizont
alPainter]; | 1218 [m_scrollbarPainterController.get() setHorizontalScrollerImp:newHorizont
alPainter]; |
| 1219 macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPa
inter); | 1219 macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPa
inter); |
| 1220 | 1220 |
| 1221 // The different scrollbar styles have different thicknesses, so we must
re-set the | 1221 // The different scrollbar styles have different thicknesses, so we must
re-set the |
| 1222 // frameRect to the new thickness, and the re-layout below will ensure t
he position | 1222 // frameRect to the new thickness, and the re-layout below will ensure t
he position |
| 1223 // and length are properly updated. | 1223 // and length are properly updated. |
| 1224 int thickness = macTheme->scrollbarThickness(horizontalScrollbar->contro
lSize()); | 1224 int thickness = macTheme->scrollbarThickness(horizontalScrollbar->contro
lSize()); |
| 1225 horizontalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); | 1225 horizontalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 // If m_needsScrollerStyleUpdate is true, then the page is restoring from th
e page cache, and | 1228 // If m_needsScrollerStyleUpdate is true, then the page is restoring from th
e page cache, and |
| 1229 // a relayout will happen on its own. Otherwise, we must initiate a re-layou
t ourselves. | 1229 // a relayout will happen on its own. Otherwise, we must initiate a re-layou
t ourselves. |
| 1230 scrollableArea()->scrollbarStyleChanged(newStyle, !m_needsScrollerStyleUpdat
e); | 1230 scrollableArea()->scrollbarStyleChanged(newStyle, !m_needsScrollerStyleUpdat
e); |
| 1231 | 1231 |
| 1232 m_needsScrollerStyleUpdate = false; | 1232 m_needsScrollerStyleUpdate = false; |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 void ScrollAnimatorMac::startScrollbarPaintTimer() | 1235 void ScrollAnimatorMac::startScrollbarPaintTimer() |
| 1236 { | 1236 { |
| 1237 m_initialScrollbarPaintTimer.startOneShot(0.1); | 1237 m_initialScrollbarPaintTimer.startOneShot(0.1, FROM_HERE); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 bool ScrollAnimatorMac::scrollbarPaintTimerIsActive() const | 1240 bool ScrollAnimatorMac::scrollbarPaintTimerIsActive() const |
| 1241 { | 1241 { |
| 1242 return m_initialScrollbarPaintTimer.isActive(); | 1242 return m_initialScrollbarPaintTimer.isActive(); |
| 1243 } | 1243 } |
| 1244 | 1244 |
| 1245 void ScrollAnimatorMac::stopScrollbarPaintTimer() | 1245 void ScrollAnimatorMac::stopScrollbarPaintTimer() |
| 1246 { | 1246 { |
| 1247 m_initialScrollbarPaintTimer.stop(); | 1247 m_initialScrollbarPaintTimer.stop(); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 void ScrollAnimatorMac::initialScrollbarPaintTimerFired(Timer<ScrollAnimatorMac>
*) | 1250 void ScrollAnimatorMac::initialScrollbarPaintTimerFired(Timer<ScrollAnimatorMac>
*) |
| 1251 { | 1251 { |
| 1252 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { | 1252 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { |
| 1253 // To force the scrollbars to flash, we have to call hide first. Otherwi
se, the ScrollbarPainterController | 1253 // To force the scrollbars to flash, we have to call hide first. Otherwi
se, the ScrollbarPainterController |
| 1254 // might think that the scrollbars are already showing and bail early. | 1254 // might think that the scrollbars are already showing and bail early. |
| 1255 [m_scrollbarPainterController.get() hideOverlayScrollers]; | 1255 [m_scrollbarPainterController.get() hideOverlayScrollers]; |
| 1256 [m_scrollbarPainterController.get() flashScrollers]; | 1256 [m_scrollbarPainterController.get() flashScrollers]; |
| 1257 } | 1257 } |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 void ScrollAnimatorMac::sendContentAreaScrolledSoon(const FloatSize& delta) | 1260 void ScrollAnimatorMac::sendContentAreaScrolledSoon(const FloatSize& delta) |
| 1261 { | 1261 { |
| 1262 m_contentAreaScrolledTimerScrollDelta = delta; | 1262 m_contentAreaScrolledTimerScrollDelta = delta; |
| 1263 | 1263 |
| 1264 if (!m_sendContentAreaScrolledTimer.isActive()) | 1264 if (!m_sendContentAreaScrolledTimer.isActive()) |
| 1265 m_sendContentAreaScrolledTimer.startOneShot(0); | 1265 m_sendContentAreaScrolledTimer.startOneShot(0, FROM_HERE); |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 void ScrollAnimatorMac::sendContentAreaScrolledTimerFired(Timer<ScrollAnimatorMa
c>*) | 1268 void ScrollAnimatorMac::sendContentAreaScrolledTimerFired(Timer<ScrollAnimatorMa
c>*) |
| 1269 { | 1269 { |
| 1270 if (supportsContentAreaScrolledInDirection()) { | 1270 if (supportsContentAreaScrolledInDirection()) { |
| 1271 [m_scrollbarPainterController.get() contentAreaScrolledInDirection:NSMak
ePoint(m_contentAreaScrolledTimerScrollDelta.width(), m_contentAreaScrolledTimer
ScrollDelta.height())]; | 1271 [m_scrollbarPainterController.get() contentAreaScrolledInDirection:NSMak
ePoint(m_contentAreaScrolledTimerScrollDelta.width(), m_contentAreaScrolledTimer
ScrollDelta.height())]; |
| 1272 m_contentAreaScrolledTimerScrollDelta = FloatSize(); | 1272 m_contentAreaScrolledTimerScrollDelta = FloatSize(); |
| 1273 } else | 1273 } else |
| 1274 [m_scrollbarPainterController.get() contentAreaScrolled]; | 1274 [m_scrollbarPainterController.get() contentAreaScrolled]; |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 void ScrollAnimatorMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb
) | 1277 void ScrollAnimatorMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb
) |
| 1278 { | 1278 { |
| 1279 IntRect rectInViewCoordinates = scrollerThumb; | 1279 IntRect rectInViewCoordinates = scrollerThumb; |
| 1280 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) | 1280 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) |
| 1281 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol
lerThumb); | 1281 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol
lerThumb); |
| 1282 | 1282 |
| 1283 if (rectInViewCoordinates == m_visibleScrollerThumbRect) | 1283 if (rectInViewCoordinates == m_visibleScrollerThumbRect) |
| 1284 return; | 1284 return; |
| 1285 | 1285 |
| 1286 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1286 m_visibleScrollerThumbRect = rectInViewCoordinates; |
| 1287 } | 1287 } |
| 1288 | 1288 |
| 1289 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { | 1289 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { |
| 1290 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); | 1290 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); |
| 1291 } | 1291 } |
| 1292 | 1292 |
| 1293 } // namespace WebCore | 1293 } // namespace WebCore |
| OLD | NEW |