diff options
author | Moonchild <moonchild@palemoon.org> | 2021-01-09 23:20:31 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-01-09 23:20:31 +0000 |
commit | ecc771848fe6e1f400b5c3622cf87a4e476950c6 (patch) | |
tree | a07aaf36cd761feba50c8702a8e40ebbd527817d /widget/gtk | |
parent | 382fe423e53a6db2cae7b75d75dca50d3613ac60 (diff) | |
download | UXP-ecc771848fe6e1f400b5c3622cf87a4e476950c6.tar UXP-ecc771848fe6e1f400b5c3622cf87a4e476950c6.tar.gz UXP-ecc771848fe6e1f400b5c3622cf87a4e476950c6.tar.lz UXP-ecc771848fe6e1f400b5c3622cf87a4e476950c6.tar.xz UXP-ecc771848fe6e1f400b5c3622cf87a4e476950c6.zip |
Issue #1705 - Part 8: Implement scrollbar-width:thin on GTK.
Diffstat (limited to 'widget/gtk')
-rw-r--r-- | widget/gtk/nsNativeThemeGTK.cpp | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 89b8ab7dc..cb4e7debf 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -1098,6 +1098,12 @@ nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType, return true; } +static bool +IsScrollbarWidthThin(nsIFrame* aFrame) +{ + return aFrame->StyleUserInterface()->mScrollbarWidth == StyleScrollbarWidth::Thin; +} + NS_IMETHODIMP nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext, nsIFrame* aFrame, @@ -1419,32 +1425,39 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, case NS_THEME_SCROLLBARBUTTON_UP: case NS_THEME_SCROLLBARBUTTON_DOWN: { - if (gtk_check_version(3,20,0) == nullptr) { - moz_gtk_get_widget_min_size(MOZ_GTK_SCROLLBAR_BUTTON, - &(aResult->width), &(aResult->height)); - } else { - MozGtkScrollbarMetrics metrics; - moz_gtk_get_scrollbar_metrics(&metrics); + if (!IsScrollbarWidthThin(aFrame)) { + // Get scrollbar button metrics from the system, except in the case of + // thin scrollbars, where we leave them at 0 (collapse) + if (gtk_check_version(3,20,0) == nullptr) { + moz_gtk_get_widget_min_size(MOZ_GTK_SCROLLBAR_BUTTON, + &(aResult->width), &(aResult->height)); + } else { + MozGtkScrollbarMetrics metrics; + moz_gtk_get_scrollbar_metrics(&metrics); - aResult->width = metrics.slider_width; - aResult->height = metrics.stepper_size; + aResult->width = metrics.slider_width; + aResult->height = metrics.stepper_size; + } } - *aIsOverridable = false; } break; case NS_THEME_SCROLLBARBUTTON_LEFT: case NS_THEME_SCROLLBARBUTTON_RIGHT: { - if (gtk_check_version(3,20,0) == nullptr) { - moz_gtk_get_widget_min_size(MOZ_GTK_SCROLLBAR_BUTTON, - &(aResult->width), &(aResult->height)); - } else { - MozGtkScrollbarMetrics metrics; - moz_gtk_get_scrollbar_metrics(&metrics); + if (!IsScrollbarWidthThin(aFrame)) { + // Get scrollbar button metrics from the system, except in the case of + // thin scrollbars, where we leave them at 0 (collapse) + if (gtk_check_version(3,20,0) == nullptr) { + moz_gtk_get_widget_min_size(MOZ_GTK_SCROLLBAR_BUTTON, + &(aResult->width), &(aResult->height)); + } else { + MozGtkScrollbarMetrics metrics; + moz_gtk_get_scrollbar_metrics(&metrics); - aResult->width = metrics.stepper_size; - aResult->height = metrics.slider_width; + aResult->width = metrics.stepper_size; + aResult->height = metrics.slider_width; + } } *aIsOverridable = false; } @@ -1514,6 +1527,24 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, } break; case NS_THEME_SCROLLBARTHUMB_VERTICAL: + { + if (gtk_check_version(3,20,0) == nullptr) { + moz_gtk_get_widget_min_size(NativeThemeToGtkTheme(aWidgetType, aFrame), + &(aResult->width), &(aResult->height)); + } else { + MozGtkScrollbarMetrics metrics; + moz_gtk_get_scrollbar_metrics(&metrics); + + aResult->width = metrics.slider_width; + aResult->height = metrics.min_slider_size; + } + if (IsScrollbarWidthThin(aFrame)) { + // If thin scrollbars, divide the thickness by 3 + aResult->width /= 3; + } + *aIsOverridable = false; + } + break; case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: { if (gtk_check_version(3,20,0) == nullptr) { @@ -1523,13 +1554,12 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, MozGtkScrollbarMetrics metrics; moz_gtk_get_scrollbar_metrics(&metrics); - if (aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL) { - aResult->width = metrics.slider_width; - aResult->height = metrics.min_slider_size; - } else { - aResult->height = metrics.slider_width; - aResult->width = metrics.min_slider_size; - } + aResult->height = metrics.slider_width; + aResult->width = metrics.min_slider_size; + } + if (IsScrollbarWidthThin(aFrame)) { + // If thin scrollbars, divide the thickness by 3 + aResult->height /= 3; } *aIsOverridable = false; } |