fix chrome button heights, fix some native button rendering issues, clean up some CSS. b=371080 r=mano sr=vlad

git-svn-id: svn://10.0.0.236/trunk@221025 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
joshmoz%gmail.com 2007-02-27 21:54:52 +00:00
parent e56196a76c
commit ec2f566245
5 changed files with 86 additions and 108 deletions

View File

@ -203,16 +203,11 @@ description {
padding: 1px 0px 0px 0px;
}
prefpane button {
-moz-appearance: button-small;
}
prefpane .groupbox-body {
border: none !important;
-moz-border-radius: 0px !important;
background-image: none !important;
padding: 8px 4px 4px 4px;
}
#paneTabs > groupbox {

View File

@ -594,17 +594,6 @@ input[disabled] {
background-color: -moz-field;
}
textarea,
textarea[disabled] {
-moz-appearance: none; /* we'll draw by hand, thanks */
font-size: 11px;
background-color: -moz-field;
}
textarea > .anonymous-div {
padding: 0px 0px 0px 2px;
}
select {
margin: 1px 1px 1px 1px;
background-color: transparent !important;
@ -668,35 +657,6 @@ input[type="radio"] {
margin: 1px 2px -3px 3px;
}
input[type="reset"],
input[type="button"],
input[type="submit"],
input[type="reset"]:active:hover,
input[type="button"]:active:hover,
input[type="submit"]:active:hover {
-moz-appearance: button-small;
font-size: 11px;
margin: 1px 2px 4px 2px;
padding: 0;
border-width: 3px 8px 2px 8px;
color: -moz-FieldText !important;
min-width: 24px;
}
/* makes sure diabled buttons have the same style as enabled buttons */
input[type="reset"][disabled]:active,
input[type="reset"][disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled] {
margin: 2px 1px 2px 1px;
padding: 0;
border-width: 2px 8px 2px 8px;
min-width: 24px;
color: GrayText !important;
}
/* this draws the square button */
button,
button[disabled],
@ -705,11 +665,6 @@ button[disabled]:active {
-moz-appearance: none;
}
/* tweak position of button part of file selector */
input[type="file"] > input[type="button"] {
margin: 0px 0px 2px 5px !important;
}
/* make sure disabled images have transparent background */
input[type="image"][disabled] {
background-color: transparent;

View File

@ -47,11 +47,10 @@
button {
-moz-appearance: button;
/* The margin used here come from the Aqua Human Interface Guidelines,
there should be 12 pixels between two buttons. */
margin: 6px;
min-width: 6.3em;
-moz-appearance: button;
padding: 0;
color: #000000;
color: ButtonText;
}
.button-text {
@ -71,10 +70,6 @@ button[type="default"] {
button[disabled="true"] {
color: #777777 !important;
-moz-border-top-colors: #cccccc #eeeeee #fdfdfd;
-moz-border-right-colors: #cccccc #d9d9d9;
-moz-border-bottom-colors: #cccccc #eeeeee #fdfdfd;
-moz-border-left-colors: #cccccc #d9d9d9;
}
/* ::::: menu/menu-button buttons ::::: */

View File

@ -87,14 +87,11 @@ public:
protected:
// Some widths and margins. You'd think there would be metrics for these, but no.
enum {
kAquaPushButtonEndcaps = 10,
kAquaPushButtonTopBottom = 2,
kAquaDropdownLeftEndcap = 9,
kAquaDropwdonRightEndcap = 20 // wider on right to encompass the button
};
// Some widths and margins. You'd think there would be metrics for these, but no.
static const int kAquaPushButtonEndcaps = 10;
static const int kAquaMinButtonWidth = 68;
static const int kAquaDropdownLeftEndcap = 9;
static const int kAquaDropwdonRightEndcap = 20; // wider on right to encompass the button
nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);

View File

@ -141,12 +141,16 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
HIRect drawRect = inBoxRect;
if (inKind == kThemePushButton ||
inKind == kThemePopupButton) {
// these buttons draw one pixel too wide on each side and two pixels too
// far down on the bottom
drawRect.origin.x += 1;
drawRect.size.width -= 2;
// These kinds of buttons draw 2 pixels too tall.
drawRect.size.height -= 2;
}
else if (inKind == kThemePushButtonSmall) {
// These kinds of buttons draw 2 pixels too wide, one pixel too far down, and
// two pixels too tall.
drawRect.origin.x += 1;
drawRect.origin.y -= 1;
drawRect.size.width -= 2;
}
#if DRAW_IN_FRAME_DEBUG
CGContextSetRGBFillColor(cgContext, 0.0, 0.0, 0.5, 0.8);
@ -473,12 +477,21 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
break;
case NS_THEME_BUTTON:
case NS_THEME_BUTTON_SMALL:
// NS_THEME_BUTTON and NS_THEME_BUTTON_SMALL draw the same way because larger native pushbuttons
// are capable of drawing themselves at any size the small native pushbuttons can.
DrawButton(cgContext, kThemePushButton, macRect,
case NS_THEME_BUTTON_SMALL: {
// Normal push buttons can only draw with a height of 20+ pixels. Small push
// buttons can only draw at a height of 17 pixels. We can't draw buttons with
// a height of 18 or 19 pixels, at least not with HITheme. So, we go down to
// 17 pixel buttons when asked to draw 18 or 19 so that we don't draw outside
// the frame. We just have to live with this until we switch to another API
// for control rendering. Remember that the frame for a 20 pixel tall button
// is 22 pixels because of the border and shadow.
ThemeButtonKind buttonKind = kThemePushButton;
if (macRect.size.height < 22)
buttonKind = kThemePushButtonSmall;
DrawButton(cgContext, buttonKind, macRect,
IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOn, kThemeAdornmentNone, eventState);
}
break;
case NS_THEME_BUTTON_BEVEL:
@ -665,14 +678,18 @@ nsNativeThemeCocoa::GetWidgetBorder(nsIDeviceContext* aContext,
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_BUTTON_SMALL:
aResult->SizeTo(kAquaPushButtonEndcaps, kAquaPushButtonTopBottom,
kAquaPushButtonEndcaps, kAquaPushButtonTopBottom);
// Top has a single pixel line, bottom has a single pixel line plus a single
// pixel shadow
aResult->SizeTo(kAquaPushButtonEndcaps, 1,
kAquaPushButtonEndcaps, 2);
break;
case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_BUTTON:
aResult->SizeTo(kAquaDropdownLeftEndcap, kAquaPushButtonTopBottom,
kAquaDropwdonRightEndcap, kAquaPushButtonTopBottom);
// Top has a single pixel line, bottom has a single pixel line plus a single
// pixel shadow
aResult->SizeTo(kAquaDropdownLeftEndcap, 1,
kAquaDropwdonRightEndcap, 2);
break;
case NS_THEME_TEXTFIELD: {
@ -700,18 +717,29 @@ nsNativeThemeCocoa::GetWidgetPadding(nsIDeviceContext* aContext,
PRUint8 aWidgetType,
nsMargin* aResult)
{
if (aWidgetType == NS_THEME_TEXTFIELD) {
SInt32 nativePadding = 0;
::GetThemeMetric(kThemeMetricEditTextWhitespace, &nativePadding);
aResult->SizeTo(nativePadding, nativePadding, nativePadding, nativePadding);
return PR_TRUE;
}
else if (aWidgetType == NS_THEME_BUTTON ||
aWidgetType == NS_THEME_BUTTON_SMALL) {
// The button draws with a shadow on the bottom so we have to move the text
// up one pixel to center it
aResult->SizeTo(0, -1, 0, 1);
return PR_TRUE;
switch (aWidgetType)
{
case NS_THEME_TEXTFIELD:
{
SInt32 nativePadding = 0;
::GetThemeMetric(kThemeMetricEditTextWhitespace, &nativePadding);
aResult->SizeTo(nativePadding, nativePadding, nativePadding, nativePadding);
return PR_TRUE;
}
case NS_THEME_BUTTON:
case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_BUTTON:
{
// The border/shadow on the bottom of the button means we have to
// draw the text a little higher than normal.
aResult->SizeTo(0, -1, 0, 1);
return PR_TRUE;
}
case NS_THEME_BUTTON_SMALL:
{
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
}
}
return PR_FALSE;
@ -732,20 +760,22 @@ nsNativeThemeCocoa::GetWidgetOverflow(nsIDeviceContext* aContext, nsIFrame* aFra
case NS_THEME_CHECKBOX_SMALL:
case NS_THEME_RADIO:
case NS_THEME_RADIO_SMALL:
// We assume that the above widgets can draw a focus ring that will be less than
// or equal to 4 pixels thick.
nsIntMargin extraSize = nsIntMargin(4, 4, 4, 4);
PRInt32 p2a = aContext->AppUnitsPerDevPixel();
nsMargin m(NSIntPixelsToAppUnits(extraSize.left, p2a),
NSIntPixelsToAppUnits(extraSize.top, p2a),
NSIntPixelsToAppUnits(extraSize.right, p2a),
NSIntPixelsToAppUnits(extraSize.bottom, p2a));
nsRect r(nsPoint(0, 0), aFrame->GetSize());
r.Inflate(m);
*aResult = r;
return PR_TRUE;
{
// We assume that the above widgets can draw a focus ring that will be less than
// or equal to 4 pixels thick.
nsIntMargin extraSize = nsIntMargin(4, 4, 4, 4);
PRInt32 p2a = aContext->AppUnitsPerDevPixel();
nsMargin m(NSIntPixelsToAppUnits(extraSize.left, p2a),
NSIntPixelsToAppUnits(extraSize.top, p2a),
NSIntPixelsToAppUnits(extraSize.right, p2a),
NSIntPixelsToAppUnits(extraSize.bottom, p2a));
nsRect r(nsPoint(0, 0), aFrame->GetSize());
r.Inflate(m);
*aResult = r;
return PR_TRUE;
}
}
return PR_FALSE;
}
@ -760,14 +790,21 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsIRenderingContext* aContext,
*aIsOverridable = PR_TRUE;
switch (aWidgetType) {
// These are the same since a normal native pushbutton can become as small
// as the small native pushbutton.
case NS_THEME_BUTTON:
case NS_THEME_BUTTON_SMALL:
{
// Height value is adjusted for shadow and border.
SInt32 buttonHeight = 0;
::GetThemeMetric(kThemeMetricPushButtonHeight, &buttonHeight);
aResult->SizeTo(kAquaPushButtonEndcaps * 2, buttonHeight);
aResult->SizeTo(kAquaMinButtonWidth, buttonHeight + 2);
break;
}
case NS_THEME_BUTTON_SMALL:
{
// Height value is adjusted for shadow and border.
SInt32 buttonHeight = 0;
::GetThemeMetric(kThemeMetricSmallPushButtonHeight, &buttonHeight);
aResult->SizeTo(kAquaMinButtonWidth, buttonHeight + 2);
break;
}
@ -919,7 +956,6 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsIRenderingContext* aContext,
*aIsOverridable = PR_FALSE;
break;
}
}
return NS_OK;