Fix for <rdar://problem/8895140> Adopt WKScrollbar metrics
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 04:08:49 +0000 (04:08 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 04:08:49 +0000 (04:08 +0000)
when using WKScrollbars.

Reviewed by Darin Adler.

Source/WebCore:

New WebKitSystemInterface Functionality.
* WebCore.exp.in:
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Some of the terrible static arrays are now only needed in the
old non-WK code, so they are if-def'd now.
* platform/mac/ScrollbarThemeMac.mm:

Just patching this function in a better way than I did
before.
(WebCore::updateArrowPlacement):

Call into WK for the right values.
(WebCore::ScrollbarThemeMac::scrollbarThickness):
(WebCore::ScrollbarThemeMac::hasThumb):
(WebCore::ScrollbarThemeMac::minimumThumbLength):

Return false if there are no buttons.
(WebCore::ScrollbarThemeMac::hasButtons):

Return an empty IntRect if there are not buttons.
(WebCore::buttonRepaintRect):

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKit2:

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm

index 49b4af4a05c3b111ae288004c85909777722cca6..94b2d346ca8d4295ac1b84dc87c1b4ea4c455445 100644 (file)
@@ -1,3 +1,34 @@
+2011-01-26  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for <rdar://problem/8895140> Adopt WKScrollbar metrics 
+        when using WKScrollbars.
+
+        New WebKitSystemInterface Functionality.
+        * WebCore.exp.in:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
+        Some of the terrible static arrays are now only needed in the 
+        old non-WK code, so they are if-def'd now.
+        * platform/mac/ScrollbarThemeMac.mm:
+        
+        Just patching this function in a better way than I did
+        before.
+        (WebCore::updateArrowPlacement):
+        
+        Call into WK for the right values.
+        (WebCore::ScrollbarThemeMac::scrollbarThickness):
+        (WebCore::ScrollbarThemeMac::hasThumb):
+        (WebCore::ScrollbarThemeMac::minimumThumbLength):
+        
+        Return false if there are no buttons.
+        (WebCore::ScrollbarThemeMac::hasButtons):
+
+        Return an empty IntRect if there are not buttons.
+        (WebCore::buttonRepaintRect):
+
 2011-01-26  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Maciej Stachowiak.
index db5feb24a21a2db7b928774bfea9d4a573f87e2f..a4a262872b078637dde23382b5c405c2136841f3 100644 (file)
@@ -1293,6 +1293,9 @@ _wkIOSurfaceContextCreate
 _wkIOSurfaceContextCreateImage
 _wkMakeScrollbarPainter
 _wkScrollbarPainterPaint
+_wkScrollbarThickness
+_wkScrollbarMinimumThumbLength
+_wkScrollbarMinimumTotalLengthNeededForThumb
 #endif
 
 #if ENABLE(3D_RENDERING)
index 032d9f3f58d5484fa8a01d7ce46fb0e9ef446f52..48ef52b59ef1de6380b0a1a5204f0e4ce889741d 100644 (file)
@@ -117,13 +117,15 @@ ScrollbarTheme* ScrollbarTheme::nativeTheme()
 }
 
 // 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 };
+#if !defined(USE_WK_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;
@@ -131,13 +133,15 @@ static int cOuterButtonOverlap = 2;
 static float gInitialButtonDelay = 0.5f;
 static float gAutoscrollButtonDelay = 0.05f;
 static bool gJumpOnTrackClick = false;
+
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsNone;
+#else
 static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd;
+#endif
 
 static void updateArrowPlacement()
 {
-#if defined(USE_WK_SCROLLBAR_PAINTER)
-    gButtonPlacement = ScrollbarButtonsNone;
-#else
     NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
     if ([buttonPlacement isEqualToString:@"Single"])
         gButtonPlacement = ScrollbarButtonsSingle;
@@ -145,9 +149,13 @@ static void updateArrowPlacement()
         gButtonPlacement = ScrollbarButtonsDoubleStart;
     else if ([buttonPlacement isEqualToString:@"DoubleBoth"])
         gButtonPlacement = ScrollbarButtonsDoubleBoth;
-    else
-        gButtonPlacement = ScrollbarButtonsDoubleEnd; // The default is ScrollbarButtonsDoubleEnd.
+    else {
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+        gButtonPlacement = ScrollbarButtonsNone;
+#else
+        gButtonPlacement = ScrollbarButtonsDoubleEnd;
 #endif
+    }
 }
 
 void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
@@ -192,7 +200,11 @@ void ScrollbarThemeMac::preferencesChanged()
 
 int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
 {
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+    return wkScrollbarThickness(controlSize);
+#else
     return cScrollbarThickness[controlSize];
+#endif
 }
 
 bool ScrollbarThemeMac::usesOverlayScrollbars() const
