mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1671704 - Unify some calls to ComputeScrollbarParams and call nsLayoutUtils::StyleForScrollbar in the caller. r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D95076
This commit is contained in:
parent
30cc69eb90
commit
aa21c0548f
@ -91,26 +91,25 @@ LayoutDeviceIntSize ScrollbarDrawingMac::GetMinimumWidgetSize(
|
||||
}
|
||||
|
||||
ScrollbarParams ScrollbarDrawingMac::ComputeScrollbarParams(
|
||||
nsIFrame* aFrame, bool aIsHorizontal) {
|
||||
ComputedStyle* style = nsLayoutUtils::StyleForScrollbar(aFrame);
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle, bool aIsHorizontal) {
|
||||
ScrollbarParams params;
|
||||
params.overlay =
|
||||
nsLookAndFeel::GetInt(LookAndFeel::IntID::UseOverlayScrollbars) != 0;
|
||||
params.rolledOver = IsParentScrollbarRolledOver(aFrame);
|
||||
params.small =
|
||||
style->StyleUIReset()->mScrollbarWidth == StyleScrollbarWidth::Thin;
|
||||
aStyle.StyleUIReset()->mScrollbarWidth == StyleScrollbarWidth::Thin;
|
||||
params.rtl = nsNativeTheme::IsFrameRTL(aFrame);
|
||||
params.horizontal = aIsHorizontal;
|
||||
params.onDarkBackground = nsNativeTheme::IsDarkBackground(aFrame);
|
||||
// Don't use custom scrollbars for overlay scrollbars since they are
|
||||
// generally good enough for use cases of custom scrollbars.
|
||||
if (!params.overlay) {
|
||||
const nsStyleUI* ui = style->StyleUI();
|
||||
const nsStyleUI* ui = aStyle.StyleUI();
|
||||
if (ui->HasCustomScrollbars()) {
|
||||
const auto& colors = ui->mScrollbarColor.AsColors();
|
||||
params.custom = true;
|
||||
params.trackColor = colors.track.CalcColor(*style);
|
||||
params.faceColor = colors.thumb.CalcColor(*style);
|
||||
params.trackColor = colors.track.CalcColor(aStyle);
|
||||
params.faceColor = colors.thumb.CalcColor(aStyle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ class ScrollbarDrawingMac final {
|
||||
nsIFrame* aFrame,
|
||||
float aDpiRatio);
|
||||
static ScrollbarParams ComputeScrollbarParams(nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
bool aIsHorizontal);
|
||||
static void DrawScrollbarThumb(gfx::DrawTarget& aDT, const gfx::Rect& aRect,
|
||||
const ScrollbarParams& aParams);
|
||||
|
@ -2706,26 +2706,35 @@ Maybe<nsNativeThemeCocoa::WidgetInfo> nsNativeThemeCocoa::ComputeWidgetInfo(
|
||||
|
||||
case StyleAppearance::ScrollbarHorizontal:
|
||||
case StyleAppearance::ScrollbarVertical:
|
||||
break;
|
||||
case StyleAppearance::ScrollbarthumbVertical:
|
||||
case StyleAppearance::ScrollbarthumbHorizontal:
|
||||
return Some(WidgetInfo::ScrollbarThumb(ScrollbarDrawingMac::ComputeScrollbarParams(
|
||||
aFrame, aAppearance == StyleAppearance::ScrollbarthumbHorizontal)));
|
||||
|
||||
case StyleAppearance::ScrollbarbuttonUp:
|
||||
case StyleAppearance::ScrollbarbuttonLeft:
|
||||
case StyleAppearance::ScrollbarbuttonDown:
|
||||
case StyleAppearance::ScrollbarbuttonRight:
|
||||
break;
|
||||
|
||||
case StyleAppearance::ScrollbarthumbVertical:
|
||||
case StyleAppearance::ScrollbarthumbHorizontal:
|
||||
case StyleAppearance::ScrollbartrackHorizontal:
|
||||
case StyleAppearance::ScrollbartrackVertical:
|
||||
return Some(WidgetInfo::ScrollbarTrack(ScrollbarDrawingMac::ComputeScrollbarParams(
|
||||
aFrame, aAppearance == StyleAppearance::ScrollbartrackHorizontal)));
|
||||
|
||||
case StyleAppearance::Scrollcorner:
|
||||
return Some(
|
||||
WidgetInfo::ScrollCorner(ScrollbarDrawingMac::ComputeScrollbarParams(aFrame, false)));
|
||||
case StyleAppearance::Scrollcorner: {
|
||||
bool isHorizontal = aAppearance == StyleAppearance::ScrollbarthumbHorizontal ||
|
||||
aAppearance == StyleAppearance::ScrollbartrackHorizontal;
|
||||
ScrollbarParams params = ScrollbarDrawingMac::ComputeScrollbarParams(
|
||||
aFrame, *nsLayoutUtils::StyleForScrollbar(aFrame), isHorizontal);
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::ScrollbarthumbVertical:
|
||||
case StyleAppearance::ScrollbarthumbHorizontal:
|
||||
return Some(WidgetInfo::ScrollbarThumb(params));
|
||||
case StyleAppearance::ScrollbartrackHorizontal:
|
||||
case StyleAppearance::ScrollbartrackVertical:
|
||||
return Some(WidgetInfo::ScrollbarTrack(params));
|
||||
case StyleAppearance::Scrollcorner:
|
||||
return Some(WidgetInfo::ScrollCorner(params));
|
||||
default:
|
||||
MOZ_CRASH("unexpected aAppearance");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case StyleAppearance::Textarea:
|
||||
return Some(WidgetInfo::MultilineTextField(eventState.HasState(NS_EVENT_STATE_FOCUS)));
|
||||
@ -3092,8 +3101,9 @@ bool nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(
|
||||
case StyleAppearance::Scrollcorner:
|
||||
case StyleAppearance::ScrollbartrackHorizontal:
|
||||
case StyleAppearance::ScrollbartrackVertical: {
|
||||
const ComputedStyle& style = *nsLayoutUtils::StyleForScrollbar(aFrame);
|
||||
ScrollbarParams params = ScrollbarDrawingMac::ComputeScrollbarParams(
|
||||
aFrame, aAppearance == StyleAppearance::ScrollbartrackHorizontal);
|
||||
aFrame, style, aAppearance == StyleAppearance::ScrollbartrackHorizontal);
|
||||
if (params.overlay && !params.rolledOver) {
|
||||
// There is no scrollbar track, draw nothing and return true.
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user