don't put a dropmarker in comboboxes if nsITheme says not to. b=370282 r/sr=roc
authorjoshmoz@gmail.com
Thu, 17 May 2007 20:04:04 -0700
changeset 1582 61b38b0adcd3484efd11498c2b1541cdfe57c3c8
parent 1581 4568a1ac01e523ac8123cd1a6730fc7298249e11
child 1583 49829e8da0c3afb90bc6706d73f912ec1b363051
push idunknown
push userunknown
push dateunknown
bugs370282
milestone1.9a5pre
don't put a dropmarker in comboboxes if nsITheme says not to. b=370282 r/sr=roc
gfx/public/nsITheme.h
layout/forms/nsComboboxControlFrame.cpp
widget/src/cocoa/nsNativeThemeCocoa.h
widget/src/cocoa/nsNativeThemeCocoa.mm
widget/src/gtk2/nsNativeThemeGTK.cpp
widget/src/gtk2/nsNativeThemeGTK.h
widget/src/windows/nsNativeThemeWin.cpp
widget/src/windows/nsNativeThemeWin.h
--- a/gfx/public/nsITheme.h
+++ b/gfx/public/nsITheme.h
@@ -146,16 +146,21 @@ public:
   virtual PRBool WidgetIsContainer(PRUint8 aWidgetType)=0;
 
   /**
    * Does the nsITheme implementation draw its own focus ring for this widget?
    */
   virtual PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext,
                                           nsIFrame* aFrame,
                                           PRUint8 aWidgetType)=0;
+  
+  /**
+    * Should we insert a dropmarker inside of combobox button?
+   */
+  virtual PRBool ThemeNeedsComboboxDropmarker()=0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme, NS_ITHEME_IID)
 
 // Creator function
 extern NS_METHOD NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
 #endif
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -648,25 +648,31 @@ nsComboboxControlFrame::Reflow(nsPresCon
     RedisplayText(selectedIndex);
   }
 
   // First reflow our dropdown so that we know how tall we should be.
   ReflowDropdown(aPresContext, aReflowState);
 
   // Get the width of the vertical scrollbar.  That will be the width of the
   // dropdown button.
-  nsIScrollableFrame* scrollable;
-  CallQueryInterface(mListControlFrame, &scrollable);
-  NS_ASSERTION(scrollable, "List must be a scrollable frame");
-  nsBoxLayoutState bls(PresContext(), aReflowState.rendContext);
-  nscoord buttonWidth = scrollable->GetDesiredScrollbarSizes(&bls).LeftRight();
-
-  if (buttonWidth > aReflowState.ComputedWidth()) {
+  nscoord buttonWidth;
+  const nsStyleDisplay *disp = GetStyleDisplay();
+  if (IsThemed(disp) && !aPresContext->GetTheme()->ThemeNeedsComboboxDropmarker()) {
     buttonWidth = 0;
   }
+  else {
+    nsIScrollableFrame* scrollable;
+    CallQueryInterface(mListControlFrame, &scrollable);
+    NS_ASSERTION(scrollable, "List must be a scrollable frame");
+    nsBoxLayoutState bls(PresContext(), aReflowState.rendContext);
+    buttonWidth = scrollable->GetDesiredScrollbarSizes(&bls).LeftRight();
+    if (buttonWidth > aReflowState.ComputedWidth()) {
+      buttonWidth = 0;
+    }
+  }
 
   mDisplayWidth = aReflowState.ComputedWidth() - buttonWidth;
 
   nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
                                     aStatus);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now set the correct width and height on our button.  The width we need to
--- a/widget/src/cocoa/nsNativeThemeCocoa.h
+++ b/widget/src/cocoa/nsNativeThemeCocoa.h
@@ -79,16 +79,17 @@ public:
                                   PRUint8 aWidgetType,
                                   nsSize* aResult, PRBool* aIsOverridable);
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
   NS_IMETHOD ThemeChanged();
   PRBool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
   PRBool WidgetIsContainer(PRUint8 aWidgetType);
   PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
+  PRBool ThemeNeedsComboboxDropmarker();
 
 protected:
 
   // Some widths and margins. You'd think there would be metrics for these, but no.
   static const int kAquaDropdownLeftEndcap = 9;
   static const int kAquaDropwdonRightEndcap = 20; // wider on right to encompass the button
 
   nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -1388,8 +1388,14 @@ PRBool
 nsNativeThemeCocoa::ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType)
 {
   if (aWidgetType == NS_THEME_DROPDOWN ||
       aWidgetType == NS_THEME_BUTTON)
     return PR_TRUE;
   
   return PR_FALSE;
 }
+
+PRBool
+nsNativeThemeCocoa::ThemeNeedsComboboxDropmarker()
+{
+  return PR_FALSE;
+}
--- a/widget/src/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/src/gtk2/nsNativeThemeGTK.cpp
@@ -1067,8 +1067,14 @@ nsNativeThemeGTK::WidgetIsContainer(PRUi
   return PR_TRUE;
 }
 
 PRBool
 nsNativeThemeGTK::ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType)
 {
   return PR_FALSE;
 }
+
+PRBool
+nsNativeThemeGTK::ThemeNeedsComboboxDropmarker()
+{
+  return PR_TRUE;
+}
--- a/widget/src/gtk2/nsNativeThemeGTK.h
+++ b/widget/src/gtk2/nsNativeThemeGTK.h
@@ -85,16 +85,18 @@ public:
                                           nsIFrame* aFrame,
                                           PRUint8 aWidgetType);
 
   NS_IMETHOD_(PRBool) WidgetIsContainer(PRUint8 aWidgetType);
   
   NS_IMETHOD_(PRBool) ThemeDrawsFocusForWidget(nsPresContext* aPresContext,
                                                nsIFrame* aFrame, PRUint8 aWidgetType);
 
+  PRBool ThemeNeedsComboboxDropmarker();
+
   nsNativeThemeGTK();
   virtual ~nsNativeThemeGTK();
 
 private:
   PRBool GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
                               GtkThemeWidgetType& aGtkWidgetType,
                               GtkWidgetState* aState, gint* aWidgetFlags);
 
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -1284,16 +1284,22 @@ nsNativeThemeWin::WidgetIsContainer(PRUi
 }
 
 PRBool
 nsNativeThemeWin::ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType)
 {
   return PR_FALSE;
 }
 
+PRBool
+nsNativeThemeWin::ThemeNeedsComboboxDropmarker()
+{
+  return PR_TRUE;
+}
+
 /* Windows 9x/NT/2000/Classic XP Theme Support */
 
 PRBool 
 nsNativeThemeWin::ClassicThemeSupportsWidget(nsPresContext* aPresContext,
                                       nsIFrame* aFrame,
                                       PRUint8 aWidgetType)
 {
   switch (aWidgetType) {
--- a/widget/src/windows/nsNativeThemeWin.h
+++ b/widget/src/windows/nsNativeThemeWin.h
@@ -78,16 +78,18 @@ public:
   PRBool ThemeSupportsWidget(nsPresContext* aPresContext, 
                              nsIFrame* aFrame,
                              PRUint8 aWidgetType);
 
   PRBool WidgetIsContainer(PRUint8 aWidgetType);
 
   PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
 
+  PRBool ThemeNeedsComboboxDropmarker();
+
   nsNativeThemeWin();
   virtual ~nsNativeThemeWin();
 
 protected:
   void UpdateConfig();
   void CloseData();
   HANDLE GetTheme(PRUint8 aWidgetType);
   nsresult GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,