Commit 5ce11413 authored by bdakin@apple.com's avatar bdakin@apple.com
Browse files

Fix for <rdar://problem/8895140> Adopt WKScrollbar metrics

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: http://svn.webkit.org/repository/webkit/trunk@76754 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d495d9e7
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.
......@@ -1293,6 +1293,9 @@ _wkIOSurfaceContextCreate
_wkIOSurfaceContextCreateImage
_wkMakeScrollbarPainter
_wkScrollbarPainterPaint
_wkScrollbarThickness
_wkScrollbarMinimumThumbLength
_wkScrollbarMinimumTotalLengthNeededForThumb
#endif
#if ENABLE(3D_RENDERING)
......
......@@ -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)
......
......@@ -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
}
......
......@@ -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
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.
......
......@@ -125,6 +125,9 @@ void InitWebCoreSystemInterface(void)
INIT(IOSurfaceContextCreateImage);
INIT(MakeScrollbarPainter);
INIT(ScrollbarPainterPaint);
INIT(ScrollbarThickness);
INIT(ScrollbarMinimumThumbLength);
INIT(ScrollbarMinimumTotalLengthNeededForThumb);
#endif
didInit = true;
......
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.
......@@ -95,6 +95,9 @@ void InitWebCoreSystemInterface(void)
INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
INIT(MakeScrollbarPainter);
INIT(ScrollbarPainterPaint);
INIT(ScrollbarThickness);
INIT(ScrollbarMinimumThumbLength);
INIT(ScrollbarMinimumTotalLengthNeededForThumb);
#else
INIT(GetHyphenationLocationBeforeIndex);
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment