diff --git a/gfx/src/nsITheme.h b/gfx/src/nsITheme.h index 8384f0f728a3..84baccea3cfd 100644 --- a/gfx/src/nsITheme.h +++ b/gfx/src/nsITheme.h @@ -166,15 +166,11 @@ class nsITheme : public nsISupports { } /** - * Get the minimum border-box size of a widget, in *pixels* (in - * |aResult|). If |aIsOverridable| is set to true, this size is a - * minimum size; if false, this size is the only valid size for the - * widget. + * Get the minimum border-box size of a widget, in device pixels. */ - NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aWidgetType, - mozilla::LayoutDeviceIntSize* aResult, - bool* aIsOverridable) = 0; + virtual mozilla::LayoutDeviceIntSize GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aWidgetType) = 0; enum Transparency { eOpaque = 0, eTransparent, eUnknownTransparency }; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index a565544363f5..220b1cfcb35e 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4748,16 +4748,14 @@ static nscoord AddIntrinsicSizeOffset( const nsStyleDisplay* disp = aFrame->StyleDisplay(); if (aFrame->IsThemed(disp)) { - LayoutDeviceIntSize devSize; - bool canOverride = true; nsPresContext* pc = aFrame->PresContext(); - pc->Theme()->GetMinimumWidgetSize(pc, aFrame, disp->EffectiveAppearance(), - &devSize, &canOverride); + LayoutDeviceIntSize devSize = pc->Theme()->GetMinimumWidgetSize( + pc, aFrame, disp->EffectiveAppearance()); nscoord themeSize = pc->DevPixelsToAppUnits( aAxis == eAxisVertical ? devSize.height : devSize.width); // GetMinimumWidgetSize() returns a border-box width. themeSize += aOffsets.margin; - if (themeSize > result || !canOverride) { + if (themeSize > result) { result = themeSize; } } diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 48d3419fc2d9..6583fe7d3911 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -291,14 +291,10 @@ nscoord nsComboboxControlFrame::DropDownButtonISize() { return 0; } - LayoutDeviceIntSize dropdownButtonSize; - bool canOverride = true; - nsPresContext* presContext = PresContext(); - presContext->Theme()->GetMinimumWidgetSize( - presContext, this, StyleAppearance::MozMenulistArrowButton, - &dropdownButtonSize, &canOverride); - - return presContext->DevPixelsToAppUnits(dropdownButtonSize.width); + nsPresContext* pc = PresContext(); + LayoutDeviceIntSize dropdownButtonSize = pc->Theme()->GetMinimumWidgetSize( + pc, this, StyleAppearance::MozMenulistArrowButton); + return pc->DevPixelsToAppUnits(dropdownButtonSize.width); } int32_t nsComboboxControlFrame::CharCountOfLargestOptionForInflation() const { diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index ca3f3b3b3529..51dc07ba97a8 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -373,14 +373,11 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) { if (IsThemed()) { // We need to get the size of the thumb from the theme. - nsPresContext* presContext = PresContext(); - bool notUsedCanOverride; - LayoutDeviceIntSize size; - presContext->Theme()->GetMinimumWidgetSize(presContext, this, - StyleAppearance::RangeThumb, - &size, ¬UsedCanOverride); - thumbSize.width = presContext->DevPixelsToAppUnits(size.width); - thumbSize.height = presContext->DevPixelsToAppUnits(size.height); + nsPresContext* pc = PresContext(); + LayoutDeviceIntSize size = pc->Theme()->GetMinimumWidgetSize( + pc, this, StyleAppearance::RangeThumb); + thumbSize = + LayoutDeviceIntSize::ToAppUnits(size, pc->AppUnitsPerDevPixel()); // For GTK, GetMinimumWidgetSize returns zero for the thumb dimension // perpendicular to the orientation of the slider. That's okay since we // only care about the dimension in the direction of the slider when using @@ -582,11 +579,9 @@ nsresult nsRangeFrame::AttributeChanged(int32_t aNameSpaceID, nscoord nsRangeFrame::AutoCrossSize(Length aEm) { nscoord minCrossSize(0); if (IsThemed()) { - bool unused; - LayoutDeviceIntSize size; nsPresContext* pc = PresContext(); - pc->Theme()->GetMinimumWidgetSize(pc, this, StyleAppearance::RangeThumb, - &size, &unused); + LayoutDeviceIntSize size = pc->Theme()->GetMinimumWidgetSize( + pc, this, StyleAppearance::RangeThumb); minCrossSize = pc->DevPixelsToAppUnits(IsHorizontal() ? size.height : size.width); } diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 1f494bd22579..3a264374fc37 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1441,14 +1441,11 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild( // Check if we're a themed widget, in which case we might have a minimum // main & cross size imposed by our widget (which we can't go below), or // (more severe) our widget might have only a single valid size. - bool isFixedSizeWidget = false; const nsStyleDisplay* disp = aChildFrame->StyleDisplay(); if (aChildFrame->IsThemed(disp)) { - LayoutDeviceIntSize widgetMinSize; - bool canOverride = true; - PresContext()->Theme()->GetMinimumWidgetSize(PresContext(), aChildFrame, - disp->EffectiveAppearance(), - &widgetMinSize, &canOverride); + LayoutDeviceIntSize widgetMinSize = + PresContext()->Theme()->GetMinimumWidgetSize( + PresContext(), aChildFrame, disp->EffectiveAppearance()); nscoord widgetMainMinSize = PresContext()->DevPixelsToAppUnits( aAxisTracker.MainComponent(widgetMinSize)); @@ -1464,26 +1461,16 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild( // ... (but don't let that push these min sizes below 0). widgetMainMinSize = std::max(0, widgetMainMinSize); widgetCrossMinSize = std::max(0, widgetCrossMinSize); + // Ensure our min/max sizes are at least as large as the widget's mandated + // minimum size, so we don't flex below that. + mainMinSize = std::max(mainMinSize, widgetMainMinSize); + mainMaxSize = std::max(mainMaxSize, widgetMainMinSize); - if (!canOverride) { - // Fixed-size widget: freeze our main-size at the widget's mandated size. - // (Set min and max main-sizes to that size, too, to keep us from - // clamping to any other size later on.) - flexBaseSize = mainMinSize = mainMaxSize = widgetMainMinSize; - tentativeCrossSize = crossMinSize = crossMaxSize = widgetCrossMinSize; - isFixedSizeWidget = true; - } else { - // Variable-size widget: ensure our min/max sizes are at least as large - // as the widget's mandated minimum size, so we don't flex below that. - mainMinSize = std::max(mainMinSize, widgetMainMinSize); - mainMaxSize = std::max(mainMaxSize, widgetMainMinSize); - - if (tentativeCrossSize != NS_UNCONSTRAINEDSIZE) { - tentativeCrossSize = std::max(tentativeCrossSize, widgetCrossMinSize); - } - crossMinSize = std::max(crossMinSize, widgetCrossMinSize); - crossMaxSize = std::max(crossMaxSize, widgetCrossMinSize); + if (tentativeCrossSize != NS_UNCONSTRAINEDSIZE) { + tentativeCrossSize = std::max(tentativeCrossSize, widgetCrossMinSize); } + crossMinSize = std::max(crossMinSize, widgetCrossMinSize); + crossMaxSize = std::max(crossMaxSize, widgetCrossMinSize); } // Construct the flex item! @@ -1523,9 +1510,8 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild( item->ResolveFlexBaseSizeFromAspectRatio(childRI); // If we're inflexible, we can just freeze to our hypothetical main-size - // up-front. Similarly, if we're a fixed-size widget, we only have one - // valid size, so we freeze to keep ourselves from flexing. - if (isFixedSizeWidget || (flexGrow == 0.0f && flexShrink == 0.0f)) { + // up-front. + if (flexGrow == 0.0f && flexShrink == 0.0f) { item->Freeze(); if (flexBaseSize < mainMinSize) { item->SetWasMinClamped(); diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index b61cb42fa1cc..1312b79cf711 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -6524,24 +6524,21 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize( } if (IsThemed(disp)) { - LayoutDeviceIntSize widget; - bool canOverride = true; - nsPresContext* presContext = PresContext(); - presContext->Theme()->GetMinimumWidgetSize( - presContext, this, disp->EffectiveAppearance(), &widget, &canOverride); + nsPresContext* pc = PresContext(); + LayoutDeviceIntSize widget = pc->Theme()->GetMinimumWidgetSize( + pc, this, disp->EffectiveAppearance()); // Convert themed widget's physical dimensions to logical coords - LogicalSize size(aWM, - nsSize(presContext->DevPixelsToAppUnits(widget.width), - presContext->DevPixelsToAppUnits(widget.height))); + LogicalSize size(aWM, LayoutDeviceIntSize::ToAppUnits( + widget, pc->AppUnitsPerDevPixel())); // GetMinimumWidgetSize() returns border-box; we need content-box. size -= aBorderPadding; - if (size.BSize(aWM) > result.BSize(aWM) || !canOverride) { + if (size.BSize(aWM) > result.BSize(aWM)) { result.BSize(aWM) = size.BSize(aWM); } - if (size.ISize(aWM) > result.ISize(aWM) || !canOverride) { + if (size.ISize(aWM) > result.ISize(aWM)) { result.ISize(aWM) = size.ISize(aWM); } } diff --git a/layout/xul/nsBox.cpp b/layout/xul/nsBox.cpp index d8cbd1a3a97c..3dd11d8a3fd2 100644 --- a/layout/xul/nsBox.cpp +++ b/layout/xul/nsBox.cpp @@ -373,8 +373,6 @@ bool nsIFrame::AddXULMinSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet, aWidthSet = false; aHeightSet = false; - bool canOverride = true; - nsPresContext* pc = aBox->PresContext(); // See if a native theme wants to supply a minimum size. @@ -383,8 +381,8 @@ bool nsIFrame::AddXULMinSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet, nsITheme* theme = pc->Theme(); StyleAppearance appearance = display->EffectiveAppearance(); if (theme->ThemeSupportsWidget(pc, aBox, appearance)) { - LayoutDeviceIntSize size; - theme->GetMinimumWidgetSize(pc, aBox, appearance, &size, &canOverride); + LayoutDeviceIntSize size = + theme->GetMinimumWidgetSize(pc, aBox, appearance); if (size.width) { aSize.width = pc->DevPixelsToAppUnits(size.width); aWidthSet = true; @@ -421,7 +419,7 @@ bool nsIFrame::AddXULMinSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet, const auto& minWidth = position->mMinWidth; if (minWidth.ConvertsToLength()) { nscoord min = minWidth.ToLength(); - if (!aWidthSet || (min > aSize.width && canOverride)) { + if (!aWidthSet || min > aSize.width) { aSize.width = min; aWidthSet = true; } @@ -440,7 +438,7 @@ bool nsIFrame::AddXULMinSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet, const auto& minHeight = position->mMinHeight; if (minHeight.ConvertsToLength()) { nscoord min = minHeight.ToLength(); - if (!aHeightSet || (min > aSize.height && canOverride)) { + if (!aHeightSet || min > aSize.height) { aSize.height = min; aHeightSet = true; } diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 5477eeea38fb..104110e07321 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -1827,10 +1827,8 @@ nsITheme* nsTreeBodyFrame::GetTwistyRect(int32_t aRowIndex, } if (useTheme) { - LayoutDeviceIntSize minTwistySizePx; - bool canOverride = true; - theme->GetMinimumWidgetSize(aPresContext, this, appearance, - &minTwistySizePx, &canOverride); + LayoutDeviceIntSize minTwistySizePx = + theme->GetMinimumWidgetSize(aPresContext, this, appearance); // GMWS() returns size in pixels, we need to convert it back to app units nsSize minTwistySize; @@ -1839,8 +1837,9 @@ nsITheme* nsTreeBodyFrame::GetTwistyRect(int32_t aRowIndex, minTwistySize.height = aPresContext->DevPixelsToAppUnits(minTwistySizePx.height); - if (aTwistyRect.width < minTwistySize.width || !canOverride) + if (aTwistyRect.width < minTwistySize.width) { aTwistyRect.width = minTwistySize.width; + } } return useTheme ? theme : nullptr; diff --git a/widget/Theme.cpp b/widget/Theme.cpp index 792c3994745d..3284ce89608d 100644 --- a/widget/Theme.cpp +++ b/widget/Theme.cpp @@ -1504,45 +1504,39 @@ UniquePtr Theme::ScrollbarStyle() { #endif } -NS_IMETHODIMP -Theme::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, - LayoutDeviceIntSize* aResult, - bool* aIsOverridable) { +LayoutDeviceIntSize Theme::GetMinimumWidgetSize(nsPresContext* aPresContext, + nsIFrame* aFrame, + StyleAppearance aAppearance) { DPIRatio dpiRatio = GetDPIRatio(aFrame, aAppearance); - aResult->width = aResult->height = 0; - *aIsOverridable = true; - if (IsWidgetScrollbarPart(aAppearance)) { - *aResult = GetScrollbarDrawing().GetMinimumWidgetSize(aPresContext, - aAppearance, aFrame); - return NS_OK; + return GetScrollbarDrawing().GetMinimumWidgetSize(aPresContext, aAppearance, + aFrame); } + LayoutDeviceIntSize result; switch (aAppearance) { case StyleAppearance::Button: if (aFrame->IsColorControlFrame()) { - aResult->height = (kMinimumColorPickerHeight * dpiRatio).Rounded(); + result.height = (kMinimumColorPickerHeight * dpiRatio).Rounded(); } break; case StyleAppearance::RangeThumb: - aResult->SizeTo((kMinimumRangeThumbSize * dpiRatio).Rounded(), - (kMinimumRangeThumbSize * dpiRatio).Rounded()); + result.SizeTo((kMinimumRangeThumbSize * dpiRatio).Rounded(), + (kMinimumRangeThumbSize * dpiRatio).Rounded()); break; case StyleAppearance::MozMenulistArrowButton: - aResult->width = (kMinimumDropdownArrowButtonWidth * dpiRatio).Rounded(); + result.width = (kMinimumDropdownArrowButtonWidth * dpiRatio).Rounded(); break; case StyleAppearance::SpinnerUpbutton: case StyleAppearance::SpinnerDownbutton: - aResult->width = (kMinimumSpinnerButtonWidth * dpiRatio).Rounded(); - aResult->height = (kMinimumSpinnerButtonHeight * dpiRatio).Rounded(); + result.width = (kMinimumSpinnerButtonWidth * dpiRatio).Rounded(); + result.height = (kMinimumSpinnerButtonHeight * dpiRatio).Rounded(); break; default: break; } - - return NS_OK; + return result; } nsITheme::Transparency Theme::GetWidgetTransparency( diff --git a/widget/Theme.h b/widget/Theme.h index cda6a0db8ae0..82508301464d 100644 --- a/widget/Theme.h +++ b/widget/Theme.h @@ -74,9 +74,8 @@ class Theme : protected nsNativeTheme, public nsITheme { LayoutDeviceIntMargin* aResult) override; bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame*, StyleAppearance, nsRect* aOverflowRect) override; - NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame*, - StyleAppearance, LayoutDeviceIntSize* aResult, - bool* aIsOverridable) override; + LayoutDeviceIntSize GetMinimumWidgetSize(nsPresContext*, nsIFrame*, + StyleAppearance) override; Transparency GetWidgetTransparency(nsIFrame*, StyleAppearance) override; NS_IMETHOD WidgetStateChanged(nsIFrame*, StyleAppearance, nsAtom* aAttribute, bool* aShouldRepaint, diff --git a/widget/ThemeCocoa.cpp b/widget/ThemeCocoa.cpp index d29e76123dc0..dd8655454f02 100644 --- a/widget/ThemeCocoa.cpp +++ b/widget/ThemeCocoa.cpp @@ -14,21 +14,16 @@ namespace mozilla::widget { -NS_IMETHODIMP -ThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, - LayoutDeviceIntSize* aResult, - bool* aIsOverridable) { +LayoutDeviceIntSize ThemeCocoa::GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aAppearance) { if (aAppearance == StyleAppearance::MozMenulistArrowButton) { - auto size = ScrollbarDrawingCocoa::GetScrollbarSize( + LayoutDeviceIntCoord size = ScrollbarDrawingCocoa::GetScrollbarSize( StyleScrollbarWidth::Auto, /* aOverlay = */ false, GetDPIRatio(aFrame, aAppearance)); - aResult->SizeTo(size, size); - return NS_OK; + return {size, size}; } - - return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance, aResult, - aIsOverridable); + return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } nsITheme::ThemeGeometryType ThemeCocoa::ThemeGeometryTypeForWidget( diff --git a/widget/ThemeCocoa.h b/widget/ThemeCocoa.h index bb19267bb14d..44b00425bccf 100644 --- a/widget/ThemeCocoa.h +++ b/widget/ThemeCocoa.h @@ -18,10 +18,9 @@ class ThemeCocoa : public Theme { explicit ThemeCocoa(UniquePtr&& aScrollbarDrawing) : Theme(std::move(aScrollbarDrawing)) {} - NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, - mozilla::LayoutDeviceIntSize* aResult, - bool* aIsOverridable) override; + LayoutDeviceIntSize GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aAppearance) override; ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame*, StyleAppearance) override; diff --git a/widget/cocoa/nsNativeThemeCocoa.h b/widget/cocoa/nsNativeThemeCocoa.h index 993df5b763ea..b7557860d962 100644 --- a/widget/cocoa/nsNativeThemeCocoa.h +++ b/widget/cocoa/nsNativeThemeCocoa.h @@ -314,10 +314,7 @@ class nsNativeThemeCocoa : public mozilla::widget::ThemeCocoa { virtual bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, StyleAppearance aAppearance, nsRect* aOverflowRect) override; - NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, - mozilla::LayoutDeviceIntSize* aResult, - bool* aIsOverridable) override; + LayoutDeviceIntSize GetMinimumWidgetSize(nsPresContext*, nsIFrame*, StyleAppearance) override; NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, StyleAppearance aAppearance, nsAtom* aAttribute, bool* aShouldRepaint, const nsAttrValue* aOldValue) override; NS_IMETHOD ThemeChanged() override; diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 1731d9ef2551..c31e5af46335 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -3035,55 +3035,47 @@ bool nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* return false; } -NS_IMETHODIMP -nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, LayoutDeviceIntSize* aResult, - bool* aIsOverridable) { +LayoutDeviceIntSize nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, + nsIFrame* aFrame, + StyleAppearance aAppearance) { NS_OBJC_BEGIN_TRY_BLOCK_RETURN; - aResult->SizeTo(0, 0); - *aIsOverridable = true; - if (IsWidgetScrollbarPart(aAppearance)) { - return ThemeCocoa::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance, aResult, - aIsOverridable); + return ThemeCocoa::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } + LayoutDeviceIntSize result; switch (aAppearance) { case StyleAppearance::Button: { - aResult->SizeTo(pushButtonSettings.minimumSizes[miniControlSize].width, - pushButtonSettings.naturalSizes[miniControlSize].height); + result.SizeTo(pushButtonSettings.minimumSizes[miniControlSize].width, + pushButtonSettings.naturalSizes[miniControlSize].height); break; } case StyleAppearance::ButtonArrowUp: case StyleAppearance::ButtonArrowDown: { - aResult->SizeTo(kMenuScrollArrowSize.width, kMenuScrollArrowSize.height); - *aIsOverridable = false; + result.SizeTo(kMenuScrollArrowSize.width, kMenuScrollArrowSize.height); break; } case StyleAppearance::Menuarrow: { - aResult->SizeTo(kMenuarrowSize.width, kMenuarrowSize.height); - *aIsOverridable = false; + result.SizeTo(kMenuarrowSize.width, kMenuarrowSize.height); break; } case StyleAppearance::MozMacDisclosureButtonOpen: case StyleAppearance::MozMacDisclosureButtonClosed: { - aResult->SizeTo(kDisclosureButtonSize.width, kDisclosureButtonSize.height); - *aIsOverridable = false; + result.SizeTo(kDisclosureButtonSize.width, kDisclosureButtonSize.height); break; } case StyleAppearance::MozMacHelpButton: { - aResult->SizeTo(kHelpButtonSize.width, kHelpButtonSize.height); - *aIsOverridable = false; + result.SizeTo(kHelpButtonSize.width, kHelpButtonSize.height); break; } case StyleAppearance::Toolbarbutton: { - aResult->SizeTo(0, toolbarButtonHeights[miniControlSize]); + result.SizeTo(0, toolbarButtonHeights[miniControlSize]); break; } @@ -3103,8 +3095,7 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* buttonHeight /= 2; } } - aResult->SizeTo(buttonWidth, buttonHeight); - *aIsOverridable = true; + result.SizeTo(buttonWidth, buttonHeight); break; } @@ -3112,7 +3103,7 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* case StyleAppearance::MenulistButton: { SInt32 popupHeight = 0; ::GetThemeMetric(kThemeMetricPopupButtonHeight, &popupHeight); - aResult->SizeTo(0, popupHeight); + result.SizeTo(0, popupHeight); break; } @@ -3123,26 +3114,25 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* // at minimum, we should be tall enough for 9pt text. // I'm using hardcoded values here because the appearance manager // values for the frame size are incorrect. - aResult->SizeTo(0, (2 + 2) /* top */ + 9 + (1 + 1) /* bottom */); + result.SizeTo(0, (2 + 2) /* top */ + 9 + (1 + 1) /* bottom */); break; } case StyleAppearance::MozWindowButtonBox: { NSSize size = WindowButtonsSize(aFrame); - aResult->SizeTo(size.width, size.height); - *aIsOverridable = false; + result.SizeTo(size.width, size.height); break; } case StyleAppearance::ProgressBar: { SInt32 barHeight = 0; ::GetThemeMetric(kThemeMetricNormalProgressBarThickness, &barHeight); - aResult->SizeTo(0, barHeight); + result.SizeTo(0, barHeight); break; } case StyleAppearance::Separator: { - aResult->SizeTo(1, 1); + result.SizeTo(1, 1); break; } @@ -3151,8 +3141,7 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* SInt32 twistyHeight = 0, twistyWidth = 0; ::GetThemeMetric(kThemeMetricDisclosureButtonWidth, &twistyWidth); ::GetThemeMetric(kThemeMetricDisclosureButtonHeight, &twistyHeight); - aResult->SizeTo(twistyWidth, twistyHeight); - *aIsOverridable = false; + result.SizeTo(twistyWidth, twistyHeight); break; } @@ -3160,12 +3149,12 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* case StyleAppearance::Treeheadercell: { SInt32 headerHeight = 0; ::GetThemeMetric(kThemeMetricListHeaderHeight, &headerHeight); - aResult->SizeTo(0, headerHeight); + result.SizeTo(0, headerHeight); break; } case StyleAppearance::Tab: { - aResult->SizeTo(0, tabHeights[miniControlSize]); + result.SizeTo(0, tabHeights[miniControlSize]); break; } @@ -3174,14 +3163,12 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* SInt32 height = 0; ::GetThemeMetric(kThemeMetricSliderMinThumbWidth, &width); ::GetThemeMetric(kThemeMetricSliderMinThumbHeight, &height); - aResult->SizeTo(width, height); - *aIsOverridable = false; + result.SizeTo(width, height); break; } case StyleAppearance::MozMenulistArrowButton: - return ThemeCocoa::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance, aResult, - aIsOverridable); + return ThemeCocoa::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); case StyleAppearance::Resizer: { HIThemeGrowBoxDrawInfo drawInfo; @@ -3193,8 +3180,7 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* HIPoint pnt = {0, 0}; HIRect bounds; HIThemeGetGrowBoxBounds(&pnt, &drawInfo, &bounds); - aResult->SizeTo(bounds.size.width, bounds.size.height); - *aIsOverridable = false; + result.SizeTo(bounds.size.width, bounds.size.height); break; } default: @@ -3202,12 +3188,12 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* } if (IsHiDPIContext(aPresContext->DeviceContext())) { - *aResult = *aResult * 2; + result = result * 2; } - return NS_OK; + return result; - NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE); + NS_OBJC_END_TRY_BLOCK_RETURN(LayoutDeviceIntSize()); } NS_IMETHODIMP diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 8705e8c7eaeb..98d1c2c7292d 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -1216,104 +1216,77 @@ auto nsNativeThemeGTK::IsWidgetNonNative(nsIFrame* aFrame, return NonNative::No; } -NS_IMETHODIMP -nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, - StyleAppearance aAppearance, - LayoutDeviceIntSize* aResult, - bool* aIsOverridable) { +LayoutDeviceIntSize nsNativeThemeGTK::GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aAppearance) { if (IsWidgetNonNative(aFrame, aAppearance) == NonNative::Always) { - return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance, - aResult, aIsOverridable); + return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } - aResult->width = aResult->height = 0; - *aIsOverridable = true; - + LayoutDeviceIntSize result; switch (aAppearance) { case StyleAppearance::Splitter: { - gint metrics; if (IsHorizontal(aFrame)) { - moz_gtk_splitter_get_metrics(GTK_ORIENTATION_HORIZONTAL, &metrics); - aResult->width = metrics; - aResult->height = 0; + moz_gtk_splitter_get_metrics(GTK_ORIENTATION_HORIZONTAL, &result.width); } else { - moz_gtk_splitter_get_metrics(GTK_ORIENTATION_VERTICAL, &metrics); - aResult->width = 0; - aResult->height = metrics; + moz_gtk_splitter_get_metrics(GTK_ORIENTATION_VERTICAL, &result.height); } - *aIsOverridable = false; } break; case StyleAppearance::RangeThumb: { - gint thumb_length, thumb_height; - if (IsRangeHorizontal(aFrame)) { moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, - &thumb_length, &thumb_height); + &result.width, &result.height); } else { - moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, - &thumb_length); + moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &result.width, + &result.width); } - aResult->width = thumb_length; - aResult->height = thumb_height; - - *aIsOverridable = false; } break; case StyleAppearance::TabScrollArrowBack: case StyleAppearance::TabScrollArrowForward: { - moz_gtk_get_tab_scroll_arrow_size(&aResult->width, &aResult->height); - *aIsOverridable = false; + moz_gtk_get_tab_scroll_arrow_size(&result.width, &result.height); } break; case StyleAppearance::MozMenulistArrowButton: { - moz_gtk_get_combo_box_entry_button_size(&aResult->width, - &aResult->height); - *aIsOverridable = false; + moz_gtk_get_combo_box_entry_button_size(&result.width, &result.height); } break; case StyleAppearance::Menuseparator: { - gint separator_height; - - moz_gtk_get_menu_separator_height(&separator_height); - aResult->height = separator_height; - - *aIsOverridable = false; + moz_gtk_get_menu_separator_height(&result.height); } break; case StyleAppearance::Checkbox: case StyleAppearance::Radio: { const ToggleGTKMetrics* metrics = GetToggleMetrics( aAppearance == StyleAppearance::Radio ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON); - aResult->width = metrics->minSizeWithBorder.width; - aResult->height = metrics->minSizeWithBorder.height; + result.width = metrics->minSizeWithBorder.width; + result.height = metrics->minSizeWithBorder.height; } break; case StyleAppearance::ToolbarbuttonDropdown: case StyleAppearance::ButtonArrowUp: case StyleAppearance::ButtonArrowDown: case StyleAppearance::ButtonArrowNext: case StyleAppearance::ButtonArrowPrevious: { - moz_gtk_get_arrow_size(MOZ_GTK_TOOLBARBUTTON_ARROW, &aResult->width, - &aResult->height); - *aIsOverridable = false; + moz_gtk_get_arrow_size(MOZ_GTK_TOOLBARBUTTON_ARROW, &result.width, + &result.height); } break; case StyleAppearance::MozWindowButtonClose: { const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(MOZ_GTK_HEADER_BAR_BUTTON_CLOSE); - aResult->width = metrics->minSizeWithBorderMargin.width; - aResult->height = metrics->minSizeWithBorderMargin.height; + result.width = metrics->minSizeWithBorderMargin.width; + result.height = metrics->minSizeWithBorderMargin.height; break; } case StyleAppearance::MozWindowButtonMinimize: { const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE); - aResult->width = metrics->minSizeWithBorderMargin.width; - aResult->height = metrics->minSizeWithBorderMargin.height; + result.width = metrics->minSizeWithBorderMargin.width; + result.height = metrics->minSizeWithBorderMargin.height; break; } case StyleAppearance::MozWindowButtonMaximize: case StyleAppearance::MozWindowButtonRestore: { const ToolbarButtonGTKMetrics* metrics = GetToolbarButtonMetrics(MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE); - aResult->width = metrics->minSizeWithBorderMargin.width; - aResult->height = metrics->minSizeWithBorderMargin.height; + result.width = metrics->minSizeWithBorderMargin.width; + result.height = metrics->minSizeWithBorderMargin.height; break; } case StyleAppearance::CheckboxContainer: @@ -1328,8 +1301,7 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, if (aAppearance == StyleAppearance::Menulist || aAppearance == StyleAppearance::MenulistButton) { // Include the arrow size. - moz_gtk_get_arrow_size(MOZ_GTK_DROPDOWN, &aResult->width, - &aResult->height); + moz_gtk_get_arrow_size(MOZ_GTK_DROPDOWN, &result.width, &result.height); } // else the minimum size is missing consideration of container // descendants; the value returned here will not be helpful, but the @@ -1338,8 +1310,8 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, LayoutDeviceIntMargin border; GetCachedWidgetBorder(aFrame, aAppearance, GetTextDirection(aFrame), &border); - aResult->width += border.left + border.right; - aResult->height += border.top + border.bottom; + result.width += border.LeftRight(); + result.height += border.TopBottom(); } break; case StyleAppearance::NumberInput: case StyleAppearance::Textfield: { @@ -1370,50 +1342,41 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, gint height = contentHeight + borderPaddingHeight; if (aFrame->GetWritingMode().IsVertical()) { - aResult->width = height; + result.width = height; } else { - aResult->height = height; + result.height = height; } } break; case StyleAppearance::Separator: { - gint separator_width; - - moz_gtk_get_toolbar_separator_width(&separator_width); - - aResult->width = separator_width; + moz_gtk_get_toolbar_separator_width(&result.width); } break; case StyleAppearance::Spinner: // hard code these sizes - aResult->width = 14; - aResult->height = 26; + result.width = 14; + result.height = 26; break; case StyleAppearance::Treeheadersortarrow: case StyleAppearance::SpinnerUpbutton: case StyleAppearance::SpinnerDownbutton: // hard code these sizes - aResult->width = 14; - aResult->height = 13; + result.width = 14; + result.height = 13; break; case StyleAppearance::Resizer: // same as Windows to make our lives easier - aResult->width = aResult->height = 15; - *aIsOverridable = false; + result.width = result.height = 15; break; case StyleAppearance::Treetwisty: case StyleAppearance::Treetwistyopen: { gint expander_size; - moz_gtk_get_treeview_expander_size(&expander_size); - aResult->width = aResult->height = expander_size; - *aIsOverridable = false; + result.width = result.height = expander_size; } break; default: break; } - *aResult = *aResult * GetMonitorScaleFactor(aFrame); - - return NS_OK; + return result * GetMonitorScaleFactor(aFrame); } NS_IMETHODIMP diff --git a/widget/gtk/nsNativeThemeGTK.h b/widget/gtk/nsNativeThemeGTK.h index 7a710f20a3d6..677492a16ba6 100644 --- a/widget/gtk/nsNativeThemeGTK.h +++ b/widget/gtk/nsNativeThemeGTK.h @@ -59,10 +59,9 @@ class nsNativeThemeGTK final : public mozilla::widget::Theme { enum class NonNative { No, Always, BecauseColorMismatch }; NonNative IsWidgetNonNative(nsIFrame*, StyleAppearance); - NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, - mozilla::LayoutDeviceIntSize* aResult, - bool* aIsOverridable) override; + mozilla::LayoutDeviceIntSize GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aAppearance) override; NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, StyleAppearance aAppearance, nsAtom* aAttribute, bool* aShouldRepaint, diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index 549539b04a9f..c9c839bb272f 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -2097,31 +2097,22 @@ bool nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, return false; } -NS_IMETHODIMP -nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, - nsIFrame* aFrame, - StyleAppearance aAppearance, - LayoutDeviceIntSize* aResult, - bool* aIsOverridable) { +LayoutDeviceIntSize nsNativeThemeWin::GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aAppearance) { if (IsWidgetNonNative(aFrame, aAppearance) == NonNative::Always) { - return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance, - aResult, aIsOverridable); + return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } - aResult->width = aResult->height = 0; - *aIsOverridable = true; - nsresult rv = NS_OK; - mozilla::Maybe themeClass = GetThemeClass(aAppearance); HTHEME theme = NULL; if (!themeClass.isNothing()) { theme = nsUXThemeData::GetTheme(themeClass.value()); } if (!theme) { - rv = ClassicGetMinimumWidgetSize(aFrame, aAppearance, aResult, - aIsOverridable); - ScaleForFrameDPI(aResult, aFrame); - return rv; + auto result = ClassicGetMinimumWidgetSize(aFrame, aAppearance); + ScaleForFrameDPI(&result, aFrame); + return result; } switch (aAppearance) { @@ -2142,13 +2133,13 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, case StyleAppearance::Menuitemtext: case StyleAppearance::MozWinGlass: case StyleAppearance::MozWinBorderlessGlass: - return NS_OK; // Don't worry about it. + return {}; // Don't worry about it. default: break; } if (aAppearance == StyleAppearance::Menuitem && IsTopLevelMenu(aFrame)) { - return NS_OK; // Don't worry about it for top level menus + return {}; // Don't worry about it for top level menus } // Call GetSystemMetrics to determine size for WinXP scrollbars @@ -2157,20 +2148,18 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, THEMESIZE sizeReq = TS_TRUE; // Best-fit size switch (aAppearance) { case StyleAppearance::MozMenulistArrowButton: { - rv = ClassicGetMinimumWidgetSize(aFrame, aAppearance, aResult, - aIsOverridable); - ScaleForFrameDPI(aResult, aFrame); - return rv; + auto result = ClassicGetMinimumWidgetSize(aFrame, aAppearance); + ScaleForFrameDPI(&result, aFrame); + return result; } case StyleAppearance::Menuitem: case StyleAppearance::Checkmenuitem: case StyleAppearance::Radiomenuitem: if (!IsTopLevelMenu(aFrame)) { SIZE gutterSize(GetCachedGutterSize(theme)); - aResult->width = gutterSize.cx; - aResult->height = gutterSize.cy; - ScaleForFrameDPI(aResult, aFrame); - return rv; + LayoutDeviceIntSize result(gutterSize.cx, gutterSize.cy); + ScaleForFrameDPI(&result, aFrame); + return result; } break; @@ -2178,15 +2167,13 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, case StyleAppearance::Menucheckbox: case StyleAppearance::Menuradio: { SIZE boxSize(GetCachedGutterSize(theme)); - aResult->width = boxSize.cx + 2; - aResult->height = boxSize.cy; - *aIsOverridable = false; - ScaleForFrameDPI(aResult, aFrame); - return rv; + LayoutDeviceIntSize result(boxSize.cx + 2, boxSize.cy); + ScaleForFrameDPI(&result, aFrame); + return result; } case StyleAppearance::Menuitemtext: - return NS_OK; + return {}; case StyleAppearance::ProgressBar: // Best-fit size for progress meters is too large for most @@ -2196,28 +2183,24 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, break; case StyleAppearance::Resizer: - *aIsOverridable = false; break; case StyleAppearance::RangeThumb: { - *aIsOverridable = false; - if (IsRangeHorizontal(aFrame)) { - aResult->width = 12; - aResult->height = 20; - } else { - aResult->width = 20; - aResult->height = 12; + LayoutDeviceIntSize result(12, 20); + if (!IsRangeHorizontal(aFrame)) { + std::swap(result.width, result.height); } - ScaleForFrameDPI(aResult, aFrame); - return rv; + ScaleForFrameDPI(&result, aFrame); + return result; } - case StyleAppearance::Separator: + case StyleAppearance::Separator: { // that's 2px left margin, 2px right margin and 2px separator // (the margin is drawn as part of the separator, though) - aResult->width = 6; - ScaleForFrameDPI(aResult, aFrame); - return rv; + LayoutDeviceIntSize result(6, 0); + ScaleForFrameDPI(&result, aFrame); + return result; + } case StyleAppearance::Button: // We should let HTML buttons shrink to their min size. @@ -2230,41 +2213,36 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, break; case StyleAppearance::MozWindowButtonMaximize: - case StyleAppearance::MozWindowButtonRestore: + case StyleAppearance::MozWindowButtonRestore: { // The only way to get accurate titlebar button info is to query a // window w/buttons when it's visible. nsWindow takes care of this and // stores that info in nsUXThemeData. - aResult->width = - nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE).cx; - aResult->height = - nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE).cy; - AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE); - *aIsOverridable = false; - return rv; + SIZE sz = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE); + LayoutDeviceIntSize result(sz.cx, sz.cy); + AddPaddingRect(&result, CAPTIONBUTTON_RESTORE); + return result; + } - case StyleAppearance::MozWindowButtonMinimize: - aResult->width = - nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE).cx; - aResult->height = - nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE).cy; - AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE); - *aIsOverridable = false; - return rv; + case StyleAppearance::MozWindowButtonMinimize: { + SIZE sz = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE); + LayoutDeviceIntSize result(sz.cx, sz.cy); + AddPaddingRect(&result, CAPTIONBUTTON_MINIMIZE); + return result; + } - case StyleAppearance::MozWindowButtonClose: - aResult->width = - nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE).cx; - aResult->height = - nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE).cy; - AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE); - *aIsOverridable = false; - return rv; + case StyleAppearance::MozWindowButtonClose: { + SIZE sz = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE); + LayoutDeviceIntSize result(sz.cx, sz.cy); + AddPaddingRect(&result, CAPTIONBUTTON_CLOSE); + return result; + } case StyleAppearance::MozWindowTitlebar: - case StyleAppearance::MozWindowTitlebarMaximized: - aResult->height = GetSystemMetrics(SM_CYCAPTION); - aResult->height += GetSystemMetrics(SM_CYFRAME); - aResult->height += GetSystemMetrics(SM_CXPADDEDBORDER); + case StyleAppearance::MozWindowTitlebarMaximized: { + LayoutDeviceIntSize result; + result.height = GetSystemMetrics(SM_CYCAPTION); + result.height += GetSystemMetrics(SM_CYFRAME); + result.height += GetSystemMetrics(SM_CXPADDEDBORDER); // On Win8.1, we don't want this scaling, because Windows doesn't scale // the non-client area of the window, and we can end up with ugly overlap // of the window frame controls into the tab bar or content area. But on @@ -2272,48 +2250,47 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, // better if we do apply this scaling (particularly with themes such as // DevEdition; see bug 1267636). if (IsWin10OrLater()) { - ScaleForFrameDPI(aResult, aFrame); + ScaleForFrameDPI(&result, aFrame); } - *aIsOverridable = false; - return rv; + return result; + } case StyleAppearance::MozWindowButtonBox: - case StyleAppearance::MozWindowButtonBoxMaximized: + case StyleAppearance::MozWindowButtonBoxMaximized: { if (gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) { - aResult->width = nsUXThemeData::GetCommandButtonBoxMetrics().cx; - aResult->height = nsUXThemeData::GetCommandButtonBoxMetrics().cy - - GetSystemMetrics(SM_CYFRAME) - - GetSystemMetrics(SM_CXPADDEDBORDER); + SIZE sz = nsUXThemeData::GetCommandButtonBoxMetrics(); + LayoutDeviceIntSize result(sz.cx, + sz.cy - GetSystemMetrics(SM_CYFRAME) - + GetSystemMetrics(SM_CXPADDEDBORDER)); if (aAppearance == StyleAppearance::MozWindowButtonBoxMaximized) { - aResult->width += 1; - aResult->height -= 2; + result.width += 1; + result.height -= 2; } - *aIsOverridable = false; - return rv; + return result; } break; + } case StyleAppearance::MozWindowFrameLeft: case StyleAppearance::MozWindowFrameRight: case StyleAppearance::MozWindowFrameBottom: - aResult->width = GetSystemMetrics(SM_CXFRAME); - aResult->height = GetSystemMetrics(SM_CYFRAME); - *aIsOverridable = false; - return rv; + return {GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME)}; default: break; } int32_t part, state; - rv = GetThemePartAndState(aFrame, aAppearance, part, state); - if (NS_FAILED(rv)) return rv; + nsresult rv = GetThemePartAndState(aFrame, aAppearance, part, state); + if (NS_FAILED(rv)) { + return {}; + } + LayoutDeviceIntSize result; rv = GetCachedMinimumWidgetSize(aFrame, theme, themeClass.value(), - aAppearance, part, state, sizeReq, aResult); - - ScaleForFrameDPI(aResult, aFrame); - return rv; + aAppearance, part, state, sizeReq, &result); + ScaleForFrameDPI(&result, aFrame); + return result; } NS_IMETHODIMP @@ -2677,41 +2654,37 @@ bool nsNativeThemeWin::ClassicGetWidgetPadding(nsDeviceContext* aContext, } } -nsresult nsNativeThemeWin::ClassicGetMinimumWidgetSize( - nsIFrame* aFrame, StyleAppearance aAppearance, LayoutDeviceIntSize* aResult, - bool* aIsOverridable) { - (*aResult).width = (*aResult).height = 0; - *aIsOverridable = true; +LayoutDeviceIntSize nsNativeThemeWin::ClassicGetMinimumWidgetSize( + nsIFrame* aFrame, StyleAppearance aAppearance) { + LayoutDeviceIntSize result; switch (aAppearance) { case StyleAppearance::Radio: case StyleAppearance::Checkbox: - (*aResult).width = (*aResult).height = 13; + result.width = result.height = 13; break; case StyleAppearance::Menucheckbox: case StyleAppearance::Menuradio: case StyleAppearance::Menuarrow: - (*aResult).width = ::GetSystemMetrics(SM_CXMENUCHECK); - (*aResult).height = ::GetSystemMetrics(SM_CYMENUCHECK); + result.width = ::GetSystemMetrics(SM_CXMENUCHECK); + result.height = ::GetSystemMetrics(SM_CYMENUCHECK); break; case StyleAppearance::SpinnerUpbutton: case StyleAppearance::SpinnerDownbutton: - (*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL); - (*aResult).height = 8; // No good metrics available for this - *aIsOverridable = false; + result.width = ::GetSystemMetrics(SM_CXVSCROLL); + result.height = 8; // No good metrics available for this break; case StyleAppearance::RangeThumb: { if (IsRangeHorizontal(aFrame)) { - (*aResult).width = 12; - (*aResult).height = 20; + result.width = 12; + result.height = 20; } else { - (*aResult).width = 20; - (*aResult).height = 12; + result.width = 20; + result.height = 12; } - *aIsOverridable = false; break; } case StyleAppearance::MozMenulistArrowButton: - (*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL); + result.width = ::GetSystemMetrics(SM_CXVSCROLL); break; case StyleAppearance::Menulist: case StyleAppearance::MenulistButton: @@ -2736,60 +2709,55 @@ nsresult nsNativeThemeWin::ClassicGetMinimumWidgetSize( NONCLIENTMETRICS nc; nc.cbSize = sizeof(nc); if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nc), &nc, 0)) - (*aResult).width = (*aResult).height = - abs(nc.lfStatusFont.lfHeight) + 4; + result.width = result.height = abs(nc.lfStatusFont.lfHeight) + 4; else - (*aResult).width = (*aResult).height = 15; - *aIsOverridable = false; + result.width = result.height = 15; break; } case StyleAppearance::Menuseparator: { - aResult->width = 0; - aResult->height = 10; + result.width = 0; + result.height = 10; break; } case StyleAppearance::MozWindowTitlebarMaximized: case StyleAppearance::MozWindowTitlebar: - aResult->height = GetSystemMetrics(SM_CYCAPTION); - aResult->height += GetSystemMetrics(SM_CYFRAME); - aResult->width = 0; + result.height = + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME); break; case StyleAppearance::MozWindowFrameLeft: case StyleAppearance::MozWindowFrameRight: - aResult->width = GetSystemMetrics(SM_CXFRAME); - aResult->height = 0; + result.width = GetSystemMetrics(SM_CXFRAME); break; case StyleAppearance::MozWindowFrameBottom: - aResult->height = GetSystemMetrics(SM_CYFRAME); - aResult->width = 0; + result.height = GetSystemMetrics(SM_CYFRAME); break; case StyleAppearance::MozWindowButtonClose: case StyleAppearance::MozWindowButtonMinimize: case StyleAppearance::MozWindowButtonMaximize: case StyleAppearance::MozWindowButtonRestore: - aResult->width = GetSystemMetrics(SM_CXSIZE); - aResult->height = GetSystemMetrics(SM_CYSIZE); + result.width = GetSystemMetrics(SM_CXSIZE); + result.height = GetSystemMetrics(SM_CYSIZE); // XXX I have no idea why these caption metrics are always off, // but they are. - aResult->width -= 2; - aResult->height -= 4; + result.width -= 2; + result.height -= 4; if (aAppearance == StyleAppearance::MozWindowButtonMinimize) { - AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE); + AddPaddingRect(&result, CAPTIONBUTTON_MINIMIZE); } else if (aAppearance == StyleAppearance::MozWindowButtonMaximize || aAppearance == StyleAppearance::MozWindowButtonRestore) { - AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE); + AddPaddingRect(&result, CAPTIONBUTTON_RESTORE); } else if (aAppearance == StyleAppearance::MozWindowButtonClose) { - AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE); + AddPaddingRect(&result, CAPTIONBUTTON_CLOSE); } break; default: - return NS_ERROR_FAILURE; + break; } - return NS_OK; + return result; } nsresult nsNativeThemeWin::ClassicGetThemePartAndState( diff --git a/widget/windows/nsNativeThemeWin.h b/widget/windows/nsNativeThemeWin.h index 9148f28c71c4..f56e5f9bc70e 100644 --- a/widget/windows/nsNativeThemeWin.h +++ b/widget/windows/nsNativeThemeWin.h @@ -61,10 +61,9 @@ class nsNativeThemeWin : public Theme { StyleAppearance aAppearance, nsRect* aOverflowRect) override; - NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, - StyleAppearance aAppearance, - LayoutDeviceIntSize* aResult, - bool* aIsOverridable) override; + LayoutDeviceIntSize GetMinimumWidgetSize( + nsPresContext* aPresContext, nsIFrame* aFrame, + StyleAppearance aAppearance) override; virtual Transparency GetWidgetTransparency( nsIFrame* aFrame, StyleAppearance aAppearance) override; @@ -114,10 +113,8 @@ class nsNativeThemeWin : public Theme { bool ClassicGetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame, StyleAppearance aAppearance, LayoutDeviceIntMargin* aResult); - nsresult ClassicGetMinimumWidgetSize(nsIFrame* aFrame, - StyleAppearance aAppearance, - LayoutDeviceIntSize* aResult, - bool* aIsOverridable); + LayoutDeviceIntSize ClassicGetMinimumWidgetSize(nsIFrame* aFrame, + StyleAppearance aAppearance); bool ClassicThemeSupportsWidget(nsIFrame* aFrame, StyleAppearance aAppearance); void DrawCheckedRect(HDC hdc, const RECT& rc, int32_t fore, int32_t back,