Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Oct 2011 04:36:07 +0000 (04:36 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Oct 2011 04:36:07 +0000 (04:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68134

Reviewed by Darin Adler.

Source/WebCore:

Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.

Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
that reads the setting, and returns the mock theme if set. All callers now use
theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.

Fix scroll animator code for Mac and Chromium that was casting the ScrollbarTheme
without type-checking it to test whether it's the mock theme.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SpinButtonElement::startRepeatingTimer):
* platform/ScrollAnimatorWin.cpp:
(WebCore::ScrollAnimatorWin::scroll):
(WebCore::ScrollAnimatorWin::accelerationTime):
(WebCore::ScrollAnimatorWin::animateScroll):
* platform/ScrollView.cpp:
(WebCore::ScrollView::wheelEvent):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::setScrollbarOverlayStyle):
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::maxOverlapBetweenPages):
(WebCore::Scrollbar::Scrollbar):
* platform/ScrollbarTheme.cpp: Copied from Source/WebCore/platform/mock/ScrollbarThemeMock.h.
(WebCore::ScrollbarTheme::theme):
* platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::isMockTheme):
* platform/chromium/PopupListBox.cpp:
(WebCore::PopupListBox::layout):
* platform/chromium/ScrollAnimatorChromiumMac.mm:
(WebCore::chromiumScrollbarTheme):
(WebCore::ScrollAnimatorChromiumMac::didAddVerticalScrollbar):
(WebCore::ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar):
(WebCore::ScrollAnimatorChromiumMac::didAddHorizontalScrollbar):
(WebCore::ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar):
(WebCore::ScrollAnimatorChromiumMac::updateScrollerStyle):
* platform/chromium/ScrollbarThemeChromiumMac.mm:
(+[ScrollbarPrefsObserver appearancePrefsChanged:]):
(+[ScrollbarPrefsObserver behaviorPrefsChanged:]):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::macScrollbarTheme):
(WebCore::ScrollAnimatorMac::didAddVerticalScrollbar):
(WebCore::ScrollAnimatorMac::willRemoveVerticalScrollbar):
(WebCore::ScrollAnimatorMac::didAddHorizontalScrollbar):
(WebCore::ScrollAnimatorMac::willRemoveHorizontalScrollbar):
(WebCore::ScrollAnimatorMac::updateScrollerStyle):
* platform/mac/ScrollbarThemeMac.mm:
(+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
(+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
* platform/mock/ScrollbarThemeMock.h:
(WebCore::ScrollbarThemeMock::isMockTheme):
* platform/qt/RenderThemeQt.cpp:
(WebCore::RenderThemeQt::adjustInnerSpinButtonStyle):
* platform/win/PopupMenuWin.cpp:
(WebCore::PopupMenuWin::calculatePositionAndSize):
* rendering/RenderLayer.cpp:
(WebCore::cornerRect):
* rendering/RenderScrollbarPart.cpp:
(WebCore::calcScrollbarThicknessUsing):
* rendering/RenderScrollbarTheme.h:
(WebCore::RenderScrollbarTheme::scrollbarThickness):
(WebCore::RenderScrollbarTheme::buttonsPlacement):
(WebCore::RenderScrollbarTheme::shouldCenterOnThumb):
(WebCore::RenderScrollbarTheme::initialAutoscrollTimerDelay):
(WebCore::RenderScrollbarTheme::autoscrollTimerDelay):
(WebCore::RenderScrollbarTheme::registerScrollbar):
(WebCore::RenderScrollbarTheme::unregisterScrollbar):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::scrollbarThickness):
* rendering/RenderThemeChromiumSkia.cpp:
(WebCore::RenderThemeChromiumSkia::menuListInternalPadding):
* rendering/RenderThemeChromiumWin.cpp:
(WebCore::RenderThemeChromiumWin::adjustInnerSpinButtonStyle):

Source/WebKit/chromium:

Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.

Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
that reads the setting, and returns the mock theme if set. All callers now use
theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.

* src/WebScrollbarImpl.cpp:
(WebKit::WebScrollbar::defaultThickness):

Source/WebKit/qt:

Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.

Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
that reads the setting, and returns the mock theme if set. All callers now use
theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.

* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::windowResizerRect):

Source/WebKit/win:

Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.

Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
that reads the setting, and returns the mock theme if set. All callers now use
theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.

* WebScrollBar.cpp:
(WebScrollBar::requestedWidth):
(WebScrollBar::requestedHeight):
* WebView.cpp:
(WebView::WebViewWndProc):

Source/WebKit2:

Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.

Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
that reads the setting, and returns the mock theme if set. All callers now use
theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.

* UIProcess/win/WebPopupMenuProxyWin.cpp:
(WebKit::WebPopupMenuProxyWin::calculatePositionAndSize):
* WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
(WebKit::BuiltInPDFView::paintControls):
* WebProcess/WebPage/PageOverlay.cpp:
(WebKit::PageOverlay::bounds):

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

40 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/platform/ScrollAnimatorWin.cpp
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/Scrollbar.cpp
Source/WebCore/platform/ScrollbarTheme.cpp [new file with mode: 0644]
Source/WebCore/platform/ScrollbarTheme.h
Source/WebCore/platform/chromium/PopupListBox.cpp
Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/platform/mock/ScrollbarThemeMock.h
Source/WebCore/platform/qt/RenderThemeQt.cpp
Source/WebCore/platform/win/PopupMenuWin.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderScrollbarPart.cpp
Source/WebCore/rendering/RenderScrollbarTheme.h
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/RenderThemeChromiumSkia.cpp
Source/WebCore/rendering/RenderThemeChromiumWin.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebScrollbarImpl.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebScrollBar.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp
Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp

