Title: [88396] trunk/Source
Revision
88396
Author
commit-qu...@webkit.org
Date
2011-06-08 15:24:38 -0700 (Wed, 08 Jun 2011)

Log Message

2011-06-08  Sailesh Agrawal  <s...@chromium.org>

        Reviewed by Mihai Parparita.

        Chromium Mac: Enable overlay scrollbars
        https://bugs.webkit.org/show_bug.cgi?id=59756

        Enable WTF_USE_WK_SCROLLBAR_PAINTER for Chromium Mac. This allows us to use overlay scrollbars on future versions of Mac OS X.

        * wtf/Platform.h:
2011-06-08  Sailesh Agrawal  <s...@chromium.org>

        Reviewed by Mihai Parparita.

        Chromium Mac: Enable overlay scrollbars
        https://bugs.webkit.org/show_bug.cgi?id=59756

        Sync ScrollbarThemeChromiumMac.mm/.h with ScrollbarThemeMac.mm to pick up support for overlay scrollbars. The only changes are renaming ScrollbarThemeMac to ScrollbarThemeChromiumMac and using runtime checks instead of #ifdef's.

        No new tests, since this code is only enabled on future versions of Mac OS X.

        * platform/chromium/ScrollAnimatorChromiumMac.mm: All changes to this file except in scroll() were to swap #if USE(WK_SCROLLBAR_PAINTER) with runtime checks.
        (WebCore::ScrollAnimatorChromiumMac::ScrollAnimatorChromiumMac):
        (WebCore::ScrollAnimatorChromiumMac::~ScrollAnimatorChromiumMac):
        (WebCore::ScrollAnimatorChromiumMac::notityPositionChanged):
        (WebCore::ScrollAnimatorChromiumMac::contentAreaWillPaint):
        (WebCore::ScrollAnimatorChromiumMac::mouseEnteredContentArea):
        (WebCore::ScrollAnimatorChromiumMac::mouseExitedContentArea):
        (WebCore::ScrollAnimatorChromiumMac::mouseMovedInContentArea):
        (WebCore::ScrollAnimatorChromiumMac::willStartLiveResize):
        (WebCore::ScrollAnimatorChromiumMac::contentsResized):
        (WebCore::ScrollAnimatorChromiumMac::willEndLiveResize):
        (WebCore::ScrollAnimatorChromiumMac::contentAreaDidShow):
        (WebCore::ScrollAnimatorChromiumMac::contentAreaDidHide):
        (WebCore::ScrollAnimatorChromiumMac::didBeginScrollGesture):
        (WebCore::ScrollAnimatorChromiumMac::didEndScrollGesture):
        (WebCore::ScrollAnimatorChromiumMac::didAddVerticalScrollbar):
        (WebCore::ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar):
        (WebCore::ScrollAnimatorChromiumMac::didAddHorizontalScrollbar):
        (WebCore::ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar):
        (WebCore::ScrollAnimatorChromiumMac::cancelAnimations):
        * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm:
        (preferredScrollerStyle): Disabled overlay scrollbar styles due to trailing artifacts.
        (wkScrollbarPainterPaint): Fixed a problem where the scrollbar track wasn't being drawn.
        (wkScrollbarPainterKnobRect): Implemented a previously unimplemented function.
        (wkSetScrollbarPainterKnobStyle): Implemented a function that's now supported by the latest Mac OS X seeds.
        (isScrollbarOverlayAPIAvailable): Enabled new scrollbar code.
        * platform/chromium/ScrollbarThemeChromiumMac.h:
        * platform/chromium/ScrollbarThemeChromiumMac.mm: Sync with ScrollbarThemeMac.mm.
        (WebCore::scrollbarMap):
        (+[ScrollbarPrefsObserver appearancePrefsChanged:]):
        (WebCore::updateArrowPlacement):
        (WebCore::ScrollbarThemeChromiumMac::registerScrollbar):
        (WebCore::ScrollbarThemeChromiumMac::unregisterScrollbar):
        (WebCore::ScrollbarThemeChromiumMac::setNewPainterForScrollbar):
        (WebCore::ScrollbarThemeChromiumMac::painterForScrollbar):
        (WebCore::ScrollbarThemeChromiumMac::scrollbarThickness):
        (WebCore::ScrollbarThemeChromiumMac::usesOverlayScrollbars):
        (WebCore::ScrollbarThemeChromiumMac::hasButtons):
        (WebCore::ScrollbarThemeChromiumMac::hasThumb):
        (WebCore::buttonRepaintRect):
        (WebCore::ScrollbarThemeChromiumMac::minimumThumbLength):
        (WebCore::ScrollbarThemeChromiumMac::shouldDragDocumentInsteadOfThumb):
        (WebCore::toScrollbarPainterKnobStyle):
        (WebCore::ScrollbarThemeChromiumMac::paint):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (88395 => 88396)


--- trunk/Source/_javascript_Core/ChangeLog	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-06-08 22:24:38 UTC (rev 88396)
@@ -1,3 +1,14 @@
+2011-06-08  Sailesh Agrawal  <s...@chromium.org>
+
+        Reviewed by Mihai Parparita.
+
+        Chromium Mac: Enable overlay scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=59756
+
+        Enable WTF_USE_WK_SCROLLBAR_PAINTER for Chromium Mac. This allows us to use overlay scrollbars on future versions of Mac OS X.
+
+        * wtf/Platform.h:
+
 2011-06-08  Oliver Hunt  <oli...@apple.com>
 
         Reviewed by Geoffrey Garen.

Modified: trunk/Source/_javascript_Core/wtf/Platform.h (88395 => 88396)


--- trunk/Source/_javascript_Core/wtf/Platform.h	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/_javascript_Core/wtf/Platform.h	2011-06-08 22:24:38 UTC (rev 88396)
@@ -640,6 +640,8 @@
 #define WTF_USE_CF 1
 #define WTF_USE_PTHREADS 1
 #define HAVE_PTHREAD_RWLOCK 1
+
+#define WTF_USE_WK_SCROLLBAR_PAINTER 1
 #endif
 
 #if PLATFORM(BREWMP)

Modified: trunk/Source/WebCore/ChangeLog (88395 => 88396)


--- trunk/Source/WebCore/ChangeLog	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/WebCore/ChangeLog	2011-06-08 22:24:38 UTC (rev 88396)
@@ -1,3 +1,59 @@
+2011-06-08  Sailesh Agrawal  <s...@chromium.org>
+
+        Reviewed by Mihai Parparita.
+
+        Chromium Mac: Enable overlay scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=59756
+
+        Sync ScrollbarThemeChromiumMac.mm/.h with ScrollbarThemeMac.mm to pick up support for overlay scrollbars. The only changes are renaming ScrollbarThemeMac to ScrollbarThemeChromiumMac and using runtime checks instead of #ifdef's.
+
+        No new tests, since this code is only enabled on future versions of Mac OS X.
+
+        * platform/chromium/ScrollAnimatorChromiumMac.mm: All changes to this file except in scroll() were to swap #if USE(WK_SCROLLBAR_PAINTER) with runtime checks.
+        (WebCore::ScrollAnimatorChromiumMac::ScrollAnimatorChromiumMac):
+        (WebCore::ScrollAnimatorChromiumMac::~ScrollAnimatorChromiumMac):
+        (WebCore::ScrollAnimatorChromiumMac::notityPositionChanged):
+        (WebCore::ScrollAnimatorChromiumMac::contentAreaWillPaint):
+        (WebCore::ScrollAnimatorChromiumMac::mouseEnteredContentArea):
+        (WebCore::ScrollAnimatorChromiumMac::mouseExitedContentArea):
+        (WebCore::ScrollAnimatorChromiumMac::mouseMovedInContentArea):
+        (WebCore::ScrollAnimatorChromiumMac::willStartLiveResize):
+        (WebCore::ScrollAnimatorChromiumMac::contentsResized):
+        (WebCore::ScrollAnimatorChromiumMac::willEndLiveResize):
+        (WebCore::ScrollAnimatorChromiumMac::contentAreaDidShow):
+        (WebCore::ScrollAnimatorChromiumMac::contentAreaDidHide):
+        (WebCore::ScrollAnimatorChromiumMac::didBeginScrollGesture):
+        (WebCore::ScrollAnimatorChromiumMac::didEndScrollGesture):
+        (WebCore::ScrollAnimatorChromiumMac::didAddVerticalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::didAddHorizontalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::cancelAnimations):
+        * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm:
+        (preferredScrollerStyle): Disabled overlay scrollbar styles due to trailing artifacts.
+        (wkScrollbarPainterPaint): Fixed a problem where the scrollbar track wasn't being drawn.
+        (wkScrollbarPainterKnobRect): Implemented a previously unimplemented function.
+        (wkSetScrollbarPainterKnobStyle): Implemented a function that's now supported by the latest Mac OS X seeds.
+        (isScrollbarOverlayAPIAvailable): Enabled new scrollbar code.
+        * platform/chromium/ScrollbarThemeChromiumMac.h:
+        * platform/chromium/ScrollbarThemeChromiumMac.mm: Sync with ScrollbarThemeMac.mm.
+        (WebCore::scrollbarMap):
+        (+[ScrollbarPrefsObserver appearancePrefsChanged:]):
+        (WebCore::updateArrowPlacement):
+        (WebCore::ScrollbarThemeChromiumMac::registerScrollbar):
+        (WebCore::ScrollbarThemeChromiumMac::unregisterScrollbar):
+        (WebCore::ScrollbarThemeChromiumMac::setNewPainterForScrollbar):
+        (WebCore::ScrollbarThemeChromiumMac::painterForScrollbar):
+        (WebCore::ScrollbarThemeChromiumMac::scrollbarThickness):
+        (WebCore::ScrollbarThemeChromiumMac::usesOverlayScrollbars):
+        (WebCore::ScrollbarThemeChromiumMac::hasButtons):
+        (WebCore::ScrollbarThemeChromiumMac::hasThumb):
+        (WebCore::buttonRepaintRect):
+        (WebCore::ScrollbarThemeChromiumMac::minimumThumbLength):
+        (WebCore::ScrollbarThemeChromiumMac::shouldDragDocumentInsteadOfThumb):
+        (WebCore::toScrollbarPainterKnobStyle):
+        (WebCore::ScrollbarThemeChromiumMac::paint):
+
 2011-06-06  Nate Chapin  <jap...@chromium.org>
 
         Reviewed by Adam Barth.

Modified: trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm (88395 => 88396)


--- trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm	2011-06-08 22:24:38 UTC (rev 88396)
@@ -516,21 +516,21 @@
     m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]);
     m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]);
 
-#if USE(WK_SCROLLBAR_PAINTER)
-    m_scrollbarPainterControllerDelegate.adoptNS([[ScrollbarPainterControllerDelegate alloc] initWithScrollAnimator:this]);
-    m_scrollbarPainterController = wkMakeScrollbarPainterController(m_scrollbarPainterControllerDelegate.get());
-    m_scrollbarPainterDelegate.adoptNS([[ScrollbarPainterDelegate alloc] initWithScrollAnimator:this]);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        m_scrollbarPainterControllerDelegate.adoptNS([[ScrollbarPainterControllerDelegate alloc] initWithScrollAnimator:this]);
+        m_scrollbarPainterController = wkMakeScrollbarPainterController(m_scrollbarPainterControllerDelegate.get());
+        m_scrollbarPainterDelegate.adoptNS([[ScrollbarPainterDelegate alloc] initWithScrollAnimator:this]);
+    }
 }
 
 ScrollAnimatorChromiumMac::~ScrollAnimatorChromiumMac()
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    [m_scrollbarPainterControllerDelegate.get() scrollAnimatorDestroyed];
-    [(id)m_scrollbarPainterController.get() setDelegate:nil];
-    [m_scrollbarPainterDelegate.get() scrollAnimatorDestroyed];
-    [m_scrollAnimationHelperDelegate.get() scrollAnimatorDestroyed];
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        [m_scrollbarPainterControllerDelegate.get() scrollAnimatorDestroyed];
+        [(id)m_scrollbarPainterController.get() setDelegate:nil];
+        [m_scrollbarPainterDelegate.get() scrollAnimatorDestroyed];
+        [m_scrollAnimationHelperDelegate.get() scrollAnimatorDestroyed];
+    }
 }
 
 bool ScrollAnimatorChromiumMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier)
