Bug 448704 – Eliminate <gripper> as an independent element. r=vlad/dbaron/enndeakin
authorKai Liu <kliu@mozilla.kailiu.com>
Wed, 13 Aug 2008 08:15:27 +0200
changeset 16607 888b724a1b9041d8c9ce446e620dead9dc426660
parent 16606 82c1a4ea20bb65b662a863c1fc598a519cf38dd5
child 16608 177454c4547a5b60e5ddb48cdcb88b6702f8f32e
push idunknown
push userunknown
push dateunknown
reviewersvlad, dbaron, enndeakin
bugs448704
milestone1.9.1a2pre
Bug 448704 – Eliminate <gripper> as an independent element. r=vlad/dbaron/enndeakin
content/base/src/nsGkAtomList.h
gfx/public/nsThemeConstants.h
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
toolkit/content/widgets/scrollbar.xml
toolkit/themes/winstripe/global/xulscrollbars.css
widget/src/gtk2/nsNativeThemeGTK.cpp
widget/src/windows/nsNativeThemeWin.cpp
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -372,17 +372,16 @@ GK_ATOM(formatNumber, "format-number")
 GK_ATOM(frame, "frame")
 GK_ATOM(frameborder, "frameborder")
 GK_ATOM(frameset, "frameset")
 GK_ATOM(from, "from")
 GK_ATOM(functionAvailable, "function-available")
 GK_ATOM(generateId, "generate-id")
 GK_ATOM(getter, "getter")
 GK_ATOM(grid, "grid")
-GK_ATOM(gripper, "gripper")
 GK_ATOM(grippy, "grippy")
 GK_ATOM(group, "group")
 GK_ATOM(groupingSeparator, "grouping-separator")
 GK_ATOM(groupingSize, "grouping-size")
 GK_ATOM(grow, "grow")
 GK_ATOM(gutter, "gutter")
 GK_ATOM(h1, "h1")
 GK_ATOM(h2, "h2")
--- a/gfx/public/nsThemeConstants.h
+++ b/gfx/public/nsThemeConstants.h
@@ -148,20 +148,16 @@
 // The scrollbar track
 #define NS_THEME_SCROLLBAR_TRACK_HORIZONTAL                86
 #define NS_THEME_SCROLLBAR_TRACK_VERTICAL                  87
 
 // The scrollbar thumb
 #define NS_THEME_SCROLLBAR_THUMB_HORIZONTAL                88
 #define NS_THEME_SCROLLBAR_THUMB_VERTICAL                  89
 
