Give radio buttons and checkboxes a useful baseline, and switch checkboxes from text-bottom to baseline alignment (to match radios). b=402940 r+sr=bzbarsky a=blocking1.9+

This commit is contained in:
dbaron@dbaron.org 2008-03-07 09:57:34 -08:00
parent 57f729547a
commit fe0cb896ea
6 changed files with 55 additions and 15 deletions

View File

@ -94,6 +94,17 @@ nsFormControlFrame::GetIntrinsicHeight()
return nsPresContext::CSSPixelsToAppUnits(13 - 2 * 2);
}
nscoord
nsFormControlFrame::GetBaseline() const
{
NS_ASSERTION(!NS_SUBTREE_DIRTY(this),
"frame must not be dirty");
// Treat radio buttons and checkboxes as having an intrinsic baseline
// at the bottom of the control (use the bottom content edge rather
// than the bottom margin edge).
return mRect.height - GetUsedBorderAndPadding().bottom;
}
NS_METHOD
nsFormControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -42,10 +42,10 @@
#include "nsLeafFrame.h"
/**
* nsFormControlFrame is the base class for frames of form controls. It
* provides a uniform way of creating widgets, resizing, and painting.
* @see nsLeafFrame and its base classes for more info
*/
* nsFormControlFrame is the base class for radio buttons and
* checkboxes. It also has two static methods (RegUnRegAccessKey and
* GetScreenHeight) that are used by other form controls.
*/
class nsFormControlFrame : public nsLeafFrame,
public nsIFormControlFrame
{
@ -74,6 +74,8 @@ public:
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
virtual nscoord GetBaseline() const;
/**
* Respond to the request to resize and/or reflow
* @see nsIFrame::Reflow

View File

@ -399,7 +399,6 @@ input[type="checkbox"] {
height: 13px;
margin: 3px 3px 3px 4px;
padding: 0 !important;
vertical-align: text-bottom;
cursor: default;
-moz-binding: none;

View File

@ -1319,9 +1319,17 @@ nsNativeThemeCocoa::GetWidgetPadding(nsIDeviceContext* aContext,
{
// We don't want CSS padding being used for certain widgets.
// See bug 381639 for an example of why.
if (aWidgetType == NS_THEME_BUTTON) {
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
switch (aWidgetType) {
case NS_THEME_BUTTON:
// Radios and checkboxes return a fixed size in GetMinimumWidgetSize
// and have a meaningful baseline, so they can't have
// author-specified padding.
case NS_THEME_CHECKBOX:
case NS_THEME_CHECKBOX_SMALL:
case NS_THEME_RADIO:
case NS_THEME_RADIO_SMALL:
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
}
return PR_FALSE;
}

View File

@ -895,13 +895,21 @@ nsNativeThemeGTK::GetWidgetPadding(nsIDeviceContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,
nsMargin* aResult)
{
if (aWidgetType == NS_THEME_BUTTON_FOCUS ||
aWidgetType == NS_THEME_TOOLBAR_BUTTON ||
aWidgetType == NS_THEME_TOOLBAR_DUAL_BUTTON ||
aWidgetType == NS_THEME_TAB_SCROLLARROW_BACK ||
aWidgetType == NS_THEME_TAB_SCROLLARROW_FORWARD) {
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
switch (aWidgetType) {
case NS_THEME_BUTTON_FOCUS:
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON:
case NS_THEME_TAB_SCROLLARROW_BACK :
case NS_THEME_TAB_SCROLLARROW_FORWARD:
// Radios and checkboxes return a fixed size in GetMinimumWidgetSize
// and have a meaningful baseline, so they can't have
// author-specified padding.
case NS_THEME_CHECKBOX:
case NS_THEME_CHECKBOX_SMALL:
case NS_THEME_RADIO:
case NS_THEME_RADIO_SMALL:
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
}
return PR_FALSE;

View File

@ -1498,6 +1498,18 @@ nsNativeThemeWin::GetWidgetPadding(nsIDeviceContext* aContext,
PRUint8 aWidgetType,
nsMargin* aResult)
{
switch (aWidgetType) {
// Radios and checkboxes return a fixed size in GetMinimumWidgetSize
// and have a meaningful baseline, so they can't have
// author-specified padding.
case NS_THEME_CHECKBOX:
case NS_THEME_CHECKBOX_SMALL:
case NS_THEME_RADIO:
case NS_THEME_RADIO_SMALL:
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
}
HANDLE theme = GetTheme(aWidgetType);
if (!theme && aWidgetType != NS_THEME_MENUITEMTEXT)
return PR_FALSE;