From 7afb3b36902a0d0fa3f552a45675145a6e0280ee Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 12 Jul 2013 17:19:28 -0400 Subject: [PATCH] Bug 892966 - Don't rely on being able to retrieve the current surface from a gfxContext when drawing cocoa menus. r=jrmuizel --- widget/cocoa/nsNativeThemeCocoa.mm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index d940ffbc4f64..631b5578c947 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -33,6 +33,8 @@ #include "gfxQuartzNativeDrawing.h" #include +using namespace mozilla::gfx; + #define DRAW_IN_FRAME_DEBUG 0 #define SCROLLBARS_VISUAL_DEBUG 0 @@ -2038,7 +2040,15 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, break; case NS_THEME_MENUITEM: { - if (thebesCtx->OriginalSurface()->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) { + bool isTransparent; + if (thebesCtx->IsCairo()) { + isTransparent = thebesCtx->OriginalSurface()->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA; + } else { + SurfaceFormat format = thebesCtx->GetDrawTarget()->GetFormat(); + isTransparent = (format == FORMAT_R8G8B8A8) || + (format == FORMAT_B8G8R8A8); + } + if (isTransparent) { // Clear the background to get correct transparency. CGContextClearRect(cgContext, macRect); }