Bug 794246. Assume inactive menu items don't paint a background of their own. r=bas
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 08 Jan 2013 00:06:11 +1300
changeset 118524 8d63c737db5702378765e2ba5940b9e8dc7221c7
parent 118523 818ed8d0886d2b82aa90783c8de898a2a052b04f
child 118525 c232dd64f733fb41e4dc7c6f2279e3f16db1a93c
push id21126
push userrocallahan@mozilla.com
push dateFri, 11 Jan 2013 13:09:28 +0000
treeherdermozilla-inbound@db4776369a2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs794246
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 794246. Assume inactive menu items don't paint a background of their own. r=bas
widget/windows/nsNativeThemeWin.cpp
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -1164,16 +1164,25 @@ nsNativeThemeWin::GetThemePartAndState(n
       return NS_OK;
   }
 
   aPart = 0;
   aState = 0;
   return NS_ERROR_FAILURE;
 }
 
+static bool
+AssumeThemePartAndStateAreTransparent(int32_t aPart, int32_t aState)
+{
+  if (aPart == MENU_POPUPITEM && aState == MBI_NORMAL) {
+    return true;
+  }
+  return false;
+}
+
 NS_IMETHODIMP
 nsNativeThemeWin::DrawWidgetBackground(nsRenderingContext* aContext,
                                        nsIFrame* aFrame,
                                        uint8_t aWidgetType,
                                        const nsRect& aRect,
                                        const nsRect& aDirtyRect)
 {
   HANDLE theme = GetTheme(aWidgetType);
@@ -1209,16 +1218,20 @@ nsNativeThemeWin::DrawWidgetBackground(n
     }
   }
 
   int32_t part, state;
   nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
   if (NS_FAILED(rv))
     return rv;
 
+  if (AssumeThemePartAndStateAreTransparent(part, state)) {
+    return NS_OK;
+  }
+
   gfxFloat p2a = gfxFloat(aContext->AppUnitsPerDevPixel());
   RECT widgetRect;
   RECT clipRect;
   gfxRect tr(aRect.x, aRect.y, aRect.width, aRect.height),
           dr(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
 
   tr.ScaleInverse(p2a);
   dr.ScaleInverse(p2a);
@@ -3144,16 +3157,20 @@ nsresult nsNativeThemeWin::ClassicDrawWi
 {
   int32_t part, state;
   bool focused;
   nsresult rv;
   rv = ClassicGetThemePartAndState(aFrame, aWidgetType, part, state, focused);
   if (NS_FAILED(rv))
     return rv;
 
+  if (AssumeThemePartAndStateAreTransparent(part, state)) {
+    return NS_OK;
+  }
+
   gfxFloat p2a = gfxFloat(aContext->AppUnitsPerDevPixel());
   RECT widgetRect;
   gfxRect tr(aRect.x, aRect.y, aRect.width, aRect.height),
           dr(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
 
   tr.ScaleInverse(p2a);
   dr.ScaleInverse(p2a);