Merge ScrollAnimatorChromiumMac.mm back to ScrollAnimatorMac
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Dec 2011 02:01:16 +0000 (02:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Dec 2011 02:01:16 +0000 (02:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=61144

Patch by Sailesh Agrawal <sail@chromium.org> on 2011-12-19
Reviewed by Beth Dakin.

At a high level the main changes are:
    - replace #ifdefs in ScrollAnimatorMac and ScrollbarThemeMac with run time checks
    - delete duplicate code in ScrollbarThemeChromiumMac. Keep the paint code since it does tickmarks and SKIA stuff.
    - delete ScrollAnimatorChromiumMac since ScrollAnimatorMac does the exact same thing
    - delete ScrollbarOverlayUtilitiesChromiumMac since NSScrollerImpDetails does the same thing

No new tests. Just refactoring.

* WebCore.gyp/WebCore.gyp:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* platform/chromium/ScrollAnimatorChromiumMac.h: Removed.
* platform/chromium/ScrollAnimatorChromiumMac.mm: Removed.
* platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h: Removed.
* platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm: Removed.
* platform/chromium/ScrollbarThemeChromiumMac.h:
* platform/chromium/ScrollbarThemeChromiumMac.mm:
(WebCore::ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac):
(WebCore::scrollbarPainterPaintTrack):
(WebCore::ScrollbarThemeChromiumMac::paint):
* platform/mac/EmptyProtocolDefinitions.h:
* platform/mac/NSScrollerImpDetails.h:
(WebCore::isScrollbarOverlayAPIAvailable):
* platform/mac/NSScrollerImpDetails.mm: Added.
(WebCore::isScrollbarOverlayAPIAvailable):
(WebCore::recommendedScrollerStyle):
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(scrollbarPainterForScrollbar):
(WebCore::ScrollAnimatorMac::ScrollAnimatorMac):
(WebCore::ScrollAnimatorMac::~ScrollAnimatorMac):
(WebCore::ScrollAnimatorMac::notifyPositionChanged):
(WebCore::ScrollAnimatorMac::contentAreaWillPaint):
(WebCore::ScrollAnimatorMac::mouseEnteredContentArea):
(WebCore::ScrollAnimatorMac::mouseExitedContentArea):
(WebCore::ScrollAnimatorMac::mouseMovedInContentArea):
(WebCore::ScrollAnimatorMac::mouseEnteredScrollbar):
(WebCore::ScrollAnimatorMac::mouseExitedScrollbar):
(WebCore::ScrollAnimatorMac::willStartLiveResize):
(WebCore::ScrollAnimatorMac::contentsResized):
(WebCore::ScrollAnimatorMac::willEndLiveResize):
(WebCore::ScrollAnimatorMac::contentAreaDidShow):
(WebCore::ScrollAnimatorMac::contentAreaDidHide):
(WebCore::ScrollAnimatorMac::didBeginScrollGesture):
(WebCore::ScrollAnimatorMac::didEndScrollGesture):
(WebCore::ScrollAnimatorMac::didAddVerticalScrollbar):
(WebCore::ScrollAnimatorMac::willRemoveVerticalScrollbar):
(WebCore::ScrollAnimatorMac::didAddHorizontalScrollbar):
(WebCore::ScrollAnimatorMac::willRemoveHorizontalScrollbar):
(WebCore::ScrollAnimatorMac::cancelAnimations):
(WebCore::ScrollAnimatorMac::setIsActive):
(WebCore::ScrollAnimatorMac::updateScrollerStyle):
(WebCore::ScrollAnimatorMac::initialScrollbarPaintTimerFired):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollbarThemeMac.h:
* platform/mac/ScrollbarThemeMac.mm:
(+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
(+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
(WebCore::updateArrowPlacement):
(WebCore::ScrollbarThemeMac::registerScrollbar):
(WebCore::ScrollbarThemeMac::setIsCurrentlyDrawingIntoLayer):
(WebCore::ScrollbarThemeMac::ScrollbarThemeMac):
(WebCore::ScrollbarThemeMac::scrollbarThickness):
(WebCore::ScrollbarThemeMac::usesOverlayScrollbars):
(WebCore::ScrollbarThemeMac::updateScrollbarOverlayStyle):
(WebCore::ScrollbarThemeMac::hasButtons):
(WebCore::ScrollbarThemeMac::hasThumb):
(WebCore::ScrollbarThemeMac::minimumThumbLength):
(WebCore::ScrollbarThemeMac::scrollbarPartToHIPressedState):
(WebCore::ScrollbarThemeMac::updateEnabledState):
(WebCore::scrollbarPainterPaint):
(WebCore::ScrollbarThemeMac::paint):

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h [deleted file]
Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm [deleted file]
Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h [deleted file]
Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm [deleted file]
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
Source/WebCore/platform/mac/EmptyProtocolDefinitions.h
Source/WebCore/platform/mac/NSScrollerImpDetails.h
Source/WebCore/platform/mac/NSScrollerImpDetails.mm [new file with mode: 0644]
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollElasticityController.h
Source/WebCore/platform/mac/ScrollbarThemeMac.h
Source/WebCore/platform/mac/ScrollbarThemeMac.mm

index fa1e171..6fe4465 100644 (file)
@@ -1,3 +1,83 @@
+2011-12-19  Sailesh Agrawal <sail@chromium.org>
+
+        Merge ScrollAnimatorChromiumMac.mm back to ScrollAnimatorMac
+        https://bugs.webkit.org/show_bug.cgi?id=61144
+
+        Reviewed by Beth Dakin.
+
+        At a high level the main changes are:
+            - replace #ifdefs in ScrollAnimatorMac and ScrollbarThemeMac with run time checks
+            - delete duplicate code in ScrollbarThemeChromiumMac. Keep the paint code since it does tickmarks and SKIA stuff.
+            - delete ScrollAnimatorChromiumMac since ScrollAnimatorMac does the exact same thing
+            - delete ScrollbarOverlayUtilitiesChromiumMac since NSScrollerImpDetails does the same thing
+
+        No new tests. Just refactoring.
+
+        * WebCore.gyp/WebCore.gyp:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/chromium/ScrollAnimatorChromiumMac.h: Removed.
+        * platform/chromium/ScrollAnimatorChromiumMac.mm: Removed.
+        * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h: Removed.
+        * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm: Removed.
+        * platform/chromium/ScrollbarThemeChromiumMac.h:
+        * platform/chromium/ScrollbarThemeChromiumMac.mm:
+        (WebCore::ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac):
+        (WebCore::scrollbarPainterPaintTrack):
+        (WebCore::ScrollbarThemeChromiumMac::paint):
+        * platform/mac/EmptyProtocolDefinitions.h:
+        * platform/mac/NSScrollerImpDetails.h:
+        (WebCore::isScrollbarOverlayAPIAvailable):
+        * platform/mac/NSScrollerImpDetails.mm: Added.
+        (WebCore::isScrollbarOverlayAPIAvailable):
+        (WebCore::recommendedScrollerStyle):
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (scrollbarPainterForScrollbar):
+        (WebCore::ScrollAnimatorMac::ScrollAnimatorMac):
+        (WebCore::ScrollAnimatorMac::~ScrollAnimatorMac):
+        (WebCore::ScrollAnimatorMac::notifyPositionChanged):
+        (WebCore::ScrollAnimatorMac::contentAreaWillPaint):
+        (WebCore::ScrollAnimatorMac::mouseEnteredContentArea):
+        (WebCore::ScrollAnimatorMac::mouseExitedContentArea):
+        (WebCore::ScrollAnimatorMac::mouseMovedInContentArea):
+        (WebCore::ScrollAnimatorMac::mouseEnteredScrollbar):
+        (WebCore::ScrollAnimatorMac::mouseExitedScrollbar):
+        (WebCore::ScrollAnimatorMac::willStartLiveResize):
+        (WebCore::ScrollAnimatorMac::contentsResized):
+        (WebCore::ScrollAnimatorMac::willEndLiveResize):
+        (WebCore::ScrollAnimatorMac::contentAreaDidShow):
+        (WebCore::ScrollAnimatorMac::contentAreaDidHide):
+        (WebCore::ScrollAnimatorMac::didBeginScrollGesture):
+        (WebCore::ScrollAnimatorMac::didEndScrollGesture):
+        (WebCore::ScrollAnimatorMac::didAddVerticalScrollbar):
+        (WebCore::ScrollAnimatorMac::willRemoveVerticalScrollbar):
+        (WebCore::ScrollAnimatorMac::didAddHorizontalScrollbar):
+        (WebCore::ScrollAnimatorMac::willRemoveHorizontalScrollbar):
+        (WebCore::ScrollAnimatorMac::cancelAnimations):
+        (WebCore::ScrollAnimatorMac::setIsActive):
+        (WebCore::ScrollAnimatorMac::updateScrollerStyle):
+        (WebCore::ScrollAnimatorMac::initialScrollbarPaintTimerFired):
+        * platform/mac/ScrollElasticityController.h:
+        * platform/mac/ScrollbarThemeMac.h:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
+        (+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
+        (WebCore::updateArrowPlacement):
+        (WebCore::ScrollbarThemeMac::registerScrollbar):
+        (WebCore::ScrollbarThemeMac::setIsCurrentlyDrawingIntoLayer):
+        (WebCore::ScrollbarThemeMac::ScrollbarThemeMac):
+        (WebCore::ScrollbarThemeMac::scrollbarThickness):
+        (WebCore::ScrollbarThemeMac::usesOverlayScrollbars):
+        (WebCore::ScrollbarThemeMac::updateScrollbarOverlayStyle):
+        (WebCore::ScrollbarThemeMac::hasButtons):
+        (WebCore::ScrollbarThemeMac::hasThumb):
+        (WebCore::ScrollbarThemeMac::minimumThumbLength):
+        (WebCore::ScrollbarThemeMac::scrollbarPartToHIPressedState):
+        (WebCore::ScrollbarThemeMac::updateEnabledState):
+        (WebCore::scrollbarPainterPaint):
+        (WebCore::ScrollbarThemeMac::paint):
+
 2011-12-19  James Robinson  <jamesr@chromium.org>
 
         [chromium] Set the CCLayerTreeHost pointer on LayerChromium instances eagerly
index 886203d..0066464 100644 (file)
               # such as:
               # com.google.Chrome[] objc[]: Class ScrollbarPrefsObserver is implemented in both .../Google Chrome.app/Contents/Versions/.../Google Chrome Helper.app/Contents/MacOS/../../../Google Chrome Framework.framework/Google Chrome Framework and /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore. One of the two will be used. Which one is undefined.
               'WebCascadeList=ChromiumWebCoreObjCWebCascadeList',
-              'ScrollbarPrefsObserver=ChromiumWebCoreObjCScrollbarPrefsObserver',
+              'WebScrollbarPrefsObserver=ChromiumWebCoreObjCWebScrollbarPrefsObserver',
               'WebCoreRenderThemeNotificationObserver=ChromiumWebCoreObjCWebCoreRenderThemeNotificationObserver',
               'WebFontCache=ChromiumWebCoreObjCWebFontCache',
-              'ScrollAnimationHelperDelegate=ChromiumWebCoreObjCScrollAnimationHelperDelegate',
-              'ScrollbarPainterControllerDelegate=ChromiumWebCoreObjCScrollbarPainterControllerDelegate',
-              'ScrollbarPainterDelegate=ChromiumWebCoreObjCScrollbarPainterDelegate',
-              'ScrollbarPartAnimation=ChromiumWebCoreObjCScrollbarPartAnimation',
+              'WebScrollAnimationHelperDelegate=ChromiumWebCoreObjCWebScrollAnimationHelperDelegate',
+              'WebScrollbarPainterControllerDelegate=ChromiumWebCoreObjCWebScrollbarPainterControllerDelegate',
+              'WebScrollbarPainterDelegate=ChromiumWebCoreObjCWebScrollbarPainterDelegate',
+              'WebScrollbarPartAnimation=ChromiumWebCoreObjCWebScrollbarPartAnimation',
             ],
             'include_dirs': [
               '<(chromium_src_dir)/third_party/apple_webkit',
             ['include', 'platform/mac/BlockExceptions\\.mm$'],
             ['include', 'platform/mac/KillRingMac\\.mm$'],
             ['include', 'platform/mac/LocalCurrentGraphicsContext\\.mm$'],
+            ['include', 'platform/mac/NSScrollerImpDetails\\.mm$'],
             ['include', 'platform/mac/PurgeableBufferMac\\.cpp$'],
+            ['include', 'platform/mac/ScrollbarThemeMac\\.mm$'],
+            ['include', 'platform/mac/ScrollAnimatorMac\\.mm$'],
+            ['include', 'platform/mac/ScrollElasticityController\\.mm$'],
             ['include', 'platform/mac/WebCoreSystemInterface\\.mm$'],
             ['include', 'platform/mac/WebCoreTextRenderer\\.mm$'],
             ['include', 'platform/text/mac/ShapeArabic\\.c$'],
index 8569870..fcdf5b8 100644 (file)
             'platform/chromium/PopupListBox.h',
             'platform/chromium/PopupMenuPrivate.h',
             'platform/chromium/SSLKeyGeneratorChromium.cpp',
-            'platform/chromium/ScrollAnimatorChromiumMac.h',
-            'platform/chromium/ScrollAnimatorChromiumMac.mm',
-            'platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h',
-            'platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm',
             'platform/chromium/ScrollbarThemeChromium.cpp',
             'platform/chromium/ScrollbarThemeChromium.h',
             'platform/chromium/ScrollbarThemeChromiumLinux.cpp',
             'platform/mac/LocalizedStringsMac.mm',
             'platform/mac/LoggingMac.mm',
             'platform/mac/MIMETypeRegistryMac.mm',
+            'platform/mac/NSScrollerImpDetails.h',
+            'platform/mac/NSScrollerImpDetails.mm',
             'platform/mac/PasteboardHelper.h',
             'platform/mac/PasteboardMac.mm',
             'platform/mac/PlatformClockCA.cpp',
             'platform/mac/SchedulePairMac.mm',
             'platform/mac/ScrollAnimatorMac.h',
             'platform/mac/ScrollAnimatorMac.mm',
+            'platform/mac/ScrollElasticityController.h',
+            'platform/mac/ScrollElasticityController.mm',
             'platform/mac/ScrollViewMac.mm',
             'platform/mac/ScrollbarThemeMac.h',
             'platform/mac/ScrollbarThemeMac.mm',
index 32a8818..0074979 100644 (file)
                51FB5505113E3E9100821176 /* JSCloseEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FB5503113E3E9100821176 /* JSCloseEvent.cpp */; };
                521D46F611AEC98100514613 /* KillRingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 521D46F511AEC98100514613 /* KillRingMac.mm */; };
                521D46F811AEC9B100514613 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = 521D46F711AEC9B100514613 /* KillRing.h */; };
+               52F52E1114A0134F00ACC397 /* NSScrollerImpDetails.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */; };
                5317612213C516690026E454 /* StyleFlexibleBoxData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5317612013C516690026E454 /* StyleFlexibleBoxData.cpp */; };
                5317612313C516690026E454 /* StyleFlexibleBoxData.h in Headers */ = {isa = PBXBuildFile; fileRef = 5317612113C516690026E454 /* StyleFlexibleBoxData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5325E4D713A6C88B00404A36 /* CSSFlexValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5325E4D513A6C88B00404A36 /* CSSFlexValue.cpp */; };
                51FB5503113E3E9100821176 /* JSCloseEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCloseEvent.cpp; sourceTree = "<group>"; };
                521D46F511AEC98100514613 /* KillRingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KillRingMac.mm; sourceTree = "<group>"; };
                521D46F711AEC9B100514613 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; };
+               52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSScrollerImpDetails.mm; sourceTree = "<group>"; };
                5317612013C516690026E454 /* StyleFlexibleBoxData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleFlexibleBoxData.cpp; path = style/StyleFlexibleBoxData.cpp; sourceTree = "<group>"; };
                5317612113C516690026E454 /* StyleFlexibleBoxData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleFlexibleBoxData.h; path = style/StyleFlexibleBoxData.h; sourceTree = "<group>"; };
                5325E4D513A6C88B00404A36 /* CSSFlexValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFlexValue.cpp; sourceTree = "<group>"; };
                                657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */,
                                BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */,
                                93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */,
+                               52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */,
                                A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
                                4B2709810AF2E5E00065127F /* PasteboardMac.mm */,
                                935C476F09AC4D7300A6AAB4 /* PlatformMouseEventMac.mm */,
                                1A1F28A1149E629800FBC35F /* ScrollingCoordinatorMac.mm in Sources */,
                                A80A9423149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp in Sources */,
                                A80A9425149F227100989291 /* JSDOMWindowWebSocketCustom.cpp in Sources */,
+                               52F52E1114A0134F00ACC397 /* NSScrollerImpDetails.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h b/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h
deleted file mode 100644 (file)
index 2fb849c..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollAnimatorChromiumMac_h
-#define ScrollAnimatorChromiumMac_h
-
-#include "FloatPoint.h"
-#include "FloatSize.h"
-#include "IntRect.h"
-#include "ScrollAnimator.h"
-#include "ScrollbarOverlayUtilitiesChromiumMac.h"
-#include "Timer.h"
-#include <wtf/RetainPtr.h>
-
-#ifdef __OBJC__
-@class ScrollAnimationHelperDelegate;
-@class ScrollbarPainterDelegate;
-@class ScrollbarPainterControllerDelegate;
-@class ScrollbarPainterDelegate;
-#else
-class ScrollAnimationHelperDelegate;
-class ScrollbarPainterDelegate;
-class ScrollbarPainterControllerDelegate;
-class ScrollbarPainterDelegate;
-#endif
-
-namespace WebCore {
-
-class Scrollbar;
-
-class ScrollAnimatorChromiumMac : public ScrollAnimator {
-public:
-    explicit ScrollAnimatorChromiumMac(ScrollableArea*);
-    virtual ~ScrollAnimatorChromiumMac();
-
-    virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
-    virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
-
-#if ENABLE(RUBBER_BANDING)
-    virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
-#if ENABLE(GESTURE_EVENTS)
-    virtual void handleGestureEvent(const PlatformGestureEvent&);
-#endif
-#endif
-
-    virtual void cancelAnimations();
-
-    void immediateScrollToPoint(const FloatPoint& newPosition);
-    void immediateScrollByDeltaX(float deltaX);
-    void immediateScrollByDeltaY(float deltaY);
-
-    void immediateScrollToPointForScrollAnimation(const FloatPoint& newPosition);
-
-    void setIsDrawingIntoLayer(bool b) { m_drawingIntoLayer = b; }
-    bool isDrawingIntoLayer() const { return m_drawingIntoLayer; }
-
-    bool haveScrolledSincePageLoad() const { return m_haveScrolledSincePageLoad; }
-
-    virtual void setIsActive();
-
-#if USE(WK_SCROLLBAR_PAINTER)
-    void updateScrollerStyle();
-
-    bool scrollbarPaintTimerIsActive() const;
-    void startScrollbarPaintTimer();
-    void stopScrollbarPaintTimer();
-#endif
-
-    void setVisibleScrollerThumbRect(const IntRect&);
-
-private:
-    RetainPtr<id> m_scrollAnimationHelper;
-    RetainPtr<ScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate;
-
-#if USE(WK_SCROLLBAR_PAINTER)
-    RetainPtr<WKScrollbarPainterControllerRef> m_scrollbarPainterController;
-    RetainPtr<ScrollbarPainterControllerDelegate> m_scrollbarPainterControllerDelegate;
-    RetainPtr<id> m_scrollbarPainterDelegate;
-
-    void initialScrollbarPaintTimerFired(Timer<ScrollAnimatorChromiumMac>*);
-    Timer<ScrollAnimatorChromiumMac> m_initialScrollbarPaintTimer;
-#endif
-    
-    virtual void notifyPositionChanged();
-    virtual void contentAreaWillPaint() const;
-    virtual void mouseEnteredContentArea() const;
-    virtual void mouseExitedContentArea() const;
-    virtual void mouseMovedInContentArea() const;
-    virtual void willStartLiveResize();
-    virtual void contentsResized() const;
-    virtual void willEndLiveResize();
-    virtual void contentAreaDidShow() const;
-    virtual void contentAreaDidHide() const;
-    void didBeginScrollGesture() const;
-    void didEndScrollGesture() const;
-
-    virtual void didAddVerticalScrollbar(Scrollbar*);
-    virtual void willRemoveVerticalScrollbar(Scrollbar*);
-    virtual void didAddHorizontalScrollbar(Scrollbar*);
-    virtual void willRemoveHorizontalScrollbar(Scrollbar*);
-
-    void setNeedsScrollerStyleUpdate(bool needsUpdate) { m_needsScrollerStyleUpdate = needsUpdate; }
-    bool needsScrollerStyleUpdate() const { return m_needsScrollerStyleUpdate; }
-
-    float adjustScrollXPositionIfNecessary(float) const;
-    float adjustScrollYPositionIfNecessary(float) const;
-    FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
-
-#if ENABLE(RUBBER_BANDING)
-    bool allowsVerticalStretching() const;
-    bool allowsHorizontalStretching() const;
-    bool pinnedInDirection(float deltaX, float deltaY);
-    void snapRubberBand();
-    void snapRubberBandTimerFired(Timer<ScrollAnimatorChromiumMac>*);
-    void smoothScrollWithEvent(const PlatformWheelEvent&);
-    void beginScrollGesture();
-    void endScrollGesture();
-
-    bool m_inScrollGesture;
-    bool m_momentumScrollInProgress;
-    bool m_ignoreMomentumScrolls;
-
-    bool m_scrollerInitiallyPinnedOnLeft;
-    bool m_scrollerInitiallyPinnedOnRight;
-    int m_cumulativeHorizontalScroll;
-    bool m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin;
-
-    CFTimeInterval m_lastMomentumScrollTimestamp;
-    FloatSize m_overflowScrollDelta;
-    FloatSize m_stretchScrollForce;
-    FloatSize m_momentumVelocity;
-
-    // Rubber band state.
-    CFTimeInterval m_startTime;
-    FloatSize m_startStretch;
-    FloatPoint m_origOrigin;
-    FloatSize m_origVelocity;
-    Timer<ScrollAnimatorChromiumMac> m_snapRubberBandTimer;
-#endif
-    bool m_drawingIntoLayer;
-    bool m_haveScrolledSincePageLoad;
-    bool m_needsScrollerStyleUpdate;
-    IntRect m_visibleScrollerThumbRect;
-};
-
-} // namespace WebCore
-
-#endif // ScrollAnimatorChromiumMac_h
diff --git a/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm b/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm
deleted file mode 100644 (file)
index d54733d..0000000
+++ /dev/null
@@ -1,1346 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <sys/time.h>
-#include <sys/sysctl.h>
-
-#include "ScrollAnimatorChromiumMac.h"
-
-#include "FloatPoint.h"
-#include "PlatformGestureEvent.h"
-#include "PlatformWheelEvent.h"
-#include "ScrollView.h"
-#include "ScrollableArea.h"
-#include "ScrollbarTheme.h"
-#include "ScrollbarThemeChromiumMac.h"
-#include "WebCoreSystemInterface.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/UnusedParam.h>
-#include <QuartzCore/QuartzCore.h>
-
-using namespace WebCore;
-using namespace std;
-
-#if !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
-@protocol NSAnimationDelegate
-@end
-
-@interface NSProcessInfo (ScrollAnimatorChromiumMacExt)
-- (NSTimeInterval)systemUptime;
-@end
-
-@implementation NSProcessInfo (ScrollAnimatorChromiumMacExt)
-- (NSTimeInterval)systemUptime
-{
-    // Get how long system has been up. Found by looking getting "boottime" from the kernel.
-    static struct timeval boottime = {0};
-    if (!boottime.tv_sec) {
-        int mib[2] = {CTL_KERN, KERN_BOOTTIME};
-        size_t size = sizeof(boottime);
-        if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0))
-            boottime.tv_sec = 0;
-    }
-    struct timeval now;
-    if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) {
-        struct timeval uptime;
-        timersub(&now, &boottime, &uptime);
-        NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6);
-        return result;
-    }
-    return 0;
-}
-@end
-#endif
-
-@interface NSObject (ScrollAnimationHelperDetails)
-- (id)initWithDelegate:(id)delegate;
-- (void)_stopRun;
-- (BOOL)_isAnimating;
-- (NSPoint)targetOrigin;
-- (CGFloat)_progress;
-@end
-
-@interface ScrollAnimationHelperDelegate : NSObject
-{
-    WebCore::ScrollAnimatorChromiumMac* _animator;
-}
-- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator;
-@end
-
-static NSSize abs(NSSize size)
-{
-    NSSize finalSize = size;
-    if (finalSize.width < 0)
-        finalSize.width = -finalSize.width;
-    if (finalSize.height < 0)
-        finalSize.height = -finalSize.height;
-    return finalSize;    
-}
-
-@implementation ScrollAnimationHelperDelegate
-
-- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator
-{
-    self = [super init];
-    if (!self)
-        return nil;
-
-    _animator = scrollAnimator;
-    return self;
-}
-
-- (void)scrollAnimatorDestroyed
-{
-    _animator = 0;
-}
-
-- (NSRect)bounds
-{
-    if (!_animator)
-        return NSZeroRect;
-
-    WebCore::FloatPoint currentPosition = _animator->currentPosition();
-    return NSMakeRect(currentPosition.x(), currentPosition.y(), 0, 0);
-}
-
-- (void)_immediateScrollToPoint:(NSPoint)newPosition
-{
-    if (!_animator)
-        return;
-    _animator->immediateScrollToPointForScrollAnimation(newPosition);
-}
-
-- (NSPoint)_pixelAlignProposedScrollPosition:(NSPoint)newOrigin
-{
-    return newOrigin;
-}
-
-- (NSSize)convertSizeToBase:(NSSize)size
-{
-    return abs(size);
-}
-
-- (NSSize)convertSizeFromBase:(NSSize)size
-{
-    return abs(size);
-}
-
-- (NSSize)convertSizeToBacking:(NSSize)size
-{
-    return abs(size);
-}
-
-- (NSSize)convertSizeFromBacking:(NSSize)size
-{
-    return abs(size);
-}
-
-- (id)superview
-{
-    return nil;
-}
-
-- (id)documentView
-{
-    return nil;
-}
-
-- (id)window
-{
-    return nil;
-}
-
-- (void)_recursiveRecomputeToolTips
-{
-}
-
-@end
-
-#if USE(WK_SCROLLBAR_PAINTER)
-
-@interface ScrollbarPainterControllerDelegate : NSObject
-{
-    WebCore::ScrollAnimatorChromiumMac* _animator;
-}
-- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator;
-@end
-
-@implementation ScrollbarPainterControllerDelegate
-
-- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator
-{
-    self = [super init];
-    if (!self)
-        return nil;
-    
-    _animator = scrollAnimator;
-    return self;
-}
-
-- (void)scrollAnimatorDestroyed
-{
-    _animator = 0;
-}
-
-- (NSRect)contentAreaRectForScrollerImpPair:(id)scrollerImpPair
-{
-    UNUSED_PARAM(scrollerImpPair);
-    if (!_animator)
-        return NSZeroRect;
-
-    WebCore::IntSize contentsSize = _animator->scrollableArea()->contentsSize();
-    return NSMakeRect(0, 0, contentsSize.width(), contentsSize.height());
-}
-
-- (BOOL)inLiveResizeForScrollerImpPair:(id)scrollerImpPair
-{
-    UNUSED_PARAM(scrollerImpPair);
-    if (!_animator)
-        return NO;
-
-    return _animator->scrollableArea()->inLiveResize();
-}
-
-- (NSPoint)mouseLocationInContentAreaForScrollerImpPair:(id)scrollerImpPair
-{
-    UNUSED_PARAM(scrollerImpPair);
-    if (!_animator)
-        return NSZeroPoint;
-
-    return _animator->scrollableArea()->currentMousePosition();
-}
-
-- (NSPoint)scrollerImpPair:(id)scrollerImpPair convertContentPoint:(NSPoint)pointInContentArea toScrollerImp:(id)scrollerImp
-{
-    UNUSED_PARAM(scrollerImpPair);
-    if (!_animator)
-        return NSZeroPoint;
-
-    WebCore::Scrollbar* scrollbar = 0;
-    if (wkScrollbarPainterIsHorizontal((WKScrollbarPainterRef)scrollerImp))
-        scrollbar = _animator->scrollableArea()->horizontalScrollbar();
-    else 
-        scrollbar = _animator->scrollableArea()->verticalScrollbar();
-
-    // It is possible to have a null scrollbar here since it is possible for this delegate
-    // method to be called between the moment when a scrollbar has been set to 0 and the
-    // moment when its destructor has been called. We should probably de-couple some
-    // of the clean-up work in ScrollbarThemeChromiumMac::unregisterScrollbar() to avoid this
-    // issue.
-    if (!scrollbar)
-        return WebCore::IntPoint();
-    
-    return scrollbar->convertFromContainingView(WebCore::IntPoint(pointInContentArea));
-}
-
-- (void)scrollerImpPair:(id)scrollerImpPair setContentAreaNeedsDisplayInRect:(NSRect)rect
-{
-    UNUSED_PARAM(scrollerImpPair);
-    UNUSED_PARAM(rect);
-}
-
-- (void)scrollerImpPair:(id)scrollerImpPair updateScrollerStyleForNewRecommendedScrollerStyle:(NSScrollerStyle)newRecommendedScrollerStyle
-{
-    if (!_animator)
-        return;
-
-    wkSetScrollbarPainterControllerStyle((WKScrollbarPainterControllerRef)scrollerImpPair, newRecommendedScrollerStyle);
-    _animator->updateScrollerStyle();
-}
-
-@end
-
-@interface ScrollbarPartAnimation : NSAnimation
-{
-    RetainPtr<WKScrollbarPainterRef> _scrollerPainter;
-    WebCore::ScrollbarPart _part;
-    WebCore::ScrollAnimatorChromiumMac* _animator;
-    CGFloat _initialAlpha;
-    CGFloat _newAlpha;
-}
-- (id)initWithScrollbarPainter:(WKScrollbarPainterRef)scrollerPainter part:(WebCore::ScrollbarPart)part scrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration;
-@end
-
-@implementation ScrollbarPartAnimation
-
-- (id)initWithScrollbarPainter:(WKScrollbarPainterRef)scrollerPainter part:(WebCore::ScrollbarPart)part scrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
-{
-    self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut];
-    if (!self)
-        return nil;
-    
-    _scrollerPainter = scrollerPainter;
-    _part = part;
-    _animator = scrollAnimator;
-    _initialAlpha = _part == WebCore::ThumbPart ? wkScrollbarPainterKnobAlpha(_scrollerPainter.get()) : wkScrollbarPainterTrackAlpha(_scrollerPainter.get());
-    _newAlpha = newAlpha;
-    
-    return self;    
-}
-
-- (void)setCurrentProgress:(NSAnimationProgress)progress
-{
-    [super setCurrentProgress:progress];
-
-    if (!_animator)
-        return;
-
-    CGFloat currentAlpha;
-    if (_initialAlpha > _newAlpha)
-        currentAlpha = 1 - progress;
-    else
-        currentAlpha = progress;
-    
-    if (_part == WebCore::ThumbPart)
-        wkSetScrollbarPainterKnobAlpha(_scrollerPainter.get(), currentAlpha);
-    else
-        wkSetScrollbarPainterTrackAlpha(_scrollerPainter.get(), currentAlpha);
-
-    // Invalidate the scrollbars so that they paint the animation
-    if (WebCore::Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar())
-        verticalScrollbar->invalidateRect(WebCore::IntRect(0, 0, verticalScrollbar->width(), verticalScrollbar->height()));
-    if (WebCore::Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar())
-        horizontalScrollbar->invalidateRect(WebCore::IntRect(0, 0, horizontalScrollbar->width(), horizontalScrollbar->height()));
-}
-
-- (void)scrollAnimatorDestroyed
-{
-    [self stopAnimation];
-    _animator = 0;
-}
-
-@end
-
-@interface ScrollbarPainterDelegate : NSObject<NSAnimationDelegate>
-{
-    WebCore::ScrollAnimatorChromiumMac* _animator;
-
-    RetainPtr<ScrollbarPartAnimation> _verticalKnobAnimation;
-    RetainPtr<ScrollbarPartAnimation> _horizontalKnobAnimation;
-
-    RetainPtr<ScrollbarPartAnimation> _verticalTrackAnimation;
-    RetainPtr<ScrollbarPartAnimation> _horizontalTrackAnimation;
-}
-- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator;
-- (void)cancelAnimations;
-@end
-
-@implementation ScrollbarPainterDelegate
-
-- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorChromiumMac*)scrollAnimator
-{
-    self = [super init];
-    if (!self)
-        return nil;
-    
-    _animator = scrollAnimator;
-    return self;
-}
-
-- (void)cancelAnimations
-{
-    [_verticalKnobAnimation.get() stopAnimation];
-    [_horizontalKnobAnimation.get() stopAnimation];
-    [_verticalTrackAnimation.get() stopAnimation];
-    [_horizontalTrackAnimation.get() stopAnimation];
-}
-
-- (NSRect)convertRectToBacking:(NSRect)aRect
-{
-    return aRect;
-}
-
-- (NSRect)convertRectFromBacking:(NSRect)aRect
-{
-    return aRect;
-}
-
-#if !PLATFORM(CHROMIUM)
-- (CALayer *)layer
-{
-    if (!_animator)
-        return nil;
-    if (!_animator->isDrawingIntoLayer())
-        return nil;
-
-    // FIXME: This should attempt to return an actual layer.
-    static CALayer *dummyLayer = [[CALayer alloc] init];
-    return dummyLayer;
-}
-#endif
-
-- (void)setUpAnimation:(RetainPtr<ScrollbarPartAnimation>&)scrollbarPartAnimation scrollerPainter:(WKScrollbarPainterRef)scrollerPainter part:(WebCore::ScrollbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
-{
-    // If the user has scrolled the page, then the scrollbars must be animated here. 
-    // This overrides the early returns.
-    bool mustAnimate = _animator->haveScrolledSincePageLoad();
-
-    if (_animator->scrollbarPaintTimerIsActive() && !mustAnimate)
-        return;
-
-    if (_animator->scrollableArea()->shouldSuspendScrollAnimations() && !mustAnimate) {
-        _animator->startScrollbarPaintTimer();
-        return;
-    }
-
-    // At this point, we are definitely going to animate now, so stop the timer.
-    _animator->stopScrollbarPaintTimer();
-
-    // If we are currently animating, stop
-    if (scrollbarPartAnimation) {
-        [scrollbarPartAnimation.get() stopAnimation];
-        scrollbarPartAnimation = nil;
-    }
-
-    if (part == WebCore::ThumbPart && !wkScrollbarPainterIsHorizontal(scrollerPainter)) {
-        if (newAlpha == 1) {
-            IntRect thumbRect = IntRect(wkScrollbarPainterKnobRect(scrollerPainter));
-            _animator->setVisibleScrollerThumbRect(thumbRect);
-        } else
-            _animator->setVisibleScrollerThumbRect(IntRect());
-    }
-
-    [NSAnimationContext beginGrouping];
-    [[NSAnimationContext currentContext] setDuration:duration];
-    scrollbarPartAnimation.adoptNS([[ScrollbarPartAnimation alloc] initWithScrollbarPainter:scrollerPainter 
-                                                                    part:part
-                                                                    scrollAnimator:_animator 
-                                                                    animateAlphaTo:newAlpha 
-                                                                    duration:duration]);
-    [scrollbarPartAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking];
-    [scrollbarPartAnimation.get() startAnimation];
-    [NSAnimationContext endGrouping];
-}
-
-- (void)scrollerImp:(id)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration
-{
-    if (!_animator)
-        return;
-
-    WKScrollbarPainterRef scrollerPainter = (WKScrollbarPainterRef)scrollerImp;
-    if (wkScrollbarPainterIsHorizontal(scrollerPainter))
-        [self setUpAnimation:_horizontalKnobAnimation scrollerPainter:scrollerPainter part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
-    else
-        [self setUpAnimation:_verticalKnobAnimation scrollerPainter:scrollerPainter part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
-}
-
-- (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration
-{
-    if (!_animator)
-        return;
-
-    WKScrollbarPainterRef scrollerPainter = (WKScrollbarPainterRef)scrollerImp;
-    if (wkScrollbarPainterIsHorizontal(scrollerPainter))
-        [self setUpAnimation:_horizontalTrackAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
-    else
-        [self setUpAnimation:_verticalTrackAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
-}
-
-- (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState
-{
-    UNUSED_PARAM(scrollerImp);
-    UNUSED_PARAM(newOverlayScrollerState);
-}
-
-- (void)scrollAnimatorDestroyed
-{
-    _animator = 0;
-    [_verticalKnobAnimation.get() scrollAnimatorDestroyed];
-    [_horizontalKnobAnimation.get() scrollAnimatorDestroyed];
-    [_verticalTrackAnimation.get() scrollAnimatorDestroyed];
-    [_horizontalTrackAnimation.get() scrollAnimatorDestroyed];
-}
-
-@end
-
-#endif // USE(WK_SCROLLBAR_PAINTER)
-
-namespace WebCore {
-
-PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea)
-{
-    return adoptPtr(new ScrollAnimatorChromiumMac(scrollableArea));
-}
-
-static ScrollbarThemeChromiumMac* chromiumScrollbarTheme()
-{
-    ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
-    return !scrollbarTheme->isMockTheme() ? static_cast<ScrollbarThemeChromiumMac*>(scrollbarTheme) : 0;
-}
-
-ScrollAnimatorChromiumMac::ScrollAnimatorChromiumMac(ScrollableArea* scrollableArea)
-    : ScrollAnimator(scrollableArea)
-#if USE(WK_SCROLLBAR_PAINTER)
-    , m_initialScrollbarPaintTimer(this, &ScrollAnimatorChromiumMac::initialScrollbarPaintTimerFired)
-#endif
-#if ENABLE(RUBBER_BANDING)
-    , m_inScrollGesture(false)
-    , m_momentumScrollInProgress(false)
-    , m_ignoreMomentumScrolls(false)
-    , m_lastMomentumScrollTimestamp(0)
-    , m_startTime(0)
-    , m_snapRubberBandTimer(this, &ScrollAnimatorChromiumMac::snapRubberBandTimerFired)
-#endif
-    , m_drawingIntoLayer(false)
-    , m_haveScrolledSincePageLoad(false)
-    , m_needsScrollerStyleUpdate(false)
-{
-    m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]);
-    m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]);
-
-    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 (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)
-{
-    m_haveScrolledSincePageLoad = true;
-
-#if !ENABLE(SMOOTH_SCROLLING)
-    return ScrollAnimator::scroll(orientation, granularity, step, multiplier);
-#endif
-
-    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollAnimationEnabled"] || !m_scrollableArea->scrollAnimatorEnabled())
-        return ScrollAnimator::scroll(orientation, granularity, step, multiplier);
-
-    if (granularity == ScrollByPixel)
-        return ScrollAnimator::scroll(orientation, granularity, step, multiplier);
-
-    float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_currentPosY;
-    float newPos = std::max<float>(std::min<float>(currentPos + (step * multiplier), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0);
-    if (currentPos == newPos)
-        return false;
-
-    NSPoint newPoint;
-    if ([m_scrollAnimationHelper.get() _isAnimating]) {
-        NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin];
-        newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targetOrigin.y) : NSMakePoint(targetOrigin.x, newPos);
-    } else {
-        newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_currentPosY) : NSMakePoint(m_currentPosX, newPos);
-        m_scrollableArea->didStartAnimatedScroll();
-    }
-    [m_scrollAnimationHelper.get() scrollToPoint:newPoint];
-    return true;
-}
-
-void ScrollAnimatorChromiumMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
-{
-    [m_scrollAnimationHelper.get() _stopRun];
-    immediateScrollToPoint(offset);
-}
-
-float ScrollAnimatorChromiumMac::adjustScrollXPositionIfNecessary(float position) const
-{
-    if (!m_scrollableArea->constrainsScrollingToContentEdge())
-        return position;
-
-    return max<float>(min<float>(position, m_scrollableArea->contentsSize().width() - m_scrollableArea->visibleWidth()), 0);
-}
-
-float ScrollAnimatorChromiumMac::adjustScrollYPositionIfNecessary(float position) const
-{
-    if (!m_scrollableArea->constrainsScrollingToContentEdge())
-        return position;
-
-    return max<float>(min<float>(position, m_scrollableArea->contentsSize().height() - m_scrollableArea->visibleHeight()), 0);
-}
-
-FloatPoint ScrollAnimatorChromiumMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const
-{
-    if (!m_scrollableArea->constrainsScrollingToContentEdge())
-        return position;
-
-    float newX = max<float>(min<float>(position.x(), m_scrollableArea->contentsSize().width() - m_scrollableArea->visibleWidth()), 0);
-    float newY = max<float>(min<float>(position.y(), m_scrollableArea->contentsSize().height() - m_scrollableArea->visibleHeight()), 0);
-
-    return FloatPoint(newX, newY);
-}
-
-void ScrollAnimatorChromiumMac::immediateScrollToPoint(const FloatPoint& newPosition)
-{
-    FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
-    m_currentPosX = adjustedPosition.x();
-    m_currentPosY = adjustedPosition.y();
-    notifyPositionChanged();
-}
-
-void ScrollAnimatorChromiumMac::immediateScrollByDeltaX(float deltaX)
-{
-    float newPosX = adjustScrollXPositionIfNecessary(m_currentPosX + deltaX);
-    
-    if (newPosX == m_currentPosX)
-        return;
-    
-    m_currentPosX = newPosX;
-    notifyPositionChanged();
-}
-
-void ScrollAnimatorChromiumMac::immediateScrollByDeltaY(float deltaY)
-{
-    float newPosY = adjustScrollYPositionIfNecessary(m_currentPosY + deltaY);
-    
-    if (newPosY == m_currentPosY)
-        return;
-    
-    m_currentPosY = newPosY;
-    notifyPositionChanged();
-}
-
-void ScrollAnimatorChromiumMac::immediateScrollToPointForScrollAnimation(const FloatPoint& newPosition)
-{
-    ASSERT(m_scrollAnimationHelper);
-    CGFloat progress = [m_scrollAnimationHelper.get() _progress];
-    
-    immediateScrollToPoint(newPosition);
-
-    if (progress >= 1.0)
-        m_scrollableArea->didCompleteAnimatedScroll();
-}
-
-void ScrollAnimatorChromiumMac::notifyPositionChanged()
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkContentAreaScrolled(m_scrollbarPainterController.get());
-    ScrollAnimator::notifyPositionChanged();
-}
-
-void ScrollAnimatorChromiumMac::contentAreaWillPaint() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkContentAreaWillPaint(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::mouseEnteredContentArea() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkMouseEnteredContentArea(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::mouseExitedContentArea() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkMouseExitedContentArea(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::mouseMovedInContentArea() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkMouseMovedInContentArea(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::willStartLiveResize()
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkWillStartLiveResize(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::contentsResized() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkContentAreaResized(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::willEndLiveResize()
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkWillEndLiveResize(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::contentAreaDidShow() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkContentAreaDidShow(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::contentAreaDidHide() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkContentAreaDidHide(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::didBeginScrollGesture() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkDidBeginScrollGesture(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::didEndScrollGesture() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        wkDidEndScrollGesture(m_scrollbarPainterController.get());
-}
-
-void ScrollAnimatorChromiumMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
-{
-    if (!isScrollbarOverlayAPIAvailable())
-        return;
-        
-    if (ScrollbarThemeChromiumMac* theme = chromiumScrollbarTheme()) {
-        WKScrollbarPainterRef painter = theme->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 (!isScrollbarOverlayAPIAvailable())
-        return;
-
-    if (ScrollbarThemeChromiumMac* theme = chromiumScrollbarTheme()) {
-        WKScrollbarPainterRef painter = theme->painterForScrollbar(scrollbar);
-        wkScrollbarPainterSetDelegate(painter, nil);
-        wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, false);
-    }
-}
-
-void ScrollAnimatorChromiumMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
-{
-    if (!isScrollbarOverlayAPIAvailable())
-        return;
-
-    if (ScrollbarThemeChromiumMac* theme = chromiumScrollbarTheme()) {
-        WKScrollbarPainterRef painter = theme->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 (!isScrollbarOverlayAPIAvailable())
-        return;
-
-    if (ScrollbarThemeChromiumMac* theme = chromiumScrollbarTheme()) {
-        WKScrollbarPainterRef painter = theme->painterForScrollbar(scrollbar);
-        wkScrollbarPainterSetDelegate(painter, nil);
-        wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, true);
-    }
-}
-
-void ScrollAnimatorChromiumMac::cancelAnimations()
-{
-    m_haveScrolledSincePageLoad = false;
-
-    if (isScrollbarOverlayAPIAvailable()) {
-        if (scrollbarPaintTimerIsActive())
-            stopScrollbarPaintTimer();
-        [m_scrollbarPainterDelegate.get() cancelAnimations];
-    }
-}
-
-#if ENABLE(RUBBER_BANDING)
-
-static const float scrollVelocityZeroingTimeout = 0.10f;
-static const float rubberbandStiffness = 20;
-static const float rubberbandDirectionLockStretchRatio = 1;
-static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
-static const float rubberbandAmplitude = 0.31f;
-static const float rubberbandPeriod = 1.6f;
-
-static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, float elapsedTime)
-{
-    float amplitude = rubberbandAmplitude;
-    float period = rubberbandPeriod;
-    float criticalDampeningFactor = expf((-elapsedTime * rubberbandStiffness) / period);
-             
-    return (initialPosition + (-initialVelocity * elapsedTime * amplitude)) * criticalDampeningFactor;
-}
-
-static float elasticDeltaForReboundDelta(float delta)
-{
-    float stiffness = std::max(rubberbandStiffness, 1.0f);
-    return delta / stiffness;
-}
-
-static float reboundDeltaForElasticDelta(float delta)
-{
-    return delta * rubberbandStiffness;
-}
-
-static float scrollWheelMultiplier()
-{
-    static float multiplier = -1;
-    if (multiplier < 0) {
-        multiplier = [[NSUserDefaults standardUserDefaults] floatForKey:@"NSScrollWheelMultiplier"];
-        if (multiplier <= 0)
-            multiplier = 1;
-    }
-    return multiplier;
-}
-
-static inline bool isScrollingLeftAndShouldNotRubberBand(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
-{
-    return wheelEvent.deltaX() > 0 && !scrollableArea->shouldRubberBandInDirection(ScrollLeft);
-}
-
-static inline bool isScrollingRightAndShouldNotRubberBand(const PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea)
-{
-    return wheelEvent.deltaX() < 0 && !scrollableArea->shouldRubberBandInDirection(ScrollRight);
-}
-
-bool ScrollAnimatorChromiumMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
-{
-    m_haveScrolledSincePageLoad = true;
-
-    if (!wheelEvent.hasPreciseScrollingDeltas())
-        return ScrollAnimator::handleWheelEvent(wheelEvent);
-
-    // FIXME: This is somewhat roundabout hack to allow forwarding wheel events
-    // up to the parent scrollable area. It takes advantage of the fact that
-    // the base class implemenatation of handleWheelEvent will not accept the
-    // wheel event if there is nowhere to scroll.
-    if (fabsf(wheelEvent.deltaY()) >= fabsf(wheelEvent.deltaX())) {
-        if (!allowsVerticalStretching())
-            return ScrollAnimator::handleWheelEvent(wheelEvent);
-    } else {
-        if (!allowsHorizontalStretching())
-            return ScrollAnimator::handleWheelEvent(wheelEvent);
-        
-        if (m_scrollableArea->horizontalScrollbar()) {
-            // If there is a scrollbar, we aggregate the wheel events to get an
-            // overall trend of the scroll. If the direction of the scroll is ever
-            // in the opposite direction of the pin location, then we switch the
-            // boolean, and rubber band. That is, if we were pinned to the left,
-            // and we ended up scrolling to the right, we rubber band.
-            m_cumulativeHorizontalScroll += wheelEvent.deltaX();
-            if (m_scrollerInitiallyPinnedOnLeft && m_cumulativeHorizontalScroll < 0)
-                m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true;
-            if (m_scrollerInitiallyPinnedOnRight && m_cumulativeHorizontalScroll > 0)
-                m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true;
-        }
-
-        // After a gesture begins, we go through:
-        // 1+ PlatformWheelEventPhaseNone
-        // 0+ PlatformWheelEventPhaseChanged
-        // 1 PlatformWheelEventPhaseEnded if there was at least one changed event
-        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseNone && !m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin) {
-            if ((isScrollingLeftAndShouldNotRubberBand(wheelEvent, m_scrollableArea) &&
-                m_scrollerInitiallyPinnedOnLeft &&
-                m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition()) ||
-                (isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea) &&
-                m_scrollerInitiallyPinnedOnRight &&
-                m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition())) {
-                return ScrollAnimator::handleWheelEvent(wheelEvent);
-            }
-        }
-    }
-
-    bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
-    if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberBandTimer.isActive())) {
-        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
-            m_ignoreMomentumScrolls = false;
-            return true;
-        }
-        return false;
-    }
-
-    smoothScrollWithEvent(wheelEvent);
-    return true;
-}
-
-void ScrollAnimatorChromiumMac::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
-{
-    if (gestureEvent.type() == PlatformEvent::GestureScrollBegin)
-        beginScrollGesture();
-    else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd)
-        endScrollGesture();
-}
-
-bool ScrollAnimatorChromiumMac::pinnedInDirection(float deltaX, float deltaY)
-{
-    FloatSize limitDelta;
-    if (fabsf(deltaY) >= fabsf(deltaX)) {
-        if (deltaY < 0) {
-            // We are trying to scroll up.  Make sure we are not pinned to the top
-            limitDelta.setHeight(m_scrollableArea->visibleContentRect().y() + + m_scrollableArea->scrollOrigin().y());
-        } else {
-            // We are trying to scroll down.  Make sure we are not pinned to the bottom
-            limitDelta.setHeight(m_scrollableArea->contentsSize().height() - (m_scrollableArea->visibleContentRect().maxY() + m_scrollableArea->scrollOrigin().y()));
-        }
-    } else if (deltaX != 0) {
-        if (deltaX < 0) {
-            // We are trying to scroll left.  Make sure we are not pinned to the left
-            limitDelta.setWidth(m_scrollableArea->visibleContentRect().x() + m_scrollableArea->scrollOrigin().x());
-        } else {
-            // We are trying to scroll right.  Make sure we are not pinned to the right
-            limitDelta.setWidth(m_scrollableArea->contentsSize().width() - (m_scrollableArea->visibleContentRect().maxX() + m_scrollableArea->scrollOrigin().x()));
-        }
-    }
-    
-    if ((deltaX != 0 || deltaY != 0) && (limitDelta.width() < 1 && limitDelta.height() < 1))
-        return true;
-    return false;
-}
-
-bool ScrollAnimatorChromiumMac::allowsVerticalStretching() const
-{
-    switch (m_scrollableArea->verticalScrollElasticity()) {
-    case ScrollElasticityAutomatic: {
-        Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
-        Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
-        return (((vScroller && vScroller->enabled()) || (!hScroller || !hScroller->enabled())));
-    }
-    case ScrollElasticityNone:
-        return false;
-    case ScrollElasticityAllowed:
-        return true;
-    }
-
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
-bool ScrollAnimatorChromiumMac::allowsHorizontalStretching() const
-{
-    switch (m_scrollableArea->horizontalScrollElasticity()) {
-    case ScrollElasticityAutomatic: {
-        Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
-        Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
-        return (((hScroller && hScroller->enabled()) || (!vScroller || !vScroller->enabled())));
-    }
-    case ScrollElasticityNone:
-        return false;
-    case ScrollElasticityAllowed:
-        return true;
-    }
-
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
-void ScrollAnimatorChromiumMac::smoothScrollWithEvent(const PlatformWheelEvent& wheelEvent)
-{
-    m_haveScrolledSincePageLoad = true;
-
-    float deltaX = m_overflowScrollDelta.width();
-    float deltaY = m_overflowScrollDelta.height();
-
-    // Reset overflow values because we may decide to remove delta at various points and put it into overflow.
-    m_overflowScrollDelta = FloatSize();
-
-    float eventCoalescedDeltaX = -wheelEvent.deltaX();
-    float eventCoalescedDeltaY = -wheelEvent.deltaY();
-
-    deltaX += eventCoalescedDeltaX;
-    deltaY += eventCoalescedDeltaY;
-
-    // Slightly prefer scrolling vertically by applying the = case to deltaY
-    if (fabsf(deltaY) >= fabsf(deltaX))
-        deltaX = 0;
-    else
-        deltaY = 0;
-
-    bool isVerticallyStretched = false;
-    bool isHorizontallyStretched = false;
-    bool shouldStretch = false;
-    
-    IntSize stretchAmount = m_scrollableArea->overhangAmount();
-
-    isHorizontallyStretched = stretchAmount.width();
-    isVerticallyStretched = stretchAmount.height();
-
-    PlatformWheelEventPhase phase = wheelEvent.momentumPhase();
-
-    // If we are starting momentum scrolling then do some setup.
-    if (!m_momentumScrollInProgress && (phase == PlatformWheelEventPhaseBegan || phase == PlatformWheelEventPhaseChanged))
-        m_momentumScrollInProgress = true;
-
-    CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp;
-    if (m_inScrollGesture || m_momentumScrollInProgress) {
-        if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {
-            m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta);
-            m_momentumVelocity.setHeight(eventCoalescedDeltaY / (float)timeDelta);
-            m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
-        } else {
-            m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
-            m_momentumVelocity = FloatSize();
-        }
-
-        if (isVerticallyStretched) {
-            if (!isHorizontallyStretched && pinnedInDirection(deltaX, 0)) {                
-                // Stretching only in the vertical.
-                if (deltaY != 0 && (fabsf(deltaX / deltaY) < rubberbandDirectionLockStretchRatio))
-                    deltaX = 0;
-                else if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
-                    m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
-                    deltaX = 0;
-                } else
-                    m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
-            }
-        } else if (isHorizontallyStretched) {
-            // Stretching only in the horizontal.
-            if (pinnedInDirection(0, deltaY)) {
-                if (deltaX != 0 && (fabsf(deltaY / deltaX) < rubberbandDirectionLockStretchRatio))
-                    deltaY = 0;
-                else if (fabsf(deltaY) < rubberbandMinimumRequiredDeltaBeforeStretch) {
-                    m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
-                    deltaY = 0;
-                } else
-                    m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
-            }
-        } else {
-            // Not stretching at all yet.
-            if (pinnedInDirection(deltaX, deltaY)) {
-                if (fabsf(deltaY) >= fabsf(deltaX)) {
-                    if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
-                        m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
-                        deltaX = 0;
-                    } else
-                        m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
-                }
-                shouldStretch = true;
-            }
-        }
-    }
-
-    if (deltaX != 0 || deltaY != 0) {
-        if (!(shouldStretch || isVerticallyStretched || isHorizontallyStretched)) {
-            if (deltaY != 0) {
-                deltaY *= scrollWheelMultiplier();
-                immediateScrollByDeltaY(deltaY);
-            }
-            if (deltaX != 0) {
-                deltaX *= scrollWheelMultiplier();
-                immediateScrollByDeltaX(deltaX);
-            }
-        } else {
-            if (!allowsHorizontalStretching()) {
-                deltaX = 0;
-                eventCoalescedDeltaX = 0;
-            } else if ((deltaX != 0) && !isHorizontallyStretched && !pinnedInDirection(deltaX, 0)) {
-                deltaX *= scrollWheelMultiplier();
-
-                m_scrollableArea->setConstrainsScrollingToContentEdge(false);
-                immediateScrollByDeltaX(deltaX);
-                m_scrollableArea->setConstrainsScrollingToContentEdge(true);
-
-                deltaX = 0;
-            }
-            
-            if (!allowsVerticalStretching()) {
-                deltaY = 0;
-                eventCoalescedDeltaY = 0;
-            } else if ((deltaY != 0) && !isVerticallyStretched && !pinnedInDirection(0, deltaY)) {
-                deltaY *= scrollWheelMultiplier();
-
-                m_scrollableArea->setConstrainsScrollingToContentEdge(false);
-                immediateScrollByDeltaY(deltaY);
-                m_scrollableArea->setConstrainsScrollingToContentEdge(true);
-
-                deltaY = 0;
-            }
-            
-            IntSize stretchAmount = m_scrollableArea->overhangAmount();
-        
-            if (m_momentumScrollInProgress) {
-                if ((pinnedInDirection(eventCoalescedDeltaX, eventCoalescedDeltaY) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) {
-                    m_ignoreMomentumScrolls = true;
-                    m_momentumScrollInProgress = false;
-                    snapRubberBand();
-                }
-            }
-
-            m_stretchScrollForce.setWidth(m_stretchScrollForce.width() + deltaX);
-            m_stretchScrollForce.setHeight(m_stretchScrollForce.height() + deltaY);
-
-            FloatSize dampedDelta(ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.width())), ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.height())));
-            FloatPoint origOrigin = (m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin()) - stretchAmount;
-            FloatPoint newOrigin = origOrigin + dampedDelta;
-
-            if (origOrigin != newOrigin) {
-                m_scrollableArea->setConstrainsScrollingToContentEdge(false);
-                immediateScrollToPoint(newOrigin);
-                m_scrollableArea->setConstrainsScrollingToContentEdge(true);
-            }
-        }
-    }
-
-    if (m_momentumScrollInProgress && phase == PlatformWheelEventPhaseEnded) {
-        m_momentumScrollInProgress = false;
-        m_ignoreMomentumScrolls = false;
-        m_lastMomentumScrollTimestamp = 0;
-    }
-}
-
-void ScrollAnimatorChromiumMac::beginScrollGesture()
-{
-    didBeginScrollGesture();
-
-    m_haveScrolledSincePageLoad = true;
-    m_inScrollGesture = true;
-    m_momentumScrollInProgress = false;
-    m_ignoreMomentumScrolls = false;
-    m_lastMomentumScrollTimestamp = 0;
-    m_momentumVelocity = FloatSize();
-    m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
-    m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
-    m_cumulativeHorizontalScroll = 0;
-    m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
-    
-    IntSize stretchAmount = m_scrollableArea->overhangAmount();
-    m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
-    m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
-
-    m_overflowScrollDelta = FloatSize();
-    
-    if (m_snapRubberBandTimer.isActive())
-        m_snapRubberBandTimer.stop();
-}
-
-void ScrollAnimatorChromiumMac::endScrollGesture()
-{
-    didEndScrollGesture();
-
-    snapRubberBand();
-}
-
-void ScrollAnimatorChromiumMac::snapRubberBand()
-{
-    CFTimeInterval timeDelta = [[NSProcessInfo processInfo] systemUptime] - m_lastMomentumScrollTimestamp;
-    if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
-        m_momentumVelocity = FloatSize();
-
-    m_inScrollGesture = false;
-
-    if (m_snapRubberBandTimer.isActive())
-        return;
-
-    m_startTime = [NSDate timeIntervalSinceReferenceDate];
-    m_startStretch = FloatSize();
-    m_origOrigin = FloatPoint();
-    m_origVelocity = FloatSize();
-
-    m_snapRubberBandTimer.startRepeating(1.0/60.0);
-}
-
-static inline float roundTowardZero(float num)
-{
-    return num > 0 ? ceilf(num - 0.5f) : floorf(num + 0.5f);
-}
-
-static inline float roundToDevicePixelTowardZero(float num)
-{
-    float roundedNum = roundf(num);
-    if (fabs(num - roundedNum) < 0.125)
-        num = roundedNum;
-
-    return roundTowardZero(num);
-}
-
-void ScrollAnimatorChromiumMac::snapRubberBandTimerFired(Timer<ScrollAnimatorChromiumMac>*)
-{
-    if (!m_momentumScrollInProgress || m_ignoreMomentumScrolls) {
-        CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_startTime;
-
-        if (m_startStretch == FloatSize()) {
-            m_startStretch = m_scrollableArea->overhangAmount();
-            if (m_startStretch == FloatSize()) {    
-                m_snapRubberBandTimer.stop();
-                m_stretchScrollForce = FloatSize();
-                m_startTime = 0;
-                m_startStretch = FloatSize();
-                m_origOrigin = FloatPoint();
-                m_origVelocity = FloatSize();
-
-                return;
-            }
-
-            m_scrollableArea->didStartRubberBand(roundedIntSize(m_startStretch));
-
-            m_origOrigin = (m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin()) - m_startStretch;
-            m_origVelocity = m_momentumVelocity;
-
-            // Just like normal scrolling, prefer vertical rubberbanding
-            if (fabsf(m_origVelocity.height()) >= fabsf(m_origVelocity.width()))
-                m_origVelocity.setWidth(0);
-            
-            // Don't rubber-band horizontally if it's not possible to scroll horizontally
-            Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
-            if (!hScroller || !hScroller->enabled())
-                m_origVelocity.setWidth(0);
-            
-            // Don't rubber-band vertically if it's not possible to scroll horizontally
-            Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
-            if (!vScroller || !vScroller->enabled())
-                m_origVelocity.setHeight(0);
-        }
-
-        FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), (float)timeDelta)),
-                         roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), (float)timeDelta)));
-
-        if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
-            FloatPoint newOrigin = m_origOrigin + delta;
-
-            m_scrollableArea->setConstrainsScrollingToContentEdge(false);
-            immediateScrollToPoint(newOrigin);
-            m_scrollableArea->setConstrainsScrollingToContentEdge(true);
-
-            FloatSize newStretch = m_scrollableArea->overhangAmount();
-            
-            m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(newStretch.width()));
-            m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(newStretch.height()));
-        } else {
-            immediateScrollToPoint(m_origOrigin);
-
-            m_scrollableArea->didCompleteRubberBand(roundedIntSize(m_startStretch));
-
-            m_snapRubberBandTimer.stop();
-            m_stretchScrollForce = FloatSize();
-            
-            m_startTime = 0;
-            m_startStretch = FloatSize();
-            m_origOrigin = FloatPoint();
-            m_origVelocity = FloatSize();
-        }
-    } else {
-        m_startTime = [NSDate timeIntervalSinceReferenceDate];
-        m_startStretch = FloatSize();
-    }
-}
-#endif
-
-void ScrollAnimatorChromiumMac::setIsActive()
-{
-    if (isScrollbarOverlayAPIAvailable()) {
-        if (needsScrollerStyleUpdate())
-            updateScrollerStyle();
-    }
-}
-
-#if USE(WK_SCROLLBAR_PAINTER)
-void ScrollAnimatorChromiumMac::updateScrollerStyle()
-{
-    if (!scrollableArea()->isOnActivePage()) {
-        setNeedsScrollerStyleUpdate(true);
-        return;
-    }
-
-    ScrollbarThemeChromiumMac* macTheme = chromiumScrollbarTheme();
-    if (!macTheme) {
-        setNeedsScrollerStyleUpdate(false);
-        return;
-    }
-
-    int newStyle = wkScrollbarPainterControllerStyle(m_scrollbarPainterController.get());
-
-    if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) {
-        verticalScrollbar->invalidate();
-
-        WKScrollbarPainterRef oldVerticalPainter = wkVerticalScrollbarPainterForController(m_scrollbarPainterController.get());
-        WKScrollbarPainterRef newVerticalPainter = wkMakeScrollbarReplacementPainter(oldVerticalPainter,
-                                                                                     newStyle,
-                                                                                     verticalScrollbar->controlSize(),
-                                                                                     false);
-        macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainter);
-        wkSetPainterForPainterController(m_scrollbarPainterController.get(), newVerticalPainter, false);
-
-        // The different scrollbar styles have different thicknesses, so we must re-set the 
-        // frameRect to the new thickness, and the re-layout below will ensure the position
-        // and length are properly updated.
-        int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlSize());
-        verticalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness));
-    }
-
-    if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()) {
-        horizontalScrollbar->invalidate();
-
-        WKScrollbarPainterRef oldHorizontalPainter = wkHorizontalScrollbarPainterForController(m_scrollbarPainterController.get());
-        WKScrollbarPainterRef newHorizontalPainter = wkMakeScrollbarReplacementPainter(oldHorizontalPainter,
-                                                                                       newStyle,
-                                                                                       horizontalScrollbar->controlSize(),
-                                                                                       true);
-        macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPainter);
-        wkSetPainterForPainterController(m_scrollbarPainterController.get(), newHorizontalPainter, true);
-
-        // The different scrollbar styles have different thicknesses, so we must re-set the 
-        // frameRect to the new thickness, and the re-layout below will ensure the position
-        // and length are properly updated.
-        int thickness = macTheme->scrollbarThickness(horizontalScrollbar->controlSize());
-        horizontalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness));
-    }
-
-    // If needsScrollerStyleUpdate() is true, then the page is restoring from the page cache, and 
-    // a relayout will happen on its own. Otherwise, we must initiate a re-layout ourselves.
-    scrollableArea()->scrollbarStyleChanged(newStyle, !needsScrollerStyleUpdate());
-
-    setNeedsScrollerStyleUpdate(false);
-}
-
-void ScrollAnimatorChromiumMac::startScrollbarPaintTimer()
-{
-    m_initialScrollbarPaintTimer.startOneShot(0.1);
-}
-
-bool ScrollAnimatorChromiumMac::scrollbarPaintTimerIsActive() const
-{
-    return m_initialScrollbarPaintTimer.isActive();
-}
-
-void ScrollAnimatorChromiumMac::stopScrollbarPaintTimer()
-{
-    m_initialScrollbarPaintTimer.stop();
-}
-
-void ScrollAnimatorChromiumMac::initialScrollbarPaintTimerFired(Timer<ScrollAnimatorChromiumMac>*)
-{
-    wkScrollbarPainterForceFlashScrollers(m_scrollbarPainterController.get());
-}
-#endif
-
-void ScrollAnimatorChromiumMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
-{
-    IntRect rectInViewCoordinates = scrollerThumb;
-    if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar())
-        rectInViewCoordinates = verticalScrollbar->convertToContainingView(scrollerThumb);
-
-    if (rectInViewCoordinates == m_visibleScrollerThumbRect)
-        return;
-
-    m_scrollableArea->setVisibleScrollerThumbRect(rectInViewCoordinates);
-    m_visibleScrollerThumbRect = rectInViewCoordinates;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h b/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h
deleted file mode 100644 (file)
index 4c7f26a..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
- * Copyright (C) 2011 Google Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef ScrollbarOverlayUtilitiesChromiumMac_h
-#define ScrollbarOverlayUtilitiesChromiumMac_h
-
-#if USE(WK_SCROLLBAR_PAINTER)
-
-// Public APIs not available on versions of Mac on which we build
-#if (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD))
-enum {
-    NSScrollerStyleLegacy       = 0,
-    NSScrollerStyleOverlay      = 1
-};
-
-#ifdef __OBJC__
-typedef NSInteger NSScrollerStyle;
-#endif
-#endif
-
-typedef uint32 wkScrollerStyle;
-
-#ifdef __OBJC__
-@class NSScrollerImp;
-@class NSScrollerImpPair;
-#else
-class NSScrollerImp;
-class NSScrollerImpPair;
-#endif
-
-typedef NSScrollerImp* WKScrollbarPainterRef;
-typedef NSScrollerImpPair* WKScrollbarPainterControllerRef;
-
-bool isScrollbarOverlayAPIAvailable();
-
-// Scrollbar Painter
-bool wkScrollbarPainterUsesOverlayScrollers(void);
-bool wkScrollbarPainterIsHorizontal(WKScrollbarPainterRef);
-CGFloat wkScrollbarPainterKnobAlpha(WKScrollbarPainterRef);
-void wkScrollbarPainterSetOverlayState(WKScrollbarPainterRef, int overlayScrollerState);
-void wkScrollbarPainterPaint(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, NSRect frameRect);
-void wkScrollbarPainterPaintTrack(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, NSRect frameRect);
-void wkScrollbarPainterPaintKnob(WKScrollbarPainterRef);
-int wkScrollbarMinimumThumbLength(WKScrollbarPainterRef);
-void wkScrollbarPainterSetDelegate(WKScrollbarPainterRef, id scrollbarPainterDelegate);
-void wkScrollbarPainterSetEnabled(WKScrollbarPainterRef, bool enabled);
-CGFloat wkScrollbarPainterTrackAlpha(WKScrollbarPainterRef);
-WKScrollbarPainterRef wkMakeScrollbarPainter(int controlSize, bool isHorizontal);
-int wkScrollbarThickness(int controlSize);
-int wkScrollbarMinimumTotalLengthNeededForThumb(WKScrollbarPainterRef);
-CGRect wkScrollbarPainterKnobRect(WKScrollbarPainterRef);
-WKScrollbarPainterRef wkMakeScrollbarReplacementPainter(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal);
-void wkSetScrollbarPainterKnobAlpha(WKScrollbarPainterRef, CGFloat);
-void wkSetScrollbarPainterTrackAlpha(WKScrollbarPainterRef, CGFloat);
-
-enum {
-    wkScrollerKnobStyleDefault = 0,
-    wkScrollerKnobStyleDark = 1,
-    wkScrollerKnobStyleLight = 2
-};
-typedef uint32 wkScrollerKnobStyle;
-extern void wkSetScrollbarPainterKnobStyle(WKScrollbarPainterRef, wkScrollerKnobStyle);
-
-// Scrollbar Painter Controller
-WKScrollbarPainterControllerRef wkMakeScrollbarPainterController(id painterControllerDelegate);
-void wkContentAreaScrolled(WKScrollbarPainterControllerRef);
-void wkContentAreaWillPaint(WKScrollbarPainterControllerRef);
-void wkMouseEnteredContentArea(WKScrollbarPainterControllerRef);
-void wkMouseExitedContentArea(WKScrollbarPainterControllerRef);
-void wkMouseMovedInContentArea(WKScrollbarPainterControllerRef);
-void wkWillStartLiveResize(WKScrollbarPainterControllerRef);
-void wkContentAreaResized(WKScrollbarPainterControllerRef);
-void wkWillEndLiveResize(WKScrollbarPainterControllerRef);
-void wkContentAreaDidShow(WKScrollbarPainterControllerRef);
-void wkContentAreaDidHide(WKScrollbarPainterControllerRef);
-void wkDidBeginScrollGesture(WKScrollbarPainterControllerRef);
-void wkDidEndScrollGesture(WKScrollbarPainterControllerRef);
-void wkScrollbarPainterForceFlashScrollers(WKScrollbarPainterControllerRef);
-void wkSetScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef, wkScrollerStyle newStyle);
-void wkSetPainterForPainterController(WKScrollbarPainterControllerRef, WKScrollbarPainterRef, bool isHorizontal);
-WKScrollbarPainterRef wkVerticalScrollbarPainterForController(WKScrollbarPainterControllerRef);
-WKScrollbarPainterRef wkHorizontalScrollbarPainterForController(WKScrollbarPainterControllerRef);
-wkScrollerStyle wkScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef);
-
-#endif // USE(WK_SCROLLBAR_PAINTER)
-
-#endif // ScrollbarOverlayUtilitiesChromiumMac_h
diff --git a/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm b/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm
deleted file mode 100644 (file)
index a8b01d4..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
- * Copyright (C) 2011 Google Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "config.h"
-
-#if USE(WK_SCROLLBAR_PAINTER)
-
-#include "ScrollbarOverlayUtilitiesChromiumMac.h"
-#include "ScrollTypes.h"
-#include <Cocoa/Cocoa.h>
-
-// -----------------------------------------------------------------------------
-// This file contains utilities to draw overlay scrollbars. There are no public
-// APIs yet on the Mac to draw overlay scrollbars so we use private APIs that
-// we look up at runtime. If the private APIs don't exist then the wkMake*
-// functions will return nil.
-//
-// Note, this file contains functions copied from WebCoreSystemInterface.h.
-// Using the same names makes the code easier to maintain.
-// -----------------------------------------------------------------------------
-
-// Public APIs not available on versions of Mac on which we build
-#if (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD))
-@interface NSScroller (NSObject)
-+ (NSScrollerStyle)preferredScrollerStyle;
-@end
-#endif
-
-// These are private APIs to draw overlay scrollbars.
-@interface NSScrollerImp : NSObject
-
-+ (id)scrollerImpWithStyle:(NSScrollerStyle)style
-               controlSize:(NSControlSize)size
-                horizontal:(BOOL)horizontal
-      replacingScrollerImp:(id)scroller;
-
-@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;
-@property(assign) id delegate;
-
-- (CGFloat)knobMinLength;
-- (CGFloat)trackOverlapEndInset;
-- (CGFloat)knobOverlapEndInset;
-- (CGFloat)trackEndInset;
-- (CGFloat)knobEndInset;
-- (CGFloat)trackBoxWidth;
-- (CGFloat)trackWidth;
-- (void)setBoundsSize:(NSSize)size;
-- (void)drawKnobSlotInRect:(NSRect)rect
-                 highlight:(BOOL)flag;
-- (void)drawKnob;
-- (void)setOverlayScrollerState:(NSScrollerStyle)state
-               forceImmediately:(BOOL)flag;
-- (void)setDelegate:(id)delegate;
-- (NSRect)rectForPart:(NSUInteger)arg1;
-
-@end
-
-// These are private APIs to manage overlay scrollbars.
-@interface NSScrollerImpPair : NSObject
-
-@property NSScrollerStyle scrollerStyle;
-@property(retain) NSScrollerImp *horizontalScrollerImp;
-@property(retain) NSScrollerImp *verticalScrollerImp;
-@property(assign) id delegate;
-
-- (void)hideOverlayScrollers;
-- (void)flashScrollers;
-- (void)contentAreaScrolled;
-- (void)contentAreaWillDraw;
-- (void)contentAreaDidHide;
-- (void)windowOrderedOut;
-- (void)windowOrderedIn;
-- (void)mouseEnteredContentArea;
-- (void)mouseMovedInContentArea;
-- (void)mouseExitedContentArea;
-- (void)startLiveResize;
-- (void)contentAreaDidResize;
-- (void)endLiveResize;
-- (void)beginScrollGesture;
-- (void)endScrollGesture;
-
-@end
-
-static Class lookUpNSScrollerImpClass()
-{
-    static Class result = NSClassFromString(@"NSScrollerImp");
-    return result;
-}
-
-static Class lookUpNSScrollerImpPairClass()
-{
-    static Class result = NSClassFromString(@"NSScrollerImpPair");
-    return result;
-}
-
-static NSControlSize scrollbarControlSizeToNSControlSize(int controlSize)
-{
-    return controlSize == WebCore::RegularScrollbar ? NSRegularControlSize : NSSmallControlSize;
-}
-
-static NSScrollerStyle preferredScrollerStyle()
-{
-    if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
-        return [NSScroller preferredScrollerStyle];
-    return NSScrollerStyleLegacy;
-}
-
-bool wkScrollbarPainterUsesOverlayScrollers(void)
-{
-    return preferredScrollerStyle() == NSScrollerStyleOverlay;
-}
-
-bool wkScrollbarPainterIsHorizontal(WKScrollbarPainterRef painter)
-{
-    return [painter isHorizontal];
-}
-
-CGFloat wkScrollbarPainterKnobAlpha(WKScrollbarPainterRef painter)
-{
-    return [painter knobAlpha];
-}
-
-void wkScrollbarPainterSetOverlayState(WKScrollbarPainterRef painter, int overlayScrollerState)
-{
-    [painter setOverlayScrollerState:overlayScrollerState
-                    forceImmediately:YES];
-}
-
-void wkScrollbarPainterPaint(WKScrollbarPainterRef painter, bool enabled, double value, CGFloat proportion, NSRect frameRect)
-{
-    wkScrollbarPainterPaintTrack(painter, enabled, value, proportion, frameRect);
-    wkScrollbarPainterPaintKnob(painter);
-}
-
-void wkScrollbarPainterPaintTrack(WKScrollbarPainterRef painter, bool enabled, double value, CGFloat proportion, NSRect frameRect)
-{
-    [painter setEnabled:enabled];
-    [painter setBoundsSize:frameRect.size];
-    [painter setDoubleValue:value];
-    [painter setKnobProportion:proportion];
-
-    if ([painter isHorizontal])
-        frameRect.size.height = [painter trackWidth];
-    else
-        frameRect.size.width = [painter trackWidth];
-    frameRect.origin = NSZeroPoint;
-
-    [painter drawKnobSlotInRect:frameRect highlight:NO];
-}
-
-void wkScrollbarPainterPaintKnob(WKScrollbarPainterRef painter)
-{
-    [painter drawKnob];
-}
-
-int wkScrollbarMinimumThumbLength(WKScrollbarPainterRef painter)
-{
-    return [painter knobMinLength];
-}
-
-void wkScrollbarPainterSetDelegate(WKScrollbarPainterRef painter, id scrollbarPainterDelegate)
-{
-    [painter setDelegate:scrollbarPainterDelegate];
-}
-
-void wkScrollbarPainterSetEnabled(WKScrollbarPainterRef painter, bool enabled)
-{
-    [painter setEnabled:enabled];
-}
-
-CGFloat wkScrollbarPainterTrackAlpha(WKScrollbarPainterRef painter)
-{
-    return [painter trackAlpha];
-}
-
-WKScrollbarPainterRef wkMakeScrollbarPainter(int controlSize, bool isHorizontal)
-{
-    return wkMakeScrollbarReplacementPainter(nil, preferredScrollerStyle(), controlSize, isHorizontal);
-}
-
-int wkScrollbarThickness(int controlSize)
-{
-    return [wkMakeScrollbarPainter(controlSize, false) trackBoxWidth];
-}
-
-int wkScrollbarMinimumTotalLengthNeededForThumb(WKScrollbarPainterRef painter)
-{
-    return [painter knobMinLength] +
-           [painter trackOverlapEndInset] +
-           [painter knobOverlapEndInset] +
-           ([painter trackEndInset] + [painter knobEndInset]) * 2;
-}
-
-WKScrollbarPainterRef wkVerticalScrollbarPainterForController(WKScrollbarPainterControllerRef controller)
-{
-    return [controller verticalScrollerImp];
-}
-
-WKScrollbarPainterRef wkHorizontalScrollbarPainterForController(WKScrollbarPainterControllerRef controller)
-{
-    return [controller horizontalScrollerImp];
-}
-
-wkScrollerStyle wkScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef controller)
-{
-    return [controller scrollerStyle];
-}
-
-WKScrollbarPainterRef wkMakeScrollbarReplacementPainter(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal)
-{
-    if (!isScrollbarOverlayAPIAvailable())
-        return nil;
-    return [lookUpNSScrollerImpClass() scrollerImpWithStyle:newStyle
-                                                controlSize:scrollbarControlSizeToNSControlSize(controlSize)
-                                                 horizontal:isHorizontal
-                                       replacingScrollerImp:oldPainter];
-}
-
-void wkSetPainterForPainterController(WKScrollbarPainterControllerRef controller, WKScrollbarPainterRef painter, bool isHorizontal)
-{
-    if (isHorizontal)
-        [controller setHorizontalScrollerImp:painter];
-    else
-        [controller setVerticalScrollerImp:painter];
-}
-
-void wkSetScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef painter, wkScrollerStyle newStyle)
-{
-    [painter setScrollerStyle:newStyle];
-}
-
-CGRect wkScrollbarPainterKnobRect(WKScrollbarPainterRef painter)
-{
-    return NSRectToCGRect([painter rectForPart:NSScrollerKnob]);
-}
-
-void wkSetScrollbarPainterKnobAlpha(WKScrollbarPainterRef painter, CGFloat alpha)
-{
-    [painter setKnobAlpha:alpha];
-}
-
-void wkSetScrollbarPainterTrackAlpha(WKScrollbarPainterRef painter, CGFloat alpha)
-{
-    [painter setTrackAlpha:alpha];
-}
-
-void wkSetScrollbarPainterKnobStyle(WKScrollbarPainterRef painter, wkScrollerKnobStyle style)
-{
-    [painter setKnobStyle:style];
-}
-
-WKScrollbarPainterControllerRef wkMakeScrollbarPainterController(id painterControllerDelegate)
-{
-    if (!isScrollbarOverlayAPIAvailable())
-        return nil;
-    NSScrollerImpPair* controller = [[[lookUpNSScrollerImpPairClass() alloc] init] autorelease];
-    [controller setDelegate:painterControllerDelegate];
-    [controller setScrollerStyle:preferredScrollerStyle()];
-    return controller;
-}
-
-void wkContentAreaScrolled(WKScrollbarPainterControllerRef controller)
-{
-    [controller contentAreaScrolled];
-}
-
-void wkContentAreaWillPaint(WKScrollbarPainterControllerRef controller)
-{
-    [controller contentAreaWillDraw];
-}
-
-void wkMouseEnteredContentArea(WKScrollbarPainterControllerRef controller)
-{
-    [controller mouseEnteredContentArea];
-}
-
-void wkMouseExitedContentArea(WKScrollbarPainterControllerRef controller)
-{
-    [controller mouseExitedContentArea];
-}
-
-void wkMouseMovedInContentArea(WKScrollbarPainterControllerRef controller)
-{
-    [controller mouseMovedInContentArea];
-}
-
-void wkWillStartLiveResize(WKScrollbarPainterControllerRef controller)
-{
-    [controller startLiveResize];
-}
-
-void wkContentAreaResized(WKScrollbarPainterControllerRef controller)
-{
-    [controller contentAreaDidResize];
-}
-
-void wkWillEndLiveResize(WKScrollbarPainterControllerRef controller)
-{
-    [controller endLiveResize];
-}
-
-void wkContentAreaDidShow(WKScrollbarPainterControllerRef controller)
-{
-    [controller windowOrderedIn];
-}
-
-void wkContentAreaDidHide(WKScrollbarPainterControllerRef controller)
-{
-    [controller windowOrderedOut];
-}
-
-void wkDidBeginScrollGesture(WKScrollbarPainterControllerRef controller)
-{
-    [controller beginScrollGesture];
-}
-
-void wkDidEndScrollGesture(WKScrollbarPainterControllerRef controller)
-{
-    [controller endScrollGesture];
-}
-
-void wkScrollbarPainterForceFlashScrollers(WKScrollbarPainterControllerRef controller)
-{
-    [controller hideOverlayScrollers];
-    [controller flashScrollers];
-}
-
-bool isScrollbarOverlayAPIAvailable()
-{
-    static bool apiAvailable = [lookUpNSScrollerImpClass() respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] &&
-                               [lookUpNSScrollerImpPairClass() instancesRespondToSelector:@selector(scrollerStyle)];
-    return apiAvailable;
-}
-
-#endif // USE(WK_SCROLLBAR_PAINTER)
index cc9a308..41a198e 100644 (file)
 #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.
-// See the .mm file for details.
+#include "ScrollbarThemeMac.h"
 
 namespace WebCore {
 
-class ScrollbarThemeChromiumMac : public ScrollbarThemeComposite {
+class ScrollbarThemeChromiumMac : public ScrollbarThemeMac {
 public:
     ScrollbarThemeChromiumMac();
     virtual ~ScrollbarThemeChromiumMac();
 
-    void preferencesChanged();
-
-    virtual void updateEnabledState(Scrollbar*);
-
     virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect);
 
-    virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-
-    virtual bool supportsControlTints() const { return true; }
-    virtual bool usesOverlayScrollbars() const;
-    virtual void updateScrollbarOverlayStyle(Scrollbar*);
-
-    virtual double initialAutoscrollTimerDelay();
-    virtual double autoscrollTimerDelay();
-
-    virtual ScrollbarButtonsPlacement buttonsPlacement() const;
-
-    virtual void registerScrollbar(Scrollbar*);
-    virtual void unregisterScrollbar(Scrollbar*);
-
-    void setNewPainterForScrollbar(Scrollbar*, WKScrollbarPainterRef);
-    WKScrollbarPainterRef painterForScrollbar(Scrollbar*);
-
     virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
     
-protected:
-    virtual bool hasButtons(Scrollbar*);
-    virtual bool hasThumb(Scrollbar*);
-
-    virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
-    virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
-    virtual IntRect trackRect(Scrollbar*, bool painting = false);
-
-    virtual int maxOverlapBetweenPages() { return 40; }
-
-    virtual int minimumThumbLength(Scrollbar*);
-
-    virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
-    virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);
-
 private:
     void paintGivenTickmarks(GraphicsContext*, Scrollbar*, const IntRect&, const Vector<IntRect>&);
 
-private:
     RefPtr<Pattern> m_overhangPattern;
 };
 
index 84d5fe1..459a58b 100644 (file)
 #include "config.h"
 #include "ScrollbarThemeChromiumMac.h"
 
-#include "BitmapImage.h"
 #include "FrameView.h"
 #include "Gradient.h"
 #include "ImageBuffer.h"
 #include "LocalCurrentGraphicsContext.h"
-#include "PlatformMouseEvent.h"
+#include "NSScrollerImpDetails.h"
 #include "PlatformSupport.h"
-#include "ScrollAnimatorChromiumMac.h"
+#include "ScrollAnimatorMac.h"
 #include "ScrollView.h"
 #include <Carbon/Carbon.h>
-#include <wtf/HashMap.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/UnusedParam.h>
 
 #if USE(SKIA)
 #include "PlatformContextSkia.h"
 #include "skia/ext/skia_utils_mac.h"
 #endif
 
-
-
-// FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow.
-
-using namespace std;
-using namespace WebCore;
-
-// This file (and its associated .h file) is a clone of ScrollbarThemeMac.mm.
-// Because we want to draw tickmarks in the scrollbar, we must maintain a fork.
-// Please maintain this file by performing parallel changes to it.
-//
-// The only changes from ScrollbarThemeMac should be:
-// - 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.
-
-namespace WebCore {
-
-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;
-
-@end
-
-@implementation ScrollbarPrefsObserver
-
-+ (void)appearancePrefsChanged:(NSNotification*)unusedNotification
-{
-    UNUSED_PARAM(unusedNotification);
-
-    ScrollbarTheme* theme = ScrollbarTheme::theme();
-    if (theme->isMockTheme())
-        return;
-
-    static_cast<ScrollbarThemeChromiumMac*>(theme)->preferencesChanged();
-    if (scrollbarMap()->isEmpty())
-        return;
-    ScrollbarPainterMap::iterator end = scrollbarMap()->end();
-    for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) {
-        it->first->styleChanged();
-        it->first->invalidate();
-    }
-}
-
-+ (void)behaviorPrefsChanged:(NSNotification*)unusedNotification
-{
-    UNUSED_PARAM(unusedNotification);
-
-    ScrollbarTheme* theme = ScrollbarTheme::theme();
-    if (theme->isMockTheme())
-        return;
-
-    static_cast<ScrollbarThemeChromiumMac*>(theme)->preferencesChanged();
-}
-
-+ (void)registerAsObserver
-{
-    [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(appearancePrefsChanged:) name:@"AppleAquaScrollBarVariantChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
-    [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(behaviorPrefsChanged:) name:@"AppleNoRedisplayAppearancePreferenceChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
-}
-
-@end
-
 namespace WebCore {
 
 ScrollbarTheme* ScrollbarTheme::nativeTheme()
@@ -137,333 +50,17 @@ ScrollbarTheme* ScrollbarTheme::nativeTheme()
     return &theme;
 }
 
-// FIXME: Get these numbers from CoreUI.
-static int cScrollbarThickness[] = { 15, 11 };
-static int cRealButtonLength[] = { 28, 21 };
-static int cButtonInset[] = { 14, 11 };
-static int cButtonHitInset[] = { 3, 2 };
-// cRealButtonLength - cButtonInset
-static int cButtonLength[] = { 14, 10 };
-static int cThumbMinLength[] = { 26, 20 };
-
-static int cOuterButtonLength[] = { 16, 14 }; // The outer button in a double button pair is a bit bigger.
-static int cOuterButtonOverlap = 2;
-
-static float gInitialButtonDelay = 0.5f;
-static float gAutoscrollButtonDelay = 0.05f;
-static bool gJumpOnTrackClick = false;
-static ScrollbarButtonsPlacement gButtonPlacement = isScrollbarOverlayAPIAvailable() ? ScrollbarButtonsNone : ScrollbarButtonsDoubleEnd;
-
-static void updateArrowPlacement()
-{
-    if (isScrollbarOverlayAPIAvailable())
-        return;
-
-    NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
-    if ([buttonPlacement isEqualToString:@"Single"])
-        gButtonPlacement = ScrollbarButtonsSingle;
-    else if ([buttonPlacement isEqualToString:@"DoubleMin"])
-        gButtonPlacement = ScrollbarButtonsDoubleStart;
-    else if ([buttonPlacement isEqualToString:@"DoubleBoth"])
-        gButtonPlacement = ScrollbarButtonsDoubleBoth;
-    else
-        gButtonPlacement = ScrollbarButtonsDoubleEnd;
-}
-
-void ScrollbarThemeChromiumMac::registerScrollbar(Scrollbar* scrollbar)
-{
-    bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;
-    WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(), isHorizontal);
-    scrollbarMap()->add(scrollbar, scrollbarPainter);
-    updateEnabledState(scrollbar);
-    updateScrollbarOverlayStyle(scrollbar);
-}
-
-void ScrollbarThemeChromiumMac::unregisterScrollbar(Scrollbar* scrollbar)
-{
-    scrollbarMap()->remove(scrollbar);
-}
-
-void ScrollbarThemeChromiumMac::setNewPainterForScrollbar(Scrollbar* scrollbar, WKScrollbarPainterRef newPainter)
-{
-    scrollbarMap()->set(scrollbar, newPainter);
-    updateEnabledState(scrollbar);
-    updateScrollbarOverlayStyle(scrollbar);
-}
-
-WKScrollbarPainterRef ScrollbarThemeChromiumMac::painterForScrollbar(Scrollbar* scrollbar)
-{
-    return scrollbarMap()->get(scrollbar).get();
-}
-
 ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac()
 {
-    static bool initialized;
-    if (!initialized) {
-        initialized = true;
-
-        // Load the linen pattern image used for overhang drawing.
-        RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern");
-        m_overhangPattern = Pattern::create(patternImage, true, true);
-
-        [ScrollbarPrefsObserver registerAsObserver];
-        preferencesChanged();
-    }
+    // Load the linen pattern image used for overhang drawing.
+    RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern");
+    m_overhangPattern = Pattern::create(patternImage, true, true);
 }
 
 ScrollbarThemeChromiumMac::~ScrollbarThemeChromiumMac()
 {
 }
 
-void ScrollbarThemeChromiumMac::preferencesChanged()
-{
-    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    [defaults synchronize];
-    updateArrowPlacement();
-    gInitialButtonDelay = [defaults floatForKey:@"NSScrollerButtonDelay"];
-    gAutoscrollButtonDelay = [defaults floatForKey:@"NSScrollerButtonPeriod"];
-    gJumpOnTrackClick = [defaults boolForKey:@"AppleScrollerPagingBehavior"];
-}
-
-int ScrollbarThemeChromiumMac::scrollbarThickness(ScrollbarControlSize controlSize)
-{
-    if (isScrollbarOverlayAPIAvailable())
-        return wkScrollbarThickness(controlSize);
-    else
-        return cScrollbarThickness[controlSize];
-}
-
-bool ScrollbarThemeChromiumMac::usesOverlayScrollbars() const
-{
-    if (isScrollbarOverlayAPIAvailable())
-        return wkScrollbarPainterUsesOverlayScrollers();
-    else
-        return false;
-}
-
-static inline wkScrollerKnobStyle toScrollbarPainterKnobStyle(ScrollbarOverlayStyle style)
-{
-    switch (style) {
-    case ScrollbarOverlayStyleDark:
-        return wkScrollerKnobStyleDark;
-    case ScrollbarOverlayStyleLight:
-        return wkScrollerKnobStyleLight;
-    default:
-        return wkScrollerKnobStyleDefault;
-    }
-}
-
-void ScrollbarThemeChromiumMac::updateScrollbarOverlayStyle(Scrollbar* scrollbar)
-{
-    if (isScrollbarOverlayAPIAvailable()) {
-        wkSetScrollbarPainterKnobStyle(painterForScrollbar(scrollbar), toScrollbarPainterKnobStyle(scrollbar->scrollableArea()->scrollbarOverlayStyle()));
-    }
-}
-
-double ScrollbarThemeChromiumMac::initialAutoscrollTimerDelay()
-{
-    return gInitialButtonDelay;
-}
-
-double ScrollbarThemeChromiumMac::autoscrollTimerDelay()
-{
-    return gAutoscrollButtonDelay;
-}
-
-ScrollbarButtonsPlacement ScrollbarThemeChromiumMac::buttonsPlacement() const
-{
-    return gButtonPlacement;
-}
-
-bool ScrollbarThemeChromiumMac::hasButtons(Scrollbar* scrollbar)
-{
-    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()) >= 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]);
-        if (!start)
-            paintRect.setX(buttonRect.x() - (cRealButtonLength[controlSize] - buttonRect.width()));
-    } else {
-        paintRect.setHeight(cRealButtonLength[controlSize]);
-        if (!start)
-            paintRect.setY(buttonRect.y() - (cRealButtonLength[controlSize] - buttonRect.height()));
-    }
-
-    return paintRect;
-}
-
-IntRect ScrollbarThemeChromiumMac::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)
-{
-    IntRect result;
-
-    if (part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd))
-        return result;
-
-    if (part == BackButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsSingle))
-        return result;
-
-    int thickness = scrollbarThickness(scrollbar->controlSize());
-    bool outerButton = part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsDoubleBoth);
-    if (outerButton) {
-        if (scrollbar->orientation() == HorizontalScrollbar)
-            result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + (painting ? cOuterButtonOverlap : 0), thickness);
-        else
-            result = IntRect(scrollbar->x(), scrollbar->y(), thickness, cOuterButtonLength[scrollbar->controlSize()] + (painting ? cOuterButtonOverlap : 0));
-        return result;
-    }
-
-    // Our repaint rect is slightly larger, since we are a button that is adjacent to the track.
-    if (scrollbar->orientation() == HorizontalScrollbar) {
-        int start = part == BackButtonStartPart ? scrollbar->x() : scrollbar->x() + scrollbar->width() - cOuterButtonLength[scrollbar->controlSize()] - cButtonLength[scrollbar->controlSize()];
-        result = IntRect(start, scrollbar->y(), cButtonLength[scrollbar->controlSize()], thickness);
-    } else {
-        int start = part == BackButtonStartPart ? scrollbar->y() : scrollbar->y() + scrollbar->height() - cOuterButtonLength[scrollbar->controlSize()] - cButtonLength[scrollbar->controlSize()];
-        result = IntRect(scrollbar->x(), start, thickness, cButtonLength[scrollbar->controlSize()]);
-    }
-
-    if (painting)
-        return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), part == BackButtonStartPart);
-    return result;
-}
-
-IntRect ScrollbarThemeChromiumMac::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)
-{
-    IntRect result;
-
-    if (part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart))
-        return result;
-
-    if (part == ForwardButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() == ScrollbarButtonsSingle))
-        return result;
-
-    int thickness = scrollbarThickness(scrollbar->controlSize());
-    int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()];
-    int buttonLength = cButtonLength[scrollbar->controlSize()];
-
-    bool outerButton = part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() == ScrollbarButtonsDoubleBoth);
-    if (outerButton) {
-        if (scrollbar->orientation() == HorizontalScrollbar) {
-            result = IntRect(scrollbar->x() + scrollbar->width() - outerButtonLength, scrollbar->y(), outerButtonLength, thickness);
-            if (painting)
-                result.inflateX(cOuterButtonOverlap);
-        } else {
-            result = IntRect(scrollbar->x(), scrollbar->y() + scrollbar->height() - outerButtonLength, thickness, outerButtonLength);
-            if (painting)
-                result.inflateY(cOuterButtonOverlap);
-        }
-        return result;
-    }
-
-    if (scrollbar->orientation() == HorizontalScrollbar) {
-        int start = part == ForwardButtonEndPart ? scrollbar->x() + scrollbar->width() - buttonLength : scrollbar->x() + outerButtonLength;
-        result = IntRect(start, scrollbar->y(), buttonLength, thickness);
-    } else {
-        int start = part == ForwardButtonEndPart ? scrollbar->y() + scrollbar->height() - buttonLength : scrollbar->y() + outerButtonLength;
-        result = IntRect(scrollbar->x(), start, thickness, buttonLength);
-    }
-    if (painting)
-        return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), part == ForwardButtonStartPart);
-    return result;
-}
-
-IntRect ScrollbarThemeChromiumMac::trackRect(Scrollbar* scrollbar, bool painting)
-{
-    if (painting || !hasButtons(scrollbar))
-        return scrollbar->frameRect();
-
-    IntRect result;
-    int thickness = scrollbarThickness(scrollbar->controlSize());
-    int startWidth = 0;
-    int endWidth = 0;
-    int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()];
-    int buttonLength = cButtonLength[scrollbar->controlSize()];
-    int doubleButtonLength = outerButtonLength + buttonLength;
-    switch (buttonsPlacement()) {
-        case ScrollbarButtonsSingle:
-            startWidth = buttonLength;
-            endWidth = buttonLength;
-            break;
-        case ScrollbarButtonsDoubleStart:
-            startWidth = doubleButtonLength;
-            break;
-        case ScrollbarButtonsDoubleEnd:
-            endWidth = doubleButtonLength;
-            break;
-        case ScrollbarButtonsDoubleBoth:
-            startWidth = doubleButtonLength;
-            endWidth = doubleButtonLength;
-            break;
-        default:
-            break;
-    }
-
-    int totalWidth = startWidth + endWidth;
-    if (scrollbar->orientation() == HorizontalScrollbar)
-        return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->width() - totalWidth, thickness);
-    return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrollbar->height() - totalWidth);
-}
-
-int ScrollbarThemeChromiumMac::minimumThumbLength(Scrollbar* scrollbar)
-{
-    if (isScrollbarOverlayAPIAvailable())
-        return wkScrollbarMinimumThumbLength(scrollbarMap()->get(scrollbar).get());
-    else
-        return cThumbMinLength[scrollbar->controlSize()];
-}
-
-bool ScrollbarThemeChromiumMac::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
-{
-    if (evt.button() != LeftButton)
-        return false;
-    if (gJumpOnTrackClick)
-        return !evt.altKey();
-    return evt.altKey();
-}
-
-bool ScrollbarThemeChromiumMac::shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent& event)
-{
-    return event.altKey();
-}
-
-static int scrollbarPartToHIPressedState(ScrollbarPart part)
-{
-    switch (part) {
-        case BackButtonStartPart:
-            return kThemeTopOutsideArrowPressed;
-        case BackButtonEndPart:
-            return kThemeTopOutsideArrowPressed; // This does not make much sense.  For some reason the outside constant is required.
-        case ForwardButtonStartPart:
-            return kThemeTopInsideArrowPressed;
-        case ForwardButtonEndPart:
-            return kThemeBottomOutsideArrowPressed;
-        case ThumbPart:
-            return kThemeThumbPressed;
-        default:
-            return 0;
-    }
-}
-
 static PlatformSupport::ThemePaintState scrollbarStateToThemeState(Scrollbar* scrollbar)
 {
     if (!scrollbar->enabled())
@@ -476,13 +73,27 @@ static PlatformSupport::ThemePaintState scrollbarStateToThemeState(Scrollbar* sc
     return PlatformSupport::StateActive;
 }
 
-void ScrollbarThemeChromiumMac::updateEnabledState(Scrollbar* scrollbar)
+static void scrollbarPainterPaintTrack(ScrollbarPainter scrollbarPainter, bool enabled, double value, CGFloat proportion, CGRect frameRect)
 {
-    if (isScrollbarOverlayAPIAvailable()) {
-        wkScrollbarPainterSetEnabled(scrollbarMap()->get(scrollbar).get(), scrollbar->enabled());
-    }
+    [scrollbarPainter setEnabled:enabled];
+    [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)];
+    [scrollbarPainter setDoubleValue:value];
+    [scrollbarPainter setKnobProportion:proportion];
+
+    // The scrollbar's frameRect includes a side inset for overlay scrollers, so we have to use the 
+    // trackWidth for drawKnobSlotInRect
+    NSRect trackRect;
+    if ([scrollbarPainter isHorizontal])
+        trackRect = NSMakeRect(0, 0, frameRect.size.width, [scrollbarPainter trackWidth]);
+    else
+        trackRect = NSMakeRect(0, 0, [scrollbarPainter trackWidth], frameRect.size.height);
+    [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO];
 }
 
+// Override ScrollbarThemeMac::paint() to add support for the following:
+//     - drawing using PlatformSupport functions
+//     - drawing tickmarks
+//     - Skia specific changes
 bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect)
 {
     // Get the tickmarks for the frameview.
@@ -510,33 +121,32 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
                 value = 0;
         }
 
-        ScrollAnimatorChromiumMac* scrollAnimator = static_cast<ScrollAnimatorChromiumMac*>(scrollbar->scrollableArea()->scrollAnimator());
 #if !USE(SKIA)
-        scrollAnimator->setIsDrawingIntoLayer(context->isCALayerContext());
+        setIsCurrentlyDrawingIntoLayer(context->isCALayerContext());
 #else
-        scrollAnimator->setIsDrawingIntoLayer(false);
+        setIsCurrentlyDrawingIntoLayer(false);
 #endif
 
         CGFloat oldKnobAlpha = 0;
         CGFloat oldTrackAlpha = 0;
         bool hasTickmarks = tickmarks.size() > 0 && scrollbar->orientation() == VerticalScrollbar;
+        ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar);
         if (hasTickmarks) {
-          oldKnobAlpha = wkScrollbarPainterKnobAlpha(painterForScrollbar(scrollbar));
-          wkSetScrollbarPainterKnobAlpha(painterForScrollbar(scrollbar), 1.0);
-          oldTrackAlpha = wkScrollbarPainterTrackAlpha(painterForScrollbar(scrollbar));
-          wkSetScrollbarPainterTrackAlpha(painterForScrollbar(scrollbar), 1.0);
+            oldKnobAlpha = [scrollbarPainter knobAlpha];
+            [scrollbarPainter setKnobAlpha:1.0];
+            oldTrackAlpha = [scrollbarPainter trackAlpha];
+            [scrollbarPainter setTrackAlpha:1.0];
         }
 
         GraphicsContextStateSaver stateSaver(*context);
         context->clip(damageRect);
         context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
         LocalCurrentGraphicsContext localContext(context);
-        WKScrollbarPainterRef scrollbarPainter = scrollbarMap()->get(scrollbar).get();
-        wkScrollbarPainterPaintTrack(scrollbarPainter,
-                                     scrollbar->enabled(),
-                                     value,
-                                     (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(),
-                                     scrollbar->frameRect());
+        scrollbarPainterPaintTrack(scrollbarPainter,
+                                   scrollbar->enabled(),
+                                   value,
+                                   (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(),
+                                   scrollbar->frameRect());
 
         IntRect tickmarkTrackRect(IntPoint(), trackRect(scrollbar, false).size());
         if (tickmarkTrackRect.width() <= 10) {
@@ -550,13 +160,14 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
         }
         paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks);
 
-        wkScrollbarPainterPaintKnob(scrollbarPainter);
+        if (scrollbar->enabled())
+            [scrollbarPainter drawKnob];
 
-        scrollAnimator->setIsDrawingIntoLayer(false);
+        setIsCurrentlyDrawingIntoLayer(false);
 
         if (hasTickmarks) {
-          wkSetScrollbarPainterKnobAlpha(scrollbarPainter, oldKnobAlpha);
-          wkSetScrollbarPainterTrackAlpha(scrollbarPainter, oldTrackAlpha);
+            [scrollbarPainter setKnobAlpha:oldKnobAlpha];
+            [scrollbarPainter setTrackAlpha:oldTrackAlpha];
         }
 
         return true;
index db5cdc6..c11b05f 100644 (file)
@@ -34,6 +34,7 @@
 EMPTY_PROTOCOL(NSTableViewDataSource)
 EMPTY_PROTOCOL(NSTableViewDelegate)
 EMPTY_PROTOCOL(NSWindowDelegate)
+EMPTY_PROTOCOL(NSAnimationDelegate)
 
 #endif
 
index ce1146d..7b3d14c 100644 (file)
 
 #include "config.h"
 
-#if USE(SCROLLBAR_PAINTER)
+// Public APIs not available on versions of Mac on which we build
+#if (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD))
+enum {
+    NSScrollerStyleLegacy       = 0,
+    NSScrollerStyleOverlay      = 1
+};
+typedef NSInteger NSScrollerStyle;
+
+enum {
+    NSScrollerKnobStyleDefault = 0,
+    NSScrollerKnobStyleDark = 1,
+    NSScrollerKnobStyleLight = 2
+};
+typedef NSInteger NSScrollerKnobStyle;
+#endif
+
+#if (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD))
+@interface NSScroller(NSObject)
++ (NSScrollerStyle)preferredScrollerStyle;
+@end
+#endif
+
 @interface NSObject (ScrollbarPainter)
 + (id)scrollerImpWithStyle:(NSScrollerStyle)newScrollerStyle controlSize:(NSControlSize)newControlSize horizontal:(BOOL)horizontal replacingScrollerImp:(id)previous;
 - (CGFloat)knobAlpha;
 - (void)beginScrollGesture;
 - (void)endScrollGesture;
 @end
+
+namespace WebCore {
+
+#if PLATFORM(CHROMIUM)
+bool isScrollbarOverlayAPIAvailable();
+#else
+static inline bool isScrollbarOverlayAPIAvailable()
+{
+#if USE(SCROLLBAR_PAINTER)
+    return true;
+#else
+    return false;
 #endif
+}
+#endif
+
+NSScrollerStyle recommendedScrollerStyle();
+
+}
 
 #endif
diff --git a/Source/WebCore/platform/mac/NSScrollerImpDetails.mm b/Source/WebCore/platform/mac/NSScrollerImpDetails.mm
new file mode 100644 (file)
index 0000000..0f44407
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2011 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "NSScrollerImpDetails.h"
+
+namespace WebCore {
+
+#if PLATFORM(CHROMIUM)
+bool isScrollbarOverlayAPIAvailable()
+{
+    static bool apiAvailable;
+    static bool shouldInitialize = true;
+    if (shouldInitialize) {
+        shouldInitialize = false;
+        Class scrollerImpClass = NSClassFromString(@"NSScrollerImp");
+        Class scrollerImpPairClass = NSClassFromString(@"NSScrollerImpPair");
+        apiAvailable = [scrollerImpClass respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)]
+                       && [scrollerImpPairClass instancesRespondToSelector:@selector(scrollerStyle)];
+    }
+    return apiAvailable;
+}
+#endif
+
+NSScrollerStyle recommendedScrollerStyle() {
+    if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
+        return [NSScroller preferredScrollerStyle];
+    return NSScrollerStyleLegacy;
+}
+
+}
index b73edbb..9cdc0d2 100644 (file)
@@ -46,9 +46,7 @@ class WebScrollbarPainterControllerDelegate;
 class WebScrollbarPainterDelegate;
 #endif
 
-#if USE(SCROLLBAR_PAINTER)
 typedef id ScrollbarPainterController;
-#endif
 
 #if !ENABLE(RUBBER_BANDING)
 class ScrollElasticityControllerClient { };
@@ -86,13 +84,11 @@ public:
 
     virtual void setIsActive();
 
-#if USE(SCROLLBAR_PAINTER)
     void updateScrollerStyle();
 
     bool scrollbarPaintTimerIsActive() const;
     void startScrollbarPaintTimer();
     void stopScrollbarPaintTimer();
-#endif
 
     void setVisibleScrollerThumbRect(const IntRect&);
 
@@ -100,7 +96,6 @@ private:
     RetainPtr<id> m_scrollAnimationHelper;
     RetainPtr<WebScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate;
 
-#if USE(SCROLLBAR_PAINTER)
     RetainPtr<ScrollbarPainterController> m_scrollbarPainterController;
     RetainPtr<WebScrollbarPainterControllerDelegate> m_scrollbarPainterControllerDelegate;
     RetainPtr<WebScrollbarPainterDelegate> m_horizontalScrollbarPainterDelegate;
@@ -108,7 +103,6 @@ private:
 
     void initialScrollbarPaintTimerFired(Timer<ScrollAnimatorMac>*);
     Timer<ScrollAnimatorMac> m_initialScrollbarPaintTimer;
-#endif
     
     virtual void notifyPositionChanged();
     virtual void contentAreaWillPaint() const;
index 0bcbba8..828d40e 100644 (file)
@@ -30,6 +30,7 @@
 #include "ScrollAnimatorMac.h"
 
 #include "BlockExceptions.h"
+#include "EmptyProtocolDefinitions.h"
 #include "FloatPoint.h"
 #include "NSScrollerImpDetails.h"
 #include "PlatformGestureEvent.h"
 using namespace WebCore;
 using namespace std;
 
-#if USE(SCROLLBAR_PAINTER)
+#ifdef BUILDING_ON_LEOPARD
+@interface NSProcessInfo (ScrollAnimatorMacExt)
+- (NSTimeInterval)systemUptime;
+@end
+#endif
+
 static bool supportsUIStateTransitionProgress()
 {
     // FIXME: This is temporary until all platforms that support ScrollbarPainter support this part of the API.
@@ -66,7 +72,6 @@ static ScrollbarPainter scrollbarPainterForScrollbar(Scrollbar* scrollbar)
 
     return nil;
 }
-#endif
 
 @interface NSObject (ScrollAnimationHelperDetails)
 - (id)initWithDelegate:(id)delegate;
@@ -172,8 +177,6 @@ static NSSize abs(NSSize size)
 
 @end
 
-#if USE(SCROLLBAR_PAINTER)
-
 @interface WebScrollbarPainterControllerDelegate : NSObject
 {
     ScrollableArea* _scrollableArea;
@@ -409,6 +412,7 @@ enum FeatureToAnimate {
     return aRect;
 }
 
+#if !PLATFORM(CHROMIUM)
 - (CALayer *)layer
 {
     if (!_scrollbar)
@@ -421,6 +425,7 @@ enum FeatureToAnimate {
     static CALayer *dummyLayer = [[CALayer alloc] init];
     return dummyLayer;
 }
+#endif
 
 - (NSPoint)mouseLocationInScrollerForScrollerImp:(id)scrollerImp
 {
@@ -541,8 +546,6 @@ enum FeatureToAnimate {
 
 @end
 
-#endif // USE(SCROLLBAR_PAINTER)
-
 namespace WebCore {
 
 PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea)
@@ -552,9 +555,7 @@ PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea
 
 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea)
     : ScrollAnimator(scrollableArea)
-#if USE(SCROLLBAR_PAINTER)
     , m_initialScrollbarPaintTimer(this, &ScrollAnimatorMac::initialScrollbarPaintTimerFired)
-#endif
 #if ENABLE(RUBBER_BANDING)
     , m_scrollElasticityController(this)
     , m_snapRubberBandTimer(this, &ScrollAnimatorMac::snapRubberBandTimerFired)
@@ -565,25 +566,25 @@ ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea)
     m_scrollAnimationHelperDelegate.adoptNS([[WebScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]);
     m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]);
 
-#if USE(SCROLLBAR_PAINTER)
-    m_scrollbarPainterControllerDelegate.adoptNS([[WebScrollbarPainterControllerDelegate alloc] initWithScrollableArea:scrollableArea]);
-    m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair") alloc] init] autorelease];
-    [m_scrollbarPainterController.get() setDelegate:m_scrollbarPainterControllerDelegate.get()];
-    [m_scrollbarPainterController.get() setScrollerStyle:wkRecommendedScrollerStyle()];
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        m_scrollbarPainterControllerDelegate.adoptNS([[WebScrollbarPainterControllerDelegate alloc] initWithScrollableArea:scrollableArea]);
+        m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair") alloc] init] autorelease];
+        [m_scrollbarPainterController.get() setDelegate:m_scrollbarPainterControllerDelegate.get()];
+        [m_scrollbarPainterController.get() setScrollerStyle:recommendedScrollerStyle()];
+    }
 }
 
 ScrollAnimatorMac::~ScrollAnimatorMac()
 {
-#if USE(SCROLLBAR_PAINTER)
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [m_scrollbarPainterControllerDelegate.get() invalidate];
-    [m_scrollbarPainterController.get() setDelegate:nil];
-    [m_horizontalScrollbarPainterDelegate.get() invalidate];
-    [m_verticalScrollbarPainterDelegate.get() invalidate];
-    [m_scrollAnimationHelperDelegate.get() invalidate];
-    END_BLOCK_OBJC_EXCEPTIONS;
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        BEGIN_BLOCK_OBJC_EXCEPTIONS;
+        [m_scrollbarPainterControllerDelegate.get() invalidate];
+        [m_scrollbarPainterController.get() setDelegate:nil];
+        [m_horizontalScrollbarPainterDelegate.get() invalidate];
+        [m_verticalScrollbarPainterDelegate.get() invalidate];
+        [m_scrollAnimationHelperDelegate.get() invalidate];
+        END_BLOCK_OBJC_EXCEPTIONS;
+    }
 }
 
 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier)
@@ -695,13 +696,13 @@ void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(const FloatPoin
 
 void ScrollAnimatorMac::notifyPositionChanged()
 {
-#if USE(SCROLLBAR_PAINTER)
-    // This function is called when a page is going into the page cache, but the page 
-    // isn't really scrolling in that case. We should only pass the message on to the
-    // ScrollbarPainterController when we're really scrolling on an active page.
-    if (scrollableArea()->isOnActivePage())
-        [m_scrollbarPainterController.get() contentAreaScrolled];
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        // This function is called when a page is going into the page cache, but the page 
+        // isn't really scrolling in that case. We should only pass the message on to the
+        // ScrollbarPainterController when we're really scrolling on an active page.
+        if (scrollableArea()->isOnActivePage())
+            [m_scrollbarPainterController.get() contentAreaScrolled];
+    }
     ScrollAnimator::notifyPositionChanged();
 }
 
@@ -709,214 +710,190 @@ void ScrollAnimatorMac::contentAreaWillPaint() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() contentAreaWillDraw];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() contentAreaWillDraw];
 }
 
 void ScrollAnimatorMac::mouseEnteredContentArea() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() mouseEnteredContentArea];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() mouseEnteredContentArea];
 }
 
 void ScrollAnimatorMac::mouseExitedContentArea() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() mouseExitedContentArea];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() mouseExitedContentArea];
 }
 
 void ScrollAnimatorMac::mouseMovedInContentArea() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() mouseMovedInContentArea];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() mouseMovedInContentArea];
 }
 
 void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    if (!supportsUIStateTransitionProgress())
-        return;
-    if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar))
-        [painter mouseEnteredScroller];
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        if (!supportsUIStateTransitionProgress())
+            return;
+        if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar))
+            [painter mouseEnteredScroller];
+    }
 }
 
 void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar* scrollbar) const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    if (!supportsUIStateTransitionProgress())
-        return;
-    if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar))
-        [painter mouseExitedScroller];
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        if (!supportsUIStateTransitionProgress())
+            return;
+        if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar))
+            [painter mouseExitedScroller];
+    }
 }
 
 void ScrollAnimatorMac::willStartLiveResize()
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() startLiveResize];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() startLiveResize];
 }
 
 void ScrollAnimatorMac::contentsResized() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() contentAreaDidResize];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() contentAreaDidResize];
 }
 
 void ScrollAnimatorMac::willEndLiveResize()
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() endLiveResize];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() endLiveResize];
 }
 
 void ScrollAnimatorMac::contentAreaDidShow() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() windowOrderedIn];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() windowOrderedIn];
 }
 
 void ScrollAnimatorMac::contentAreaDidHide() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() windowOrderedOut];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() windowOrderedOut];
 }
 
 void ScrollAnimatorMac::didBeginScrollGesture() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() beginScrollGesture];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() beginScrollGesture];
 }
 
 void ScrollAnimatorMac::didEndScrollGesture() const
 {
     if (!scrollableArea()->isOnActivePage())
         return;
-#if USE(SCROLLBAR_PAINTER)
-    [m_scrollbarPainterController.get() endScrollGesture];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [m_scrollbarPainterController.get() endScrollGesture];
 }
 
 void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
-    if (!painter)
-        return;
-
-    ASSERT(!m_verticalScrollbarPainterDelegate);
-    m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]);
+    if (isScrollbarOverlayAPIAvailable()) {
+        ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
+        if (!painter)
+            return;
 
-    [painter setDelegate:m_verticalScrollbarPainterDelegate.get()];
-    [m_scrollbarPainterController.get() setVerticalScrollerImp:painter];
-    if (scrollableArea()->inLiveResize())
-        [painter setKnobAlpha:1];
+        ASSERT(!m_verticalScrollbarPainterDelegate);
+        m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]);
 
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+        [painter setDelegate:m_verticalScrollbarPainterDelegate.get()];
+        [m_scrollbarPainterController.get() setVerticalScrollerImp:painter];
+        if (scrollableArea()->inLiveResize())
+            [painter setKnobAlpha:1];
+    }
 }
 
 void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
-    if (!painter)
-        return;
+    if (isScrollbarOverlayAPIAvailable()) {
+        ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
+        if (!painter)
+            return;
 
-    ASSERT(m_verticalScrollbarPainterDelegate);
-    [m_verticalScrollbarPainterDelegate.get() invalidate];
-    m_verticalScrollbarPainterDelegate = nullptr;
+        ASSERT(m_verticalScrollbarPainterDelegate);
+        [m_verticalScrollbarPainterDelegate.get() invalidate];
+        m_verticalScrollbarPainterDelegate = nullptr;
 
-    [painter setDelegate:nil];
-    [m_scrollbarPainterController.get() setVerticalScrollerImp:nil];
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+        [painter setDelegate:nil];
+        [m_scrollbarPainterController.get() setVerticalScrollerImp:nil];
+    }
 }
 
 void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
-    if (!painter)
-        return;
+    if (isScrollbarOverlayAPIAvailable()) {
+        ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
+        if (!painter)
+            return;
 
-    ASSERT(!m_horizontalScrollbarPainterDelegate);
-    m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]);
+        ASSERT(!m_horizontalScrollbarPainterDelegate);
+        m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]);
 
-    [painter setDelegate:m_horizontalScrollbarPainterDelegate.get()];
-    [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter];
-    if (scrollableArea()->inLiveResize())
-        [painter setKnobAlpha:1];
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+        [painter setDelegate:m_horizontalScrollbarPainterDelegate.get()];
+        [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter];
+        if (scrollableArea()->inLiveResize())
+            [painter setKnobAlpha:1];
+    }
 }
 
 void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
-    if (!painter)
-        return;
+    if (isScrollbarOverlayAPIAvailable()) {
+        ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar);
+        if (!painter)
+            return;
 
-    ASSERT(m_horizontalScrollbarPainterDelegate);
-    [m_horizontalScrollbarPainterDelegate.get() invalidate];
-    m_horizontalScrollbarPainterDelegate = nullptr;
+        ASSERT(m_horizontalScrollbarPainterDelegate);
+        [m_horizontalScrollbarPainterDelegate.get() invalidate];
+        m_horizontalScrollbarPainterDelegate = nullptr;
 
-    [painter setDelegate:nil];
-    [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil];
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+        [painter setDelegate:nil];
+        [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil];
+    }
 }
 
 void ScrollAnimatorMac::cancelAnimations()
 {
     m_haveScrolledSincePageLoad = false;
 
-#if USE(SCROLLBAR_PAINTER)
-    if (scrollbarPaintTimerIsActive())
-        stopScrollbarPaintTimer();
-    [m_horizontalScrollbarPainterDelegate.get() cancelAnimations];
-    [m_verticalScrollbarPainterDelegate.get() cancelAnimations];
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        if (scrollbarPaintTimerIsActive())
+            stopScrollbarPaintTimer();
+        [m_horizontalScrollbarPainterDelegate.get() cancelAnimations];
+        [m_verticalScrollbarPainterDelegate.get() cancelAnimations];
+    }
 }
 
 #if ENABLE(RUBBER_BANDING)
@@ -1404,15 +1381,17 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
 
 void ScrollAnimatorMac::setIsActive()
 {
-#if USE(SCROLLBAR_PAINTER)
-    if (needsScrollerStyleUpdate())
-        updateScrollerStyle();
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        if (needsScrollerStyleUpdate())
+            updateScrollerStyle();
+    }
 }
 
-#if USE(SCROLLBAR_PAINTER)
 void ScrollAnimatorMac::updateScrollerStyle()
 {
+    if (!isScrollbarOverlayAPIAvailable())
+        return;
+
     if (!scrollableArea()->isOnActivePage()) {
         setNeedsScrollerStyleUpdate(true);
         return;
@@ -1486,12 +1465,13 @@ void ScrollAnimatorMac::stopScrollbarPaintTimer()
 
 void ScrollAnimatorMac::initialScrollbarPaintTimerFired(Timer<ScrollAnimatorMac>*)
 {
-    // To force the scrollbars to flash, we have to call hide first. Otherwise, the ScrollbarPainterController
-    // might think that the scrollbars are already showing and bail early.
-    [m_scrollbarPainterController.get() hideOverlayScrollers];
-    [m_scrollbarPainterController.get() flashScrollers];
+    if (isScrollbarOverlayAPIAvailable()) {
+        // To force the scrollbars to flash, we have to call hide first. Otherwise, the ScrollbarPainterController
+        // might think that the scrollbars are already showing and bail early.
+        [m_scrollbarPainterController.get() hideOverlayScrollers];
+        [m_scrollbarPainterController.get() flashScrollers];
+    }
 }
-#endif
 
 void ScrollAnimatorMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
 {
index b60b464..3c5692c 100644 (file)
@@ -28,8 +28,8 @@
 
 #if ENABLE(RUBBER_BANDING)
 
-#include <WebCore/FloatPoint.h>
-#include <WebCore/FloatSize.h>
+#include "FloatPoint.h"
+#include "FloatSize.h"
 #include <wtf/Noncopyable.h>
 
 namespace WebCore {
index 40cfcd8..a74a759 100644 (file)
@@ -28,9 +28,7 @@
 
 #include "ScrollbarThemeComposite.h"
 
-#if USE(SCROLLBAR_PAINTER)
 typedef id ScrollbarPainter;
-#endif
 
 namespace WebCore {
 
@@ -43,7 +41,9 @@ public:
 
     virtual void updateEnabledState(Scrollbar*);
 
+#if !PLATFORM(CHROMIUM)
     virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect);
+#endif
 
     virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
     
@@ -59,12 +59,11 @@ public:
     virtual void registerScrollbar(Scrollbar*);
     virtual void unregisterScrollbar(Scrollbar*);
 
-#if USE(SCROLLBAR_PAINTER)
     void setNewPainterForScrollbar(Scrollbar*, ScrollbarPainter);
     ScrollbarPainter painterForScrollbar(Scrollbar*);
 
     static bool isCurrentlyDrawingIntoLayer();
-#endif
+    static void setIsCurrentlyDrawingIntoLayer(bool);
 
 protected:
     virtual bool hasButtons(Scrollbar*);
@@ -80,6 +79,7 @@ protected:
     
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
     virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);
+    int scrollbarPartToHIPressedState(ScrollbarPart);
 };
 
 }
index 954bd0a..c807944 100644 (file)
@@ -46,11 +46,7 @@ using namespace WebCore;
 
 namespace WebCore {
 
-#if USE(SCROLLBAR_PAINTER)
 typedef HashMap<Scrollbar*, RetainPtr<ScrollbarPainter> > ScrollbarPainterMap;
-#else
-typedef HashSet<Scrollbar*> ScrollbarPainterMap;
-#endif
 
 static ScrollbarPainterMap* scrollbarMap()
 {
@@ -76,18 +72,17 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
+    ScrollbarTheme* theme = ScrollbarTheme::theme();
+    if (theme->isMockTheme())
+        return;
+
     static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged();
     if (scrollbarMap()->isEmpty())
         return;
     ScrollbarPainterMap::iterator end = scrollbarMap()->end();
     for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) {
-#if USE(SCROLLBAR_PAINTER)
         it->first->styleChanged();
         it->first->invalidate();
-#else
-        (*it)->styleChanged();
-        (*it)->invalidate();
-#endif
     }
 }
 
@@ -95,6 +90,10 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
+    ScrollbarTheme* theme = ScrollbarTheme::theme();
+    if (theme->isMockTheme())
+        return;
+
     static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged();
 }
 
@@ -108,22 +107,22 @@ static ScrollbarPainterMap* scrollbarMap()
 
 namespace WebCore {
 
+#if !PLATFORM(CHROMIUM)
 ScrollbarTheme* ScrollbarTheme::nativeTheme()
 {
     DEFINE_STATIC_LOCAL(ScrollbarThemeMac, theme, ());
     return &theme;
 }
+#endif
 
 // FIXME: Get these numbers from CoreUI.
 static int cRealButtonLength[] = { 28, 21 };
 static int cButtonHitInset[] = { 3, 2 };
 // cRealButtonLength - cButtonInset
 static int cButtonLength[] = { 14, 10 };
-#if !USE(SCROLLBAR_PAINTER)
 static int cScrollbarThickness[] = { 15, 11 };
 static int cButtonInset[] = { 14, 11 };
 static int cThumbMinLength[] = { 26, 20 };
-#endif
 
 static int cOuterButtonLength[] = { 16, 14 }; // The outer button in a double button pair is a bit bigger.
 static int cOuterButtonOverlap = 2;
@@ -132,17 +131,13 @@ static float gInitialButtonDelay = 0.5f;
 static float gAutoscrollButtonDelay = 0.05f;
 static bool gJumpOnTrackClick = false;
 
-#if USE(SCROLLBAR_PAINTER)
-static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsNone;
-#else
 static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd;
-#endif
 
 static void updateArrowPlacement()
 {
-#if USE(SCROLLBAR_PAINTER)
-    return;
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        return;
+
     NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
     if ([buttonPlacement isEqualToString:@"Single"])
         gButtonPlacement = ScrollbarButtonsSingle;
@@ -158,15 +153,15 @@ static void updateArrowPlacement()
 
 void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;
-    ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:wkRecommendedScrollerStyle() controlSize:(NSControlSize)scrollbar->controlSize() horizontal:isHorizontal replacingScrollerImp:nil];
-    scrollbarMap()->add(scrollbar, scrollbarPainter);
-    updateEnabledState(scrollbar);
-    updateScrollbarOverlayStyle(scrollbar);
-#else
-    scrollbarMap()->add(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;
+        ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:recommendedScrollerStyle() controlSize:(NSControlSize)scrollbar->controlSize() horizontal:isHorizontal replacingScrollerImp:nil];
+        scrollbarMap()->add(scrollbar, scrollbarPainter);
+        updateEnabledState(scrollbar);
+        updateScrollbarOverlayStyle(scrollbar);
+    } else {
+        scrollbarMap()->add(scrollbar, nil);
+    }
 }
 
 void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar)
@@ -174,7 +169,6 @@ void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar)
     scrollbarMap()->remove(scrollbar);
 }
 
-#if USE(SCROLLBAR_PAINTER)
 void ScrollbarThemeMac::setNewPainterForScrollbar(Scrollbar* scrollbar, ScrollbarPainter newPainter)
 {
     scrollbarMap()->set(scrollbar, newPainter);
@@ -194,13 +188,17 @@ bool ScrollbarThemeMac::isCurrentlyDrawingIntoLayer()
     return g_isCurrentlyDrawingIntoLayer;
 }
 
-#endif
+void ScrollbarThemeMac::setIsCurrentlyDrawingIntoLayer(bool b)
+{
+    g_isCurrentlyDrawingIntoLayer = b;
+}
 
 ScrollbarThemeMac::ScrollbarThemeMac()
 {
     static bool initialized;
     if (!initialized) {
         initialized = true;
+        gButtonPlacement = isScrollbarOverlayAPIAvailable() ? ScrollbarButtonsNone : ScrollbarButtonsDoubleEnd;
         [WebScrollbarPrefsObserver registerAsObserver];
         preferencesChanged();
     }
@@ -222,26 +220,23 @@ void ScrollbarThemeMac::preferencesChanged()
 
 int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
 {
-#if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:wkRecommendedScrollerStyle() controlSize:controlSize horizontal:NO replacingScrollerImp:nil];
-    return [scrollbarPainter trackBoxWidth];
-#else
-    return cScrollbarThickness[controlSize];
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:recommendedScrollerStyle() controlSize:controlSize horizontal:NO replacingScrollerImp:nil];
+        return [scrollbarPainter trackBoxWidth];
+    } else
+        return cScrollbarThickness[controlSize];
 }
 
 bool ScrollbarThemeMac::usesOverlayScrollbars() const
 {
-#if USE(SCROLLBAR_PAINTER)
-    return wkRecommendedScrollerStyle() == NSScrollerStyleOverlay;
-#else
-    return false;
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        return recommendedScrollerStyle() == NSScrollerStyleOverlay;
+    else
+        return false;
 }
 
 void ScrollbarThemeMac::updateScrollbarOverlayStyle(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
     ScrollbarPainter painter = painterForScrollbar(scrollbar);
     switch (scrollbar->scrollableArea()->scrollbarOverlayStyle()) {
     case ScrollbarOverlayStyleDefault:
@@ -254,9 +249,6 @@ void ScrollbarThemeMac::updateScrollbarOverlayStyle(Scrollbar* scrollbar)
         [painter setKnobStyle:NSScrollerKnobStyleLight];
         break;
     }
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
 }
 
 double ScrollbarThemeMac::initialAutoscrollTimerDelay()
@@ -276,7 +268,7 @@ ScrollbarButtonsPlacement ScrollbarThemeMac::buttonsPlacement() const
 
 bool ScrollbarThemeMac::hasButtons(Scrollbar* scrollbar)
 {
-    return scrollbar->enabled() && gButtonPlacement != ScrollbarButtonsNone
+    return scrollbar->enabled() && buttonsPlacement() != ScrollbarButtonsNone
              && (scrollbar->orientation() == HorizontalScrollbar
              ? scrollbar->width()
              : scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
@@ -285,13 +277,12 @@ bool ScrollbarThemeMac::hasButtons(Scrollbar* scrollbar)
 bool ScrollbarThemeMac::hasThumb(Scrollbar* scrollbar)
 {
     int minLengthForThumb;
-#if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = scrollbarMap()->get(scrollbar).get();
-    minLengthForThumb = [painter knobMinLength] + [painter trackOverlapEndInset] + [painter knobOverlapEndInset]
-        + 2 * ([painter trackEndInset] + [painter knobEndInset]);
-#else
-    minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
-#endif
+    if (isScrollbarOverlayAPIAvailable()) {
+        ScrollbarPainter painter = scrollbarMap()->get(scrollbar).get();
+        minLengthForThumb = [painter knobMinLength] + [painter trackOverlapEndInset] + [painter knobOverlapEndInset]
+            + 2 * ([painter trackEndInset] + [painter knobEndInset]);
+    } else
+        minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
     return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ? 
              scrollbar->width() : 
              scrollbar->height()) >= minLengthForThumb;
@@ -428,11 +419,10 @@ IntRect ScrollbarThemeMac::trackRect(Scrollbar* scrollbar, bool painting)
 
 int ScrollbarThemeMac::minimumThumbLength(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    return [scrollbarMap()->get(scrollbar).get() knobMinLength];
-#else
-    return cThumbMinLength[scrollbar->controlSize()];
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        return [scrollbarMap()->get(scrollbar).get() knobMinLength];
+    else
+        return cThumbMinLength[scrollbar->controlSize()];
 }
 
 bool ScrollbarThemeMac::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
@@ -449,7 +439,7 @@ bool ScrollbarThemeMac::shouldDragDocumentInsteadOfThumb(Scrollbar*, const Platf
     return event.altKey();
 }
 
-static int scrollbarPartToHIPressedState(ScrollbarPart part)
+int ScrollbarThemeMac::scrollbarPartToHIPressedState(ScrollbarPart part)
 {
     switch (part) {
         case BackButtonStartPart:
@@ -469,14 +459,10 @@ static int scrollbarPartToHIPressedState(ScrollbarPart part)
 
 void ScrollbarThemeMac::updateEnabledState(Scrollbar* scrollbar)
 {
-#if USE(SCROLLBAR_PAINTER)
-    [scrollbarMap()->get(scrollbar).get() setEnabled:scrollbar->enabled()];
-#else
-    UNUSED_PARAM(scrollbar);
-#endif
+    if (isScrollbarOverlayAPIAvailable())
+        [scrollbarMap()->get(scrollbar).get() setEnabled:scrollbar->enabled()];
 }
 
-#if USE(SCROLLBAR_PAINTER)
 static void scrollbarPainterPaint(ScrollbarPainter scrollbarPainter, bool enabled, double value, CGFloat proportion, CGRect frameRect)
 {
     [scrollbarPainter setEnabled:enabled];
@@ -498,45 +484,45 @@ static void scrollbarPainterPaint(ScrollbarPainter scrollbarPainter, bool enable
     if (enabled)
         [scrollbarPainter drawKnob];
 }
-#endif
 
+#if !PLATFORM(CHROMIUM)
 bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect)
 {
-#if USE(SCROLLBAR_PAINTER)
-    float value = 0;
-    float overhang = 0;
+    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
+        if (scrollbar->currentPos() < 0) {
+            // Scrolled past the top.
             value = 0;
-    }
-
-    TemporaryChange<bool> isCurrentlyDrawingIntoLayer(g_isCurrentlyDrawingIntoLayer, context->isCALayerContext());
-    
-    GraphicsContextStateSaver stateSaver(*context);
-    context->clip(damageRect);
-    context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
-    LocalCurrentGraphicsContext localContext(context);
-    scrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(),
-                            scrollbar->enabled(),
-                            value,
-                            (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(),
-                            scrollbar->frameRect());
+            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;
+        }
 
-    return true;
-#endif
+        TemporaryChange<bool> isCurrentlyDrawingIntoLayer(g_isCurrentlyDrawingIntoLayer, context->isCALayerContext());
+        
+        GraphicsContextStateSaver stateSaver(*context);
+        context->clip(damageRect);
+        context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
+        LocalCurrentGraphicsContext localContext(context);
+        scrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(),
+                                scrollbar->enabled(),
+                                value,
+                                (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(),
+                                scrollbar->frameRect());
+
+        return true;
+    }
 
     HIThemeTrackDrawInfo trackInfo;
     trackInfo.version = 0;
@@ -601,6 +587,7 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co
 
     return true;
 }
+#endif
 
 }