@@ -632,146 +632,126 @@
 
 void ScrollAnimatorChromiumMac::notityPositionChanged()
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkContentAreaScrolled(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkContentAreaScrolled(m_scrollbarPainterController.get());
     ScrollAnimator::notityPositionChanged();
 }
 
 void ScrollAnimatorChromiumMac::contentAreaWillPaint() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkContentAreaWillPaint(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkContentAreaWillPaint(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::mouseEnteredContentArea() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkMouseEnteredContentArea(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkMouseEnteredContentArea(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::mouseExitedContentArea() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkMouseExitedContentArea(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkMouseExitedContentArea(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::mouseMovedInContentArea() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkMouseMovedInContentArea(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkMouseMovedInContentArea(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::willStartLiveResize()
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkWillStartLiveResize(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkWillStartLiveResize(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::contentsResized() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkContentAreaResized(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkContentAreaResized(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::willEndLiveResize()
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkWillEndLiveResize(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkWillEndLiveResize(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::contentAreaDidShow() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkContentAreaDidShow(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkContentAreaDidShow(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::contentAreaDidHide() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkContentAreaDidHide(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkContentAreaDidHide(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::didBeginScrollGesture() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkDidBeginScrollGesture(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkDidBeginScrollGesture(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::didEndScrollGesture() const
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkDidEndScrollGesture(m_scrollbarPainterController.get());
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        wkDidEndScrollGesture(m_scrollbarPainterController.get());
 }
 
 void ScrollAnimatorChromiumMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get());
-    wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter, false);
-    if (scrollableArea()->inLiveResize())
-        wkSetScrollbarPainterKnobAlpha(painter, 1);
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
+        wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get());
+        wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter, false);
+        if (scrollableArea()->inLiveResize())
+            wkSetScrollbarPainterKnobAlpha(painter, 1);
+    }
 }
 
 void ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    wkScrollbarPainterSetDelegate(painter, nil);
-    wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, false);
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
+        wkScrollbarPainterSetDelegate(painter, nil);
+        wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, false);
+    }
 }
 
 void ScrollAnimatorChromiumMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get());
-    wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter, true);
-    if (scrollableArea()->inLiveResize())
-        wkSetScrollbarPainterKnobAlpha(painter, 1);
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
+        wkScrollbarPainterSetDelegate(painter, m_scrollbarPainterDelegate.get());
+        wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter, true);
+        if (scrollableArea()->inLiveResize())
+            wkSetScrollbarPainterKnobAlpha(painter, 1);
+    }
 }
 
 void ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(WK_SCROLLBAR_PAINTER)
-    WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    wkScrollbarPainterSetDelegate(painter, nil);
-    wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, true);
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
+        wkScrollbarPainterSetDelegate(painter, nil);
+        wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, true);
+    }
 }
 
 void ScrollAnimatorChromiumMac::cancelAnimations()
 {
     m_haveScrolledSincePageLoad = false;
 
-#if USE(WK_SCROLLBAR_PAINTER)
-    if (scrollbarPaintTimerIsActive())
-        stopScrollbarPaintTimer();
-    [m_scrollbarPainterDelegate.get() cancelAnimations];
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        if (scrollbarPaintTimerIsActive())
+            stopScrollbarPaintTimer();
+        [m_scrollbarPainterDelegate.get() cancelAnimations];
+    }
 }
 
 #if ENABLE(RUBBER_BANDING)

Modified: trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm (88395 => 88396)


--- trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm	2011-06-08 22:24:38 UTC (rev 88396)
@@ -60,6 +60,7 @@
 @property CGFloat knobAlpha;
 @property CGFloat trackAlpha;
 @property CGFloat knobProportion;
+@property NSInteger knobStyle;
 @property(getter=isEnabled) BOOL enabled;
 @property(getter=isHorizontal) BOOL horizontal;
 @property double doubleValue;
@@ -75,6 +76,7 @@
 - (void)setOverlayScrollerState:(NSScrollerStyle)state
                forceImmediately:(BOOL)flag;
 - (void)setDelegate:(id)delegate;
+- (NSRect)rectForPart:(NSUInteger)arg1;
 
 @end
 