-// The gripper that goes on the thumb
-#define NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL              90
-#define NS_THEME_SCROLLBAR_GRIPPER_VERTICAL                91
-
 // A textfield or text area
 #define NS_THEME_TEXTFIELD                                 95
 
 // The caret of a text area
 #define NS_THEME_TEXTFIELD_CARET                           96
 
 // A multiline text field
 #define NS_THEME_TEXTFIELD_MULTILINE                       97
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -527,18 +527,16 @@ CSS_KEY(spinner-textfield, spinner_textf
 CSS_KEY(scrollbarbutton-up, scrollbarbutton_up)
 CSS_KEY(scrollbarbutton-down, scrollbarbutton_down)
 CSS_KEY(scrollbarbutton-left, scrollbarbutton_left)
 CSS_KEY(scrollbarbutton-right, scrollbarbutton_right)
 CSS_KEY(scrollbartrack-horizontal, scrollbartrack_horizontal)
 CSS_KEY(scrollbartrack-vertical, scrollbartrack_vertical)
 CSS_KEY(scrollbarthumb-horizontal, scrollbarthumb_horizontal)
 CSS_KEY(scrollbarthumb-vertical, scrollbarthumb_vertical)
-CSS_KEY(scrollbargripper-horizontal, scrollbargripper_horizontal)
-CSS_KEY(scrollbargripper-vertical, scrollbargripper_vertical)
 CSS_KEY(textfield, textfield)
 CSS_KEY(textfield-multiline, textfield_multiline)
 CSS_KEY(caret, caret)
 CSS_KEY(menubar, menubar)
 CSS_KEY(menupopup, menupopup)
 CSS_KEY(menuitem, menuitem)
 CSS_KEY(checkmenuitem, checkmenuitem)
 CSS_KEY(radiomenuitem, radiomenuitem)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -286,18 +286,16 @@ const PRInt32 nsCSSProps::kAppearanceKTa
   eCSSKeyword_scrollbarbutton_up,     NS_THEME_SCROLLBAR_BUTTON_UP,
   eCSSKeyword_scrollbarbutton_down,   NS_THEME_SCROLLBAR_BUTTON_DOWN,
   eCSSKeyword_scrollbarbutton_left,   NS_THEME_SCROLLBAR_BUTTON_LEFT,
   eCSSKeyword_scrollbarbutton_right,  NS_THEME_SCROLLBAR_BUTTON_RIGHT,
   eCSSKeyword_scrollbartrack_horizontal,    NS_THEME_SCROLLBAR_TRACK_HORIZONTAL,
   eCSSKeyword_scrollbartrack_vertical,      NS_THEME_SCROLLBAR_TRACK_VERTICAL,
   eCSSKeyword_scrollbarthumb_horizontal,    NS_THEME_SCROLLBAR_THUMB_HORIZONTAL,
   eCSSKeyword_scrollbarthumb_vertical,      NS_THEME_SCROLLBAR_THUMB_VERTICAL,
-  eCSSKeyword_scrollbargripper_horizontal,  NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL,
-  eCSSKeyword_scrollbargripper_vertical,    NS_THEME_SCROLLBAR_GRIPPER_VERTICAL,
   eCSSKeyword_textfield,              NS_THEME_TEXTFIELD,
   eCSSKeyword_textfield_multiline,    NS_THEME_TEXTFIELD_MULTILINE,
   eCSSKeyword_caret,                  NS_THEME_TEXTFIELD_CARET,
   eCSSKeyword_menulist,               NS_THEME_DROPDOWN,
   eCSSKeyword_menulistbutton,         NS_THEME_DROPDOWN_BUTTON,
   eCSSKeyword_menulisttext,           NS_THEME_DROPDOWN_TEXT,
   eCSSKeyword_menulisttextfield,      NS_THEME_DROPDOWN_TEXTFIELD,
   eCSSKeyword_scale_horizontal,       NS_THEME_SCALE_HORIZONTAL,
--- a/toolkit/content/widgets/scrollbar.xml
+++ b/toolkit/content/widgets/scrollbar.xml
@@ -1,20 +1,16 @@
 <?xml version="1.0"?>
 
 <bindings id="scrollbarBindings"
    xmlns="http://www.mozilla.org/xbl"
    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:xbl="http://www.mozilla.org/xbl">
   
-  <binding id="thumb" extends="xul:button">
-    <content>
-      <xul:gripper/>
-    </content>
-  </binding>
+  <binding id="thumb" extends="xul:button" />
 
   <binding id="scrollbar-base">
     <handlers>
       <handler event="contextmenu" preventdefault="true" action="event.stopPropagation();"/>
       <handler event="click" preventdefault="true" action="event.stopPropagation();"/>
       <handler event="dblclick" action="event.stopPropagation();"/>
       <handler event="command" action="event.stopPropagation();"/>
     </handlers>
--- a/toolkit/themes/winstripe/global/xulscrollbars.css
+++ b/toolkit/themes/winstripe/global/xulscrollbars.css
@@ -76,24 +76,16 @@ thumb {
   min-height: 8px;
 }
 
 thumb[orient="horizontal"] {
   -moz-appearance: scrollbarthumb-horizontal;
   min-width: 8px;
 }
 
-thumb > gripper {
-  -moz-appearance: scrollbargripper-vertical;
-}
-
-thumb[orient="horizontal"] > gripper {
-  -moz-appearance: scrollbargripper-horizontal;
-}
-
 /* ::::: scrollbar button ::::: */
 
 scrollbarbutton {
   background: -moz-Dialog no-repeat 0px 1px;
   min-width: 16px;
   min-height: 16px;
 }
 
@@ -192,24 +184,16 @@ scrollbar[orient="vertical"] > scrollbar
     min-height: 8px;
   }
 
   html|div thumb[orient="horizontal"] {
     -moz-appearance: scrollbarthumb-horizontal;
     min-width: 8px;
   }
 
-  html|div thumb > gripper {
-    -moz-appearance: scrollbargripper-vertical;
-  }
-
-  html|div thumb[orient="horizontal"] > gripper {
-    -moz-appearance: scrollbargripper-horizontal;
-  }
-
   /* ::::: scrollbar button ::::: */
 
   html|div scrollbarbutton {
     background: -moz-Dialog no-repeat 0px 1px;
     min-width: 16px;
     min-height: 16px;
   }
 
