b=419383, extract native vista toolbar styles and expose to themes ; r+sr=roc; a=beltzner
authorvladimir@pobox.com
Thu, 28 Feb 2008 21:10:38 -0800
changeset 12425 d80683b79345001f6ab27895209a7e7651449059
parent 12424 be4b3730d6aff7f0b852ef3f5cc97b678b91ae9e
child 12426 d953ab0ecab8a3ed7a30eb51dd858b8436db35d2
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbeltzner
bugs419383
milestone1.9b4pre
b=419383, extract native vista toolbar styles and expose to themes ; r+sr=roc; a=beltzner
gfx/public/nsThemeConstants.h
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
widget/src/windows/nsNativeThemeWin.cpp
widget/src/windows/nsNativeThemeWin.h
--- a/gfx/public/nsThemeConstants.h
+++ b/gfx/public/nsThemeConstants.h
@@ -226,8 +226,12 @@
 #define NS_THEME_MENURADIO                                 216
 #define NS_THEME_MENUSEPARATOR                             217
 #define NS_THEME_MENUARROW                                 218
 // An image in the menu gutter, like in bookmarks or history
 #define NS_THEME_MENUIMAGE                                 219
 // For text on non-iconic menuitems only
 #define NS_THEME_MENUITEMTEXT                              220
 
