Bug 1914661 Part 1 - Rename NS_CSS_MINMAX, and move it into mozilla namespace. r=dholbert
`NS_CSS_MINMAX` looks like a macro, but it is a function. Let's name it like a function. Differential Revision: https://phabricator.services.mozilla.com/D220021
This commit is contained in:
@@ -5131,7 +5131,7 @@ nsSize nsLayoutUtils::ComputeAutoSizeWithIntrinsicDimensions(
|
|||||||
if (heightAtMinWidth > maxHeight) heightAtMinWidth = maxHeight;
|
if (heightAtMinWidth > maxHeight) heightAtMinWidth = maxHeight;
|
||||||
} else {
|
} else {
|
||||||
heightAtMaxWidth = heightAtMinWidth =
|
heightAtMaxWidth = heightAtMinWidth =
|
||||||
NS_CSS_MINMAX(tentHeight, minHeight, maxHeight);
|
CSSMinMax(tentHeight, minHeight, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tentHeight > 0) {
|
if (tentHeight > 0) {
|
||||||
@@ -5141,7 +5141,7 @@ nsSize nsLayoutUtils::ComputeAutoSizeWithIntrinsicDimensions(
|
|||||||
if (widthAtMinHeight > maxWidth) widthAtMinHeight = maxWidth;
|
if (widthAtMinHeight > maxWidth) widthAtMinHeight = maxWidth;
|
||||||
} else {
|
} else {
|
||||||
widthAtMaxHeight = widthAtMinHeight =
|
widthAtMaxHeight = widthAtMinHeight =
|
||||||
NS_CSS_MINMAX(tentWidth, minWidth, maxWidth);
|
CSSMinMax(tentWidth, minWidth, maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The table at http://www.w3.org/TR/CSS21/visudet.html#min-max-widths :
|
// The table at http://www.w3.org/TR/CSS21/visudet.html#min-max-widths :
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ struct StyleSizeOverrides {
|
|||||||
// than their min-content inline size.
|
// than their min-content inline size.
|
||||||
bool mApplyOverridesVerbatim = false;
|
bool mApplyOverridesVerbatim = false;
|
||||||
};
|
};
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return aValue clamped to [aMinValue, aMaxValue].
|
* @return aValue clamped to [aMinValue, aMaxValue].
|
||||||
@@ -82,20 +81,22 @@ struct StyleSizeOverrides {
|
|||||||
* block-size, it is simpler to use ReflowInput::ApplyMinMaxBSize().
|
* block-size, it is simpler to use ReflowInput::ApplyMinMaxBSize().
|
||||||
* Similarly, there is ReflowInput::ApplyMinMaxISize() for clamping an
|
* Similarly, there is ReflowInput::ApplyMinMaxISize() for clamping an
|
||||||
* inline-size.
|
* inline-size.
|
||||||
* @see http://www.w3.org/TR/CSS21/visudet.html#min-max-widths
|
* @see https://www.w3.org/TR/CSS22/visudet.html#min-max-widths
|
||||||
* @see http://www.w3.org/TR/CSS21/visudet.html#min-max-heights
|
* @see https://www.w3.org/TR/CSS22/visudet.html#min-max-heights
|
||||||
*/
|
*/
|
||||||
template <class NumericType>
|
template <class NumericType>
|
||||||
NumericType NS_CSS_MINMAX(NumericType aValue, NumericType aMinValue,
|
NumericType CSSMinMax(NumericType aValue, NumericType aMinValue,
|
||||||
NumericType aMaxValue) {
|
NumericType aMaxValue) {
|
||||||
NumericType result = aValue;
|
NumericType result = aValue;
|
||||||
if (aMaxValue < result) result = aMaxValue;
|
if (aMaxValue < result) {
|
||||||
if (aMinValue > result) result = aMinValue;
|
result = aMaxValue;
|
||||||
|
}
|
||||||
|
if (aMinValue > result) {
|
||||||
|
result = aMinValue;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
|
|
||||||
// A base class of ReflowInput that computes only the padding,
|
// A base class of ReflowInput that computes only the padding,
|
||||||
// border, and margin, since those values are needed more often.
|
// border, and margin, since those values are needed more often.
|
||||||
struct SizeComputationInput {
|
struct SizeComputationInput {
|
||||||
|
|||||||
@@ -2463,12 +2463,12 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
|
|||||||
bSize = autoSize.height;
|
bSize = autoSize.height;
|
||||||
} else {
|
} else {
|
||||||
// Not honoring an intrinsic ratio: clamp the dimensions independently.
|
// Not honoring an intrinsic ratio: clamp the dimensions independently.
|
||||||
iSize = NS_CSS_MINMAX(tentISize, minISize, maxISize);
|
iSize = CSSMinMax(tentISize, minISize, maxISize);
|
||||||
bSize = NS_CSS_MINMAX(tentBSize, minBSize, maxBSize);
|
bSize = CSSMinMax(tentBSize, minBSize, maxBSize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 'auto' iSize, non-'auto' bSize
|
// 'auto' iSize, non-'auto' bSize
|
||||||
bSize = NS_CSS_MINMAX(bSize, minBSize, maxBSize);
|
bSize = CSSMinMax(bSize, minBSize, maxBSize);
|
||||||
if (stretchI != eStretch) {
|
if (stretchI != eStretch) {
|
||||||
if (aspectRatio) {
|
if (aspectRatio) {
|
||||||
iSize = aspectRatio.ComputeRatioDependentSize(
|
iSize = aspectRatio.ComputeRatioDependentSize(
|
||||||
@@ -2482,12 +2482,12 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
|
|||||||
iSize = fallbackIntrinsicSize.ISize(aWM);
|
iSize = fallbackIntrinsicSize.ISize(aWM);
|
||||||
}
|
}
|
||||||
} // else - leave iSize as is to fill the CB
|
} // else - leave iSize as is to fill the CB
|
||||||
iSize = NS_CSS_MINMAX(iSize, minISize, maxISize);
|
iSize = CSSMinMax(iSize, minISize, maxISize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isAutoBSize) {
|
if (isAutoBSize) {
|
||||||
// non-'auto' iSize, 'auto' bSize
|
// non-'auto' iSize, 'auto' bSize
|
||||||
iSize = NS_CSS_MINMAX(iSize, minISize, maxISize);
|
iSize = CSSMinMax(iSize, minISize, maxISize);
|
||||||
if (stretchB != eStretch) {
|
if (stretchB != eStretch) {
|
||||||
if (aspectRatio) {
|
if (aspectRatio) {
|
||||||
bSize = aspectRatio.ComputeRatioDependentSize(LogicalAxis::Block, aWM,
|
bSize = aspectRatio.ComputeRatioDependentSize(LogicalAxis::Block, aWM,
|
||||||
@@ -2501,12 +2501,12 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
|
|||||||
bSize = fallbackIntrinsicSize.BSize(aWM);
|
bSize = fallbackIntrinsicSize.BSize(aWM);
|
||||||
}
|
}
|
||||||
} // else - leave bSize as is to fill the CB
|
} // else - leave bSize as is to fill the CB
|
||||||
bSize = NS_CSS_MINMAX(bSize, minBSize, maxBSize);
|
bSize = CSSMinMax(bSize, minBSize, maxBSize);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// non-'auto' iSize, non-'auto' bSize
|
// non-'auto' iSize, non-'auto' bSize
|
||||||
iSize = NS_CSS_MINMAX(iSize, minISize, maxISize);
|
iSize = CSSMinMax(iSize, minISize, maxISize);
|
||||||
bSize = NS_CSS_MINMAX(bSize, minBSize, maxBSize);
|
bSize = CSSMinMax(bSize, minBSize, maxBSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -693,7 +693,7 @@ class nsFlexContainerFrame::FlexItem final {
|
|||||||
// Before we've resolved flexible lengths, we keep mMainSize set to
|
// Before we've resolved flexible lengths, we keep mMainSize set to
|
||||||
// the 'hypothetical main size', which is the flex base size, clamped
|
// the 'hypothetical main size', which is the flex base size, clamped
|
||||||
// to the [min,max] range:
|
// to the [min,max] range:
|
||||||
mMainSize = NS_CSS_MINMAX(mFlexBaseSize, mMainMinSize, mMainMaxSize);
|
mMainSize = CSSMinMax(mFlexBaseSize, mMainMinSize, mMainMaxSize);
|
||||||
|
|
||||||
FLEX_ITEM_LOG(mFrame, "Set flex base size: %d, hypothetical main size: %d",
|
FLEX_ITEM_LOG(mFrame, "Set flex base size: %d, hypothetical main size: %d",
|
||||||
mFlexBaseSize, mMainSize);
|
mFlexBaseSize, mMainSize);
|
||||||
@@ -3883,7 +3883,7 @@ void FlexItem::ResolveStretchedCrossSize(nscoord aLineCrossSize) {
|
|||||||
// remains as our item's cross-size (clamped to its min/max range).
|
// remains as our item's cross-size (clamped to its min/max range).
|
||||||
nscoord stretchedSize = aLineCrossSize - MarginBorderPaddingSizeInCrossAxis();
|
nscoord stretchedSize = aLineCrossSize - MarginBorderPaddingSizeInCrossAxis();
|
||||||
|
|
||||||
stretchedSize = NS_CSS_MINMAX(stretchedSize, mCrossMinSize, mCrossMaxSize);
|
stretchedSize = CSSMinMax(stretchedSize, mCrossMinSize, mCrossMaxSize);
|
||||||
|
|
||||||
// Update the cross-size & make a note that it's stretched, so we know to
|
// Update the cross-size & make a note that it's stretched, so we know to
|
||||||
// override the reflow input's computed cross-size in our final reflow.
|
// override the reflow input's computed cross-size in our final reflow.
|
||||||
|
|||||||
@@ -4899,8 +4899,8 @@ void nsGridContainerFrame::Grid::PlaceGridItems(
|
|||||||
// This clamping only applies to auto sizes.
|
// This clamping only applies to auto sizes.
|
||||||
if (containBSize &&
|
if (containBSize &&
|
||||||
aSizes.mSize.BSize(aState.mWM) == NS_UNCONSTRAINEDSIZE) {
|
aSizes.mSize.BSize(aState.mWM) == NS_UNCONSTRAINEDSIZE) {
|
||||||
return NS_CSS_MINMAX(*containBSize, aSizes.mMin.BSize(aState.mWM),
|
return CSSMinMax(*containBSize, aSizes.mMin.BSize(aState.mWM),
|
||||||
aSizes.mMax.BSize(aState.mWM));
|
aSizes.mMax.BSize(aState.mWM));
|
||||||
}
|
}
|
||||||
return aSizes.mSize.BSize(aState.mWM);
|
return aSizes.mSize.BSize(aState.mWM);
|
||||||
}();
|
}();
|
||||||
|
|||||||
@@ -6493,8 +6493,8 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
|
|||||||
aWM, aCBSize, boxSizingAdjust,
|
aWM, aCBSize, boxSizingAdjust,
|
||||||
maxBSizeCoord.AsLengthPercentage(), aspectRatio);
|
maxBSizeCoord.AsLengthPercentage(), aspectRatio);
|
||||||
|
|
||||||
result.ISize(aWM) = NS_CSS_MINMAX(result.ISize(aWM), transferredMinISize,
|
result.ISize(aWM) =
|
||||||
transferredMaxISize);
|
CSSMinMax(result.ISize(aWM), transferredMinISize, transferredMaxISize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flex items ignore their min & max sizing properties in their
|
// Flex items ignore their min & max sizing properties in their
|
||||||
|
|||||||
@@ -639,10 +639,9 @@ nsresult nsSplitterFrameInner::MouseDown(Event* aMouseEvent) {
|
|||||||
|
|
||||||
maxSize.width = std::max(maxSize.width, minSize.width);
|
maxSize.width = std::max(maxSize.width, minSize.width);
|
||||||
maxSize.height = std::max(maxSize.height, minSize.height);
|
maxSize.height = std::max(maxSize.height, minSize.height);
|
||||||
prefSize.width =
|
prefSize.width = CSSMinMax(prefSize.width, minSize.width, maxSize.width);
|
||||||
NS_CSS_MINMAX(prefSize.width, minSize.width, maxSize.width);
|
|
||||||
prefSize.height =
|
prefSize.height =
|
||||||
NS_CSS_MINMAX(prefSize.height, minSize.height, maxSize.height);
|
CSSMinMax(prefSize.height, minSize.height, maxSize.height);
|
||||||
|
|
||||||
nsMargin m;
|
nsMargin m;
|
||||||
childBox->StyleMargin()->GetMargin(m);
|
childBox->StyleMargin()->GetMargin(m);
|
||||||
|
|||||||
Reference in New Issue
Block a user