--- a/widget/src/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/src/gtk2/nsNativeThemeGTK.cpp
@@ -1260,18 +1260,16 @@ nsNativeThemeGTK::ThemeSupportsWidget(ns
   case NS_THEME_SCROLLBAR_BUTTON_UP:
   case NS_THEME_SCROLLBAR_BUTTON_DOWN:
   case NS_THEME_SCROLLBAR_BUTTON_LEFT:
   case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
   case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
   case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
   case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
   case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
-    // case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:  (n/a for gtk)
-    // case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:  (n/a for gtk)
   case NS_THEME_TEXTFIELD:
   case NS_THEME_TEXTFIELD_MULTILINE:
   case NS_THEME_TEXTFIELD_CARET:
   case NS_THEME_DROPDOWN_TEXTFIELD:
   case NS_THEME_SCALE_HORIZONTAL:
   case NS_THEME_SCALE_THUMB_HORIZONTAL:
   case NS_THEME_SCALE_VERTICAL:
   case NS_THEME_SCALE_THUMB_VERTICAL:
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -299,18 +299,16 @@ nsNativeThemeWin::GetTheme(PRUint8 aWidg
     case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
     case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
     case NS_THEME_SCROLLBAR_BUTTON_UP:
     case NS_THEME_SCROLLBAR_BUTTON_DOWN:
     case NS_THEME_SCROLLBAR_BUTTON_LEFT:
     case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
     case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
     case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
-    case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
-    case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
       return nsUXThemeData::GetTheme(eUXScrollbar);
     case NS_THEME_SCALE_HORIZONTAL:
     case NS_THEME_SCALE_VERTICAL:
     case NS_THEME_SCALE_THUMB_HORIZONTAL:
     case NS_THEME_SCALE_THUMB_VERTICAL:
       return nsUXThemeData::GetTheme(eUXTrackbar);
     case NS_THEME_SPINNER_UP_BUTTON:
     case NS_THEME_SPINNER_DOWN_BUTTON:
@@ -610,37 +608,16 @@ nsNativeThemeWin::GetThemePartAndState(n
           aState = TS_ACTIVE;
         else if (eventState & NS_EVENT_STATE_HOVER)
           aState = TS_HOVER;
         else 
           aState = TS_NORMAL;
       }
       return NS_OK;
     }
-    case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
-    case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL: {
-      aPart = (aWidgetType == NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL) ?
-              SP_GRIPPERHOR : SP_GRIPPERVERT;
-      if (!aFrame)
-        aState = TS_NORMAL;
-      else if (IsDisabled(aFrame->GetParent()))
-        aState = TS_DISABLED;
-      else {
-        PRInt32 eventState = GetContentState(aFrame->GetParent(), aWidgetType);
-        if (eventState & NS_EVENT_STATE_ACTIVE) // Hover is not also a requirement for
-                                                // the gripper, since the drag is not canceled
-                                                // when you move outside the gripper.
-          aState = TS_ACTIVE;
-        else if (eventState & NS_EVENT_STATE_HOVER)
-          aState = TS_HOVER;
-        else 
-          aState = TS_NORMAL;
-      }
-      return NS_OK;
-    }
     case NS_THEME_SCALE_HORIZONTAL:
     case NS_THEME_SCALE_VERTICAL: {
       aPart = (aWidgetType == NS_THEME_SCALE_HORIZONTAL) ?
               TKP_TRACK : TKP_TRACKVERT;
 
       aState = TS_NORMAL;
       return NS_OK;
     }
@@ -1171,16 +1148,34 @@ RENDER_AGAIN:
     // The lines are part of the Rebar theme, which is loaded for NS_THEME_TOOLBOX.
     theme = GetTheme(NS_THEME_TOOLBOX);
     if (!theme)
       return NS_ERROR_FAILURE;
 
     widgetRect.bottom = widgetRect.top + TB_SEPARATOR_HEIGHT;
     nsUXThemeData::drawThemeEdge(theme, hdc, RP_BAND, 0, &widgetRect, EDGE_ETCHED, BF_TOP, NULL);
   }
+  else if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL ||
+           aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL)
+  {
+    // Draw the decorative gripper for the scrollbar thumb button, if it fits
+
+    SIZE gripSize;
+    MARGINS thumbMgns;
+    int gripPart = (aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) ?
+                   SP_GRIPPERHOR : SP_GRIPPERVERT;
+
+    if (nsUXThemeData::getThemePartSize(theme, hdc, gripPart, state, NULL, TS_TRUE, &gripSize) == S_OK &&
+        nsUXThemeData::getThemeMargins(theme, hdc, part, state, TMT_CONTENTMARGINS, NULL, &thumbMgns) == S_OK &&
+        gripSize.cx + thumbMgns.cxLeftWidth + thumbMgns.cxRightWidth <= widgetRect.right - widgetRect.left &&
+        gripSize.cy + thumbMgns.cyTopHeight + thumbMgns.cyBottomHeight <= widgetRect.bottom - widgetRect.top)
+    {
+      nsUXThemeData::drawThemeBG(theme, hdc, gripPart, state, &widgetRect, &clipRect);
+    }
+  }
 
   nativeDrawing.EndNativeDrawing();
 
   if (nativeDrawing.ShouldRenderAgain())
     goto RENDER_AGAIN;
 
   nativeDrawing.PaintToContext();