Remove unnecessary respondsToSelector checks for methods that exist on all supported...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Feb 2016 03:20:17 +0000 (03:20 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Feb 2016 03:20:17 +0000 (03:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153970

Reviewed by Dan Bernstein.

-[NSScrollerImp mouseEnteredScroller], -[NSScrollerImp expansionTransitionProgress],
-[NSScrollerImpPair contentAreaScrolledInDirection:], and -[NSScrollerImp setExpanded:]
are now available on all supported OS's. No need to check for them.

* platform/mac/ScrollAnimatorMac.mm:
(macScrollbarTheme):
(-[WebScrollbarPainterDelegate scrollerImp:animateUIStateTransitionWithDuration:]):
(-[WebScrollbarPainterDelegate scrollerImp:animateExpansionTransitionWithDuration:]):
(WebCore::ScrollAnimatorMac::mouseEnteredScrollbar):
(WebCore::ScrollAnimatorMac::mouseExitedScrollbar):
(WebCore::ScrollAnimatorMac::sendContentAreaScrolled):
(WebCore::ScrollAnimatorMac::sendContentAreaScrolledTimerFired):
(supportsUIStateTransitionProgress): Deleted.
(supportsExpansionTransitionProgress): Deleted.
(supportsContentAreaScrolledInDirection): Deleted.
* platform/mac/ScrollbarThemeMac.mm:
(+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
(+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
(WebCore::ScrollbarThemeMac::scrollbarThickness):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.mm

index c696e9d..0639104 100644 (file)
@@ -1,5 +1,32 @@
 2016-02-07  Sam Weinig  <sam@webkit.org>
 
+        Remove unnecessary respondsToSelector checks for methods that exist on all supported platforms
+        https://bugs.webkit.org/show_bug.cgi?id=153970
+
+        Reviewed by Dan Bernstein.
+
+        -[NSScrollerImp mouseEnteredScroller], -[NSScrollerImp expansionTransitionProgress],
+        -[NSScrollerImpPair contentAreaScrolledInDirection:], and -[NSScrollerImp setExpanded:]
+        are now available on all supported OS's. No need to check for them.
+
+        * platform/mac/ScrollAnimatorMac.mm:
+        (macScrollbarTheme):
+        (-[WebScrollbarPainterDelegate scrollerImp:animateUIStateTransitionWithDuration:]):
+        (-[WebScrollbarPainterDelegate scrollerImp:animateExpansionTransitionWithDuration:]):
+        (WebCore::ScrollAnimatorMac::mouseEnteredScrollbar):
+        (WebCore::ScrollAnimatorMac::mouseExitedScrollbar):
+        (WebCore::ScrollAnimatorMac::sendContentAreaScrolled):
+        (WebCore::ScrollAnimatorMac::sendContentAreaScrolledTimerFired):
+        (supportsUIStateTransitionProgress): Deleted.
+        (supportsExpansionTransitionProgress): Deleted.
+        (supportsContentAreaScrolledInDirection): Deleted.
+        * platform/mac/ScrollbarThemeMac.mm:
+        (+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
+        (+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
+        (WebCore::ScrollbarThemeMac::scrollbarThickness):
+
+2016-02-07  Sam Weinig  <sam@webkit.org>
+
         Use modern SPI header idiom for NSScrollerImp and NSScrollerImpPair
         https://bugs.webkit.org/show_bug.cgi?id=153969
 
index 2dd5349..b5b4100 100644 (file)
 
 using namespace WebCore;
 
-static bool supportsUIStateTransitionProgress()
-{
-    // FIXME: This is temporary until all platforms that support ScrollbarPainter support this part of the API.
-    static const bool globalSupportsUIStateTransitionProgress = [[NSScrollerImp class] instancesRespondToSelector:@selector(mouseEnteredScroller)];
-    return globalSupportsUIStateTransitionProgress;
-}
-
-static bool supportsExpansionTransitionProgress()
-{
-    static const bool globalSupportsExpansionTransitionProgress = [[NSScrollerImp class] instancesRespondToSelector:@selector(expansionTransitionProgress)];
-    return globalSupportsExpansionTransitionProgress;
-}
-
-static bool supportsContentAreaScrolledInDirection()
-{
-    static const bool globalSupportsContentAreaScrolledInDirection = [[NSScrollerImpPair class] instancesRespondToSelector:@selector(contentAreaScrolledInDirection:)];
-    return globalSupportsContentAreaScrolledInDirection;
-}
-
 static ScrollbarThemeMac* macScrollbarTheme()
 {
     ScrollbarTheme& scrollbarTheme = ScrollbarTheme::theme();
@@ -556,9 +537,6 @@ enum FeatureToAnimate {
     if (!_scrollbar)
         return;
 
-    if (!supportsUIStateTransitionProgress())
-        return;
-
     ASSERT(scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
 
     ScrollbarPainter scrollbarPainter = (ScrollbarPainter)scrollerImp;
@@ -590,9 +568,6 @@ enum FeatureToAnimate {
     if (!_scrollbar)
         return;
 
-    if (!supportsExpansionTransitionProgress())
-        return;
-
     ASSERT(scrollerImp == scrollbarPainterForScrollbar(*_scrollbar));
 
     ScrollbarPainter scrollbarPainter = (ScrollbarPainter)scrollerImp;
@@ -840,8 +815,6 @@ void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const
     if ([m_scrollbarPainterController overlayScrollerStateIsLocked])
         return;
 
-    if (!supportsUIStateTransitionProgress())
-        return;
     if (ScrollbarPainter painter = scrollbarPainterForScrollbar(*scrollbar))
         [painter mouseEnteredScroller];
 }
@@ -855,8 +828,6 @@ void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar* scrollbar) const
     if ([m_scrollbarPainterController overlayScrollerStateIsLocked])
         return;
 
-    if (!supportsUIStateTransitionProgress())
-        return;
     if (ScrollbarPainter painter = scrollbarPainterForScrollbar(*scrollbar))
         [painter mouseExitedScroller];
 }
@@ -1403,10 +1374,7 @@ void ScrollAnimatorMac::sendContentAreaScrolledSoon(const FloatSize& delta)
 
 void ScrollAnimatorMac::sendContentAreaScrolled(const FloatSize& delta)
 {
-    if (supportsContentAreaScrolledInDirection())
-        [m_scrollbarPainterController contentAreaScrolledInDirection:NSMakePoint(delta.width(), delta.height())];
-    else
-        [m_scrollbarPainterController contentAreaScrolled];
+    [m_scrollbarPainterController contentAreaScrolledInDirection:NSMakePoint(delta.width(), delta.height())];
 }
 
 void ScrollAnimatorMac::sendContentAreaScrolledTimerFired()
index 574ad59..2a50f3a 100644 (file)
@@ -68,14 +68,14 @@ static ScrollbarPainterMap* scrollbarMap()
 }
 
 + (void)registerAsObserver;
-+ (void)appearancePrefsChanged:(NSNotification*)theNotification;
-+ (void)behaviorPrefsChanged:(NSNotification*)theNotification;
++ (void)appearancePrefsChanged:(NSNotification *)theNotification;
++ (void)behaviorPrefsChanged:(NSNotification *)theNotification;
 
 @end
 
 @implementation WebScrollbarPrefsObserver
 
-+ (void)appearancePrefsChanged:(NSNotification*)unusedNotification
++ (void)appearancePrefsChanged:(NSNotification *)unusedNotification
 {
     UNUSED_PARAM(unusedNotification);
 
@@ -93,7 +93,7 @@ static ScrollbarPainterMap* scrollbarMap()
     }
 }
 
-+ (void)behaviorPrefsChanged:(NSNotification*)unusedNotification
++ (void)behaviorPrefsChanged:(NSNotification *)unusedNotification
 {
     UNUSED_PARAM(unusedNotification);
 
@@ -136,13 +136,6 @@ static bool gUsesOverlayScrollbars = false;
 
 static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd;
 
-static bool supportsExpandedScrollbars()
-{
-    // FIXME: This is temporary until all platforms that support ScrollbarPainter support this part of the API.
-    static bool globalSupportsExpandedScrollbars = [[NSScrollerImp class] instancesRespondToSelector:@selector(setExpanded:)];
-    return globalSupportsExpandedScrollbars;
-}
-
 static NSControlSize scrollbarControlSizeToNSControlSize(ScrollbarControlSize controlSize)
 {
     switch (controlSize) {
@@ -226,8 +219,7 @@ int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     ScrollbarPainter scrollbarPainter = [NSScrollerImp scrollerImpWithStyle:recommendedScrollerStyle() controlSize:scrollbarControlSizeToNSControlSize(controlSize) horizontal:NO replacingScrollerImp:nil];
-    if (supportsExpandedScrollbars())
-        [scrollbarPainter setExpanded:YES];
+    [scrollbarPainter setExpanded:YES];
     return [scrollbarPainter trackBoxWidth];
     END_BLOCK_OBJC_EXCEPTIONS;
 }