index ed3d8a9..5071e3f 100644 (file)
@@ -1040,6 +1040,7 @@ SET(WebCore_SOURCES
     platform/ScrollAnimator.cpp
     platform/ScrollableArea.cpp
     platform/Scrollbar.cpp
+    platform/ScrollbarTheme.cpp
     platform/ScrollbarThemeComposite.cpp
     platform/ScrollView.cpp
     platform/SharedBuffer.cpp
index 86b6ded..a1600e7 100644 (file)
@@ -1,3 +1,90 @@
+2011-10-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
+        https://bugs.webkit.org/show_bug.cgi?id=68134
+
+        Reviewed by Darin Adler.
+
+        Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.
+        
+        Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
+        that reads the setting, and returns the mock theme if set. All callers now use
+        theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.
+        
+        Fix scroll animator code for Mac and Chromium that was casting the ScrollbarTheme
+        without type-checking it to test whether it's the mock theme.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::SpinButtonElement::startRepeatingTimer):
+        * platform/ScrollAnimatorWin.cpp:
+        (WebCore::ScrollAnimatorWin::scroll):
+        (WebCore::ScrollAnimatorWin::accelerationTime):
+        (WebCore::ScrollAnimatorWin::animateScroll):
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::wheelEvent):
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::setScrollbarOverlayStyle):
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::maxOverlapBetweenPages):
+        (WebCore::Scrollbar::Scrollbar):
+        * platform/ScrollbarTheme.cpp: Copied from Source/WebCore/platform/mock/ScrollbarThemeMock.h.
+        (WebCore::ScrollbarTheme::theme):
+        * platform/ScrollbarTheme.h:
+        (WebCore::ScrollbarTheme::isMockTheme):
+        * platform/chromium/PopupListBox.cpp:
+        (WebCore::PopupListBox::layout):
+        * platform/chromium/ScrollAnimatorChromiumMac.mm:
+        (WebCore::chromiumScrollbarTheme):
+        (WebCore::ScrollAnimatorChromiumMac::didAddVerticalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::didAddHorizontalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar):
+        (WebCore::ScrollAnimatorChromiumMac::updateScrollerStyle):
+        * platform/chromium/ScrollbarThemeChromiumMac.mm:
+        (+[ScrollbarPrefsObserver appearancePrefsChanged:]):
+        (+[ScrollbarPrefsObserver behaviorPrefsChanged:]):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::macScrollbarTheme):
+        (WebCore::ScrollAnimatorMac::didAddVerticalScrollbar):
+        (WebCore::ScrollAnimatorMac::willRemoveVerticalScrollbar):
+        (WebCore::ScrollAnimatorMac::didAddHorizontalScrollbar):
+        (WebCore::ScrollAnimatorMac::willRemoveHorizontalScrollbar):
+        (WebCore::ScrollAnimatorMac::updateScrollerStyle):
+        * platform/mac/ScrollbarThemeMac.mm:
+        (+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
+        (+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
+        * platform/mock/ScrollbarThemeMock.h:
+        (WebCore::ScrollbarThemeMock::isMockTheme):
+        * platform/qt/RenderThemeQt.cpp:
+        (WebCore::RenderThemeQt::adjustInnerSpinButtonStyle):
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenuWin::calculatePositionAndSize):
+        * rendering/RenderLayer.cpp:
+        (WebCore::cornerRect):
+        * rendering/RenderScrollbarPart.cpp:
+        (WebCore::calcScrollbarThicknessUsing):
+        * rendering/RenderScrollbarTheme.h:
+        (WebCore::RenderScrollbarTheme::scrollbarThickness):
+        (WebCore::RenderScrollbarTheme::buttonsPlacement):
+        (WebCore::RenderScrollbarTheme::shouldCenterOnThumb):
+        (WebCore::RenderScrollbarTheme::initialAutoscrollTimerDelay):
+        (WebCore::RenderScrollbarTheme::autoscrollTimerDelay):
+        (WebCore::RenderScrollbarTheme::registerScrollbar):
+        (WebCore::RenderScrollbarTheme::unregisterScrollbar):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::scrollbarThickness):
+        * rendering/RenderThemeChromiumSkia.cpp:
+        (WebCore::RenderThemeChromiumSkia::menuListInternalPadding):
+        * rendering/RenderThemeChromiumWin.cpp:
+        (WebCore::RenderThemeChromiumWin::adjustInnerSpinButtonStyle):
+
 2011-10-11  Kentaro Hara  <haraken@chromium.org>
 
         Implement a WebKitTransitionEvent constructor for JSC
index 645de2e..3829923 100644 (file)
@@ -2821,6 +2821,7 @@ webcore_sources += \
        Source/WebCore/platform/Scrollbar.h \
        Source/WebCore/platform/ScrollbarThemeComposite.cpp \
        Source/WebCore/platform/ScrollbarThemeComposite.h \
+       Source/WebCore/platform/ScrollbarTheme.cpp \
        Source/WebCore/platform/ScrollbarTheme.h \
        Source/WebCore/platform/ScrollTypes.h \
        Source/WebCore/platform/ScrollView.cpp \
index db6e309..203c7a6 100644 (file)
@@ -379,7 +379,7 @@ __ZN7WebCore14ScrollableArea29willRemoveHorizontalScrollbarEPNS_9ScrollbarE
 __ZN7WebCore14ScrollableArea6scrollENS_15ScrollDirectionENS_17ScrollGranularityEf
 __ZN7WebCore14ScrollableAreaC2Ev
 __ZN7WebCore14ScrollableAreaD2Ev
-__ZN7WebCore14ScrollbarTheme11nativeThemeEv
+__ZN7WebCore14ScrollbarTheme5themeEv
 __ZN7WebCore14SecurityOrigin14threadsafeCopyEv
 __ZN7WebCore14SecurityOrigin16createFromStringERKN3WTF6StringE
 __ZN7WebCore14SecurityOrigin18setLocalLoadPolicyENS0_15LocalLoadPolicyE
index 430559e..c526286 100644 (file)
             'platform/ScrollView.cpp',
             'platform/ScrollableArea.cpp',
             'platform/Scrollbar.cpp',
+            'platform/ScrollbarTheme.cpp',
             'platform/ScrollbarThemeComposite.cpp',
             'platform/ScrollbarThemeComposite.h',
             'platform/SecureTextInput.cpp',
index 8bb837a..8c3a1f4 100644 (file)
@@ -1081,6 +1081,7 @@ SOURCES += \
     platform/ScrollableArea.cpp \
     platform/ScrollAnimator.cpp \
     platform/Scrollbar.cpp \
+    platform/ScrollbarTheme.cpp \
     platform/ScrollbarThemeComposite.cpp \
     platform/ScrollView.cpp \
     platform/text/SegmentedString.cpp \
index 0e8450d..a3a277d 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\platform\ScrollbarTheme.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\platform\ScrollbarThemeComposite.cpp"
                                >
                        </File>
index 6b2ffde..bf14e65 100644 (file)
                0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C3F1F5810C8871200D72CE1 /* WebGLUniformLocation.h */; };
                0C45342710CDBBFA00869157 /* JSWebGLUniformLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C45342510CDBBFA00869157 /* JSWebGLUniformLocation.cpp */; };
                0C45342810CDBBFA00869157 /* JSWebGLUniformLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C45342610CDBBFA00869157 /* JSWebGLUniformLocation.h */; };
+               0F09087F1444FDB200028917 /* ScrollbarTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE71415142189FC00DB33BA /* ScrollbarTheme.cpp */; };
                0F11A54F0F39233100C37884 /* RenderSelectionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F11A54E0F39233100C37884 /* RenderSelectionInfo.h */; };
                0F15DA8A0F3AAEE70000CE47 /* AnimationControllerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15DA890F3AAEE70000CE47 /* AnimationControllerPrivate.h */; };
                0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F29C16D1300C2E2002D794E /* AccessibilityAllInOne.cpp */; };
                0FD723810EC8BD9300CA5DD7 /* FloatQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatQuad.cpp; sourceTree = "<group>"; };
                0FE71403142170B800DB33BA /* ScrollbarThemeMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScrollbarThemeMock.cpp; path = mock/ScrollbarThemeMock.cpp; sourceTree = "<group>"; };
                0FE71404142170B800DB33BA /* ScrollbarThemeMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScrollbarThemeMock.h; path = mock/ScrollbarThemeMock.h; sourceTree = "<group>"; };
+               0FE71415142189FC00DB33BA /* ScrollbarTheme.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollbarTheme.cpp; sourceTree = "<group>"; };
                0FF50259102BA9010066F39A /* DOMStyleMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMStyleMedia.h; sourceTree = "<group>"; };
                0FF5025A102BA9010066F39A /* DOMStyleMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMStyleMedia.mm; sourceTree = "<group>"; };
                0FF50262102BA92B0066F39A /* DOMStyleMediaInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMStyleMediaInternal.h; sourceTree = "<group>"; };
                                CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */,
                                BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */,
                                BC7B2AF80450824100A8000F /* Scrollbar.h */,
+                               0FE71415142189FC00DB33BA /* ScrollbarTheme.cpp */,
                                BC8B854A0E7C7F5600AB6984 /* ScrollbarTheme.h */,
                                BC1402890E83680800319717 /* ScrollbarThemeComposite.h */,
                                BC1402880E83680800319717 /* ScrollbarThemeComposite.cpp */,
                                310603741432819C00ABF4BA /* JSWebKitCSSFilterValue.cpp in Sources */,
                                3106037A143281CD00ABF4BA /* DOMWebKitCSSFilterValue.mm in Sources */,
                                29ACB214143E7498006BCA5F /* AccessibilityMockObject.cpp in Sources */,
