tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit cf6f70caf9023f2ee0fa46ec23c405bc09368844
parent 14c77950c9e4aeb9cfe29bb65c19639e999e6e62
Author: Greg Stoll <gstoll@mozilla.com>
Date:   Mon, 17 Nov 2025 14:11:02 +0000

Bug 1993814 - draw an outline around scrollbars in high-contrast mode r=desktop-theme-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D270042

Diffstat:
Mwidget/ScrollbarDrawing.cpp | 44+++++++++++++++++++++++++++-----------------
Mwidget/ScrollbarDrawingWin11.cpp | 8++++++--
2 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/widget/ScrollbarDrawing.cpp b/widget/ScrollbarDrawing.cpp @@ -188,19 +188,25 @@ bool ScrollbarDrawing::DoPaintDefaultScrollbar( ElementState::ACTIVE)) { return true; } - const auto color = ComputeScrollbarTrackColor(aFrame, aStyle, aColors); - if (overlay && mKind == Kind::Win11 && - StaticPrefs::widget_non_native_theme_win11_scrollbar_round_track()) { - LayoutDeviceCoord radius = - (aScrollbarKind == ScrollbarKind::Horizontal ? aRect.height - : aRect.width) / - 2.0f; - ThemeDrawing::PaintRoundedRectWithRadius(aPaintData, aRect, color, - sRGBColor(), 0, radius / aDpiRatio, - aDpiRatio); - } else { - ThemeDrawing::FillRect(aPaintData, aRect, color); - } + const auto backgroundColor = + ComputeScrollbarTrackColor(aFrame, aStyle, aColors); + auto radius = [&]() -> CSSCoord { + if (overlay && mKind == Kind::Win11 && + StaticPrefs::widget_non_native_theme_win11_scrollbar_round_track()) { + LayoutDeviceCoord radius = + (aScrollbarKind == ScrollbarKind::Horizontal ? aRect.height + : aRect.width) / + 2.0f; + return radius / aDpiRatio; + } + return 0.0f; + }(); + auto borderColor = aColors.System(StyleSystemColor::Buttontext); + // Draw an outline around the scrollbar in high contrast mode + auto borderWidth = aColors.HighContrast() ? CSSCoord(1.0f) : CSSCoord(0.0f); + ThemeDrawing::PaintRoundedRectWithRadius(aPaintData, aRect, backgroundColor, + borderColor, borderWidth, radius, + aDpiRatio); return true; } @@ -350,12 +356,15 @@ bool ScrollbarDrawing::PaintScrollbarButton( DrawTarget& aDrawTarget, StyleAppearance aAppearance, const LayoutDeviceRect& aRect, ScrollbarKind aScrollbarKind, nsIFrame* aFrame, const ComputedStyle& aStyle, - const ElementState& aElementState, const Colors& aColors, const DPIRatio&) { + const ElementState& aElementState, const Colors& aColors, + const DPIRatio& aDpiRatio) { auto [buttonColor, arrowColor] = ComputeScrollbarButtonColors( aFrame, aAppearance, aStyle, aElementState, aColors); - aDrawTarget.FillRect(aRect.ToUnknownRect(), - ColorPattern(ToDeviceColor(buttonColor))); - + auto borderColor = aColors.System(StyleSystemColor::Buttontext); + // Draw an outline around the scrollbar in high contrast mode + auto borderWidth = aColors.HighContrast() ? CSSCoord(1.0f) : CSSCoord(0.0f); + ThemeDrawing::PaintRoundedRectWithRadius( + aDrawTarget, aRect, buttonColor, borderColor, borderWidth, 0, aDpiRatio); // Start with Up arrow. 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}; @@ -390,6 +399,7 @@ bool ScrollbarDrawing::PaintScrollbarButton( } ThemeDrawing::PaintArrow(aDrawTarget, aRect, arrowPolygonX, arrowPolygonY, kPolygonSize, arrowNumPoints, arrowColor); + return true; } diff --git a/widget/ScrollbarDrawingWin11.cpp b/widget/ScrollbarDrawingWin11.cpp @@ -144,8 +144,12 @@ bool ScrollbarDrawingWin11::PaintScrollbarButton( auto [buttonColor, arrowColor] = ComputeScrollbarButtonColors( aFrame, aAppearance, aStyle, aElementState, aColors); if (style != Style::Overlay) { - aDrawTarget.FillRect(aRect.ToUnknownRect(), - gfx::ColorPattern(ToDeviceColor(buttonColor))); + auto borderColor = aColors.System(StyleSystemColor::Buttontext); + // Draw an outline around the scrollbar in high contrast mode + auto borderWidth = aColors.HighContrast() ? CSSCoord(1.0f) : CSSCoord(0.0f); + ThemeDrawing::PaintRoundedRectWithRadius(aDrawTarget, aRect, buttonColor, + borderColor, borderWidth, 0, + aDpiRatio); } // Start with Up arrow.