@@ -122,6 +124,11 @@
 
 static NSScrollerStyle preferredScrollerStyle()
 {
+    // TODO(sail): Disable overlay scrollbars for now until the following issues are fixed:
+    // #1: Invalidation issues causes the scrollbar to leave trailing artifacts.
+    // #2: Find tick marks need to be drawn on the scrollbar track.
+    return NSScrollerStyleLegacy;
+
     if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
         return [NSScroller preferredScrollerStyle];
     return NSScrollerStyleLegacy;
@@ -159,6 +166,7 @@
         frameRect.size.height = [painter trackWidth];
     else
         frameRect.size.width = [painter trackWidth];
+    frameRect.origin = NSZeroPoint;
 
     [painter drawKnobSlotInRect:frameRect highlight:NO];
     [painter drawKnob];
@@ -230,7 +238,7 @@
 
 CGRect wkScrollbarPainterKnobRect(WKScrollbarPainterRef painter)
 {
-    return NSRectToCGRect(NSZeroRect);
+    return NSRectToCGRect([painter rectForPart:NSScrollerKnob]);
 }
 
 void wkSetScrollbarPainterKnobAlpha(WKScrollbarPainterRef painter, CGFloat alpha)
@@ -245,7 +253,7 @@
 
 void wkSetScrollbarPainterKnobStyle(WKScrollbarPainterRef painter, wkScrollerKnobStyle style)
 {
-    // TODO(sail): A knob style API doesn't exist in the seeds currently available. 
+    [painter setKnobStyle:style];
 }
 
 WKScrollbarPainterControllerRef wkMakeScrollbarPainterController(id painterControllerDelegate)
@@ -325,13 +333,6 @@
 
 bool isScrollbarOverlayAPIAvailable()
 {
-    // TODO(sail): Disable overlay scrollbars for now until the following issues are fixed:
-    // #1: Invalidation issues causes the scrollbar to leave trailing artifacts.
-    // #2: Various messages such as live resize started/ended need to be piped from the UI.
-    // #3: Find tick marks need to be drawn on the scrollbar track.
-    // #4: Need to have the theme engine draw the thumb.
-    return false;
-
     static bool apiAvailable = [lookUpNSScrollerImpClass() respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] &&
                                [lookUpNSScrollerImpPairClass() instancesRespondToSelector:@selector(scrollerStyle)];
     return apiAvailable;

Modified: trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h (88395 => 88396)


--- trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h	2011-06-08 22:24:38 UTC (rev 88396)
@@ -27,6 +27,7 @@
 #ifndef ScrollbarThemeChromiumMac_h
 #define ScrollbarThemeChromiumMac_h
 
+#include "ScrollbarOverlayUtilitiesChromiumMac.h"
 #include "ScrollbarThemeComposite.h"
 
 // This file (and its associated .mm file) is a clone of ScrollbarThemeMac.h.
@@ -44,6 +45,7 @@
     virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
 
     virtual bool supportsControlTints() const { return true; }
+    virtual bool usesOverlayScrollbars() const;
 
     virtual double initialAutoscrollTimerDelay();
     virtual double autoscrollTimerDelay();
@@ -53,6 +55,9 @@
     virtual void registerScrollbar(Scrollbar*);
     virtual void unregisterScrollbar(Scrollbar*);
 
+    void setNewPainterForScrollbar(Scrollbar*, WKScrollbarPainterRef);
+    WKScrollbarPainterRef painterForScrollbar(Scrollbar*);
+
 protected:
     virtual bool hasButtons(Scrollbar*);
     virtual bool hasThumb(Scrollbar*);
@@ -64,6 +69,7 @@
     virtual int minimumThumbLength(Scrollbar*);
 
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
+    virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);
 
 public:
     void preferencesChanged();

Modified: trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm (88395 => 88396)


--- trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm	2011-06-08 22:07:56 UTC (rev 88395)
+++ trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm	2011-06-08 22:24:38 UTC (rev 88396)
@@ -29,10 +29,13 @@
 
 #include "FrameView.h"
 #include "ImageBuffer.h"
+#include "LocalCurrentGraphicsContext.h"
 #include "PlatformBridge.h"
 #include "PlatformMouseEvent.h"
+#include "ScrollAnimatorChromiumMac.h"
 #include "ScrollView.h"
 #include <Carbon/Carbon.h>
+#include <wtf/HashMap.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
 
@@ -54,18 +57,29 @@
 // - The classname change from ScrollbarThemeMac to ScrollbarThemeChromiumMac.
 // - In paint() the code to paint the track, tickmarks, and thumb separately.
 // - In paint() the thumb is drawn via ChromeBridge/WebThemeEngine.
+// - Various functions that were split using #if USE(WK_SCROLLBAR_PAINTER)
+//   have been combined using runtime checks instead.
 //
 // For all other differences, if it was introduced in this file, then the
 // maintainer forgot to include it in the list; otherwise it is an update that
 // should have been applied to this file but was not.
 
-static HashSet<Scrollbar*>* gScrollbars;
+namespace WebCore {
 
-@interface ScrollbarPrefsObserver : NSObject
+typedef HashMap<Scrollbar*, RetainPtr<WKScrollbarPainterRef> > ScrollbarPainterMap;
+
+static ScrollbarPainterMap* scrollbarMap()
 {
+    static ScrollbarPainterMap* map = new ScrollbarPainterMap;
+    return map;
+}
 
 }
 
+@interface ScrollbarPrefsObserver : NSObject
+{
+}
+
 + (void)registerAsObserver;
 + (void)appearancePrefsChanged:(NSNotification*)theNotification;
 + (void)behaviorPrefsChanged:(NSNotification*)theNotification;
@@ -79,12 +93,12 @@
     UNUSED_PARAM(unusedNotification);
 
     static_cast<ScrollbarThemeChromiumMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
-    if (!gScrollbars)
+    if (scrollbarMap()->isEmpty())
         return;
-    HashSet<Scrollbar*>::iterator end = gScrollbars->end();
-    for (HashSet<Scrollbar*>::iterator it = gScrollbars->begin(); it != end; ++it) {
-        (*it)->styleChanged();
-        (*it)->invalidate();
+    ScrollbarPainterMap::iterator end = scrollbarMap()->end();
+    for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) {
+        it->first->styleChanged();
+        it->first->invalidate();
     }
 }
 
@@ -126,10 +140,13 @@
 static float gInitialButtonDelay = 0.5f;
 static float gAutoscrollButtonDelay = 0.05f;
 static bool gJumpOnTrackClick = false;
-static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd;
+static ScrollbarButtonsPlacement gButtonPlacement = isScrollbarOverlayAPIAvailable() ? ScrollbarButtonsNone : ScrollbarButtonsDoubleEnd;
 
 static void updateArrowPlacement()
 {
+    if (isScrollbarOverlayAPIAvailable())
+        return;
+
     NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
     if ([buttonPlacement isEqualToString:@"Single"])
         gButtonPlacement = ScrollbarButtonsSingle;
@@ -138,25 +155,31 @@
     else if ([buttonPlacement isEqualToString:@"DoubleBoth"])
         gButtonPlacement = ScrollbarButtonsDoubleBoth;
     else
-        gButtonPlacement = ScrollbarButtonsDoubleEnd; // The default is ScrollbarButtonsDoubleEnd.
+        gButtonPlacement = ScrollbarButtonsDoubleEnd;
 }
 
 void ScrollbarThemeChromiumMac::registerScrollbar(Scrollbar* scrollbar)
 {
-    if (!gScrollbars)
-        gScrollbars = new HashSet<Scrollbar*>;
-    gScrollbars->add(scrollbar);
+    bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;
+    WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(), isHorizontal);
+    scrollbarMap()->add(scrollbar, scrollbarPainter);
 }
 
 void ScrollbarThemeChromiumMac::unregisterScrollbar(Scrollbar* scrollbar)
 {
-    gScrollbars->remove(scrollbar);
-    if (gScrollbars->isEmpty()) {
-        delete gScrollbars;
-        gScrollbars = 0;
-    }
+    scrollbarMap()->remove(scrollbar);
 }
 
+void ScrollbarThemeChromiumMac::setNewPainterForScrollbar(Scrollbar* scrollbar, WKScrollbarPainterRef newPainter)
+{
+    scrollbarMap()->set(scrollbar, newPainter);
+}
+
+WKScrollbarPainterRef ScrollbarThemeChromiumMac::painterForScrollbar(Scrollbar* scrollbar)
+{
+    return scrollbarMap()->get(scrollbar).get();
+}
+
 ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac()
 {
     static bool initialized;
@@ -183,9 +206,20 @@
 
 int ScrollbarThemeChromiumMac::scrollbarThickness(ScrollbarControlSize controlSize)
 {
-    return cScrollbarThickness[controlSize];
+    if (isScrollbarOverlayAPIAvailable())
+        return wkScrollbarThickness(controlSize);
+    else
+        return cScrollbarThickness[controlSize];
 }
 
+bool ScrollbarThemeChromiumMac::usesOverlayScrollbars() const
+{
+    if (isScrollbarOverlayAPIAvailable())
+        return wkScrollbarPainterUsesOverlayScrollers();
+    else
+        return false;
+}
+
 double ScrollbarThemeChromiumMac::initialAutoscrollTimerDelay()
 {
     return gInitialButtonDelay;
@@ -203,20 +237,28 @@
 
 bool ScrollbarThemeChromiumMac::hasButtons(Scrollbar* scrollbar)
 {
-    return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?
-             scrollbar->width() :
-             scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
+    return scrollbar->enabled() && gButtonPlacement != ScrollbarButtonsNone
+             && (scrollbar->orientation() == HorizontalScrollbar
+             ? scrollbar->width()
+             : scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
 }
 
 bool ScrollbarThemeChromiumMac::hasThumb(Scrollbar* scrollbar)
 {
+    int minLengthForThumb;
+    if (isScrollbarOverlayAPIAvailable())
+        minLengthForThumb = wkScrollbarMinimumTotalLengthNeededForThumb(scrollbarMap()->get(scrollbar).get());
+    else
+        minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
     return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?
              scrollbar->width() :
-             scrollbar->height()) >= 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
+             scrollbar->height()) >= minLengthForThumb;
 }
 
 static IntRect buttonRepaintRect(const IntRect& buttonRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start)
 {
+    ASSERT(gButtonPlacement != ScrollbarButtonsNone);
+
     IntRect paintRect(buttonRect);
     if (orientation == HorizontalScrollbar) {
         paintRect.setWidth(cRealButtonLength[controlSize]);
@@ -344,7 +386,10 @@
 
 int ScrollbarThemeChromiumMac::minimumThumbLength(Scrollbar* scrollbar)
 {
-    return cThumbMinLength[scrollbar->controlSize()];
+    if (isScrollbarOverlayAPIAvailable())
+        return wkScrollbarMinimumThumbLength(scrollbarMap()->get(scrollbar).get());
+    else
+        return cThumbMinLength[scrollbar->controlSize()];
 }
 
 bool ScrollbarThemeChromiumMac::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
@@ -356,6 +401,11 @@
     return evt.altKey();
 }
 
+bool ScrollbarThemeChromiumMac::shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent& event)
+{
+    return event.altKey();
+}
+
 static int scrollbarPartToHIPressedState(ScrollbarPart part)
 {
     switch (part) {
@@ -374,6 +424,18 @@
     }
 }
 
+static inline wkScrollerKnobStyle toScrollbarPainterKnobStyle(ScrollbarOverlayStyle style)
+{
+    switch (style) {
+    case ScrollbarOverlayStyleDark:
+        return wkScrollerKnobStyleDark;
+    case ScrollbarOverlayStyleLight:
+        return wkScrollerKnobStyleLight;
+    default:
+        return wkScrollerKnobStyleDefault;
+    }
+}
+
 static PlatformBridge::ThemePaintState scrollbarStateToThemeState(Scrollbar* scrollbar) {
     if (!scrollbar->enabled())
         return PlatformBridge::StateDisabled;
@@ -387,6 +449,46 @@
 
 bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect)
 {
+    if (isScrollbarOverlayAPIAvailable()) {
+        float value = 0;
+        float overhang = 0;
+
+        if (scrollbar->currentPos() < 0) {
+            // Scrolled past the top.
+            value = 0;
+            overhang = -scrollbar->currentPos();
+        } else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->totalSize()) {
+            // Scrolled past the bottom.
+            value = 1;
+            overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollbar->totalSize();
+        } else {
+            // Within the bounds of the scrollable area.
+            int maximum = scrollbar->maximum();
+            if (maximum > 0)
+                value = scrollbar->currentPos() / maximum;
+            else
+                value = 0;
+        }
+
+        ScrollAnimatorChromiumMac* scrollAnimator = static_cast<ScrollAnimatorChromiumMac*>(scrollbar->scrollableArea()->scrollAnimator());
+        scrollAnimator->setIsDrawingIntoLayer(context->isCALayerContext());
+
+        wkSetScrollbarPainterKnobStyle(painterForScrollbar(scrollbar), toScrollbarPainterKnobStyle(scrollbar->scrollableArea()->recommendedScrollbarOverlayStyle()));
+
+        GraphicsContextStateSaver stateSaver(*context);
+        context->clip(damageRect);
+        context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
+        LocalCurrentGraphicsContext localContext(context);
+        wkScrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(),
+                                scrollbar->enabled(),
+                                value,
+                                (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(),
+                                scrollbar->frameRect());
+
+        scrollAnimator->setIsDrawingIntoLayer(false);
+        return true;
+    }
+
     HIThemeTrackDrawInfo trackInfo;
     trackInfo.version = 0;
     trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMediumScrollBar : kThemeSmallScrollBar;
@@ -501,4 +603,3 @@
 }
 
 }
-
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to