From 2ef90f06902bf723c6c1ab92d85c7f44e959c4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 18 Mar 2021 19:12:49 +0000 Subject: [PATCH] Bug 1698783 - Make non-native scrollbar size configurable in Windows too. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D108960 --- modules/libpref/init/StaticPrefList.yaml | 8 ++++++-- widget/gtk/nsNativeBasicThemeGTK.cpp | 12 ------------ widget/gtk/nsNativeBasicThemeGTK.h | 2 -- widget/nsNativeBasicTheme.cpp | 9 +++++---- widget/nsNativeBasicTheme.h | 2 -- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 80b418a4b385..0e50361a290c 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -10715,13 +10715,17 @@ mirror: always # The size in CSS pixels at full zoom of the minimum scrollbar width. -- name: widget.non-native-theme.gtk.scrollbar.normal-size +- name: widget.non-native-theme.scrollbar.normal-size type: uint32_t +#if defined(MOZ_WIDGET_GTK) value: 12 +#else + value: 17 +#endif mirror: always # The size in CSS pixels at full zoom of the "thin" scrollbars. -- name: widget.non-native-theme.gtk.scrollbar.thin-size +- name: widget.non-native-theme.scrollbar.thin-size type: uint32_t value: 6 mirror: always diff --git a/widget/gtk/nsNativeBasicThemeGTK.cpp b/widget/gtk/nsNativeBasicThemeGTK.cpp index 5ef6e69ff0ee..d851c16f149c 100644 --- a/widget/gtk/nsNativeBasicThemeGTK.cpp +++ b/widget/gtk/nsNativeBasicThemeGTK.cpp @@ -41,18 +41,6 @@ bool nsNativeBasicThemeGTK::ThemeSupportsScrollbarButtons() { return StaticPrefs::widget_non_native_theme_gtk_scrollbar_allow_buttons(); } -auto nsNativeBasicThemeGTK::GetScrollbarSizes(nsPresContext* aPresContext, - StyleScrollbarWidth aWidth, - Overlay) -> ScrollbarSizes { - DPIRatio dpiRatio = GetDPIRatioForScrollbarPart(aPresContext); - CSSCoord size = - aWidth == StyleScrollbarWidth::Thin - ? StaticPrefs::widget_non_native_theme_gtk_scrollbar_thin_size() - : StaticPrefs::widget_non_native_theme_gtk_scrollbar_normal_size(); - LayoutDeviceIntCoord s = (size * dpiRatio).Truncated(); - return {s, s}; -} - NS_IMETHODIMP nsNativeBasicThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, diff --git a/widget/gtk/nsNativeBasicThemeGTK.h b/widget/gtk/nsNativeBasicThemeGTK.h index c5807b4fea22..c102ac311307 100644 --- a/widget/gtk/nsNativeBasicThemeGTK.h +++ b/widget/gtk/nsNativeBasicThemeGTK.h @@ -40,8 +40,6 @@ class nsNativeBasicThemeGTK : public nsNativeBasicTheme { DPIRatio); bool ThemeSupportsScrollbarButtons() override; - ScrollbarSizes GetScrollbarSizes(nsPresContext*, StyleScrollbarWidth, - Overlay) override; protected: virtual ~nsNativeBasicThemeGTK() = default; diff --git a/widget/nsNativeBasicTheme.cpp b/widget/nsNativeBasicTheme.cpp index 374103666a39..791b8d6cf72c 100644 --- a/widget/nsNativeBasicTheme.cpp +++ b/widget/nsNativeBasicTheme.cpp @@ -1518,7 +1518,7 @@ void nsNativeBasicTheme::PaintScrollbarButton( float arrowPolygonX[] = {-4.0f, 0.0f, 4.0f, 4.0f, 0.0f, -4.0f}; float arrowPolygonY[] = {0.0f, -4.0f, 0.0f, 3.0f, -1.0f, 3.0f}; - const float kPolygonSize = kMinimumScrollbarSize; + const float kPolygonSize = 17; const int32_t arrowNumPoints = ArrayLength(arrowPolygonX); switch (aAppearance) { @@ -1934,9 +1934,10 @@ bool nsNativeBasicTheme::GetWidgetOverflow(nsDeviceContext* aContext, auto nsNativeBasicTheme::GetScrollbarSizes(nsPresContext* aPresContext, StyleScrollbarWidth aWidth, Overlay) -> ScrollbarSizes { - CSSCoord size = aWidth == StyleScrollbarWidth::Thin - ? kMinimumThinScrollbarSize - : kMinimumScrollbarSize; + CSSCoord size = + aWidth == StyleScrollbarWidth::Thin + ? StaticPrefs::widget_non_native_theme_scrollbar_thin_size() + : StaticPrefs::widget_non_native_theme_scrollbar_normal_size(); LayoutDeviceIntCoord s = (size * GetDPIRatioForScrollbarPart(aPresContext)).Rounded(); return {s, s}; diff --git a/widget/nsNativeBasicTheme.h b/widget/nsNativeBasicTheme.h index f3ad33e55f70..b779dcd3cb7e 100644 --- a/widget/nsNativeBasicTheme.h +++ b/widget/nsNativeBasicTheme.h @@ -66,8 +66,6 @@ static const gfx::sRGBColor sScrollbarBorderColor(gfx::sRGBColor(1.0f, 1.0f, static const gfx::sRGBColor sScrollbarThumbColor( gfx::sRGBColor::UnusualFromARGB(0xffcdcdcd)); -static const CSSCoord kMinimumScrollbarSize = 17.0f; -static const CSSCoord kMinimumThinScrollbarSize = 6.0f; static const CSSCoord kMinimumColorPickerHeight = 32.0f; static const CSSCoord kMinimumRangeThumbSize = 20.0f; static const CSSCoord kMinimumDropdownArrowButtonWidth = 18.0f;