@@ -218,20 +230,29 @@ ScrollbarButtonsPlacement ScrollbarThemeMac::buttonsPlacement() const
 
 bool ScrollbarThemeMac::hasButtons(Scrollbar* scrollbar)
 {
-    return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ? 
-             scrollbar->width() : 
-             scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
+    return scrollbar->enabled() && gButtonPlacement != ScrollbarButtonsNone
+             && (scrollbar->orientation() == HorizontalScrollbar
+             ? scrollbar->width()
+             : scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
 }
 
 bool ScrollbarThemeMac::hasThumb(Scrollbar* scrollbar)
 {
+    int minLengthForThumb;
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+    minLengthForThumb = wkScrollbarMinimumTotalLengthNeededForThumb(scrollbarMap()->get(scrollbar).get());
+#else
+    minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
+#endif
     return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ? 
              scrollbar->width() : 
-             scrollbar->height()) >= 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
+             scrollbar->height()) >= minLengthForThumb;
 }
 
 static IntRect buttonRepaintRect(const IntRect& buttonRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start)
 {
+    ASSERT(gButtonPlacement != ScrollbarButtonsNone);
+
     IntRect paintRect(buttonRect);
     if (orientation == HorizontalScrollbar) {
         paintRect.setWidth(cRealButtonLength[controlSize]);
@@ -359,7 +380,11 @@ IntRect ScrollbarThemeMac::trackRect(Scrollbar* scrollbar, bool painting)
 
 int ScrollbarThemeMac::minimumThumbLength(Scrollbar* scrollbar)
 {
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+    return wkScrollbarMinimumThumbLength(scrollbarMap()->get(scrollbar).get());
+#else
     return cThumbMinLength[scrollbar->controlSize()];
+#endif
 }
 
 bool ScrollbarThemeMac::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
index 045864a92c6e84d7d782c2b14c54867c30f7284f..4e5f9ce00e6aaf502189e581d8f6dc3e9be03105 100644 (file)
@@ -190,6 +190,9 @@ extern CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
 typedef struct __WKScrollbarPainter *WKScrollbarPainterRef;
 extern WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
 extern void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
+extern int (*wkScrollbarThickness)(int controlSize);
+extern int (*wkScrollbarMinimumThumbLength)(WKScrollbarPainterRef);
+extern int (*wkScrollbarMinimumTotalLengthNeededForThumb)(WKScrollbarPainterRef);
 #endif
 
 }
index 047827f463ebba90e0fc3bebf7867c7160706878..08a5023bd38ea40f9670f821ed87dfa729ce8dee 100644 (file)
@@ -128,4 +128,7 @@ CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
 
 WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
 void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
+int (*wkScrollbarThickness)(int controlSize);
+int (*wkScrollbarMinimumThumbLength)(WKScrollbarPainterRef);
+int (*wkScrollbarMinimumTotalLengthNeededForThumb)(WKScrollbarPainterRef);
 #endif
index 1f4e3c443d31f628f47f52da4949ad086c95120c..2831e560e3ca36b80e9a71c8e3efb38f0357c012 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-26  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for <rdar://problem/8895140> Adopt WKScrollbar metrics 
+        when using WKScrollbars.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2011-01-25  Darin Adler  <darin@apple.com>
 
         Reviewed by Anders Carlsson.
index 70767ee902f97a6205ba529fa70a066a6b0f42c5..483d6d6d0eb7f230442beeb5ca9be89b1eef0101 100644 (file)
@@ -125,6 +125,9 @@ void InitWebCoreSystemInterface(void)
     INIT(IOSurfaceContextCreateImage);
     INIT(MakeScrollbarPainter);
     INIT(ScrollbarPainterPaint);
+    INIT(ScrollbarThickness);
+    INIT(ScrollbarMinimumThumbLength);
+    INIT(ScrollbarMinimumTotalLengthNeededForThumb);
 #endif
 
     didInit = true;
index 5473a23e6e46543461b7dd182d63bcbfea5e41c8..5f611898ab6e99d8d30fedd250eceaf8c6dbf5a8 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-26  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for <rdar://problem/8895140> Adopt WKScrollbar metrics 
+        when using WKScrollbars.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2011-01-26  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Maciej Stachowiak.
index f81b627590d92d1583b56a46d33f4f383930dda7..3d8bae76d7f4d84ac0717076532e4fb14fbf1271 100644 (file)
@@ -95,6 +95,9 @@ void InitWebCoreSystemInterface(void)
         INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
         INIT(MakeScrollbarPainter);
         INIT(ScrollbarPainterPaint);
+        INIT(ScrollbarThickness);
+        INIT(ScrollbarMinimumThumbLength);
+        INIT(ScrollbarMinimumTotalLengthNeededForThumb);
 #else
         INIT(GetHyphenationLocationBeforeIndex);
 #endif