+// Vista Rebars
+#define NS_THEME_COMMUNICATIONS_TOOLBOX                    221
+#define NS_THEME_MEDIA_TOOLBOX                             222
+#define NS_THEME_BROWSER_TAB_BAR_TOOLBOX                   223
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -550,16 +550,19 @@ CSS_KEY(scalethumb-vertical, scalethumb_
 CSS_KEY(scalethumbstart, scalethumbstart)
 CSS_KEY(scalethumbend, scalethumbend)
 CSS_KEY(scalethumbtick, scalethumbtick)
 CSS_KEY(checkbox-container, checkboxcontainer)
 CSS_KEY(radio-container, radiocontainer)
 CSS_KEY(checkbox-label, checkboxlabel)
 CSS_KEY(radio-label, radiolabel)
 CSS_KEY(button-focus, buttonfocus)
+CSS_KEY(media-toolbox, media_toolbox)
+CSS_KEY(communications-toolbox, communications_toolbox)
+CSS_KEY(browsertabbar-toolbox, browsertabbar_toolbox)
 
 #ifdef MOZ_SVG
 //CSS_KEY(all, all)
 CSS_KEY(alphabetic, alphabetic)
 //CSS_KEY(auto, auto)
 CSS_KEY(bevel, bevel)
 CSS_KEY(butt, butt)
 CSS_KEY(central, central)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -260,16 +260,19 @@ const PRInt32 nsCSSProps::kAppearanceKTa
   eCSSKeyword_checkmenuitem,          NS_THEME_CHECKMENUITEM,
   eCSSKeyword_radiomenuitem,          NS_THEME_RADIOMENUITEM,
   eCSSKeyword_menucheckbox,           NS_THEME_MENUCHECKBOX,
   eCSSKeyword_menuradio,              NS_THEME_MENURADIO,
   eCSSKeyword_menuseparator,          NS_THEME_MENUSEPARATOR,
   eCSSKeyword_menuarrow,              NS_THEME_MENUARROW,
   eCSSKeyword_menuimage,              NS_THEME_MENUIMAGE,
   eCSSKeyword_menuitemtext,           NS_THEME_MENUITEMTEXT,
+  eCSSKeyword_media_toolbox,          NS_THEME_MEDIA_TOOLBOX,
+  eCSSKeyword_communications_toolbox, NS_THEME_COMMUNICATIONS_TOOLBOX,
+  eCSSKeyword_browsertabbar_toolbox,  NS_THEME_BROWSER_TAB_BAR_TOOLBOX,
   eCSSKeyword_UNKNOWN,-1
 };
 
 // Keyword id tables for variant/enum parsing
 const PRInt32 nsCSSProps::kAzimuthKTable[] = {
   eCSSKeyword_left_side,    NS_STYLE_AZIMUTH_LEFT_SIDE,
   eCSSKeyword_far_left,     NS_STYLE_AZIMUTH_FAR_LEFT,
   eCSSKeyword_left,         NS_STYLE_AZIMUTH_LEFT,
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -208,16 +208,17 @@
 #define TS_DRAW 2
 
 #define TMT_SIZINGMARGINS 3601
 #define TMT_CONTENTMARGINS 3602
 #define TMT_CAPTIONMARGINS 3603
 
 // Rebar constants
 #define RP_BAND              3
+#define RP_BACKGROUND        6
 
 // Constants only found in new (98+, 2K+, XP+, etc.) Windows.
 #ifdef DFCS_HOT
 #undef DFCS_HOT
 #endif
 #define DFCS_HOT             0x00001000
 
 #ifdef COLOR_MENUHILIGHT
@@ -298,16 +299,19 @@ static inline bool IsHTMLContent(nsIFram
 
 nsNativeThemeWin::nsNativeThemeWin() {
   mThemeDLL = NULL;
   mButtonTheme = NULL;
   mTextFieldTheme = NULL;
   mTooltipTheme = NULL;
   mToolbarTheme = NULL;
   mRebarTheme = NULL;
+  mMediaRebarTheme = NULL;
+  mCommunicationsRebarTheme = NULL;
+  mBrowserTabBarRebarTheme = NULL;
   mProgressTheme = NULL;
   mScrollbarTheme = NULL;
   mSpinTheme = NULL;
   mScaleTheme = NULL;
   mStatusbarTheme = NULL;
   mTabTheme = NULL;
   mTreeViewTheme = NULL;
   mComboBoxTheme = NULL;
@@ -470,16 +474,31 @@ nsNativeThemeWin::GetTheme(PRUint8 aWidg
         mTooltipTheme = openTheme(NULL, L"Tooltip");
       return mTooltipTheme;
     }
     case NS_THEME_TOOLBOX: {
       if (!mRebarTheme)
         mRebarTheme = openTheme(NULL, L"Rebar");
       return mRebarTheme;
     }
+    case NS_THEME_MEDIA_TOOLBOX: {
+      if (!mMediaRebarTheme)
+        mMediaRebarTheme = openTheme(NULL, L"Media::Rebar");
+      return mMediaRebarTheme;
+    }
+    case NS_THEME_COMMUNICATIONS_TOOLBOX: {
+      if (!mCommunicationsRebarTheme)
+        mCommunicationsRebarTheme = openTheme(NULL, L"Communications::Rebar");
+      return mCommunicationsRebarTheme;
+    }
+    case NS_THEME_BROWSER_TAB_BAR_TOOLBOX: {
+      if (!mBrowserTabBarRebarTheme)
+        mBrowserTabBarRebarTheme = openTheme(NULL, L"BrowserTabBar::Rebar");
+      return mBrowserTabBarRebarTheme;
+    }
     case NS_THEME_TOOLBAR:
     case NS_THEME_TOOLBAR_BUTTON:
     case NS_THEME_TOOLBAR_SEPARATOR: {
       if (!mToolbarTheme)
         mToolbarTheme = openTheme(NULL, L"Toolbar");
       return mToolbarTheme;
     }
     case NS_THEME_PROGRESSBAR:
@@ -884,21 +903,32 @@ nsNativeThemeWin::GetThemePartAndState(n
         aState = TS_NORMAL;
       else if (IsDisabled(aFrame))
         aState = TS_DISABLED;
       else
         aState = StandardGetState(aFrame, aWidgetType, PR_FALSE);
       return NS_OK;    
     }
     case NS_THEME_TOOLBOX:
+    case NS_THEME_MEDIA_TOOLBOX:
+    case NS_THEME_COMMUNICATIONS_TOOLBOX:
+    case NS_THEME_BROWSER_TAB_BAR_TOOLBOX:
     case NS_THEME_STATUSBAR:
     case NS_THEME_SCROLLBAR:
     case NS_THEME_SCROLLBAR_SMALL: {
-      aPart = aState = 0;
-      return NS_OK; // These have no part or state.
+      aState = 0;
+      if (mIsVistaOrLater) {
+        // On vista, they have a part
+        aPart = RP_BACKGROUND;
+      } else {
+        // Otherwise, they don't.  (But I bet
+        // RP_BACKGROUND would work here, too);
+        aPart = 0;
+      }
+      return NS_OK;
     }
     case NS_THEME_TOOLBAR: {
       // Use -1 to indicate we don't wish to have the theme background drawn
       // for this item. We will pass any nessessary information via aState,
       // and will render the item using separate code.
       aPart = -1;
       aState = 0;
       if (aFrame) {
@@ -1354,16 +1384,19 @@ nsNativeThemeWin::GetWidgetBorder(nsIDev
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicGetWidgetBorder(aContext, aFrame, aWidgetType, aResult); 
 
   (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
 
   if (!WidgetIsContainer(aWidgetType) ||
       aWidgetType == NS_THEME_TOOLBOX || 
+      aWidgetType == NS_THEME_MEDIA_TOOLBOX ||
+      aWidgetType == NS_THEME_COMMUNICATIONS_TOOLBOX ||
+      aWidgetType == NS_THEME_BROWSER_TAB_BAR_TOOLBOX ||
       aWidgetType == NS_THEME_STATUSBAR || 
       aWidgetType == NS_THEME_RESIZER || aWidgetType == NS_THEME_TAB_PANEL ||
       aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL ||
       aWidgetType == NS_THEME_SCROLLBAR_TRACK_VERTICAL ||
       aWidgetType == NS_THEME_MENUITEM || aWidgetType == NS_THEME_CHECKMENUITEM ||
       aWidgetType == NS_THEME_RADIOMENUITEM || aWidgetType == NS_THEME_MENUPOPUP ||
       aWidgetType == NS_THEME_MENUIMAGE || aWidgetType == NS_THEME_MENUITEMTEXT ||
       aWidgetType == NS_THEME_TOOLBAR_SEPARATOR)
@@ -1558,17 +1591,21 @@ nsNativeThemeWin::GetMinimumWidgetSize(n
 {
   (*aResult).width = (*aResult).height = 0;
   *aIsOverridable = PR_TRUE;
 
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicGetMinimumWidgetSize(aContext, aFrame, aWidgetType, aResult, aIsOverridable);
 
-  if (aWidgetType == NS_THEME_TOOLBOX || aWidgetType == NS_THEME_TOOLBAR || 
+  if (aWidgetType == NS_THEME_TOOLBOX ||
+      aWidgetType == NS_THEME_MEDIA_TOOLBOX ||
+      aWidgetType == NS_THEME_COMMUNICATIONS_TOOLBOX ||
+      aWidgetType == NS_THEME_BROWSER_TAB_BAR_TOOLBOX ||
+      aWidgetType == NS_THEME_TOOLBAR || 
       aWidgetType == NS_THEME_STATUSBAR || aWidgetType == NS_THEME_PROGRESSBAR_CHUNK ||
       aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
       aWidgetType == NS_THEME_TAB_PANELS || aWidgetType == NS_THEME_TAB_PANEL ||
       aWidgetType == NS_THEME_LISTBOX || aWidgetType == NS_THEME_TREEVIEW || aWidgetType == NS_THEME_MENUITEMTEXT)
     return NS_OK; // Don't worry about it.
 
   if (aWidgetType == NS_THEME_MENUITEM && IsTopLevelMenu(aFrame))
       return NS_OK; // Don't worry about it for top level menus
@@ -1686,17 +1723,21 @@ nsNativeThemeWin::GetMinimumWidgetSize(n
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                      nsIAtom* aAttribute, PRBool* aShouldRepaint)
 {
   // Some widget types just never change state.
-  if (aWidgetType == NS_THEME_TOOLBOX || aWidgetType == NS_THEME_TOOLBAR ||
+  if (aWidgetType == NS_THEME_TOOLBOX ||
+      aWidgetType == NS_THEME_MEDIA_TOOLBOX ||
+      aWidgetType == NS_THEME_COMMUNICATIONS_TOOLBOX ||
+      aWidgetType == NS_THEME_BROWSER_TAB_BAR_TOOLBOX ||
+      aWidgetType == NS_THEME_TOOLBAR ||
       aWidgetType == NS_THEME_STATUSBAR || aWidgetType == NS_THEME_STATUSBAR_PANEL ||
       aWidgetType == NS_THEME_STATUSBAR_RESIZER_PANEL ||
       aWidgetType == NS_THEME_PROGRESSBAR_CHUNK ||
       aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
       aWidgetType == NS_THEME_PROGRESSBAR ||
       aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
       aWidgetType == NS_THEME_TOOLTIP ||
       aWidgetType == NS_THEME_TAB_PANELS ||
@@ -1735,76 +1776,36 @@ nsNativeThemeWin::WidgetStateChanged(nsI
   }
 
   return NS_OK;
 }
 
 void
 nsNativeThemeWin::CloseData()
 {
-  if (mToolbarTheme) {
-    closeTheme(mToolbarTheme);
-    mToolbarTheme = NULL;
-  }
-  if (mScrollbarTheme) {
-    closeTheme(mScrollbarTheme);
-    mScrollbarTheme = NULL;
-  }
-  if (mScaleTheme) {
-    closeTheme(mScaleTheme);
-    mScaleTheme = NULL;
-  }
-  if (mSpinTheme) {
-    closeTheme(mSpinTheme);
-    mSpinTheme = NULL;
-  }
-  if (mRebarTheme) {
-    closeTheme(mRebarTheme);
-    mRebarTheme = NULL;
-  }
-  if (mProgressTheme) {
-    closeTheme(mProgressTheme);
-    mProgressTheme = NULL;
-  }
-  if (mButtonTheme) {
-    closeTheme(mButtonTheme);
-    mButtonTheme = NULL;
-  }
-  if (mTextFieldTheme) {
-    closeTheme(mTextFieldTheme);
-    mTextFieldTheme = NULL;
-  }
-  if (mTooltipTheme) {
-    closeTheme(mTooltipTheme);
-    mTooltipTheme = NULL;
-  }
-  if (mStatusbarTheme) {
-    closeTheme(mStatusbarTheme);
-    mStatusbarTheme = NULL;
-  }
-  if (mTabTheme) {
-    closeTheme(mTabTheme);
-    mTabTheme = NULL;
-  }
-  if (mTreeViewTheme) {
-    closeTheme(mTreeViewTheme);
-    mTreeViewTheme = NULL;
-  }
-  if (mComboBoxTheme) {
-    closeTheme(mComboBoxTheme);
-    mComboBoxTheme = NULL;
-  }
-  if (mHeaderTheme) {
-    closeTheme(mHeaderTheme);
-    mHeaderTheme = NULL;
-  }
-  if (mMenuTheme) {
-    closeTheme(mMenuTheme);
-    mMenuTheme = NULL;
-  }
+#define CLOSE_THEME(_x)  if (_x) { closeTheme(_x); _x = NULL; }
+  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(mStatusbarTheme);
+  CLOSE_THEME(mTabTheme);
+  CLOSE_THEME(mTreeViewTheme);
+  CLOSE_THEME(mComboBoxTheme);
+  CLOSE_THEME(mHeaderTheme);
+  CLOSE_THEME(mMenuTheme);
+  CLOSE_THEME(mCommunicationsRebarTheme);
+  CLOSE_THEME(mMediaRebarTheme);
+  CLOSE_THEME(mBrowserTabBarRebarTheme);
+#undef CLOSE_THEME
 }
 
 NS_IMETHODIMP
 nsNativeThemeWin::ThemeChanged()
 {
   CloseData();
   UpdateConfig();
   return NS_OK;
--- a/widget/src/windows/nsNativeThemeWin.h
+++ b/widget/src/windows/nsNativeThemeWin.h
@@ -131,16 +131,19 @@ protected:
 
 private:
   HMODULE mThemeDLL;
   HANDLE mButtonTheme;
   HANDLE mTextFieldTheme;
   HANDLE mTooltipTheme;
   HANDLE mToolbarTheme;
   HANDLE mRebarTheme;
+  HANDLE mMediaRebarTheme;
+  HANDLE mCommunicationsRebarTheme;
+  HANDLE mBrowserTabBarRebarTheme;
   HANDLE mProgressTheme;
   HANDLE mScrollbarTheme;
   HANDLE mScaleTheme;
   HANDLE mSpinTheme;
   HANDLE mStatusbarTheme;
   HANDLE mTabTheme;
   HANDLE mTreeViewTheme;
   HANDLE mComboBoxTheme;