Bug 469683 - Wrong context menu transparency, r=josh sr=roc
authorMarkus Stange <mstange@themasta.com>
Mon, 15 Dec 2008 21:27:30 +0100
changeset 22820 62f5ef005bcd77fd48eb8d9674498214e74c46bd
parent 22819 23e4c322ac1bd3b57e9b6893165dad348699ca4f
child 22821 923d927753cee4b276924069d136152fbba107fa
push id4199
push usermstange@themasta.com
push dateMon, 15 Dec 2008 20:28:26 +0000
treeherdermozilla-central@62f5ef005bcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh, roc
bugs469683
milestone1.9.2a1pre
Bug 469683 - Wrong context menu transparency, r=josh sr=roc
widget/src/cocoa/nsCocoaWindow.mm
widget/src/cocoa/nsNativeThemeCocoa.mm
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -80,18 +80,16 @@ extern NSMenu* sApplicationMenu; // Appl
 
 // defined in nsChildView.mm
 extern nsIRollupListener * gRollupListener;
 extern nsIWidget         * gRollupWidget;
 extern BOOL                gSomeMenuBarPainted;
 
 #define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1"
 
-#define POPUP_DEFAULT_TRANSPARENCY 0.95
-
 NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa)
 
 
 // A note on testing to see if your object is a sheet...
 // |mWindowType == eWindowType_sheet| is true if your gecko nsIWidget is a sheet
 // widget - whether or not the sheet is showing. |[mWindow isSheet]| will return
 // true *only when the sheet is actually showing*. Choose your test wisely.
 
@@ -354,17 +352,16 @@ nsresult nsCocoaWindow::StandardCreate(n
     else if (features == NSBorderlessWindowMask)
       windowClass = [BorderlessWindow class];
 
     // Create the window
     mWindow = [[windowClass alloc] initWithContentRect:rect styleMask:features 
                                    backing:NSBackingStoreBuffered defer:YES];
     
     if (mWindowType == eWindowType_popup) {
-      [mWindow setAlphaValue:POPUP_DEFAULT_TRANSPARENCY];
       [mWindow setLevel:NSPopUpMenuWindowLevel];
       [mWindow setHasShadow:YES];
 
       // we need to make our content view a ChildView
       mPopupContentView = new nsChildView();
       if (mPopupContentView) {
         NS_ADDREF(mPopupContentView);
 
@@ -785,20 +782,16 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
 
 
 void nsCocoaWindow::MakeBackgroundTransparent(PRBool aTransparent)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   BOOL currentTransparency = ![mWindow isOpaque];
   if (aTransparent != currentTransparency) {
-    // Popups have an alpha value we need to toggle.
-    if (mWindowType == eWindowType_popup) {
-      [mWindow setAlphaValue:(aTransparent ? 1.0 : POPUP_DEFAULT_TRANSPARENCY)];
-    }
     [mWindow setOpaque:!aTransparent];
     [mWindow setBackgroundColor:(aTransparent ? [NSColor clearColor] : [NSColor whiteColor])];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -1448,16 +1448,19 @@ nsNativeThemeCocoa::DrawWidgetBackground
       // The rounded corners draw outside the frame.
       CGRect deflatedRect = CGRectMake(macRect.origin.x, macRect.origin.y + 4,
                                        macRect.size.width, macRect.size.height - 8);
       HIThemeDrawMenuBackground(&deflatedRect, &mdi, cgContext, HITHEME_ORIENTATION);
     }
       break;
 
     case NS_THEME_MENUITEM: {
+      // Clear the background to get correct transparency.
+      CGContextClearRect(cgContext, macRect);
+
       // maybe use kThemeMenuItemHierBackground or PopUpBackground instead of just Plain?
       HIThemeMenuItemDrawInfo drawInfo = {
         version: 0,
         itemType: kThemeMenuItemPlain,
         state: (IsDisabled(aFrame) ? kThemeMenuDisabled :
                 CheckBooleanAttr(aFrame, nsWidgetAtoms::mozmenuactive) ? kThemeMenuSelected :
                 kThemeMenuActive)
       };