+                               0F09087F1444FDB200028917 /* ScrollbarTheme.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 4762181..f7c38e4 100644 (file)
@@ -335,7 +335,7 @@ void SpinButtonElement::releaseCapture()
 void SpinButtonElement::startRepeatingTimer()
 {
     m_pressStartingState = m_upDownState;
-    ScrollbarTheme* theme = ScrollbarTheme::nativeTheme();
+    ScrollbarTheme* theme = ScrollbarTheme::theme();
     m_repeatingTimer.start(theme->initialAutoscrollTimerDelay(), theme->autoscrollTimerDelay());
 }
 
index d970d27..58b049d 100644 (file)
@@ -99,7 +99,7 @@ bool ScrollAnimatorWin::scroll(ScrollbarOrientation orientation, ScrollGranulari
     //
     // When autoscrolling, the scrollbar's autoscroll timer will call us to
     // increment the desired position by |step| (with |multiplier| == 1) every
-    // ScrollbarTheme::nativeTheme()->autoscrollTimerDelay() seconds.  If we set
+    // ScrollbarTheme::theme()->autoscrollTimerDelay() seconds. If we set
     // the desired velocity to exactly this rate, smooth scrolling will neither
     // race ahead (and then have to slow down) nor increasingly lag behind, but
     // will be smooth and synchronized.
@@ -110,7 +110,7 @@ bool ScrollAnimatorWin::scroll(ScrollbarOrientation orientation, ScrollGranulari
     //   lag = |step| - v(0.5tA + tD)
     // Where
     //   v = The steady-state velocity,
-    //       |step| / ScrollbarTheme::nativeTheme()->autoscrollTimerDelay()
+    //       |step| / ScrollbarTheme::theme()->autoscrollTimerDelay()
     //   tA = accelerationTime()
     //   tD = The time we pretend has already passed when starting to scroll,
     //        |animationTimerDelay|
@@ -152,7 +152,7 @@ bool ScrollAnimatorWin::scroll(ScrollbarOrientation orientation, ScrollGranulari
     //   lag = |step| * ((r / k) - 1)
     // Where
     //   r = The ratio of the autoscroll repeat delay,
-    //       ScrollbarTheme::nativeTheme()->autoscrollTimerDelay(), to the
+    //       ScrollbarTheme::theme()->autoscrollTimerDelay(), to the
     //       key/wheel repeat delay (i.e. > 1 when keys repeat faster)
     //   k = The velocity trim constant given below
     //
@@ -163,14 +163,14 @@ bool ScrollAnimatorWin::scroll(ScrollbarOrientation orientation, ScrollGranulari
     // calculated above being larger than that).  This will result in "perfect"
     // behavior for autoscrolling without having to special-case it.
     if (alreadyAnimating)
-        animationStep /= (2.0 - ((1.0 / ScrollbarTheme::nativeTheme()->autoscrollTimerDelay()) * (0.5 * accelerationTime() + animationTimerDelay)));
+        animationStep /= (2.0 - ((1.0 / ScrollbarTheme::theme()->autoscrollTimerDelay()) * (0.5 * accelerationTime() + animationTimerDelay)));
     // The result of all this is that single keypresses or wheel flicks will
     // scroll in the same time period as single presses of scrollbar elements;
     // holding the mouse down on a scrollbar part will scroll as fast as
     // possible without hitching; and other repeated scroll events will also
     // scroll with the same time lag as holding down the mouse on a scrollbar
     // part.
-    data->m_desiredVelocity = animationStep / ScrollbarTheme::nativeTheme()->autoscrollTimerDelay();
+    data->m_desiredVelocity = animationStep / ScrollbarTheme::theme()->autoscrollTimerDelay();
 
     // If we're not already scrolling, start.
     if (!alreadyAnimating)
@@ -198,11 +198,11 @@ void ScrollAnimatorWin::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
 
 double ScrollAnimatorWin::accelerationTime()
 {
-    // We elect to use ScrollbarTheme::nativeTheme()->autoscrollTimerDelay() as
+    // We elect to use ScrollbarTheme::theme()->autoscrollTimerDelay() as
     // the length of time we'll take to accelerate from 0 to our target
     // velocity.  Choosing a larger value would produce a more pronounced
     // acceleration effect.
-    return ScrollbarTheme::nativeTheme()->autoscrollTimerDelay();
+    return ScrollbarTheme::theme()->autoscrollTimerDelay();
 }
 
 void ScrollAnimatorWin::animationTimerFired(Timer<ScrollAnimatorWin>* timer)
@@ -224,7 +224,7 @@ void ScrollAnimatorWin::animateScroll(PerAxisData* data)
     // Where
     //   t0 = The time to perform the scroll without smooth scrolling
     //   tA = The acceleration time,
-    //        ScrollbarTheme::nativeTheme()->autoscrollTimerDelay() (see below)
+    //        ScrollbarTheme::theme()->autoscrollTimerDelay() (see below)
     //   tD = |animationTimerDelay|
     //   tS = A value less than or equal to the time required to perform a
     //        single scroll increment, i.e. the work done due to calling
index 78d1ece..2205b2e 100644 (file)
@@ -944,7 +944,7 @@ void ScrollView::updateScrollCorner()
 
 void ScrollView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect)
 {
-    ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, cornerRect);
+    ScrollbarTheme::theme()->paintScrollCorner(this, context, cornerRect);
 }
 
 void ScrollView::invalidateScrollCornerRect(const IntRect& rect)
@@ -1084,7 +1084,7 @@ void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRe
 
 void ScrollView::paintOverhangAreas(GraphicsContext* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
 {
-    ScrollbarTheme::nativeTheme()->paintOverhangAreas(this, context, horizontalOverhangRect, verticalOverhangRect, dirtyRect);
+    ScrollbarTheme::theme()->paintOverhangAreas(this, context, horizontalOverhangRect, verticalOverhangRect, dirtyRect);
 }
 
 void ScrollView::calculateAndPaintOverhangAreas(GraphicsContext* context, const IntRect& dirtyRect)
index af234fa..df8517e 100644 (file)
@@ -228,12 +228,12 @@ void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
     m_scrollbarOverlayStyle = overlayStyle;
 
     if (horizontalScrollbar()) {
-        ScrollbarTheme::nativeTheme()->updateScrollbarOverlayStyle(horizontalScrollbar());
+        ScrollbarTheme::theme()->updateScrollbarOverlayStyle(horizontalScrollbar());
         horizontalScrollbar()->invalidate();
     }
     
     if (verticalScrollbar()) {
-        ScrollbarTheme::nativeTheme()->updateScrollbarOverlayStyle(verticalScrollbar());
+        ScrollbarTheme::theme()->updateScrollbarOverlayStyle(verticalScrollbar());
         verticalScrollbar()->invalidate();
     }
 }
index 776d26a..c2fd74d 100644 (file)
@@ -60,7 +60,7 @@ PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollableArea* scrollabl
 
 int Scrollbar::maxOverlapBetweenPages()
 {
-    static int maxOverlapBetweenPages = ScrollbarTheme::nativeTheme()->maxOverlapBetweenPages();
+    static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetweenPages();
     return maxOverlapBetweenPages;
 }
 
@@ -88,7 +88,7 @@ Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient
     , m_suppressInvalidation(false)
 {
     if (!m_theme)
-        m_theme = ScrollbarTheme::nativeTheme();
+        m_theme = ScrollbarTheme::theme();
 
     m_theme->registerScrollbar(this);
 
diff --git a/Source/WebCore/platform/ScrollbarTheme.cpp b/Source/WebCore/platform/ScrollbarTheme.cpp
new file mode 100644 (file)
index 0000000..c374d2b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 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. ``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 "ScrollbarTheme.h"
+
+#include "ScrollbarThemeMock.h"
+#include "Settings.h"
+
+namespace WebCore {
+
+ScrollbarTheme* ScrollbarTheme::theme()
+{
+    if (Settings::mockScrollbarsEnabled()) {
+        DEFINE_STATIC_LOCAL(ScrollbarThemeMock, mockTheme, ());
+        return &mockTheme;
+    }
+    return nativeTheme();
+}
+
+}
index 0e9f091..9ef1242 100644 (file)
@@ -100,6 +100,11 @@ public:
     virtual void registerScrollbar(Scrollbar*) {}
     virtual void unregisterScrollbar(Scrollbar*) {}
 
+    virtual bool isMockTheme() const { return false; }
+
+    static ScrollbarTheme* theme();
+
+private:
     static ScrollbarTheme* nativeTheme(); // Must be implemented to return the correct theme subclass.
 };
 
index f735567..4935781 100644 (file)
@@ -857,7 +857,7 @@ void PopupListBox::layout()
     // Set our widget and scrollable contents sizes.
     int scrollbarWidth = 0;
     if (m_visibleRows < numItems()) {
-        scrollbarWidth = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+        scrollbarWidth = ScrollbarTheme::theme()->scrollbarThickness();
 
         // Use kMinEndOfLinePadding when there is a scrollbar so that we use
         // as much as (lineEndPaddingWidth - kMinEndOfLinePadding) padding
index dae2d3d..79e5dca 100644 (file)
@@ -461,6 +461,12 @@ 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)
@@ -682,8 +688,11 @@ void ScrollAnimatorChromiumMac::didEndScrollGesture() const
 
 void ScrollAnimatorChromiumMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 {
-    if (isScrollbarOverlayAPIAvailable()) {
-        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(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())
@@ -693,8 +702,11 @@ void ScrollAnimatorChromiumMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 
 void ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
 {
-    if (isScrollbarOverlayAPIAvailable()) {
-        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
+    if (!isScrollbarOverlayAPIAvailable())
+        return;
+
+    if (ScrollbarThemeChromiumMac* theme = chromiumScrollbarTheme()) {
+        WKScrollbarPainterRef painter = theme->painterForScrollbar(scrollbar);
         wkScrollbarPainterSetDelegate(painter, nil);
         wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, false);
     }
@@ -702,8 +714,11 @@ void ScrollAnimatorChromiumMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar
 
 void ScrollAnimatorChromiumMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 {
-    if (isScrollbarOverlayAPIAvailable()) {
-        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(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())
@@ -713,8 +728,11 @@ void ScrollAnimatorChromiumMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 
 void ScrollAnimatorChromiumMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
 {
-    if (isScrollbarOverlayAPIAvailable()) {
-        WKScrollbarPainterRef painter = static_cast<WebCore::ScrollbarThemeChromiumMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
+    if (!isScrollbarOverlayAPIAvailable())
+        return;
+
+    if (ScrollbarThemeChromiumMac* theme = chromiumScrollbarTheme()) {
+        WKScrollbarPainterRef painter = theme->painterForScrollbar(scrollbar);
         wkScrollbarPainterSetDelegate(painter, nil);
         wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, true);
     }
@@ -1218,7 +1236,12 @@ void ScrollAnimatorChromiumMac::updateScrollerStyle()
         return;
     }
 
-    ScrollbarThemeChromiumMac* macTheme = (ScrollbarThemeChromiumMac*)ScrollbarTheme::nativeTheme();
+    ScrollbarThemeChromiumMac* macTheme = chromiumScrollbarTheme();
+    if (!macTheme) {
+        setNeedsScrollerStyleUpdate(false);
+        return;
+    }
+
     int newStyle = wkScrollbarPainterControllerStyle(m_scrollbarPainterController.get());
 
     if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) {
index 472343d..177bc92 100644 (file)
@@ -96,7 +96,11 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
-    static_cast<ScrollbarThemeChromiumMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
+    ScrollbarTheme* theme = ScrollbarTheme::theme();
+    if (theme->isMockTheme())
+        return;
+
+    static_cast<ScrollbarThemeChromiumMac*>(isMockTheme)->preferencesChanged();
     if (scrollbarMap()->isEmpty())
         return;
     ScrollbarPainterMap::iterator end = scrollbarMap()->end();
@@ -110,7 +114,11 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
-    static_cast<ScrollbarThemeChromiumMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
+    ScrollbarTheme* theme = ScrollbarTheme::theme();
+    if (theme->isMockTheme())
+        return;
+
+    static_cast<ScrollbarThemeChromiumMac*>(theme)->preferencesChanged();
 }
 
 + (void)registerAsObserver
index f36c885..a2d93f8 100644 (file)
@@ -452,6 +452,12 @@ PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea
     return adoptPtr(new ScrollAnimatorMac(scrollableArea));
 }
 
+static ScrollbarThemeMac* macScrollbarTheme()
+{
+    ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
+    return !scrollbarTheme->isMockTheme() ? static_cast<ScrollbarThemeMac*>(scrollbarTheme) : 0;
+}
+
 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea)
     : ScrollAnimator(scrollableArea)
 #if USE(SCROLLBAR_PAINTER)
@@ -682,11 +688,13 @@ void ScrollAnimatorMac::didEndScrollGesture() const
 void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 {
 #if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = static_cast<WebCore::ScrollbarThemeMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    [painter setDelegate:m_scrollbarPainterDelegate.get()];
-    [m_scrollbarPainterController.get() setVerticalScrollerImp:painter];
-    if (scrollableArea()->inLiveResize())
-        [painter setKnobAlpha:1];
+    if (ScrollbarThemeMac* theme = macScrollbarTheme()) {
+        ScrollbarPainter painter = theme->painterForScrollbar(scrollbar);
+        [painter setDelegate:m_scrollbarPainterDelegate.get()];
+        [m_scrollbarPainterController.get() setVerticalScrollerImp:painter];
+        if (scrollableArea()->inLiveResize())
+            [painter setKnobAlpha:1];
+    }
 #else
     UNUSED_PARAM(scrollbar);
 #endif
@@ -695,9 +703,11 @@ void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
 {
 #if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = static_cast<WebCore::ScrollbarThemeMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    [painter setDelegate:nil];
-    [m_scrollbarPainterController.get() setVerticalScrollerImp:nil];
+    if (ScrollbarThemeMac* theme = macScrollbarTheme()) {
+        ScrollbarPainter painter = theme->painterForScrollbar(scrollbar);
+        [painter setDelegate:nil];
+        [m_scrollbarPainterController.get() setVerticalScrollerImp:nil];
+    }
 #else
     UNUSED_PARAM(scrollbar);
 #endif
@@ -706,11 +716,13 @@ void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
 void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 {
 #if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = static_cast<WebCore::ScrollbarThemeMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    [painter setDelegate:m_scrollbarPainterDelegate.get()];
-    [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter];
-    if (scrollableArea()->inLiveResize())
-        [painter setKnobAlpha:1];
+    if (ScrollbarThemeMac* theme = macScrollbarTheme()) {
+        ScrollbarPainter painter = theme->painterForScrollbar(scrollbar);
+        [painter setDelegate:m_scrollbarPainterDelegate.get()];
+        [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter];
+        if (scrollableArea()->inLiveResize())
+            [painter setKnobAlpha:1];
+    }
 #else
     UNUSED_PARAM(scrollbar);
 #endif
@@ -719,9 +731,11 @@ void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
 {
 #if USE(SCROLLBAR_PAINTER)
-    ScrollbarPainter painter = static_cast<WebCore::ScrollbarThemeMac*>(WebCore::ScrollbarTheme::nativeTheme())->painterForScrollbar(scrollbar);
-    [painter setDelegate:nil];
-    [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil];
+    if (ScrollbarThemeMac* theme = macScrollbarTheme()) {
+        ScrollbarPainter painter = theme->painterForScrollbar(scrollbar);
+        [painter setDelegate:nil];
+        [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil];
+    }
 #else
     UNUSED_PARAM(scrollbar);
 #endif
@@ -1237,7 +1251,12 @@ void ScrollAnimatorMac::updateScrollerStyle()
         return;
     }
 
-    ScrollbarThemeMac* macTheme = (ScrollbarThemeMac*)ScrollbarTheme::nativeTheme();
+    ScrollbarThemeMac* macTheme = macScrollbarTheme();
+    if (!macTheme) {
+        setNeedsScrollerStyleUpdate(false);
+        return;
+    }
+
     NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle];
 
     if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) {
index 3487598..d782b5b 100644 (file)
@@ -75,7 +75,7 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
-    static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
+    static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged();
     if (scrollbarMap()->isEmpty())
         return;
     ScrollbarPainterMap::iterator end = scrollbarMap()->end();
@@ -94,7 +94,7 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
-    static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
+    static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged();
 }
 
 + (void)registerAsObserver
index 2bf2a2b..e254842 100644 (file)
@@ -45,6 +45,9 @@ protected:
     
     virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&);
     virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
+    
+private:
+    virtual bool isMockTheme() const { return true; }
 };
 
 }
index c354aa2..88d349b 100644 (file)
@@ -1074,7 +1074,7 @@ void RenderThemeQt::adjustInnerSpinButtonStyle(CSSStyleSelector* selector, Rende
                                                Element* e) const
 {
     // Use the same width as our native scrollbar
-    int width = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+    int width = ScrollbarTheme::theme()->scrollbarThickness();
     style->setWidth(Length(width, Fixed));
     style->setMinWidth(Length(width, Fixed));
 }
index 44a896e..578eea1 100644 (file)
@@ -334,7 +334,7 @@ void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
 
     if (naturalHeight > maxPopupHeight)
         // We need room for a scrollbar
-        popupWidth += ScrollbarTheme::nativeTheme()->scrollbarThickness(SmallScrollbar);
+        popupWidth += ScrollbarTheme::theme()->scrollbarThickness(SmallScrollbar);
 
     // Add padding to align the popup text with the <select> text
     popupWidth += max(0, client()->clientPaddingRight() - client()->clientInsetRight()) + max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
index 3fa883e..9cb2672 100644 (file)
@@ -1753,7 +1753,7 @@ static LayoutRect cornerRect(const RenderLayer* layer, const LayoutRect& bounds)
     if (!layer->verticalScrollbar() && !layer->horizontalScrollbar()) {
         // FIXME: This isn't right.  We need to know the thickness of custom scrollbars
         // even when they don't exist in order to set the resizer square size properly.
-        horizontalThickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+        horizontalThickness = ScrollbarTheme::theme()->scrollbarThickness();
         verticalThickness = horizontalThickness;
     } else if (layer->verticalScrollbar() && !layer->horizontalScrollbar()) {
         horizontalThickness = layer->verticalScrollbar()->width();
index 69b9b20..cbae68c 100644 (file)
@@ -82,7 +82,7 @@ void RenderScrollbarPart::layoutVerticalPart()
 static int calcScrollbarThicknessUsing(const Length& l, int containingLength)
 {
     if (l.isIntrinsicOrAuto())
-        return ScrollbarTheme::nativeTheme()->scrollbarThickness();
+        return ScrollbarTheme::theme()->scrollbarThickness();
     return l.calcMinValue(containingLength);
 }
 
index 9b8b2c1..70c24a5 100644 (file)
@@ -38,21 +38,21 @@ class RenderScrollbarTheme : public ScrollbarThemeComposite {
 public:
     virtual ~RenderScrollbarTheme() {};
     
-    virtual int scrollbarThickness(ScrollbarControlSize controlSize) { return ScrollbarTheme::nativeTheme()->scrollbarThickness(controlSize); }
+    virtual int scrollbarThickness(ScrollbarControlSize controlSize) { return ScrollbarTheme::theme()->scrollbarThickness(controlSize); }
 
-    virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarTheme::nativeTheme()->buttonsPlacement(); }
+    virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarTheme::theme()->buttonsPlacement(); }
 
     virtual bool supportsControlTints() const { return true; }
 
     virtual void paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect);
 
-    virtual bool shouldCenterOnThumb(Scrollbar* scrollbar, const PlatformMouseEvent& event) { return ScrollbarTheme::nativeTheme()->shouldCenterOnThumb(scrollbar, event); }
+    virtual bool shouldCenterOnThumb(Scrollbar* scrollbar, const PlatformMouseEvent& event) { return ScrollbarTheme::theme()->shouldCenterOnThumb(scrollbar, event); }
     
-    virtual double initialAutoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->initialAutoscrollTimerDelay(); }
-    virtual double autoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->autoscrollTimerDelay(); }
+    virtual double initialAutoscrollTimerDelay() { return ScrollbarTheme::theme()->initialAutoscrollTimerDelay(); }
+    virtual double autoscrollTimerDelay() { return ScrollbarTheme::theme()->autoscrollTimerDelay(); }
 
-    virtual void registerScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->registerScrollbar(scrollbar); }
-    virtual void unregisterScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->unregisterScrollbar(scrollbar); }
+    virtual void registerScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::theme()->registerScrollbar(scrollbar); }
+    virtual void unregisterScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::theme()->unregisterScrollbar(scrollbar); }
 
     virtual int minimumThumbLength(Scrollbar*);
 
index 1a788a7..82490f2 100644 (file)
@@ -158,7 +158,7 @@ VisiblePosition RenderTextControl::visiblePositionForIndex(int index) const
 int RenderTextControl::scrollbarThickness() const
 {
     // FIXME: We should get the size of the scrollbar from the RenderTheme instead.
-    return ScrollbarTheme::nativeTheme()->scrollbarThickness();
+    return ScrollbarTheme::theme()->scrollbarThickness();
 }
 
 void RenderTextControl::computeLogicalHeight()
index c16e1d3..3f3c6ae 100644 (file)
@@ -535,7 +535,7 @@ int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int pad
     // we don't draw a button, so don't reserve space for it.
     const int barType = style->direction() == LTR ? RightPadding : LeftPadding;
     if (paddingType == barType && style->appearance() != NoControlPart)
-        padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
+        padding += ScrollbarTheme::theme()->scrollbarThickness();
 
     return padding;
 }
index 9cc57c5..d4328df 100644 (file)
@@ -716,7 +716,7 @@ bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o,
 
 void RenderThemeChromiumWin::adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
 {
-    int width = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+    int width = ScrollbarTheme::theme()->scrollbarThickness();
     style->setWidth(Length(width, Fixed));
     style->setMinWidth(Length(width, Fixed));
 }
index a7a083a..a40fc05 100644 (file)
@@ -1,3 +1,19 @@
+2011-10-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
+        https://bugs.webkit.org/show_bug.cgi?id=68134
+
+        Reviewed by Darin Adler.
+
+        Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.
+        
+        Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
+        that reads the setting, and returns the mock theme if set. All callers now use
+        theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.
+
+        * src/WebScrollbarImpl.cpp:
+        (WebKit::WebScrollbar::defaultThickness):
+
 2011-10-11  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r97202, r97207, and r97215.
index b5bad5b..f9110db 100644 (file)
@@ -63,7 +63,7 @@ WebScrollbar* WebScrollbar::createForPlugin(Orientation orientation,
 
 int WebScrollbar::defaultThickness()
 {
-    return ScrollbarTheme::nativeTheme()->scrollbarThickness();
+    return ScrollbarTheme::theme()->scrollbarThickness();
 }
 
 WebScrollbarImpl::WebScrollbarImpl(Orientation orientation,
index 3b883dd..ed74e87 100644 (file)
@@ -1,3 +1,19 @@
+2011-10-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
+        https://bugs.webkit.org/show_bug.cgi?id=68134
+
+        Reviewed by Darin Adler.
+
+        Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.
+        
+        Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
+        that reads the setting, and returns the mock theme if set. All callers now use
+        theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.
+
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::windowResizerRect):
+
 2011-10-11  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         [Qt] Remove all references to QTDIR_build and standalone_package
index f64e454..ef26f1d 100644 (file)
@@ -384,7 +384,7 @@ IntRect ChromeClientQt::windowResizerRect() const
 
     // There's no API in Qt to query for the size of the resizer, so we assume
     // it has the same width and height as the scrollbar thickness.
-    int scollbarThickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+    int scollbarThickness = ScrollbarTheme::theme()->scrollbarThickness();
 
     // There's no API in Qt to query for the position of the resizer. Sometimes
     // it's drawn by the system, and sometimes it's a QSizeGrip. For RTL locales
index ba43488..dd23601 100644 (file)
@@ -1,3 +1,22 @@
+2011-10-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
+        https://bugs.webkit.org/show_bug.cgi?id=68134
+
+        Reviewed by Darin Adler.
+
+        Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.
+        
+        Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
+        that reads the setting, and returns the mock theme if set. All callers now use
+        theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.
+
+        * WebScrollBar.cpp:
+        (WebScrollBar::requestedWidth):
+        (WebScrollBar::requestedHeight):
+        * WebView.cpp:
+        (WebView::WebViewWndProc):
+
 2011-10-03  Anders Carlsson  <andersca@apple.com>
 
         Remove custom scrollbar painting hooks
index 224a72a..a252100 100644 (file)
@@ -203,7 +203,7 @@ HRESULT STDMETHODCALLTYPE WebScrollBar::requestedWidth(
     if (!w)
         return E_POINTER;
 
-    *w = m_scrollBar->orientation() == VerticalScrollbar ? ScrollbarTheme::nativeTheme()->scrollbarThickness(m_scrollBar->controlSize()) : -1;
+    *w = m_scrollBar->orientation() == VerticalScrollbar ? ScrollbarTheme::theme()->scrollbarThickness(m_scrollBar->controlSize()) : -1;
     return S_OK;
 }
 
@@ -213,7 +213,7 @@ HRESULT STDMETHODCALLTYPE WebScrollBar::requestedHeight(
     if (!h)
         return E_POINTER;
 
-    *h = m_scrollBar->orientation() == HorizontalScrollbar ? ScrollbarTheme::nativeTheme()->scrollbarThickness(m_scrollBar->controlSize()) : -1;
+    *h = m_scrollBar->orientation() == HorizontalScrollbar ? ScrollbarTheme::theme()->scrollbarThickness(m_scrollBar->controlSize()) : -1;
     return S_OK;
 }
 
index 1f5b0c1..047feab 100644 (file)
@@ -2299,7 +2299,7 @@ LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
             if (Frame* coreFrame = core(mainFrameImpl)) {
                 webView->deleteBackingStore();
                 coreFrame->page()->theme()->themeChanged();
-                ScrollbarTheme::nativeTheme()->themeChanged();
+                ScrollbarTheme::theme()->themeChanged();
                 RECT windowRect;
                 ::GetClientRect(hWnd, &windowRect);
                 ::InvalidateRect(hWnd, &windowRect, false);
index 68e1a3f..991651b 100644 (file)
@@ -1,3 +1,35 @@
+2011-10-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
+        https://bugs.webkit.org/show_bug.cgi?id=68134
+
+        Reviewed by Darin Adler.
+
+        Use ScrollbarThemeMock when the setting to use mock scrollbars is enabled.
+        
+        Make ScrollbarTheme::nativeTheme() private, and add a new static theme() method
+        that reads the setting, and returns the mock theme if set. All callers now use
+        theme() rther than nativeTheme(). Add the new ScrollbarTheme.cpp file to the build.
+
+        * UIProcess/win/WebPopupMenuProxyWin.cpp:
+        (WebKit::WebPopupMenuProxyWin::calculatePositionAndSize):
+        * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
+        (WebKit::BuiltInPDFView::paintControls):
+        * WebProcess/WebPage/PageOverlay.cpp:
+        (WebKit::PageOverlay::bounds):
+
+2011-10-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Make custom scrollbar theme for use in DRT, to reduce pixel diffs between platforms
+        https://bugs.webkit.org/show_bug.cgi?id=68134
+
+        Reviewed by Darin Adler.
+
+        ScrollbarTheme::nativeTheme() renamed to theme().
+
+        * WebProcess/WebPage/PageOverlay.cpp:
+        (WebKit::PageOverlay::bounds):
+
 2011-10-10  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] [WebKit2] Make adding another unit test easier
index a8d8063..b1224fb 100644 (file)
@@ -382,7 +382,7 @@ void WebPopupMenuProxyWin::calculatePositionAndSize(const IntRect& rect)
 
     if (naturalHeight > maxPopupHeight) {
         // We need room for a scrollbar
-        popupWidth += ScrollbarTheme::nativeTheme()->scrollbarThickness(SmallScrollbar);
+        popupWidth += ScrollbarTheme::theme()->scrollbarThickness(SmallScrollbar);
     }
 
     popupHeight += 2 * popupWindowBorderWidth;
index 58f532a..29be428 100644 (file)
@@ -301,7 +301,7 @@ void BuiltInPDFView::paintControls(GraphicsContext* graphicsContext, const IntRe
         m_verticalScrollbar->paint(graphicsContext, dirtyRect);
 
     IntRect dirtyCornerRect = intersection(scrollCornerRect(), dirtyRect);
-    ScrollbarTheme::nativeTheme()->paintScrollCorner(0, graphicsContext, dirtyCornerRect);
+    ScrollbarTheme::theme()->paintScrollCorner(0, graphicsContext, dirtyCornerRect);
 }
 
 void BuiltInPDFView::updateControlTints(GraphicsContext* graphicsContext)
index a0fa7f0..aa32b6a 100644 (file)
@@ -68,7 +68,7 @@ IntRect PageOverlay::bounds() const
     int width = frameView->width();
     int height = frameView->height();
 
-    if (!ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()) {
+    if (!ScrollbarTheme::theme()->usesOverlayScrollbars()) {
         if (frameView->verticalScrollbar())
             width -= frameView->verticalScrollbar()->width();
         if (frameView->horizontalScrollbar())