зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1040582 - Change nsLayoutUtils.cpp's MULDIV Macro to inline function in nsCoord.h. r=dholbert
This commit is contained in:
Родитель
835169b7a8
Коммит
507f505826
|
@ -57,6 +57,14 @@ inline void VERIFY_COORD(nscoord aCoord) {
|
|||
#endif
|
||||
}
|
||||
|
||||
inline nscoord NSCoordMulDiv(nscoord aMult1, nscoord aMult2, nscoord aDiv) {
|
||||
#ifdef NS_COORD_IS_FLOAT
|
||||
return (aMult1 * aMult2 / aDiv);
|
||||
#else
|
||||
return (int64_t(aMult1) * int64_t(aMult2) / int64_t(aDiv));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline nscoord NSToCoordRound(float aValue)
|
||||
{
|
||||
#if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__) && !defined(__clang__)
|
||||
|
|
|
@ -3706,8 +3706,6 @@ GetIntrinsicCoord(const nsStyleCoord& aStyle,
|
|||
static int32_t gNoiseIndent = 0;
|
||||
#endif
|
||||
|
||||
#define MULDIV(a,b,c) (nscoord(int64_t(a) * int64_t(b) / int64_t(c)))
|
||||
|
||||
/* static */ nscoord
|
||||
nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext,
|
||||
nsIFrame *aFrame,
|
||||
|
@ -3847,13 +3845,13 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext,
|
|||
if (GetAbsoluteCoord(styleHeight, h) ||
|
||||
GetPercentHeight(styleHeight, aFrame, h)) {
|
||||
h = std::max(0, h - heightTakenByBoxSizing);
|
||||
result = MULDIV(h, ratio.width, ratio.height);
|
||||
result = NSCoordMulDiv(h, ratio.width, ratio.height);
|
||||
}
|
||||
|
||||
if (GetAbsoluteCoord(styleMaxHeight, h) ||
|
||||
GetPercentHeight(styleMaxHeight, aFrame, h)) {
|
||||
h = std::max(0, h - heightTakenByBoxSizing);
|
||||
nscoord maxWidth = MULDIV(h, ratio.width, ratio.height);
|
||||
nscoord maxWidth = NSCoordMulDiv(h, ratio.width, ratio.height);
|
||||
if (maxWidth < result)
|
||||
result = maxWidth;
|
||||
}
|
||||
|
@ -3861,7 +3859,7 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext,
|
|||
if (GetAbsoluteCoord(styleMinHeight, h) ||
|
||||
GetPercentHeight(styleMinHeight, aFrame, h)) {
|
||||
h = std::max(0, h - heightTakenByBoxSizing);
|
||||
nscoord minWidth = MULDIV(h, ratio.width, ratio.height);
|
||||
nscoord minWidth = NSCoordMulDiv(h, ratio.width, ratio.height);
|
||||
if (minWidth > result)
|
||||
result = minWidth;
|
||||
}
|
||||
|
@ -4318,7 +4316,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(WritingMode aWM,
|
|||
if (hasIntrinsicISize) {
|
||||
tentISize = intrinsicISize;
|
||||
} else if (hasIntrinsicBSize && logicalRatio.BSize(aWM) > 0) {
|
||||
tentISize = MULDIV(intrinsicBSize, logicalRatio.ISize(aWM), logicalRatio.BSize(aWM));
|
||||
tentISize = NSCoordMulDiv(intrinsicBSize, logicalRatio.ISize(aWM), logicalRatio.BSize(aWM));
|
||||
} else if (logicalRatio.ISize(aWM) > 0) {
|
||||
tentISize = aCBSize.ISize(aWM) - boxSizingToMarginEdgeISize; // XXX scrollbar?
|
||||
if (tentISize < 0) tentISize = 0;
|
||||
|
@ -4329,7 +4327,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(WritingMode aWM,
|
|||
if (hasIntrinsicBSize) {
|
||||
tentBSize = intrinsicBSize;
|
||||
} else if (logicalRatio.ISize(aWM) > 0) {
|
||||
tentBSize = MULDIV(tentISize, logicalRatio.BSize(aWM), logicalRatio.ISize(aWM));
|
||||
tentBSize = NSCoordMulDiv(tentISize, logicalRatio.BSize(aWM), logicalRatio.ISize(aWM));
|
||||
} else {
|
||||
tentBSize = nsPresContext::CSSPixelsToAppUnits(150);
|
||||
}
|
||||
|
@ -4348,7 +4346,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(WritingMode aWM,
|
|||
// 'auto' iSize, non-'auto' bSize
|
||||
bSize = NS_CSS_MINMAX(bSize, minBSize, maxBSize);
|
||||
if (logicalRatio.BSize(aWM) > 0) {
|
||||
iSize = MULDIV(bSize, logicalRatio.ISize(aWM), logicalRatio.BSize(aWM));
|
||||
iSize = NSCoordMulDiv(bSize, logicalRatio.ISize(aWM), logicalRatio.BSize(aWM));
|
||||
} else if (hasIntrinsicISize) {
|
||||
iSize = intrinsicISize;
|
||||
} else {
|
||||
|
@ -4363,7 +4361,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(WritingMode aWM,
|
|||
// non-'auto' iSize, 'auto' bSize
|
||||
iSize = NS_CSS_MINMAX(iSize, minISize, maxISize);
|
||||
if (logicalRatio.ISize(aWM) > 0) {
|
||||
bSize = MULDIV(iSize, logicalRatio.BSize(aWM), logicalRatio.ISize(aWM));
|
||||
bSize = NSCoordMulDiv(iSize, logicalRatio.BSize(aWM), logicalRatio.ISize(aWM));
|
||||
} else if (hasIntrinsicBSize) {
|
||||
bSize = intrinsicBSize;
|
||||
} else {
|
||||
|
@ -4399,10 +4397,10 @@ nsLayoutUtils::ComputeAutoSizeWithIntrinsicDimensions(nscoord minWidth, nscoord
|
|||
widthAtMaxHeight, widthAtMinHeight;
|
||||
|
||||
if (tentWidth > 0) {
|
||||
heightAtMaxWidth = MULDIV(maxWidth, tentHeight, tentWidth);
|
||||
heightAtMaxWidth = NSCoordMulDiv(maxWidth, tentHeight, tentWidth);
|
||||
if (heightAtMaxWidth < minHeight)
|
||||
heightAtMaxWidth = minHeight;
|
||||
heightAtMinWidth = MULDIV(minWidth, tentHeight, tentWidth);
|
||||
heightAtMinWidth = NSCoordMulDiv(minWidth, tentHeight, tentWidth);
|
||||
if (heightAtMinWidth > maxHeight)
|
||||
heightAtMinWidth = maxHeight;
|
||||
} else {
|
||||
|
@ -4410,10 +4408,10 @@ nsLayoutUtils::ComputeAutoSizeWithIntrinsicDimensions(nscoord minWidth, nscoord
|
|||
}
|
||||
|
||||
if (tentHeight > 0) {
|
||||
widthAtMaxHeight = MULDIV(maxHeight, tentWidth, tentHeight);
|
||||
widthAtMaxHeight = NSCoordMulDiv(maxHeight, tentWidth, tentHeight);
|
||||
if (widthAtMaxHeight < minWidth)
|
||||
widthAtMaxHeight = minWidth;
|
||||
widthAtMinHeight = MULDIV(minHeight, tentWidth, tentHeight);
|
||||
widthAtMinHeight = NSCoordMulDiv(minHeight, tentWidth, tentHeight);
|
||||
if (widthAtMinHeight > maxWidth)
|
||||
widthAtMinHeight = maxWidth;
|
||||
} else {
|
||||
|
|
|
@ -1125,10 +1125,6 @@ CrossSizeToUseWithRatio(const FlexItem& aFlexItem,
|
|||
return NS_AUTOHEIGHT;
|
||||
}
|
||||
|
||||
// XXX This macro shamelessly stolen from nsLayoutUtils.cpp.
|
||||
// (Maybe it should be exposed via a nsLayoutUtils method?)
|
||||
#define MULDIV(a,b,c) (nscoord(int64_t(a) * int64_t(b) / int64_t(c)))
|
||||
|
||||
// Convenience function; returns a main-size, given a cross-size and an
|
||||
// intrinsic ratio. The intrinsic ratio must not have 0 in its cross-axis
|
||||
// component (or else we'll divide by 0).
|
||||
|
@ -1142,10 +1138,10 @@ MainSizeFromAspectRatio(nscoord aCrossSize,
|
|||
|
||||
if (IsAxisHorizontal(aAxisTracker.GetCrossAxis())) {
|
||||
// cross axis horiz --> aCrossSize is a width. Converting to height.
|
||||
return MULDIV(aCrossSize, aIntrinsicRatio.height, aIntrinsicRatio.width);
|
||||
return NSCoordMulDiv(aCrossSize, aIntrinsicRatio.height, aIntrinsicRatio.width);
|
||||
}
|
||||
// cross axis vert --> aCrossSize is a height. Converting to width.
|
||||
return MULDIV(aCrossSize, aIntrinsicRatio.width, aIntrinsicRatio.height);
|
||||
return NSCoordMulDiv(aCrossSize, aIntrinsicRatio.width, aIntrinsicRatio.height);
|
||||
}
|
||||
|
||||
// Partially resolves "min-[width|height]:auto" and returns the resulting value.
|
||||
|
|
Загрузка…
Ссылка в новой задаче