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