summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-01-08 16:33:36 +0000
committerMoonchild <moonchild@palemoon.org>2021-01-09 23:19:35 +0000
commit382fe423e53a6db2cae7b75d75dca50d3613ac60 (patch)
treedfbdc08824e0929319fd814a30ae9c4b80e69228 /widget
parent764e13c912c8603983dbecd93164161f7cca92c4 (diff)
downloadUXP-382fe423e53a6db2cae7b75d75dca50d3613ac60.tar
UXP-382fe423e53a6db2cae7b75d75dca50d3613ac60.tar.gz
UXP-382fe423e53a6db2cae7b75d75dca50d3613ac60.tar.lz
UXP-382fe423e53a6db2cae7b75d75dca50d3613ac60.tar.xz
UXP-382fe423e53a6db2cae7b75d75dca50d3613ac60.zip
Issue #1705 - Part 7: Implement scrollbar-width:thin on Windows.
Diffstat (limited to 'widget')
-rw-r--r--widget/windows/nsNativeThemeWin.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp
index e84a2b80c..0947019ca 100644
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -1388,6 +1388,12 @@ GetThemeDpiScaleFactor(nsIFrame* aFrame)
return 1.0;
}
+static bool
+IsScrollbarWidthThin(nsIFrame* aFrame)
+{
+ return aFrame->StyleUserInterface()->mScrollbarWidth == StyleScrollbarWidth::Thin;
+}
+
NS_IMETHODIMP
nsNativeThemeWin::DrawWidgetBackground(nsRenderingContext* aContext,
nsIFrame* aFrame,
@@ -2788,14 +2794,21 @@ nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIFrame* aFrame,
break;
case NS_THEME_SCROLLBARBUTTON_UP:
case NS_THEME_SCROLLBARBUTTON_DOWN:
- (*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
- (*aResult).height = ::GetSystemMetrics(SM_CYVSCROLL);
+ // Get scrollbar button metrics from the system, except in the case of
+ // thin scrollbars, where we leave them at 0 (collapsing them to invisible)
+ if (!IsScrollbarWidthThin(aFrame)) {
+ (*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
+ (*aResult).height = ::GetSystemMetrics(SM_CYVSCROLL);
+ }
*aIsOverridable = false;
break;
case NS_THEME_SCROLLBARBUTTON_LEFT:
case NS_THEME_SCROLLBARBUTTON_RIGHT:
- (*aResult).width = ::GetSystemMetrics(SM_CXHSCROLL);
- (*aResult).height = ::GetSystemMetrics(SM_CYHSCROLL);
+ // See comment above.
+ if (!IsScrollbarWidthThin(aFrame)) {
+ (*aResult).width = ::GetSystemMetrics(SM_CXHSCROLL);
+ (*aResult).height = ::GetSystemMetrics(SM_CYHSCROLL);
+ }
*aIsOverridable = false;
break;
case NS_THEME_SCROLLBAR_VERTICAL:
@@ -2871,8 +2884,14 @@ nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIFrame* aFrame,
(*aResult).height = ::GetSystemMetrics(SM_CYVTHUMB);
// Without theming, divide the thumb size by two in order to look more
// native
- if (!GetTheme(aWidgetType))
- (*aResult).height >>= 1;
+ if (!GetTheme(aWidgetType)) {
+ (*aResult).height /= 2;
+ }
+ // If scrollbar-width is thin, divide the thickness by three to make
+ // it more compact.
+ if (IsScrollbarWidthThin(aFrame)) {
+ (*aResult).width /= 3;
+ }
*aIsOverridable = false;
break;
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
@@ -2880,8 +2899,14 @@ nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIFrame* aFrame,
(*aResult).height = ::GetSystemMetrics(SM_CYHSCROLL);
// Without theming, divide the thumb size by two in order to look more
// native
- if (!GetTheme(aWidgetType))
- (*aResult).width >>= 1;
+ if (!GetTheme(aWidgetType)) {
+ (*aResult).width /= 2;
+ }
+ // If scrollbar-width is thin, divide the thickness by three to make
+ // it more compact.
+ if (IsScrollbarWidthThin(aFrame)) {
+ (*aResult).height /= 3;
+ }
*aIsOverridable = false;
break;
case NS_THEME_SCROLLBAR_HORIZONTAL: