Bug 332314: Menu items are improperly aligned when using iconic menuitems, patch by Kai Liu <kliu@mozilla.kailiu.com>, r=me, r=zeniko, r=roc, a=damon
authorgavin@gavinsharp.com
Thu, 08 May 2008 17:18:46 -0700
changeset 15078 a3274d6273d402b1ef52da08f15f5befad9da59f
parent 15077 d3d258fdc27ed90d64734bd3a6187c98c701dcbf
child 15079 b833e0c1f7d92cbe4f39b9eef098fa18b3c5b6b7
push idunknown
push userunknown
push dateunknown
reviewersme, zeniko, roc, damon
bugs332314
milestone1.9pre
Bug 332314: Menu items are improperly aligned when using iconic menuitems, patch by Kai Liu <kliu@mozilla.kailiu.com>, r=me, r=zeniko, r=roc, a=damon
toolkit/themes/winstripe/global/menu.css
widget/src/windows/nsNativeThemeWin.cpp
--- a/toolkit/themes/winstripe/global/menu.css
+++ b/toolkit/themes/winstripe/global/menu.css
@@ -75,25 +75,25 @@ menuitem.spell-suggestion {
 .menu-text,
 .menu-iconic-text {
   margin: 0px !important;
   padding: 0px;
   color: inherit;
 }
 
 .menu-text {
-  -moz-padding-start: 1.28em !important;
+  -moz-padding-start: 1.45em !important;
   -moz-appearance: menuitemtext;
 }
 
 .menu-text,
 .menu-iconic-text {
   font-weight: inherit;
-  padding-left: 2px;
-  padding-right: 2px;
+  -moz-margin-start: 2px !important;
+  -moz-padding-end: 2px;
 }
 
 .menu-description {
   font-style: italic;
   color: GrayText;
   -moz-margin-start: 1ex !important;
 }
 
@@ -101,30 +101,35 @@ menuitem.spell-suggestion {
 .menu-iconic-accel {
   color: inherit;
   -moz-margin-start: 0.74em !important;
   -moz-margin-end: 1.35em !important;
 }
 
 .menu-iconic-left,
 .menu-right {
-  min-width:  1.28em;
+  min-width:  1.45em;
   min-height: 1.21em;
 }
 
 .menu-iconic-icon {
   width: 16px;
   height: 16px;
 }
 
 menu.menu-iconic > .menu-iconic-left,
 menuitem.menuitem-iconic > .menu-iconic-left {
-  /* there's only space for 15px - make room for one more */
+  -moz-appearance: menuimage;
+}
+
+menu.menu-iconic > .menu-iconic-left > .menu-iconic-icon,
+menuitem.menuitem-iconic > .menu-iconic-left > .menu-iconic-icon {
+  /* reduce icon-text crowding */
   -moz-margin-start: -1px;
-  -moz-appearance: menuimage;
+  -moz-margin-end: 1px;
 }
 
 /* ..... menu arrow box ..... */
 
 .menu-right {
   -moz-appearance: menuarrow;
   -moz-margin-end: -2px;
   list-style-image: none;
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -1534,17 +1534,17 @@ nsNativeThemeWin::GetWidgetPadding(nsIDe
     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)
+  if (!theme)
     return PR_FALSE;
 
   if (aWidgetType == NS_THEME_MENUPOPUP)
   {
     SIZE popupSize;
     getThemePartSize(theme, NULL, MENU_POPUPBORDERS, /* state */ 0, NULL, TS_TRUE, &popupSize);
     aResult->top = aResult->bottom = popupSize.cy;
     aResult->left = aResult->right = popupSize.cx;
@@ -1583,36 +1583,29 @@ nsNativeThemeWin::GetWidgetPadding(nsIDe
     }
   }
 
   PRInt32 right, left, top, bottom;
   right = left = top = bottom = 0;
   switch (aWidgetType)
   {
     case NS_THEME_MENUIMAGE:
-        right = 9;
+        right = 8;
         left = 3;
         break;
     case NS_THEME_MENUCHECKBOX:
     case NS_THEME_MENURADIO:
         right = 8;
         left = 0;
         break;
     case NS_THEME_MENUITEMTEXT:
-        if (!theme)
-        {
-          left = 18;
-        }
-        else
-        {
-          // There seem to be exactly 4 pixels from the edge
-          // of the gutter to the text
-          SIZE size(GetGutterSize(theme, NULL));
-          left = size.cx + 4;
-        }
+        // There seem to be exactly 4 pixels from the edge
+        // of the gutter to the text: 2px margin (CSS) + 2px padding (here)
+        SIZE size(GetGutterSize(theme, NULL));
+        left = size.cx + 2;
         break;
     case NS_THEME_MENUSEPARATOR:
         {
           SIZE size(GetGutterSize(theme, NULL));
           left = size.cx + 5;
           top = 10;
           bottom = 7;
         }
@@ -1719,22 +1712,21 @@ nsNativeThemeWin::GetMinimumWidgetSize(n
       {
         SIZE gutterSize(GetGutterSize(theme, NULL));
         aResult->width = gutterSize.cx;
         aResult->height = gutterSize.cy;
         return NS_OK;
       }
       break;
     case NS_THEME_MENUIMAGE:
-      aResult->width = 1;
     case NS_THEME_MENUCHECKBOX:
     case NS_THEME_MENURADIO:
       {
         SIZE boxSize(GetGutterSize(theme, NULL));
-        aResult->width += boxSize.cx+2;
+        aResult->width = boxSize.cx+2;
         aResult->height = boxSize.cy;
         *aIsOverridable = PR_FALSE;
       }
     case NS_THEME_MENUITEMTEXT:
       return NS_OK;
     case NS_THEME_MENUARROW:
       aResult->width = 26;
       aResult->height = 16;