Fix for <rdar://problem/8890255>
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 23:18:35 +0000 (23:18 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 23:18:35 +0000 (23:18 +0000)
Reviewed by Geoffrey Garen.

Source/WebCore:

Allow WebKitSystemInterface to draw scrollbars
when appropriate.
* WebCore.exp.in:
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::scrollbarMap):
(+[ScrollbarPrefsObserver appearancePrefsChanged:]):
(WebCore::ScrollbarThemeMac::registerScrollbar):
(WebCore::ScrollbarThemeMac::unregisterScrollbar):
(WebCore::ScrollbarThemeMac::paint):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Source/WebKit/mac:

Allow WebKitSystemInterface to draw scrollbars
when appropriate.
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKit2:

Allow WebKitSystemInterface to draw scrollbars
when appropriate.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76292 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 a8d920337c24fb4ecb779cb66129f9e06bcd1aa6..5f9829db0772539468749f4953af19a602552958 100644 (file)
@@ -1,3 +1,21 @@
+2011-01-20  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Geoffrey Garen.
+
+        Fix for <rdar://problem/8890255>
+
+        Allow WebKitSystemInterface to draw scrollbars 
+        when appropriate.
+        * WebCore.exp.in:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::scrollbarMap):
+        (+[ScrollbarPrefsObserver appearancePrefsChanged:]):
+        (WebCore::ScrollbarThemeMac::registerScrollbar):
+        (WebCore::ScrollbarThemeMac::unregisterScrollbar):
+        (WebCore::ScrollbarThemeMac::paint):
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
 2011-01-20  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Dave Hyatt.
index fcb8a0054f59ba9eae64aa1f7c82afc0e9811598..efa861548d239f66d9c9f0054642f4a2d908d34e 100644 (file)
@@ -1288,6 +1288,8 @@ _wkSignalCFReadStreamHasBytes
 _wkCreateCTTypesetterWithUniCharProviderAndOptions
 _wkIOSurfaceContextCreate
 _wkIOSurfaceContextCreateImage
+_wkMakeScrollbarPainter
+_wkScrollbarPainterPaint
 #endif
 
 #if ENABLE(3D_RENDERING)
index 3266b8f54caa4b33edd2126333c4fb20545a35f8..d27a3c6cf222a4406d06c9ef1da7c6b959a89198 100644 (file)
 #include "ScrollbarThemeMac.h"
 
 #include "ImageBuffer.h"
+#include "LocalCurrentGraphicsContext.h"
 #include "PlatformMouseEvent.h"
 #include "ScrollView.h"
+#include "WebCoreSystemInterface.h"
 #include <Carbon/Carbon.h>
+#include <wtf/HashMap.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
 
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#define USE_WK_SCROLLBAR_PAINTER
+#endif
+
 // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow.
 
 using namespace std;
 using namespace WebCore;
 
-static HashSet<Scrollbar*>* gScrollbars;
+namespace WebCore {
+
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+typedef HashMap<Scrollbar*, RetainPtr<WKScrollbarPainterRef> > ScrollbarPainterMap;
+#else
+typedef HashSet<Scrollbar*> ScrollbarPainterMap;
+#endif
+
+static ScrollbarPainterMap* scrollbarMap()
+{
+    static ScrollbarPainterMap* map = new ScrollbarPainterMap;
+    return map;
+}
+    
+}
 
 @interface ScrollbarPrefsObserver : NSObject
 {
@@ -58,12 +79,17 @@ static HashSet<Scrollbar*>* gScrollbars;
     UNUSED_PARAM(unusedNotification);
 
     static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
-    if (!gScrollbars)
+    if (scrollbarMap()->isEmpty())
         return;
-    HashSet<Scrollbar*>::iterator end = gScrollbars->end();
-    for (HashSet<Scrollbar*>::iterator it = gScrollbars->begin(); it != end; ++it) {
+    ScrollbarPainterMap::iterator end = scrollbarMap()->end();
+    for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) {
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+        it->first->styleChanged();
+        it->first->invalidate();
+#else
         (*it)->styleChanged();
         (*it)->invalidate();
+#endif
     }
 }
 
