Bug 1464723 - Implement custom scrollbar support for GTK widget. r=karlt,dholbert
authorXidorn Quan <me@upsuper.org>
Fri, 24 Aug 2018 07:40:07 +0000
changeset 491122 fcae76a34c32ad73442d7440a203230c053a7649
parent 491121 e846d4b1012d958c701b535d89911f3ac019d78b
child 491123 f3fa1af05d494c8b363bad855e754d2c472d15af
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, dholbert
bugs1464723
milestone63.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 1464723 - Implement custom scrollbar support for GTK widget. r=karlt,dholbert When any scrollbar color is specified, or scrollbar-width is thin, we switch to use the fallback rendering. The change to xulscrollbars.css is for ensuring that the scrollbar is displayed for scrollbar-width: thin when there is no scrollbar color specified. It wouldn't affect cases where -moz-appearance takes effect. This also changes the fallback width of the scrollbars. Since the two widths was picked rather randomly, I think it should be fine to change it if a value looks better than the old one, especially on Linux which is the main usecase for this fallback rendering. Differential Revision: https://phabricator.services.mozilla.com/D3952
layout/xul/nsBox.cpp
toolkit/themes/windows/global/xulscrollbars.css
widget/gtk/nsNativeThemeGTK.cpp
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -527,19 +527,19 @@ nsIFrame::AddXULPrefSize(nsIFrame* aBox,
 // scrollbar.
 static nscoord
 GetScrollbarWidthNoTheme(nsIFrame* aBox)
 {
     ComputedStyle* scrollbarStyle = nsLayoutUtils::StyleForScrollbar(aBox);
     switch (scrollbarStyle->StyleUIReset()->mScrollbarWidth) {
       default:
       case StyleScrollbarWidth::Auto:
-        return 16 * AppUnitsPerCSSPixel();
+        return 12 * AppUnitsPerCSSPixel();
       case StyleScrollbarWidth::Thin:
-        return 8 * AppUnitsPerCSSPixel();
+        return 6 * AppUnitsPerCSSPixel();
       case StyleScrollbarWidth::None:
         return 0;
     }
 }
 
 bool
 nsIFrame::AddXULMinSize(nsBoxLayoutState& aState, nsIFrame* aBox, nsSize& aSize,
                       bool &aWidthSet, bool &aHeightSet)
--- a/toolkit/themes/windows/global/xulscrollbars.css
+++ b/toolkit/themes/windows/global/xulscrollbars.css
@@ -9,16 +9,17 @@
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
 @namespace html url("http://www.w3.org/1999/xhtml"); /* namespace for HTML elements */
 
 /* ::::: scrollbar ::::: */
 
 scrollbar {
   -moz-appearance: scrollbar-horizontal;
   cursor: default;
+  background-color: #f0f0f0;
 }
 
 @media all and (-moz-overlay-scrollbars) {
   scrollbar[root="true"] {
     position: relative;
     z-index: 2147483647; /* largest positive value of a signed 32-bit integer */
   }
 
@@ -38,16 +39,20 @@ slider {
 }
 
 slider[orient="vertical"] {
   -moz-appearance: scrollbartrack-vertical;
 }
 
 /* ::::: thumb (horizontal) ::::: */
 
+thumb {
+  background-color: #cdcdcd;
+}
+
 thumb[orient="vertical"] {
   -moz-appearance: scrollbarthumb-vertical;
   min-height: 8px;
 }
 
 thumb[orient="horizontal"] {
   -moz-appearance: scrollbarthumb-horizontal;
   min-width: 8px;
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1861,16 +1861,25 @@ nsNativeThemeGTK::ThemeChanged()
 NS_IMETHODIMP_(bool)
 nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
                                       nsIFrame* aFrame,
                                       StyleAppearance aWidgetType)
 {
   if (IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType))
     return false;
 
+  if (IsWidgetScrollbarPart(aWidgetType)) {
+    ComputedStyle* cs = nsLayoutUtils::StyleForScrollbar(aFrame);
+    if (cs->StyleUI()->HasCustomScrollbars() ||
+        // We cannot handle thin scrollbar on GTK+ widget directly as well.
+        cs->StyleUIReset()->mScrollbarWidth == StyleScrollbarWidth::Thin) {
+      return false;
+    }
+  }
+
   if (aWidgetType == StyleAppearance::MenulistButton &&
       StaticPrefs::layout_css_webkit_appearance_enabled()) {
     aWidgetType = StyleAppearance::Menulist;
   }
 
   switch (aWidgetType) {
   // Combobox dropdowns don't support native theming in vertical mode.
   case StyleAppearance::Menulist: