Bug 1793689 - Make GetMinimumWidgetSize work properly on non-XUL flexbox. r=TYLin,layout-reviewers

The XUL behavior in nsBox.cpp is fairly different to what the non-XUL
layout code paths do. In particular, canOverride=false means that the
min-{width,height} properties cannot go under the min widget size of the
widget, but that doesn't mean that intrinsic sizes don't affect the
final size of the widget.

This is very visible if you turn on flex emulation on Windows or macOS,
where the toolbar has an appearance that returns
width=0,height=N,canOverride=false.

With flex emulation we'd collapse the item to be zero-width, which is
not good at all.

The good thing is that this is no longer exposed to the web
(non-native-theme always returns canOverride=true), and our front-end
code doesn't seem to rely on this, so we can just remove support for
canOverride=false.

Differential Revision: https://phabricator.services.mozilla.com/D158608
This commit is contained in:
Emilio Cobos Álvarez
2022-10-05 19:09:29 +00:00
parent 096c0353da
commit 99a3719f8e
18 changed files with 245 additions and 383 deletions

View File

@@ -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 };

View File

@@ -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;
}
}

View File

@@ -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 {

View File

@@ -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, &notUsedCanOverride);
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);
}

View File

@@ -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,17 +1461,8 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
// ... (but don't let that push these min sizes below 0).
widgetMainMinSize = std::max(0, widgetMainMinSize);
widgetCrossMinSize = std::max(0, widgetCrossMinSize);
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.
// 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);
@@ -1484,7 +1472,6 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
crossMinSize = std::max(crossMinSize, widgetCrossMinSize);
crossMaxSize = std::max(crossMaxSize, widgetCrossMinSize);
}
}
// Construct the flex item!
FlexItem* item = aLine.Items().EmplaceBack(
@@ -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();

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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,9 +1837,10 @@ 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;
}

View File

@@ -1504,45 +1504,39 @@ UniquePtr<ScrollbarDrawing> 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(),
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(

View File

@@ -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,

View File

@@ -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(

View File

@@ -18,10 +18,9 @@ class ThemeCocoa : public Theme {
explicit ThemeCocoa(UniquePtr<ScrollbarDrawing>&& 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;

View File

@@ -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;

View File

@@ -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,
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

View File

@@ -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

View File

@@ -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,

View File

@@ -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<nsUXThemeClass> 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);
}
return result;
}
*aIsOverridable = false;
return rv;
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(

View File

@@ -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,