2021-12-16 00:06:58 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "ScrollbarDrawingWin11.h"
|
|
|
|
|
|
|
|
#include "mozilla/gfx/Helpers.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "mozilla/StaticPrefs_widget.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2022-01-12 19:33:31 +03:00
|
|
|
#include "Theme.h"
|
2021-12-16 00:06:58 +03:00
|
|
|
#include "nsNativeTheme.h"
|
|
|
|
|
2021-12-27 21:53:32 +03:00
|
|
|
using mozilla::gfx::sRGBColor;
|
|
|
|
|
2021-12-16 00:06:58 +03:00
|
|
|
namespace mozilla::widget {
|
|
|
|
|
2022-03-04 16:44:51 +03:00
|
|
|
// There are effectively three kinds of scrollbars in Windows 11:
|
|
|
|
//
|
|
|
|
// * Overlay scrollbars (the ones where the scrollbar disappears automatically
|
|
|
|
// and doesn't take space)
|
|
|
|
// * Non-overlay scrollbar with thin (overlay-like) thumb.
|
|
|
|
// * Non-overlay scrollbar with thick thumb.
|
|
|
|
//
|
|
|
|
// See bug 1755193 for some discussion on non-overlay scrollbar styles.
|
|
|
|
enum class Style {
|
|
|
|
Overlay,
|
|
|
|
ThinThumb,
|
|
|
|
ThickThumb,
|
|
|
|
};
|
|
|
|
|
|
|
|
static Style ScrollbarStyle(nsPresContext* aPresContext) {
|
|
|
|
if (aPresContext->UseOverlayScrollbars()) {
|
|
|
|
return Style::Overlay;
|
|
|
|
}
|
|
|
|
if (StaticPrefs::
|
|
|
|
widget_non_native_theme_win11_scrollbar_force_overlay_style()) {
|
|
|
|
return Style::ThinThumb;
|
|
|
|
}
|
|
|
|
return Style::ThickThumb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr CSSIntCoord kDefaultWinOverlayScrollbarSize = CSSIntCoord(12);
|
|
|
|
static constexpr CSSIntCoord kDefaultWinOverlayThinScrollbarSize =
|
|
|
|
CSSIntCoord(10);
|
|
|
|
|
2021-12-16 00:06:58 +03:00
|
|
|
LayoutDeviceIntSize ScrollbarDrawingWin11::GetMinimumWidgetSize(
|
|
|
|
nsPresContext* aPresContext, StyleAppearance aAppearance,
|
|
|
|
nsIFrame* aFrame) {
|
|
|
|
MOZ_ASSERT(nsNativeTheme::IsWidgetScrollbarPart(aAppearance));
|
2022-03-04 16:44:51 +03:00
|
|
|
if (ScrollbarStyle(aPresContext) != Style::ThinThumb) {
|
2021-12-27 21:53:31 +03:00
|
|
|
return ScrollbarDrawingWin::GetMinimumWidgetSize(aPresContext, aAppearance,
|
|
|
|
aFrame);
|
|
|
|
}
|
2021-12-27 21:53:32 +03:00
|
|
|
constexpr float kArrowRatio = 14.0f / kDefaultWinScrollbarSize;
|
2021-12-16 00:06:58 +03:00
|
|
|
switch (aAppearance) {
|
|
|
|
case StyleAppearance::ScrollbarbuttonUp:
|
2023-01-29 00:35:51 +03:00
|
|
|
case StyleAppearance::ScrollbarbuttonDown:
|
2021-12-16 00:06:58 +03:00
|
|
|
case StyleAppearance::ScrollbarbuttonLeft:
|
2021-12-27 21:53:32 +03:00
|
|
|
case StyleAppearance::ScrollbarbuttonRight: {
|
2021-12-27 21:53:33 +03:00
|
|
|
if (IsScrollbarWidthThin(aFrame)) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
const LayoutDeviceIntCoord size =
|
2023-01-29 00:35:51 +03:00
|
|
|
ScrollbarDrawing::GetScrollbarSize(aPresContext, aFrame);
|
2021-12-27 21:53:32 +03:00
|
|
|
return LayoutDeviceIntSize{
|
2023-01-29 00:35:51 +03:00
|
|
|
size, (kArrowRatio * LayoutDeviceCoord(size)).Rounded()};
|
2021-12-27 21:53:32 +03:00
|
|
|
}
|
2021-12-16 00:06:58 +03:00
|
|
|
default:
|
|
|
|
return ScrollbarDrawingWin::GetMinimumWidgetSize(aPresContext,
|
|
|
|
aAppearance, aFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sRGBColor ScrollbarDrawingWin11::ComputeScrollbarTrackColor(
|
|
|
|
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const DocumentState& aDocumentState, const Colors& aColors) {
|
2021-12-16 00:06:58 +03:00
|
|
|
if (aColors.HighContrast()) {
|
|
|
|
return ScrollbarDrawingWin::ComputeScrollbarTrackColor(
|
|
|
|
aFrame, aStyle, aDocumentState, aColors);
|
|
|
|
}
|
|
|
|
const nsStyleUI* ui = aStyle.StyleUI();
|
|
|
|
if (ui->mScrollbarColor.IsColors()) {
|
|
|
|
return sRGBColor::FromABGR(
|
|
|
|
ui->mScrollbarColor.AsColors().track.CalcColor(aStyle));
|
|
|
|
}
|
2022-02-09 14:27:16 +03:00
|
|
|
return aColors.IsDark() ? sRGBColor::FromU8(23, 23, 23, 255)
|
|
|
|
: sRGBColor::FromU8(240, 240, 240, 255);
|
2021-12-16 00:06:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sRGBColor ScrollbarDrawingWin11::ComputeScrollbarThumbColor(
|
|
|
|
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const ElementState& aElementState, const DocumentState& aDocumentState,
|
2021-12-16 00:06:58 +03:00
|
|
|
const Colors& aColors) {
|
|
|
|
if (aColors.HighContrast()) {
|
|
|
|
return ScrollbarDrawingWin::ComputeScrollbarThumbColor(
|
|
|
|
aFrame, aStyle, aElementState, aDocumentState, aColors);
|
|
|
|
}
|
2021-12-27 21:53:33 +03:00
|
|
|
const nscolor baseColor = [&] {
|
|
|
|
const nsStyleUI* ui = aStyle.StyleUI();
|
|
|
|
if (ui->mScrollbarColor.IsColors()) {
|
|
|
|
return ui->mScrollbarColor.AsColors().thumb.CalcColor(aStyle);
|
|
|
|
}
|
2022-02-09 14:27:16 +03:00
|
|
|
return aColors.IsDark() ? NS_RGBA(149, 149, 149, 255)
|
|
|
|
: NS_RGBA(133, 133, 133, 255);
|
2021-12-27 21:53:33 +03:00
|
|
|
}();
|
2022-06-08 02:09:52 +03:00
|
|
|
ElementState state = aElementState;
|
2021-12-27 21:53:33 +03:00
|
|
|
if (!IsScrollbarWidthThin(aStyle)) {
|
|
|
|
// non-thin scrollbars get hover feedback by changing thumb shape, so we
|
|
|
|
// only provide active feedback (and we use the hover state for that as it's
|
|
|
|
// more subtle).
|
2022-06-08 02:09:52 +03:00
|
|
|
state &= ~ElementState::HOVER;
|
|
|
|
if (state.HasState(ElementState::ACTIVE)) {
|
|
|
|
state &= ~ElementState::ACTIVE;
|
|
|
|
state |= ElementState::HOVER;
|
2021-12-27 21:53:33 +03:00
|
|
|
}
|
2021-12-16 00:06:58 +03:00
|
|
|
}
|
2021-12-27 21:53:33 +03:00
|
|
|
return sRGBColor::FromABGR(
|
|
|
|
ThemeColors::AdjustUnthemedScrollbarThumbColor(baseColor, state));
|
2021-12-16 00:06:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<sRGBColor, sRGBColor>
|
|
|
|
ScrollbarDrawingWin11::ComputeScrollbarButtonColors(
|
|
|
|
nsIFrame* aFrame, StyleAppearance aAppearance, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const ElementState& aElementState, const DocumentState& aDocumentState,
|
2021-12-16 00:06:58 +03:00
|
|
|
const Colors& aColors) {
|
|
|
|
if (aColors.HighContrast()) {
|
|
|
|
return ScrollbarDrawingWin::ComputeScrollbarButtonColors(
|
|
|
|
aFrame, aAppearance, aStyle, aElementState, aDocumentState, aColors);
|
|
|
|
}
|
2022-03-04 16:44:51 +03:00
|
|
|
// The button always looks transparent (the track behind it is visible), so we
|
|
|
|
// can hardcode it.
|
2021-12-16 00:06:58 +03:00
|
|
|
sRGBColor arrowColor = ComputeScrollbarThumbColor(
|
|
|
|
aFrame, aStyle, aElementState, aDocumentState, aColors);
|
2022-03-04 16:44:51 +03:00
|
|
|
return {sRGBColor::White(0.0f), arrowColor};
|
2021-12-16 00:06:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollbarDrawingWin11::PaintScrollbarButton(
|
|
|
|
DrawTarget& aDrawTarget, StyleAppearance aAppearance,
|
2022-05-09 20:09:24 +03:00
|
|
|
const LayoutDeviceRect& aRect, ScrollbarKind aScrollbarKind,
|
|
|
|
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const ElementState& aElementState, const DocumentState& aDocumentState,
|
2022-05-09 20:09:24 +03:00
|
|
|
const Colors& aColors, const DPIRatio& aDpiRatio) {
|
2021-12-16 00:06:58 +03:00
|
|
|
if (!ScrollbarDrawing::IsParentScrollbarHoveredOrActive(aFrame)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-04 16:44:51 +03:00
|
|
|
const auto style = ScrollbarStyle(aFrame->PresContext());
|
2021-12-16 00:06:58 +03:00
|
|
|
auto [buttonColor, arrowColor] = ComputeScrollbarButtonColors(
|
|
|
|
aFrame, aAppearance, aStyle, aElementState, aDocumentState, aColors);
|
2022-03-04 16:44:51 +03:00
|
|
|
if (style != Style::Overlay) {
|
|
|
|
aDrawTarget.FillRect(aRect.ToUnknownRect(),
|
|
|
|
gfx::ColorPattern(ToDeviceColor(buttonColor)));
|
|
|
|
}
|
2021-12-16 00:06:58 +03:00
|
|
|
|
|
|
|
// Start with Up arrow.
|
2021-12-27 21:53:31 +03:00
|
|
|
float arrowPolygonX[] = {-4.5f, 4.5f, 4.5f, 0.5f, -0.5f, -4.5f, -4.5f};
|
|
|
|
float arrowPolygonXActive[] = {-4.0f, 4.0f, 4.0f, -0.25f,
|
|
|
|
-0.25f, -4.0f, -4.0f};
|
|
|
|
float arrowPolygonXHover[] = {-5.0f, 5.0f, 5.0f, 0.75f, -0.75f, -5.0f, -5.0f};
|
2021-12-16 00:06:58 +03:00
|
|
|
float arrowPolygonY[] = {2.5f, 2.5f, 1.0f, -4.0f, -4.0f, 1.0f, 2.5f};
|
|
|
|
float arrowPolygonYActive[] = {2.0f, 2.0f, 0.5f, -3.5f, -3.5f, 0.5f, 2.0f};
|
|
|
|
float arrowPolygonYHover[] = {3.0f, 3.0f, 1.5f, -4.5f, -4.5f, 1.5f, 3.0f};
|
|
|
|
float* arrowX = arrowPolygonX;
|
|
|
|
float* arrowY = arrowPolygonY;
|
2022-05-09 20:09:24 +03:00
|
|
|
const bool horizontal = aScrollbarKind == ScrollbarKind::Horizontal;
|
2021-12-27 21:53:31 +03:00
|
|
|
|
2022-03-04 16:44:51 +03:00
|
|
|
const float verticalOffset = [&] {
|
|
|
|
if (style != Style::Overlay) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
// To compensate for the scrollbar track radius we shift stuff vertically a
|
|
|
|
// bit. This 1px is arbitrary, but enough for the triangle not to overflow.
|
|
|
|
return 1.0f;
|
|
|
|
}();
|
|
|
|
const float horizontalOffset = [&] {
|
|
|
|
if (style != Style::ThinThumb) {
|
2021-12-27 21:53:31 +03:00
|
|
|
return 0.0f; // Always center it in the rect.
|
|
|
|
}
|
2021-12-27 21:53:31 +03:00
|
|
|
// Compensate for the displacement we do of the thumb position by displacing
|
|
|
|
// the arrow as well, see comment in DoPaintScrollbarThumb.
|
|
|
|
if (horizontal) {
|
|
|
|
return -0.5f;
|
|
|
|
}
|
2022-05-09 20:09:24 +03:00
|
|
|
return aScrollbarKind == ScrollbarKind::VerticalRight ? 0.5f : -0.5f;
|
2021-12-27 21:53:31 +03:00
|
|
|
}();
|
2022-03-04 16:44:51 +03:00
|
|
|
const float polygonSize = style == Style::Overlay
|
|
|
|
? float(kDefaultWinOverlayScrollbarSize)
|
|
|
|
: float(kDefaultWinScrollbarSize);
|
2021-12-16 00:06:58 +03:00
|
|
|
const int32_t arrowNumPoints = ArrayLength(arrowPolygonX);
|
|
|
|
|
2022-06-08 02:09:52 +03:00
|
|
|
if (aElementState.HasState(ElementState::ACTIVE)) {
|
2021-12-16 00:06:58 +03:00
|
|
|
arrowX = arrowPolygonXActive;
|
|
|
|
arrowY = arrowPolygonYActive;
|
2022-06-08 02:09:52 +03:00
|
|
|
} else if (aElementState.HasState(ElementState::HOVER)) {
|
2021-12-16 00:06:58 +03:00
|
|
|
arrowX = arrowPolygonXHover;
|
|
|
|
arrowY = arrowPolygonYHover;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aAppearance) {
|
|
|
|
case StyleAppearance::ScrollbarbuttonDown:
|
2021-12-27 21:53:31 +03:00
|
|
|
case StyleAppearance::ScrollbarbuttonRight:
|
2021-12-16 00:06:58 +03:00
|
|
|
for (int32_t i = 0; i < arrowNumPoints; i++) {
|
2022-03-04 16:44:51 +03:00
|
|
|
arrowY[i] += verticalOffset;
|
2021-12-16 00:06:58 +03:00
|
|
|
arrowY[i] *= -1;
|
|
|
|
}
|
|
|
|
[[fallthrough]];
|
|
|
|
case StyleAppearance::ScrollbarbuttonUp:
|
|
|
|
case StyleAppearance::ScrollbarbuttonLeft:
|
2022-03-04 16:44:51 +03:00
|
|
|
if (horizontalOffset != 0.0f) {
|
2021-12-27 21:53:31 +03:00
|
|
|
for (int32_t i = 0; i < arrowNumPoints; i++) {
|
2022-03-04 16:44:51 +03:00
|
|
|
arrowX[i] += horizontalOffset;
|
2021-12-27 21:53:31 +03:00
|
|
|
}
|
|
|
|
}
|
2021-12-16 00:06:58 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-27 21:53:31 +03:00
|
|
|
if (horizontal) {
|
|
|
|
std::swap(arrowX, arrowY);
|
|
|
|
}
|
|
|
|
|
2021-12-27 21:53:31 +03:00
|
|
|
LayoutDeviceRect arrowRect(aRect);
|
2022-03-04 16:44:51 +03:00
|
|
|
if (style != Style::ThinThumb) {
|
|
|
|
auto margin = CSSCoord(style == Style::Overlay ? 1 : 2) * aDpiRatio;
|
2021-12-27 21:53:31 +03:00
|
|
|
arrowRect.Deflate(margin, margin);
|
|
|
|
}
|
|
|
|
|
2022-03-04 16:44:51 +03:00
|
|
|
ThemeDrawing::PaintArrow(aDrawTarget, arrowRect, arrowX, arrowY, polygonSize,
|
2021-12-16 00:06:58 +03:00
|
|
|
arrowNumPoints, arrowColor);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename PaintBackendData>
|
|
|
|
bool ScrollbarDrawingWin11::DoPaintScrollbarThumb(
|
|
|
|
PaintBackendData& aPaintData, const LayoutDeviceRect& aRect,
|
2022-05-09 20:09:24 +03:00
|
|
|
ScrollbarKind aScrollbarKind, nsIFrame* aFrame, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const ElementState& aElementState, const DocumentState& aDocumentState,
|
2021-12-16 00:06:58 +03:00
|
|
|
const Colors& aColors, const DPIRatio& aDpiRatio) {
|
|
|
|
sRGBColor thumbColor = ComputeScrollbarThumbColor(
|
|
|
|
aFrame, aStyle, aElementState, aDocumentState, aColors);
|
|
|
|
|
|
|
|
LayoutDeviceRect thumbRect(aRect);
|
|
|
|
|
2022-03-04 16:44:51 +03:00
|
|
|
const auto style = ScrollbarStyle(aFrame->PresContext());
|
2021-12-27 21:53:31 +03:00
|
|
|
const bool hovered =
|
2021-12-27 21:53:33 +03:00
|
|
|
ScrollbarDrawing::IsParentScrollbarHoveredOrActive(aFrame) ||
|
2022-03-04 16:44:51 +03:00
|
|
|
(style != Style::Overlay && IsScrollbarWidthThin(aStyle));
|
2022-05-09 20:09:24 +03:00
|
|
|
const bool horizontal = aScrollbarKind == ScrollbarKind::Horizontal;
|
2022-03-04 16:44:51 +03:00
|
|
|
if (style == Style::ThickThumb) {
|
2021-12-27 21:53:32 +03:00
|
|
|
constexpr float kHoveredThumbRatio =
|
|
|
|
(1.0f - (11.0f / kDefaultWinScrollbarSize)) / 2.0f;
|
|
|
|
constexpr float kUnhoveredThumbRatio =
|
|
|
|
(1.0f - (9.0f / kDefaultWinScrollbarSize)) / 2.0f;
|
|
|
|
const float ratio = hovered ? kHoveredThumbRatio : kUnhoveredThumbRatio;
|
2022-05-09 20:09:24 +03:00
|
|
|
if (horizontal) {
|
2021-12-27 21:53:32 +03:00
|
|
|
thumbRect.Deflate(0, thumbRect.height * ratio);
|
2021-12-27 21:53:31 +03:00
|
|
|
} else {
|
2021-12-27 21:53:32 +03:00
|
|
|
thumbRect.Deflate(thumbRect.width * ratio, 0);
|
2021-12-27 21:53:31 +03:00
|
|
|
}
|
2021-12-27 21:53:32 +03:00
|
|
|
|
2021-12-27 21:53:31 +03:00
|
|
|
auto radius = CSSCoord(hovered ? 2 : 0);
|
|
|
|
ThemeDrawing::PaintRoundedRectWithRadius(aPaintData, thumbRect, thumbColor,
|
|
|
|
sRGBColor(), 0, radius, aDpiRatio);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-04 16:44:51 +03:00
|
|
|
const float defaultTrackSize = style == Style::Overlay
|
|
|
|
? float(kDefaultWinOverlayScrollbarSize)
|
|
|
|
: float(kDefaultWinScrollbarSize);
|
2022-05-09 20:09:24 +03:00
|
|
|
const float trackSize = horizontal ? thumbRect.height : thumbRect.width;
|
2022-03-04 16:44:51 +03:00
|
|
|
const float thumbSizeInPixels = hovered ? 6.0f : 2.0f;
|
|
|
|
|
|
|
|
// The thumb might be a bit off-center, depending on our scrollbar styles.
|
|
|
|
//
|
|
|
|
// Hovered shifts, if any, need to be accounted for in PaintScrollbarButton.
|
|
|
|
// For example, for the hovered horizontal thin scrollbar shift:
|
|
|
|
//
|
|
|
|
// Scrollbar is 17px high by default. We make the thumb 6px tall and move
|
|
|
|
// it 5px towards the bottom, so the center (8.5 initially) is displaced
|
|
|
|
// by:
|
|
|
|
// (5px + 6px / 2) - 8.5px = -0.5px
|
|
|
|
//
|
|
|
|
// Same calculations apply to other shifts.
|
|
|
|
const float shiftInPixels = [&] {
|
|
|
|
if (style == Style::Overlay) {
|
|
|
|
if (hovered) {
|
|
|
|
// Keep the center intact.
|
|
|
|
return (defaultTrackSize - thumbSizeInPixels) / 2.0f;
|
|
|
|
}
|
2022-05-09 20:09:24 +03:00
|
|
|
// We want logical pixels from the thumb to the edge. For LTR and
|
2022-03-04 16:44:51 +03:00
|
|
|
// horizontal scrollbars that means shifting down the scrollbar size minus
|
|
|
|
// the thumb.
|
|
|
|
constexpr float kSpaceToEdge = 3.0f;
|
2022-05-09 20:09:24 +03:00
|
|
|
if (horizontal || aScrollbarKind == ScrollbarKind::VerticalRight) {
|
2022-03-04 16:44:51 +03:00
|
|
|
return defaultTrackSize - thumbSizeInPixels - kSpaceToEdge;
|
2021-12-16 00:06:58 +03:00
|
|
|
}
|
2022-03-04 16:44:51 +03:00
|
|
|
// For rtl is simpler.
|
|
|
|
return kSpaceToEdge;
|
2021-12-16 00:06:58 +03:00
|
|
|
}
|
2022-05-09 20:09:24 +03:00
|
|
|
if (horizontal) {
|
2022-03-04 16:44:51 +03:00
|
|
|
return hovered ? 5.0f : 7.0f;
|
|
|
|
}
|
2022-05-09 20:09:24 +03:00
|
|
|
const bool ltr = aScrollbarKind == ScrollbarKind::VerticalRight;
|
2022-03-04 16:44:51 +03:00
|
|
|
return ltr ? (hovered ? 6.0f : 8.0f) : (hovered ? 5.0f : 7.0f);
|
|
|
|
}();
|
|
|
|
|
2022-05-09 20:09:24 +03:00
|
|
|
if (horizontal) {
|
2022-03-04 16:44:51 +03:00
|
|
|
thumbRect.y += shiftInPixels * trackSize / defaultTrackSize;
|
|
|
|
thumbRect.height *= thumbSizeInPixels / defaultTrackSize;
|
|
|
|
} else {
|
|
|
|
thumbRect.x += shiftInPixels * trackSize / defaultTrackSize;
|
|
|
|
thumbRect.width *= thumbSizeInPixels / defaultTrackSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style == Style::Overlay || hovered) {
|
2021-12-16 00:06:58 +03:00
|
|
|
LayoutDeviceCoord radius =
|
2022-05-09 20:09:24 +03:00
|
|
|
(horizontal ? thumbRect.height : thumbRect.width) / 2.0f;
|
2021-12-16 00:06:58 +03:00
|
|
|
|
|
|
|
MOZ_ASSERT(aRect.Contains(thumbRect));
|
|
|
|
ThemeDrawing::PaintRoundedRectWithRadius(aPaintData, thumbRect, thumbColor,
|
|
|
|
sRGBColor(), 0, radius / aDpiRatio,
|
|
|
|
aDpiRatio);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThemeDrawing::FillRect(aPaintData, thumbRect, thumbColor);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollbarDrawingWin11::PaintScrollbarThumb(
|
2022-05-09 20:09:24 +03:00
|
|
|
DrawTarget& aDrawTarget, const LayoutDeviceRect& aRect,
|
|
|
|
ScrollbarKind aScrollbarKind, nsIFrame* aFrame, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const ElementState& aElementState, const DocumentState& aDocumentState,
|
2021-12-16 00:06:58 +03:00
|
|
|
const Colors& aColors, const DPIRatio& aDpiRatio) {
|
2022-05-09 20:09:24 +03:00
|
|
|
return DoPaintScrollbarThumb(aDrawTarget, aRect, aScrollbarKind, aFrame,
|
|
|
|
aStyle, aElementState, aDocumentState, aColors,
|
2021-12-16 00:06:58 +03:00
|
|
|
aDpiRatio);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollbarDrawingWin11::PaintScrollbarThumb(
|
|
|
|
WebRenderBackendData& aWrData, const LayoutDeviceRect& aRect,
|
2022-05-09 20:09:24 +03:00
|
|
|
ScrollbarKind aScrollbarKind, nsIFrame* aFrame, const ComputedStyle& aStyle,
|
2022-06-08 02:09:52 +03:00
|
|
|
const ElementState& aElementState, const DocumentState& aDocumentState,
|
2021-12-16 00:06:58 +03:00
|
|
|
const Colors& aColors, const DPIRatio& aDpiRatio) {
|
2022-05-09 20:09:24 +03:00
|
|
|
return DoPaintScrollbarThumb(aWrData, aRect, aScrollbarKind, aFrame, aStyle,
|
2021-12-16 00:06:58 +03:00
|
|
|
aElementState, aDocumentState, aColors,
|
|
|
|
aDpiRatio);
|
|
|
|
}
|
|
|
|
|
2023-01-29 00:35:51 +03:00
|
|
|
void ScrollbarDrawingWin11::RecomputeScrollbarParams() {
|
|
|
|
ScrollbarDrawingWin::RecomputeScrollbarParams();
|
|
|
|
// TODO(emilio): Maybe make this configurable? Though this doesn't respect
|
|
|
|
// classic Windows registry settings, and cocoa overlay scrollbars also don't
|
|
|
|
// respect the override it seems, so this should be fine.
|
|
|
|
ConfigureScrollbarSize(StyleScrollbarWidth::Thin, Overlay::Yes,
|
|
|
|
kDefaultWinOverlayThinScrollbarSize);
|
|
|
|
ConfigureScrollbarSize(StyleScrollbarWidth::Auto, Overlay::Yes,
|
|
|
|
kDefaultWinOverlayScrollbarSize);
|
|
|
|
}
|
|
|
|
|
2021-12-16 00:06:58 +03:00
|
|
|
} // namespace mozilla::widget
|