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

Side by Side Diff: Source/platform/mac/ScrollAnimatorMac.mm

Issue 136333009: Move preferred scrollbar style preference change listening from renderer to browser, 3 of 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 static bool supportsContentAreaScrolledInDirection() 60 static bool supportsContentAreaScrolledInDirection()
61 { 61 {
62 static bool globalSupportsContentAreaScrolledInDirection = [NSClassFromStrin g(@"NSScrollerImpPair") instancesRespondToSelector:@selector(contentAreaScrolled InDirection:)]; 62 static bool globalSupportsContentAreaScrolledInDirection = [NSClassFromStrin g(@"NSScrollerImpPair") instancesRespondToSelector:@selector(contentAreaScrolled InDirection:)];
63 return globalSupportsContentAreaScrolledInDirection; 63 return globalSupportsContentAreaScrolledInDirection;
64 } 64 }
65 65
66 static ScrollbarThemeMacOverlayAPI* macOverlayScrollbarTheme() 66 static ScrollbarThemeMacOverlayAPI* macOverlayScrollbarTheme()
67 { 67 {
68 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isScrollbarOverlayAPIAvailable()); 68 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScrollbarThemeMacCommon::isOverlayA PIAvailable());
69 ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme(); 69 ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
70 return !scrollbarTheme->isMockTheme() ? static_cast<ScrollbarThemeMacOverlay API*>(scrollbarTheme) : 0; 70 return !scrollbarTheme->isMockTheme() ? static_cast<ScrollbarThemeMacOverlay API*>(scrollbarTheme) : 0;
71 } 71 }
72 72
73 static ScrollbarPainter scrollbarPainterForScrollbar(Scrollbar* scrollbar) 73 static ScrollbarPainter scrollbarPainterForScrollbar(Scrollbar* scrollbar)
74 { 74 {
75 if (ScrollbarThemeMacOverlayAPI* scrollbarTheme = macOverlayScrollbarTheme() ) 75 if (ScrollbarThemeMacOverlayAPI* scrollbarTheme = macOverlayScrollbarTheme() )
76 return scrollbarTheme->painterForScrollbar(scrollbar); 76 return scrollbarTheme->painterForScrollbar(scrollbar);
77 77
78 return nil; 78 return nil;
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 #if USE(RUBBER_BANDING) 593 #if USE(RUBBER_BANDING)
594 , m_scrollElasticityController(this) 594 , m_scrollElasticityController(this)
595 , m_snapRubberBandTimer(this, &ScrollAnimatorMac::snapRubberBandTimerFired) 595 , m_snapRubberBandTimer(this, &ScrollAnimatorMac::snapRubberBandTimerFired)
596 #endif 596 #endif
597 , m_haveScrolledSincePageLoad(false) 597 , m_haveScrolledSincePageLoad(false)
598 , m_needsScrollerStyleUpdate(false) 598 , m_needsScrollerStyleUpdate(false)
599 { 599 {
600 m_scrollAnimationHelperDelegate.adoptNS([[WebScrollAnimationHelperDelegate a lloc] initWithScrollAnimator:this]); 600 m_scrollAnimationHelperDelegate.adoptNS([[WebScrollAnimationHelperDelegate a lloc] initWithScrollAnimator:this]);
601 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelpe r") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); 601 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelpe r") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]);
602 602
603 if (isScrollbarOverlayAPIAvailable()) { 603 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) {
604 m_scrollbarPainterControllerDelegate.adoptNS([[WebScrollbarPainterContro llerDelegate alloc] initWithScrollableArea:scrollableArea]); 604 m_scrollbarPainterControllerDelegate.adoptNS([[WebScrollbarPainterContro llerDelegate alloc] initWithScrollableArea:scrollableArea]);
605 m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair" ) alloc] init] autorelease]; 605 m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair" ) alloc] init] autorelease];
606 [m_scrollbarPainterController.get() setDelegate:m_scrollbarPainterContro llerDelegate.get()]; 606 [m_scrollbarPainterController.get() setDelegate:m_scrollbarPainterContro llerDelegate.get()];
607 [m_scrollbarPainterController.get() setScrollerStyle:recommendedScroller Style()]; 607 [m_scrollbarPainterController.get() setScrollerStyle:ScrollbarThemeMacCo mmon::recommendedScrollerStyle()];
608 } 608 }
609 } 609 }
610 610
611 ScrollAnimatorMac::~ScrollAnimatorMac() 611 ScrollAnimatorMac::~ScrollAnimatorMac()
612 { 612 {
613 if (isScrollbarOverlayAPIAvailable()) { 613 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) {
614 BEGIN_BLOCK_OBJC_EXCEPTIONS; 614 BEGIN_BLOCK_OBJC_EXCEPTIONS;
615 [m_scrollbarPainterControllerDelegate.get() invalidate]; 615 [m_scrollbarPainterControllerDelegate.get() invalidate];
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
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 void ScrollAnimatorMac::notifyPositionChanged(const FloatSize& delta) 726 void ScrollAnimatorMac::notifyPositionChanged(const FloatSize& delta)
727 { 727 {
728 notifyContentAreaScrolled(delta); 728 notifyContentAreaScrolled(delta);
729 ScrollAnimator::notifyPositionChanged(delta); 729 ScrollAnimator::notifyPositionChanged(delta);
730 } 730 }
731 731
732 void ScrollAnimatorMac::contentAreaWillPaint() const 732 void ScrollAnimatorMac::contentAreaWillPaint() const
733 { 733 {
734 if (!scrollableArea()->scrollbarsCanBeActive()) 734 if (!scrollableArea()->scrollbarsCanBeActive())
735 return; 735 return;
736 if (isScrollbarOverlayAPIAvailable()) 736 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
737 [m_scrollbarPainterController.get() contentAreaWillDraw]; 737 [m_scrollbarPainterController.get() contentAreaWillDraw];
738 } 738 }
739 739
740 void ScrollAnimatorMac::mouseEnteredContentArea() const 740 void ScrollAnimatorMac::mouseEnteredContentArea() const
741 { 741 {
742 if (!scrollableArea()->scrollbarsCanBeActive()) 742 if (!scrollableArea()->scrollbarsCanBeActive())
743 return; 743 return;
744 if (isScrollbarOverlayAPIAvailable()) 744 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
745 [m_scrollbarPainterController.get() mouseEnteredContentArea]; 745 [m_scrollbarPainterController.get() mouseEnteredContentArea];
746 } 746 }
747 747
748 void ScrollAnimatorMac::mouseExitedContentArea() const 748 void ScrollAnimatorMac::mouseExitedContentArea() const
749 { 749 {
750 if (!scrollableArea()->scrollbarsCanBeActive()) 750 if (!scrollableArea()->scrollbarsCanBeActive())
751 return; 751 return;
752 if (isScrollbarOverlayAPIAvailable()) 752 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
753 [m_scrollbarPainterController.get() mouseExitedContentArea]; 753 [m_scrollbarPainterController.get() mouseExitedContentArea];
754 } 754 }
755 755
756 void ScrollAnimatorMac::mouseMovedInContentArea() const 756 void ScrollAnimatorMac::mouseMovedInContentArea() const
757 { 757 {
758 if (!scrollableArea()->scrollbarsCanBeActive()) 758 if (!scrollableArea()->scrollbarsCanBeActive())
759 return; 759 return;
760 if (isScrollbarOverlayAPIAvailable()) 760 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
761 [m_scrollbarPainterController.get() mouseMovedInContentArea]; 761 [m_scrollbarPainterController.get() mouseMovedInContentArea];
762 } 762 }
763 763
764 void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const 764 void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const
765 { 765 {
766 // At this time, only legacy scrollbars needs to send notifications here. 766 // At this time, only legacy scrollbars needs to send notifications here.
767 if (recommendedScrollerStyle() != NSScrollerStyleLegacy) 767 if (ScrollbarThemeMacCommon::recommendedScrollerStyle() != NSScrollerStyleLe gacy)
768 return; 768 return;
769 769
770 if (!scrollableArea()->scrollbarsCanBeActive()) 770 if (!scrollableArea()->scrollbarsCanBeActive())
771 return; 771 return;
772 772
773 if (isScrollbarOverlayAPIAvailable()) { 773 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) {
774 if (!supportsUIStateTransitionProgress()) 774 if (!supportsUIStateTransitionProgress())
775 return; 775 return;
776 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar)) 776 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar))
777 [painter mouseEnteredScroller]; 777 [painter mouseEnteredScroller];
778 } 778 }
779 } 779 }
780 780
781 void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar* scrollbar) const 781 void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar* scrollbar) const
782 { 782 {
783 // At this time, only legacy scrollbars needs to send notifications here. 783 // At this time, only legacy scrollbars needs to send notifications here.
784 if (recommendedScrollerStyle() != NSScrollerStyleLegacy) 784 if (ScrollbarThemeMacCommon::recommendedScrollerStyle() != NSScrollerStyleLe gacy)
785 return; 785 return;
786 786
787 if (!scrollableArea()->scrollbarsCanBeActive()) 787 if (!scrollableArea()->scrollbarsCanBeActive())
788 return; 788 return;
789 789
790 if (isScrollbarOverlayAPIAvailable()) { 790 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) {
791 if (!supportsUIStateTransitionProgress()) 791 if (!supportsUIStateTransitionProgress())
792 return; 792 return;
793 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar)) 793 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar))
794 [painter mouseExitedScroller]; 794 [painter mouseExitedScroller];
795 } 795 }
796 } 796 }
797 797
798 void ScrollAnimatorMac::willStartLiveResize() 798 void ScrollAnimatorMac::willStartLiveResize()
799 { 799 {
800 if (!scrollableArea()->scrollbarsCanBeActive()) 800 if (!scrollableArea()->scrollbarsCanBeActive())
801 return; 801 return;
802 if (isScrollbarOverlayAPIAvailable()) 802 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
803 [m_scrollbarPainterController.get() startLiveResize]; 803 [m_scrollbarPainterController.get() startLiveResize];
804 } 804 }
805 805
806 void ScrollAnimatorMac::contentsResized() const 806 void ScrollAnimatorMac::contentsResized() const
807 { 807 {
808 if (!scrollableArea()->scrollbarsCanBeActive()) 808 if (!scrollableArea()->scrollbarsCanBeActive())
809 return; 809 return;
810 if (isScrollbarOverlayAPIAvailable()) 810 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
811 [m_scrollbarPainterController.get() contentAreaDidResize]; 811 [m_scrollbarPainterController.get() contentAreaDidResize];
812 } 812 }
813 813
814 void ScrollAnimatorMac::willEndLiveResize() 814 void ScrollAnimatorMac::willEndLiveResize()
815 { 815 {
816 if (!scrollableArea()->scrollbarsCanBeActive()) 816 if (!scrollableArea()->scrollbarsCanBeActive())
817 return; 817 return;
818 if (isScrollbarOverlayAPIAvailable()) 818 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
819 [m_scrollbarPainterController.get() endLiveResize]; 819 [m_scrollbarPainterController.get() endLiveResize];
820 } 820 }
821 821
822 void ScrollAnimatorMac::contentAreaDidShow() const 822 void ScrollAnimatorMac::contentAreaDidShow() const
823 { 823 {
824 if (!scrollableArea()->scrollbarsCanBeActive()) 824 if (!scrollableArea()->scrollbarsCanBeActive())
825 return; 825 return;
826 if (isScrollbarOverlayAPIAvailable()) 826 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
827 [m_scrollbarPainterController.get() windowOrderedIn]; 827 [m_scrollbarPainterController.get() windowOrderedIn];
828 } 828 }
829 829
830 void ScrollAnimatorMac::contentAreaDidHide() const 830 void ScrollAnimatorMac::contentAreaDidHide() const
831 { 831 {
832 if (!scrollableArea()->scrollbarsCanBeActive()) 832 if (!scrollableArea()->scrollbarsCanBeActive())
833 return; 833 return;
834 if (isScrollbarOverlayAPIAvailable()) 834 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
835 [m_scrollbarPainterController.get() windowOrderedOut]; 835 [m_scrollbarPainterController.get() windowOrderedOut];
836 } 836 }
837 837
838 void ScrollAnimatorMac::didBeginScrollGesture() const 838 void ScrollAnimatorMac::didBeginScrollGesture() const
839 { 839 {
840 if (!scrollableArea()->scrollbarsCanBeActive()) 840 if (!scrollableArea()->scrollbarsCanBeActive())
841 return; 841 return;
842 if (isScrollbarOverlayAPIAvailable()) 842 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
843 [m_scrollbarPainterController.get() beginScrollGesture]; 843 [m_scrollbarPainterController.get() beginScrollGesture];
844 } 844 }
845 845
846 void ScrollAnimatorMac::didEndScrollGesture() const 846 void ScrollAnimatorMac::didEndScrollGesture() const
847 { 847 {
848 if (!scrollableArea()->scrollbarsCanBeActive()) 848 if (!scrollableArea()->scrollbarsCanBeActive())
849 return; 849 return;
850 if (isScrollbarOverlayAPIAvailable()) 850 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
851 [m_scrollbarPainterController.get() endScrollGesture]; 851 [m_scrollbarPainterController.get() endScrollGesture];
852 } 852 }
853 853
854 void ScrollAnimatorMac::mayBeginScrollGesture() const 854 void ScrollAnimatorMac::mayBeginScrollGesture() const
855 { 855 {
856 if (!scrollableArea()->scrollbarsCanBeActive()) 856 if (!scrollableArea()->scrollbarsCanBeActive())
857 return; 857 return;
858 if (!isScrollbarOverlayAPIAvailable()) 858 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
859 return; 859 return;
860 860
861 [m_scrollbarPainterController.get() beginScrollGesture]; 861 [m_scrollbarPainterController.get() beginScrollGesture];
862 [m_scrollbarPainterController.get() contentAreaScrolled]; 862 [m_scrollbarPainterController.get() contentAreaScrolled];
863 } 863 }
864 864
865 void ScrollAnimatorMac::finishCurrentScrollAnimations() 865 void ScrollAnimatorMac::finishCurrentScrollAnimations()
866 { 866 {
867 if (isScrollbarOverlayAPIAvailable()) { 867 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) {
868 [m_scrollbarPainterController.get() hideOverlayScrollers]; 868 [m_scrollbarPainterController.get() hideOverlayScrollers];
869 } 869 }
870 } 870 }
871 871
872 void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar) 872 void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
873 { 873 {
874 if (!isScrollbarOverlayAPIAvailable()) 874 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
875 return; 875 return;
876 876
877 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 877 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
878 if (!painter) 878 if (!painter)
879 return; 879 return;
880 880
881 ASSERT(!m_verticalScrollbarPainterDelegate); 881 ASSERT(!m_verticalScrollbarPainterDelegate);
882 m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate all oc] initWithScrollbar:scrollbar]); 882 m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate all oc] initWithScrollbar:scrollbar]);
883 883
884 [painter setDelegate:m_verticalScrollbarPainterDelegate.get()]; 884 [painter setDelegate:m_verticalScrollbarPainterDelegate.get()];
885 [m_scrollbarPainterController.get() setVerticalScrollerImp:painter]; 885 [m_scrollbarPainterController.get() setVerticalScrollerImp:painter];
886 if (scrollableArea()->inLiveResize()) 886 if (scrollableArea()->inLiveResize())
887 [painter setKnobAlpha:1]; 887 [painter setKnobAlpha:1];
888 } 888 }
889 889
890 void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar) 890 void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
891 { 891 {
892 if (!isScrollbarOverlayAPIAvailable()) 892 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
893 return; 893 return;
894 894
895 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 895 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
896 if (!painter) 896 if (!painter)
897 return; 897 return;
898 898
899 ASSERT(m_verticalScrollbarPainterDelegate); 899 ASSERT(m_verticalScrollbarPainterDelegate);
900 [m_verticalScrollbarPainterDelegate.get() invalidate]; 900 [m_verticalScrollbarPainterDelegate.get() invalidate];
901 m_verticalScrollbarPainterDelegate = nullptr; 901 m_verticalScrollbarPainterDelegate = nullptr;
902 902
903 [painter setDelegate:nil]; 903 [painter setDelegate:nil];
904 [m_scrollbarPainterController.get() setVerticalScrollerImp:nil]; 904 [m_scrollbarPainterController.get() setVerticalScrollerImp:nil];
905 } 905 }
906 906
907 void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar) 907 void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
908 { 908 {
909 if (!isScrollbarOverlayAPIAvailable()) 909 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
910 return; 910 return;
911 911
912 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 912 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
913 if (!painter) 913 if (!painter)
914 return; 914 return;
915 915
916 ASSERT(!m_horizontalScrollbarPainterDelegate); 916 ASSERT(!m_horizontalScrollbarPainterDelegate);
917 m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate a lloc] initWithScrollbar:scrollbar]); 917 m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate a lloc] initWithScrollbar:scrollbar]);
918 918
919 [painter setDelegate:m_horizontalScrollbarPainterDelegate.get()]; 919 [painter setDelegate:m_horizontalScrollbarPainterDelegate.get()];
920 [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter]; 920 [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter];
921 if (scrollableArea()->inLiveResize()) 921 if (scrollableArea()->inLiveResize())
922 [painter setKnobAlpha:1]; 922 [painter setKnobAlpha:1];
923 } 923 }
924 924
925 void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar) 925 void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
926 { 926 {
927 if (!isScrollbarOverlayAPIAvailable()) 927 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
928 return; 928 return;
929 929
930 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 930 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
931 if (!painter) 931 if (!painter)
932 return; 932 return;
933 933
934 ASSERT(m_horizontalScrollbarPainterDelegate); 934 ASSERT(m_horizontalScrollbarPainterDelegate);
935 [m_horizontalScrollbarPainterDelegate.get() invalidate]; 935 [m_horizontalScrollbarPainterDelegate.get() invalidate];
936 m_horizontalScrollbarPainterDelegate = nullptr; 936 m_horizontalScrollbarPainterDelegate = nullptr;
937 937
938 [painter setDelegate:nil]; 938 [painter setDelegate:nil];
939 [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil]; 939 [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil];
940 } 940 }
941 941
942 bool ScrollAnimatorMac::shouldScrollbarParticipateInHitTesting(Scrollbar* scroll bar) 942 bool ScrollAnimatorMac::shouldScrollbarParticipateInHitTesting(Scrollbar* scroll bar)
943 { 943 {
944 // Non-overlay scrollbars should always participate in hit testing. 944 // Non-overlay scrollbars should always participate in hit testing.
945 if (recommendedScrollerStyle() != NSScrollerStyleOverlay) 945 if (ScrollbarThemeMacCommon::recommendedScrollerStyle() != NSScrollerStyleOv erlay)
946 return true; 946 return true;
947 947
948 if (!isScrollbarOverlayAPIAvailable()) 948 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
949 return true; 949 return true;
950 950
951 if (scrollbar->isAlphaLocked()) 951 if (scrollbar->isAlphaLocked())
952 return true; 952 return true;
953 953
954 // Overlay scrollbars should participate in hit testing whenever they are at all visible. 954 // Overlay scrollbars should participate in hit testing whenever they are at all visible.
955 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 955 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
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 (!isScrollbarOverlayAPIAvailable()) 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
977 if (isScrollbarOverlayAPIAvailable()) { 977 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) {
978 if (scrollbarPaintTimerIsActive()) 978 if (scrollbarPaintTimerIsActive())
979 stopScrollbarPaintTimer(); 979 stopScrollbarPaintTimer();
980 [m_horizontalScrollbarPainterDelegate.get() cancelAnimations]; 980 [m_horizontalScrollbarPainterDelegate.get() cancelAnimations];
981 [m_verticalScrollbarPainterDelegate.get() cancelAnimations]; 981 [m_verticalScrollbarPainterDelegate.get() cancelAnimations];
982 } 982 }
983 } 983 }
984 984
985 void ScrollAnimatorMac::handleWheelEventPhase(PlatformWheelEventPhase phase) 985 void ScrollAnimatorMac::handleWheelEventPhase(PlatformWheelEventPhase phase)
986 { 986 {
987 // This may not have been set to true yet if the wheel event was handled by the ScrollingTree, 987 // This may not have been set to true yet if the wheel event was handled by the ScrollingTree,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
1160 } 1160 }
1161 #endif 1161 #endif
1162 1162
1163 void ScrollAnimatorMac::setIsActive() 1163 void ScrollAnimatorMac::setIsActive()
1164 { 1164 {
1165 if (!isScrollbarOverlayAPIAvailable()) 1165 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
1166 return; 1166 return;
1167 1167
1168 if (!m_needsScrollerStyleUpdate) 1168 if (!m_needsScrollerStyleUpdate)
1169 return; 1169 return;
1170 1170
1171 updateScrollerStyle(); 1171 updateScrollerStyle();
1172 } 1172 }
1173 1173
1174 void ScrollAnimatorMac::updateScrollerStyle() 1174 void ScrollAnimatorMac::updateScrollerStyle()
1175 { 1175 {
1176 if (!isScrollbarOverlayAPIAvailable()) 1176 if (!ScrollbarThemeMacCommon::isOverlayAPIAvailable())
1177 return; 1177 return;
1178 1178
1179 if (!scrollableArea()->scrollbarsCanBeActive()) { 1179 if (!scrollableArea()->scrollbarsCanBeActive()) {
1180 m_needsScrollerStyleUpdate = true; 1180 m_needsScrollerStyleUpdate = true;
1181 return; 1181 return;
1182 } 1182 }
1183 1183
1184 ScrollbarThemeMacOverlayAPI* macTheme = macOverlayScrollbarTheme(); 1184 ScrollbarThemeMacOverlayAPI* macTheme = macOverlayScrollbarTheme();
1185 if (!macTheme) { 1185 if (!macTheme) {
1186 m_needsScrollerStyleUpdate = false; 1186 m_needsScrollerStyleUpdate = false;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (isScrollbarOverlayAPIAvailable()) { 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;
(...skipping 17 matching lines...) Expand all
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 isScrollbarOverlayAPIAvailable(); 1290 return ScrollbarThemeMacCommon::isOverlayAPIAvailable();
1291 } 1291 }
1292 1292
1293 } // namespace WebCore 1293 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/mac/NSScrollerImpDetails.mm ('k') | Source/platform/scroll/ScrollbarThemeMacCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698