@@ -122,18 +148,18 @@ static void updateArrowPlacement()
 
 void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
 {
-    if (!gScrollbars)
-        gScrollbars = new HashSet<Scrollbar*>;
-    gScrollbars->add(scrollbar);
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+    WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(),
+        scrollbar->orientation() == HorizontalScrollbar);
+    scrollbarMap()->add(scrollbar, scrollbarPainter);
+#else
+    scrollbarMap()->add(scrollbar);
+#endif
 }
 
 void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar)
 {
-    gScrollbars->remove(scrollbar);
-    if (gScrollbars->isEmpty()) {
-        delete gScrollbars;
-        gScrollbars = 0;
-    }
+    scrollbarMap()->remove(scrollbar);
 }
 
 ScrollbarThemeMac::ScrollbarThemeMac()
@@ -361,6 +387,20 @@ static int scrollbarPartToHIPressedState(ScrollbarPart part)
 
 bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect)
 {
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+    context->save();
+    context->clip(damageRect);
+    context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
+    LocalCurrentGraphicsContext localContext(context);
+    wkScrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(),
+                            scrollbar->enabled(),
+                            scrollbar->currentPos() / scrollbar->maximum(),
+                            static_cast<CGFloat>(scrollbar->visibleSize()) / scrollbar->totalSize(),
+                            scrollbar->frameRect());
+    context->restore();
+    return true;
+#endif
+
     HIThemeTrackDrawInfo trackInfo;
     trackInfo.version = 0;
     trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMediumScrollBar : kThemeSmallScrollBar;
index 0c78c238e9f2cd6cacba4ebb61174d0e889dcd6c..045864a92c6e84d7d782c2b14c54867c30f7284f 100644 (file)
@@ -186,6 +186,10 @@ extern CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(cons
 
 extern CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace);
 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);
 #endif
 
 }
index df3c77c68d857ca72f37355e26fa737995f04138..047827f463ebba90e0fc3bebf7867c7160706878 100644 (file)
@@ -125,4 +125,7 @@ CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniCh
 
 CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace);
 CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
+
+WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
+void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
 #endif
index 4f0d2efd2e479d2cc8bff751189b1bdb51b5af74..da6e1e33f4948552c5cc39cc46fcaa9e543d0b38 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-20  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Geoffrey Garen.
+
+        Fix for <rdar://problem/8890255>
+
+        Allow WebKitSystemInterface to draw scrollbars 
+        when appropriate.
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2011-01-19  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Sam Weinig.
index e1c10586b10d705bd211978bc63a2cfa94d4132d..70767ee902f97a6205ba529fa70a066a6b0f42c5 100644 (file)
@@ -123,6 +123,8 @@ void InitWebCoreSystemInterface(void)
     INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
     INIT(IOSurfaceContextCreate);
     INIT(IOSurfaceContextCreateImage);
+    INIT(MakeScrollbarPainter);
+    INIT(ScrollbarPainterPaint);
 #endif
 
     didInit = true;
index 5339117b429a25858986ec985c5fec73d85d2efa..703bf66228cbb1468187f494dcb4652b96272433 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-20  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Geoffrey Garen.
+
+        Fix for <rdar://problem/8890255>
+
+        Allow WebKitSystemInterface to draw scrollbars 
+        when appropriate.
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2011-01-20  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Dave Hyatt.
index 90b9a643e51934eacddeb7186ae6e9ba85877439..f81b627590d92d1583b56a46d33f4f383930dda7 100644 (file)
@@ -93,6 +93,8 @@ void InitWebCoreSystemInterface(void)
 
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
         INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
+        INIT(MakeScrollbarPainter);
+        INIT(ScrollbarPainterPaint);
 #else
         INIT(GetHyphenationLocationBeforeIndex);
 #endif