Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm

Issue 7134051: Merge 88396 - 2011-06-08 Sailesh Agrawal <sail@chromium.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 , m_lastMomemtumScrollTimestamp(0) 509 , m_lastMomemtumScrollTimestamp(0)
510 , m_startTime(0) 510 , m_startTime(0)
511 , m_snapRubberBandTimer(this, &ScrollAnimatorChromiumMac::snapRubberBandTime rFired) 511 , m_snapRubberBandTimer(this, &ScrollAnimatorChromiumMac::snapRubberBandTime rFired)
512 #endif 512 #endif
513 , m_drawingIntoLayer(false) 513 , m_drawingIntoLayer(false)
514 , m_haveScrolledSincePageLoad(false) 514 , m_haveScrolledSincePageLoad(false)
515 { 515 {
516 m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate allo c] initWithScrollAnimator:this]); 516 m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate allo c] initWithScrollAnimator:this]);
517 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelpe r") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); 517 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelpe r") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]);
518 518
519 #if USE(WK_SCROLLBAR_PAINTER) 519 if (isScrollbarOverlayAPIAvailable()) {
520 m_scrollbarPainterControllerDelegate.adoptNS([[ScrollbarPainterControllerDel egate alloc] initWithScrollAnimator:this]); 520 m_scrollbarPainterControllerDelegate.adoptNS([[ScrollbarPainterControlle rDelegate alloc] initWithScrollAnimator:this]);
521 m_scrollbarPainterController = wkMakeScrollbarPainterController(m_scrollbarP ainterControllerDelegate.get()); 521 m_scrollbarPainterController = wkMakeScrollbarPainterController(m_scroll barPainterControllerDelegate.get());
522 m_scrollbarPainterDelegate.adoptNS([[ScrollbarPainterDelegate alloc] initWit hScrollAnimator:this]); 522 m_scrollbarPainterDelegate.adoptNS([[ScrollbarPainterDelegate alloc] ini tWithScrollAnimator:this]);
523 #endif 523 }
524 } 524 }
525 525
526 ScrollAnimatorChromiumMac::~ScrollAnimatorChromiumMac() 526 ScrollAnimatorChromiumMac::~ScrollAnimatorChromiumMac()
527 { 527 {
528 #if USE(WK_SCROLLBAR_PAINTER) 528 if (isScrollbarOverlayAPIAvailable()) {
529 [m_scrollbarPainterControllerDelegate.get() scrollAnimatorDestroyed]; 529 [m_scrollbarPainterControllerDelegate.get() scrollAnimatorDestroyed];
530 [(id)m_scrollbarPainterController.get() setDelegate:nil]; 530 [(id)m_scrollbarPainterController.get() setDelegate:nil];
531 [m_scrollbarPainterDelegate.get() scrollAnimatorDestroyed]; 531 [m_scrollbarPainterDelegate.get() scrollAnimatorDestroyed];
532 [m_scrollAnimationHelperDelegate.get() scrollAnimatorDestroyed]; 532 [m_scrollAnimationHelperDelegate.get() scrollAnimatorDestroyed];
533 #endif 533 }
534 } 534 }
535 535
536 bool ScrollAnimatorChromiumMac::scroll(ScrollbarOrientation orientation, ScrollG ranularity granularity, float step, float multiplier) 536 bool ScrollAnimatorChromiumMac::scroll(ScrollbarOrientation orientation, ScrollG ranularity granularity, float step, float multiplier)
537 { 537 {
538 m_haveScrolledSincePageLoad = true; 538 m_haveScrolledSincePageLoad = true;
539 539
540 #if !ENABLE(SMOOTH_SCROLLING) 540 #if !ENABLE(SMOOTH_SCROLLING)
541 return ScrollAnimator::scroll(orientation, granularity, step, multiplier); 541 return ScrollAnimator::scroll(orientation, granularity, step, multiplier);
542 #endif 542 #endif
543 543
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 625
626 if (newPosY == m_currentPosY) 626 if (newPosY == m_currentPosY)
627 return; 627 return;
628 628
629 m_currentPosY = newPosY; 629 m_currentPosY = newPosY;
630 notityPositionChanged(); 630 notityPositionChanged();
631 } 631 }
632 632
633 void ScrollAnimatorChromiumMac::notityPositionChanged() 633 void ScrollAnimatorChromiumMac::notityPositionChanged()
634 { 634 {
635 #if USE(WK_SCROLLBAR_PAINTER) 635 if (isScrollbarOverlayAPIAvailable())
636 wkContentAreaScrolled(m_scrollbarPainterController.get()); 636 wkContentAreaScrolled(m_scrollbarPainterController.get());
637 #endif
638 ScrollAnimator::notityPositionChanged(); 637 ScrollAnimator::notityPositionChanged();
639 } 638 }
640 639
641 void ScrollAnimatorChromiumMac::contentAreaWillPaint() const 640 void ScrollAnimatorChromiumMac::contentAreaWillPaint() const
642 { 641 {
643 #if USE(WK_SCROLLBAR_PAINTER) 642 if (isScrollbarOverlayAPIAvailable())
644 wkContentAreaWillPaint(m_scrollbarPainterController.get()); 643 wkContentAreaWillPaint(m_scrollbarPainterController.get());
645 #endif
646 } 644 }
647 645
648 void ScrollAnimatorChromiumMac::mouseEnteredContentArea() const 646 void ScrollAnimatorChromiumMac::mouseEnteredContentArea() const
649 { 647 {
650 #if USE(WK_SCROLLBAR_PAINTER) 648 if (isScrollbarOverlayAPIAvailable())
651 wkMouseEnteredContentArea(m_scrollbarPainterController.get()); 649 wkMouseEnteredContentArea(m_scrollbarPainterController.get());
652 #endif
653 } 650 }
654 651
655 void ScrollAnimatorChromiumMac::mouseExitedContentArea() const 652 void ScrollAnimatorChromiumMac::mouseExitedContentArea() const
656 { 653 {
657 #if USE(WK_SCROLLBAR_PAINTER) 654 if (isScrollbarOverlayAPIAvailable())
658 wkMouseExitedContentArea(m_scrollbarPainterController.get()); 655 wkMouseExitedContentArea(m_scrollbarPainterController.get());
659 #endif
660 } 656 }
661 657
662 void ScrollAnimatorChromiumMac::mouseMovedInContentArea() const 658 void ScrollAnimatorChromiumMac::mouseMovedInContentArea() const
663 { 659 {
664 #if USE(WK_SCROLLBAR_PAINTER) 660 if (isScrollbarOverlayAPIAvailable())
665 wkMouseMovedInContentArea(m_scrollbarPainterController.get()); 661 wkMouseMovedInContentArea(m_scrollbarPainterController.get());
666 #endif
667 } 662 }
668 663
669 void ScrollAnimatorChromiumMac::willStartLiveResize() 664 void ScrollAnimatorChromiumMac::willStartLiveResize()
670 { 665 {
671 #if USE(WK_SCROLLBAR_PAINTER) 666 if (isScrollbarOverlayAPIAvailable())
672 wkWillStartLiveResize(m_scrollbarPainterController.get()); 667 wkWillStartLiveResize(m_scrollbarPainterController.get());
673 #endif
674 } 668 }
675 669
676 void ScrollAnimatorChromiumMac::contentsResized() const 670 void ScrollAnimatorChromiumMac::contentsResized() const
677 { 671 {
678 #if USE(WK_SCROLLBAR_PAINTER) 672 if (isScrollbarOverlayAPIAvailable())
679 wkContentAreaResized(m_scrollbarPainterController.get()); 673 wkContentAreaResized(m_scrollbarPainterController.get());
680 #endif
681 } 674 }
682 675
683 void ScrollAnimatorChromiumMac::willEndLiveResize() 676 void ScrollAnimatorChromiumMac::willEndLiveResize()
684 { 677 {
685 #if USE(WK_SCROLLBAR_PAINTER) 678 if (isScrollbarOverlayAPIAvailable())
686 wkWillEndLiveResize(m_scrollbarPainterController.get()); 679 wkWillEndLiveResize(m_scrollbarPainterController.get());
687 #endif
688 } 680 }
689 681
690 void ScrollAnimatorChromiumMac::contentAreaDidShow() const 682 void ScrollAnimatorChromiumMac::contentAreaDidShow() const
691 { 683 {
692 #if USE(WK_SCROLLBAR_PAINTER) 684 if (isScrollbarOverlayAPIAvailable())
693 wkContentAreaDidShow(m_scrollbarPainterController.get()); 685 wkContentAreaDidShow(m_scrollbarPainterController.get());
694 #endif
695 } 686 }
696 687
697 void ScrollAnimatorChromiumMac::contentAreaDidHide() const 688 void ScrollAnimatorChromiumMac::contentAreaDidHide() const
698 { 689 {
699 #if USE(WK_SCROLLBAR_PAINTER) 690 if (isScrollbarOverlayAPIAvailable())
700 wkContentAreaDidHide(m_scrollbarPainterController.get()); 691 wkContentAreaDidHide(m_scrollbarPainterController.get());
701 #endif
702 } 692 }
703 693
704 void ScrollAnimatorChromiumMac::didBeginScrollGesture() const 694 void ScrollAnimatorChromiumMac::didBeginScrollGesture() const
705 { 695 {
706 #if USE(WK_SCROLLBAR_PAINTER) 696 if (isScrollbarOverlayAPIAvailable())
707 wkDidBeginScrollGesture(m_scrollbarPainterController.get()); 697 wkDidBeginScrollGesture(m_scrollbarPainterController.get());
708 #endif
709 } 698 }
710 699
711 void ScrollAnimatorChromiumMac::didEndScrollGesture() const 700 void ScrollAnimatorChromiumMac::didEndScrollGesture() const
712 { 701 {
713 #if USE(WK_SCROLLBAR_PAINTER) 702 if (isScrollbarOverlayAPIAvailable())
714 wkDidEndScrollGesture(m_scrollbarPainterController.get()); 703 wkDidEndScrollGesture(m_scrollbarPainterController.get());
715 #endif
716 } 704 }
717 705
718 void ScrollAnimatorChromiumMac::didAddVerticalScrollbar(Scrollbar* scrollbar) 706 void ScrollAnimatorChromiumMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
719 { 707 {
720 #if USE(WK_SCROLLBAR_PAINTER) 708 if (isScrollbarOverlayAPIAvailable()) {
721 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumM ac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar); 709 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChrom iumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar) ;
722 wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get()); 710 wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get()) ;
723 wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter , false); 711 wkSetPainterForPainterController(m_scrollbarPainterController.get(), pai nter, false);
724 if (scrollableArea()->inLiveResize()) 712 if (scrollableArea()->inLiveResize())
725 wkSetScrollbarPainterKnobAlpha(painter, 1); 713 wkSetScrollbarPainterKnobAlpha(painter, 1);
726 #else 714 }
727 UNUSED_PARAM(scrollbar);
728 #endif
729 } 715 }
730 716
731 void ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar ) 717 void ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar )
732 { 718 {
733 #if USE(WK_SCROLLBAR_PAINTER) 719 if (isScrollbarOverlayAPIAvailable()) {
734 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumM ac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar); 720 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChrom iumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar) ;
735 wkScrollbarPainterSetDelegate(painter, nil); 721 wkScrollbarPainterSetDelegate(painter, nil);
736 wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, fa lse); 722 wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil , false);
737 #else 723 }
738 UNUSED_PARAM(scrollbar);
739 #endif
740 } 724 }
741 725
742 void ScrollAnimatorChromiumMac::didAddHorizontalScrollbar(Scrollbar* scrollbar) 726 void ScrollAnimatorChromiumMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
743 { 727 {
744 #if USE(WK_SCROLLBAR_PAINTER) 728 if (isScrollbarOverlayAPIAvailable()) {
745 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumM ac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar); 729 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChrom iumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar) ;
746 wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get()); 730 wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get()) ;
747 wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter , true); 731 wkSetPainterForPainterController(m_scrollbarPainterController.get(), pai nter, true);
748 if (scrollableArea()->inLiveResize()) 732 if (scrollableArea()->inLiveResize())
749 wkSetScrollbarPainterKnobAlpha(painter, 1); 733 wkSetScrollbarPainterKnobAlpha(painter, 1);
750 #else 734 }
751 UNUSED_PARAM(scrollbar);
752 #endif
753 } 735 }
754 736
755 void ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar(Scrollbar* scrollb ar) 737 void ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar(Scrollbar* scrollb ar)
756 { 738 {
757 #if USE(WK_SCROLLBAR_PAINTER) 739 if (isScrollbarOverlayAPIAvailable()) {
758 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumM ac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar); 740 WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChrom iumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar) ;
759 wkScrollbarPainterSetDelegate(painter, nil); 741 wkScrollbarPainterSetDelegate(painter, nil);
760 wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, tr ue); 742 wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil , true);
761 #else 743 }
762 UNUSED_PARAM(scrollbar);
763 #endif
764 } 744 }
765 745
766 void ScrollAnimatorChromiumMac::cancelAnimations() 746 void ScrollAnimatorChromiumMac::cancelAnimations()
767 { 747 {
768 m_haveScrolledSincePageLoad = false; 748 m_haveScrolledSincePageLoad = false;
769 749
770 #if USE(WK_SCROLLBAR_PAINTER) 750 if (isScrollbarOverlayAPIAvailable()) {
771 if (scrollbarPaintTimerIsActive()) 751 if (scrollbarPaintTimerIsActive())
772 stopScrollbarPaintTimer(); 752 stopScrollbarPaintTimer();
773 [m_scrollbarPainterDelegate.get() cancelAnimations]; 753 [m_scrollbarPainterDelegate.get() cancelAnimations];
774 #endif 754 }
775 } 755 }
776 756
777 #if ENABLE(RUBBER_BANDING) 757 #if ENABLE(RUBBER_BANDING)
778 758
779 static const float scrollVelocityZeroingTimeout = 0.10f; 759 static const float scrollVelocityZeroingTimeout = 0.10f;
780 static const float rubberbandStiffness = 20; 760 static const float rubberbandStiffness = 20;
781 static const float rubberbandDirectionLockStretchRatio = 1; 761 static const float rubberbandDirectionLockStretchRatio = 1;
782 static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10; 762 static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
783 static const float rubberbandAmplitude = 0.31f; 763 static const float rubberbandAmplitude = 0.31f;
784 static const float rubberbandPeriod = 1.6f; 764 static const float rubberbandPeriod = 1.6f;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol lerThumb); 1215 rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrol lerThumb);
1236 1216
1237 if (rectInViewCoordinates == m_visibleScrollerThumbRect) 1217 if (rectInViewCoordinates == m_visibleScrollerThumbRect)
1238 return; 1218 return;
1239 1219
1240 m_scrollableArea->setVisibleScrollerThumbRect(rectInViewCoordinates); 1220 m_scrollableArea->setVisibleScrollerThumbRect(rectInViewCoordinates);
1241 m_visibleScrollerThumbRect = rectInViewCoordinates; 1221 m_visibleScrollerThumbRect = rectInViewCoordinates;
1242 } 1222 }
1243 1223
1244 } // namespace WebCore 1224 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698