зеркало из https://github.com/mozilla/pjs.git
Ensure compatibility with OS X 10.7's arrowless scrollbar. r=mstange
This commit is contained in:
Родитель
c4246ec726
Коммит
0134af60ca
|
@ -43,10 +43,10 @@
|
||||||
// for |#ifdef NS_DEBUG|
|
// for |#ifdef NS_DEBUG|
|
||||||
struct nsSize;
|
struct nsSize;
|
||||||
|
|
||||||
// 2e89c566-0a31-4c93-bdff-222651df45a0
|
// 89401022-94b3-413e-a6b8-2203dab824f3
|
||||||
#define NS_ILOOKANDFEEL_IID \
|
#define NS_ILOOKANDFEEL_IID \
|
||||||
{ 0x2e89c566, 0x0a31, 0x4c93, \
|
{ 0x89401022, 0x94b3, 0x413e, \
|
||||||
{ 0xbd, 0xff, 0x22, 0x26, 0x51, 0xdf, 0x45, 0xa0 } }
|
{ 0xa6, 0xb8, 0x22, 0x03, 0xda, 0xb8, 0x24, 0xf3 } }
|
||||||
|
|
||||||
class nsILookAndFeel: public nsISupports {
|
class nsILookAndFeel: public nsISupports {
|
||||||
public:
|
public:
|
||||||
|
@ -326,6 +326,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
eMetric_ScrollArrowNone = 0,
|
||||||
eMetric_ScrollArrowStartBackward = 0x1000,
|
eMetric_ScrollArrowStartBackward = 0x1000,
|
||||||
eMetric_ScrollArrowStartForward = 0x0100,
|
eMetric_ScrollArrowStartForward = 0x0100,
|
||||||
eMetric_ScrollArrowEndBackward = 0x0010,
|
eMetric_ScrollArrowEndBackward = 0x0010,
|
||||||
|
|
|
@ -343,22 +343,25 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
||||||
aMetric = 4;
|
aMetric = 4;
|
||||||
break;
|
break;
|
||||||
case eMetric_ScrollArrowStyle:
|
case eMetric_ScrollArrowStyle:
|
||||||
{
|
if (nsToolkit::OnLionOrLater()) {
|
||||||
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
// OS X Lion's scrollbars have no arrows
|
||||||
if ([buttonPlacement isEqualToString:@"Single"]) {
|
aMetric = eMetric_ScrollArrowNone;
|
||||||
aMetric = eMetric_ScrollArrowStyleSingle;
|
|
||||||
} else if ([buttonPlacement isEqualToString:@"DoubleMin"]) {
|
|
||||||
aMetric = eMetric_ScrollArrowStyleBothAtTop;
|
|
||||||
} else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
|
|
||||||
aMetric = eMetric_ScrollArrowStyleBothAtEachEnd;
|
|
||||||
} else {
|
} else {
|
||||||
aMetric = eMetric_ScrollArrowStyleBothAtBottom; // The default is BothAtBottom.
|
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
||||||
|
if ([buttonPlacement isEqualToString:@"Single"]) {
|
||||||
|
aMetric = eMetric_ScrollArrowStyleSingle;
|
||||||
|
} else if ([buttonPlacement isEqualToString:@"DoubleMin"]) {
|
||||||
|
aMetric = eMetric_ScrollArrowStyleBothAtTop;
|
||||||
|
} else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
|
||||||
|
aMetric = eMetric_ScrollArrowStyleBothAtEachEnd;
|
||||||
|
} else {
|
||||||
|
aMetric = eMetric_ScrollArrowStyleBothAtBottom; // The default is BothAtBottom.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
case eMetric_ScrollSliderStyle:
|
case eMetric_ScrollSliderStyle:
|
||||||
aMetric = eMetric_ScrollThumbStyleProportional;
|
aMetric = eMetric_ScrollThumbStyleProportional;
|
||||||
break;
|
break;
|
||||||
case eMetric_TreeOpenDelay:
|
case eMetric_TreeOpenDelay:
|
||||||
aMetric = 1000;
|
aMetric = 1000;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1428,9 +1428,12 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo(HIThemeTrackDrawInfo& aTdi, nsIFrame *a
|
||||||
|
|
||||||
aTdi.trackInfo.scrollbar.pressState = 0;
|
aTdi.trackInfo.scrollbar.pressState = 0;
|
||||||
|
|
||||||
// Only go get these scrollbar button states if we need it. For example, there's no reaon to look up scrollbar button
|
// Only go get these scrollbar button states if we need it. For example,
|
||||||
// states when we're only creating a TrackDrawInfo to determine the size of the thumb.
|
// there's no reason to look up scrollbar button states when we're only
|
||||||
if (aShouldGetButtonStates) {
|
// creating a TrackDrawInfo to determine the size of the thumb. There's
|
||||||
|
// also no reason to do this on Lion or later, whose scrollbars have no
|
||||||
|
// arrow buttons.
|
||||||
|
if (aShouldGetButtonStates && !nsToolkit::OnLionOrLater()) {
|
||||||
nsEventStates buttonStates[4];
|
nsEventStates buttonStates[4];
|
||||||
GetScrollbarPressStates(aFrame, buttonStates);
|
GetScrollbarPressStates(aFrame, buttonStates);
|
||||||
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
||||||
|
@ -2155,23 +2158,26 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
|
||||||
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
||||||
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
||||||
{
|
{
|
||||||
// There's only an endcap to worry about when both arrows are on the bottom
|
// On Lion and later, scrollbars have no arrows.
|
||||||
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
if (!nsToolkit::OnLionOrLater()) {
|
||||||
if (!buttonPlacement || [buttonPlacement isEqualToString:@"DoubleMax"]) {
|
// There's only an endcap to worry about when both arrows are on the bottom
|
||||||
PRBool isHorizontal = (aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL);
|
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
||||||
|
if (!buttonPlacement || [buttonPlacement isEqualToString:@"DoubleMax"]) {
|
||||||
|
PRBool isHorizontal = (aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL);
|
||||||
|
|
||||||
nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame);
|
nsIFrame *scrollbarFrame = GetParentScrollbarFrame(aFrame);
|
||||||
if (!scrollbarFrame) return NS_ERROR_FAILURE;
|
if (!scrollbarFrame) return NS_ERROR_FAILURE;
|
||||||
PRBool isSmall = (scrollbarFrame->GetStyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
|
PRBool isSmall = (scrollbarFrame->GetStyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
|
||||||
|
|
||||||
// There isn't a metric for this, so just hardcode a best guess at the value.
|
// There isn't a metric for this, so just hardcode a best guess at the value.
|
||||||
// This value is even less exact due to the fact that the endcap is partially concave.
|
// This value is even less exact due to the fact that the endcap is partially concave.
|
||||||
PRInt32 endcapSize = isSmall ? 5 : 6;
|
PRInt32 endcapSize = isSmall ? 5 : 6;
|
||||||
|
|
||||||
if (isHorizontal)
|
if (isHorizontal)
|
||||||
aResult->SizeTo(endcapSize, 0, 0, 0);
|
aResult->SizeTo(endcapSize, 0, 0, 0);
|
||||||
else
|
else
|
||||||
aResult->SizeTo(0, endcapSize, 0, 0);
|
aResult->SizeTo(0, endcapSize, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
#define MAC_OS_X_VERSION_10_5_HEX 0x00001050
|
#define MAC_OS_X_VERSION_10_5_HEX 0x00001050
|
||||||
#define MAC_OS_X_VERSION_10_6_HEX 0x00001060
|
#define MAC_OS_X_VERSION_10_6_HEX 0x00001060
|
||||||
|
#define MAC_OS_X_VERSION_10_7_HEX 0x00001070
|
||||||
|
|
||||||
class nsToolkit : public nsIToolkit
|
class nsToolkit : public nsIToolkit
|
||||||
{
|
{
|
||||||
|
@ -60,6 +61,7 @@ public:
|
||||||
|
|
||||||
static PRInt32 OSXVersion();
|
static PRInt32 OSXVersion();
|
||||||
static PRBool OnSnowLeopardOrLater();
|
static PRBool OnSnowLeopardOrLater();
|
||||||
|
static PRBool OnLionOrLater();
|
||||||
|
|
||||||
static void PostSleepWakeNotification(const char* aNotification);
|
static void PostSleepWakeNotification(const char* aNotification);
|
||||||
|
|
||||||
|
|
|
@ -407,6 +407,11 @@ PRBool nsToolkit::OnSnowLeopardOrLater()
|
||||||
return (OSXVersion() >= MAC_OS_X_VERSION_10_6_HEX);
|
return (OSXVersion() >= MAC_OS_X_VERSION_10_6_HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool nsToolkit::OnLionOrLater()
|
||||||
|
{
|
||||||
|
return (OSXVersion() >= MAC_OS_X_VERSION_10_7_HEX);
|
||||||
|
}
|
||||||
|
|
||||||
// An alternative to [NSObject poseAsClass:] that isn't deprecated on OS X
|
// An alternative to [NSObject poseAsClass:] that isn't deprecated on OS X
|
||||||
// Leopard and is available to 64-bit binaries on Leopard and above. Based on
|
// Leopard and is available to 64-bit binaries on Leopard and above. Based on
|
||||||
// ideas and code from http://www.cocoadev.com/index.pl?MethodSwizzling.
|
// ideas and code from http://www.cocoadev.com/index.pl?MethodSwizzling.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче