From 3a9dbcaaba6c6c34d6b136fa8526530c17c66617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 13 May 2022 15:59:24 +0000 Subject: [PATCH] Bug 1769269 - Center non-overlay scrollbar thumb on cocoa. r=mstange As per discussion in bug 1764435. Differential Revision: https://phabricator.services.mozilla.com/D146315 --- widget/ScrollbarDrawingCocoa.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/widget/ScrollbarDrawingCocoa.cpp b/widget/ScrollbarDrawingCocoa.cpp index 3454044bef84..c79911591969 100644 --- a/widget/ScrollbarDrawingCocoa.cpp +++ b/widget/ScrollbarDrawingCocoa.cpp @@ -162,11 +162,17 @@ static ThumbRect GetThumbRect(const LayoutDeviceRect& aRect, } thickness *= aScale; - // Compute the thumb rect. - const float outerSpacing = - ((aParams.isOverlay || aParams.isSmall) ? 1.0f : 2.0f) * aScale; LayoutDeviceRect thumbRect = aRect; thumbRect.Deflate(1.0f * aScale); + // Compute the thumb rect. The thumb rect is centered in non-overlay mode, + // and spaced in overlay mode. + const float outerSpacing = [&] { + if (aParams.isOverlay) { + return 1.0f * aScale; + } + float size = aParams.isHorizontal ? thumbRect.Height() : thumbRect.Width(); + return (size - thickness) / 2.0f; + }(); if (aParams.isHorizontal) { float bottomEdge = thumbRect.YMost() - outerSpacing; thumbRect.SetBoxY(bottomEdge - thickness, bottomEdge);