Bug 1751644 - Don't shrink padding of non-native menulist items. r=stransky

Native ones also have a big-ish padding (set by the theme).

Differential Revision: https://phabricator.services.mozilla.com/D136813
This commit is contained in:
Emilio Cobos Álvarez 2022-02-11 18:41:46 +00:00
parent 298b987a56
commit f25b45a97f
4 changed files with 9 additions and 31 deletions

View File

@ -15,9 +15,6 @@ menubar {
font: menu;
}
menuitem {
padding: 4px 6px;
}
menu,
menuitem,
@ -25,6 +22,7 @@ menucaption {
appearance: auto;
-moz-default-appearance: menuitem;
-moz-box-align: center;
padding: 4px 6px;
max-width: 42em;
list-style-image: none;
-moz-image-region: auto;
@ -84,10 +82,7 @@ menulist > menupopup {
font: inherit;
}
menulist > menupopup > menuitem,
menulist > menupopup > menucaption,
menulist > menupopup > menu {
padding: 1px 5px;
menulist > menupopup > :is(menuitem, menucaption, menu) {
max-width: none;
}
@ -155,9 +150,7 @@ menulist > menupopup > menu {
}
menulist > menupopup > menuitem > .menu-iconic-left,
menulist > menupopup > menucaption > .menu-iconic-left,
menulist > menupopup > menu > .menu-iconic-left {
menulist > menupopup > :is(menuitem, menucaption, menu) > .menu-iconic-left {
display: none;
}

View File

@ -1098,6 +1098,11 @@ LayoutDeviceIntMargin nsNativeThemeGTK::GetWidgetBorder(
// gtk's 'toolbar' for purposes of painting the widget background,
// we don't use the toolbar border for toolbox.
break;
case StyleAppearance::Menuitem:
case StyleAppearance::Checkmenuitem:
case StyleAppearance::Radiomenuitem:
// We use GetWidgetPadding for these.
break;
case StyleAppearance::Dualbutton:
// TOOLBAR_DUAL_BUTTON is an interesting case. We want a border to draw
// around the entire button + dropdown, and also an inner border if you're
@ -1118,14 +1123,6 @@ LayoutDeviceIntMargin nsNativeThemeGTK::GetWidgetBorder(
&result.bottom, direction, (GtkTabFlags)flags,
gtkWidgetType);
} break;
case StyleAppearance::Menuitem:
case StyleAppearance::Checkmenuitem:
case StyleAppearance::Radiomenuitem:
// For regular menuitems, we will be using GetWidgetPadding instead of
// GetWidgetBorder to pad up the widget's internals; other menuitems
// will need to fall through and use the default case as before.
if (IsRegularMenuItem(aFrame)) break;
[[fallthrough]];
default: {
GetCachedWidgetBorder(aFrame, aAppearance, direction, &result);
}
@ -1171,13 +1168,10 @@ bool nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
case StyleAppearance::Menuitem:
case StyleAppearance::Checkmenuitem:
case StyleAppearance::Radiomenuitem: {
// Menubar and menulist have their padding specified in CSS.
if (!IsRegularMenuItem(aFrame)) return false;
GetCachedWidgetBorder(aFrame, aAppearance, GetTextDirection(aFrame),
aResult);
gint horizontal_padding;
gint horizontal_padding = 0;
if (aAppearance == StyleAppearance::Menuitem)
moz_gtk_menuitem_get_horizontal_padding(&horizontal_padding);
else

View File

@ -447,12 +447,6 @@ bool nsNativeTheme::IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent) {
return false;
}
bool nsNativeTheme::IsRegularMenuItem(nsIFrame* aFrame) {
nsMenuFrame* menuFrame = do_QueryFrame(aFrame);
return !(menuFrame &&
(menuFrame->IsOnMenuBar() || menuFrame->IsParentMenuList()));
}
bool nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent,
uint32_t aMinimumFrameRate) {
NS_ASSERTION(aContent, "Null pointer!");

View File

@ -139,9 +139,6 @@ class nsNativeTheme : public nsITimerCallback, public nsINamed {
// menupopup:
bool IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent);
// True if it's not a menubar item or menulist item
bool IsRegularMenuItem(nsIFrame* aFrame);
static bool CheckBooleanAttr(nsIFrame* aFrame, nsAtom* aAtom);
static int32_t CheckIntAttr(nsIFrame* aFrame, nsAtom* aAtom,
int32_t defaultValue);