Bug 427173: fix massive tooltips after switching OS themes by making sure we release the right theme handle, patch by Kai Liu <kliu@mozilla.kailiu.com>, r+sr=roc, a=schrep
authorgavin@gavinsharp.com
Thu, 08 May 2008 08:17:23 -0700
changeset 15057 9c978e713ef0593d8acb8df8e0064e968e7a97c0
parent 15056 ce6c0483e55f1a4faab67ab8ae0ffa9fb2f76126
child 15058 97153eec874c3be76c168b197a4c17a45bd0eae4
push idunknown
push userunknown
push dateunknown
reviewersschrep
bugs427173
milestone1.9pre
Bug 427173: fix massive tooltips after switching OS themes by making sure we release the right theme handle, patch by Kai Liu <kliu@mozilla.kailiu.com>, r+sr=roc, a=schrep
widget/src/windows/nsNativeThemeWin.cpp
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -489,17 +489,18 @@ nsNativeThemeWin::GetTheme(PRUint8 aWidg
     }
     case NS_THEME_TEXTFIELD:
     case NS_THEME_TEXTFIELD_MULTILINE: {
       if (!mTextFieldTheme)
         mTextFieldTheme = openTheme(NULL, L"Edit");
       return mTextFieldTheme;
     }
     case NS_THEME_TOOLTIP: {
-      if (!mTooltipTheme)
+      // BUG #161600: XP/2K3 should force a classic treatment of tooltips
+      if (!mTooltipTheme && mIsVistaOrLater)
         mTooltipTheme = openTheme(NULL, L"Tooltip");
       return mTooltipTheme;
     }
     case NS_THEME_TOOLBOX: {
       if (!mRebarTheme)
         mRebarTheme = openTheme(NULL, L"Rebar");
       return mRebarTheme;
     }
@@ -1224,24 +1225,16 @@ nsNativeThemeWin::DrawWidgetBackground(n
                                        PRUint8 aWidgetType,
                                        const nsRect& aRect,
                                        const nsRect& aClipRect)
 {
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicDrawWidgetBackground(aContext, aFrame, aWidgetType, aRect, aClipRect); 
 
-#ifndef WINCE
-  if (aWidgetType == NS_THEME_TOOLTIP && !mIsVistaOrLater) {
-    // BUG #161600: When rendering a non-classic tooltip, check
-    // for Windows prior to Vista, and if so, force a classic rendering
-    return ClassicDrawWidgetBackground(aContext, aFrame, aWidgetType, aRect, aClipRect);
-  }
-#endif
-
   if (!drawThemeBG)
     return NS_ERROR_FAILURE;    
 
   PRInt32 part, state;
   nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
   if (NS_FAILED(rv))
     return rv;
 
@@ -1888,17 +1881,17 @@ nsNativeThemeWin::CloseData()
   CLOSE_THEME(mToolbarTheme);
   CLOSE_THEME(mScrollbarTheme);
   CLOSE_THEME(mScaleTheme);
   CLOSE_THEME(mSpinTheme);
   CLOSE_THEME(mRebarTheme);
   CLOSE_THEME(mProgressTheme);
   CLOSE_THEME(mButtonTheme);
   CLOSE_THEME(mTextFieldTheme);
-  CLOSE_THEME(mToolbarTheme);
+  CLOSE_THEME(mTooltipTheme);
   CLOSE_THEME(mStatusbarTheme);
   CLOSE_THEME(mTabTheme);
   CLOSE_THEME(mTreeViewTheme);
   CLOSE_THEME(mComboBoxTheme);
   CLOSE_THEME(mHeaderTheme);
   CLOSE_THEME(mMenuTheme);
   CLOSE_THEME(mCommunicationsRebarTheme);
   CLOSE_THEME(mMediaRebarTheme);