Bug 823483 patch 4 - Make a percentage max-width override a fixed width for replaced element intrinsic size computation. r?dholbert
This just reorders the if-else chain to change which conditions are
tested first. Prior to patch 1, the order didn't matter, but with patch
1, the order does matter, and the order that we happened to have was the
opposite of the one that matches Chromium and Edge.
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4538,28 +4538,30 @@ AddIntrinsicSizeOffset(nsRenderingContex
coordOutsideSize += aOffsets.hMargin;
pctOutsideSize += aOffsets.hPctMargin;
min += coordOutsideSize;
result = NSCoordSaturatingAdd(result, coordOutsideSize);
pctTotal += pctOutsideSize;
nscoord size;
- if (GetAbsoluteCoord(aStyleSize, size) ||
- GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
- PROP_WIDTH, size)) {
+ if (aType == nsLayoutUtils::MIN_ISIZE &&
+ (aStyleSize.HasPercent() ||
+ aStyleMaxSize.HasPercent()) &&
+ aFrame->IsFrameOfType(nsIFrame::eReplacedSizing)) {
+ // A percentage width or max-width on replaced elements means they
+ // can shrink to 0.
+ // Note that if this is max-width, this overrides the fixed-width
+ // rule in the next condition.
+ result = 0; // let |min| handle padding/border/margin
+ } else if (GetAbsoluteCoord(aStyleSize, size) ||
+ GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
+ PROP_WIDTH, size)) {
result = nsLayoutUtils::AddPercents(aType, size + coordOutsideSize,
pctOutsideSize);
- } else if (aType == nsLayoutUtils::MIN_ISIZE &&
- (aStyleSize.HasPercent() ||
- aStyleMaxSize.HasPercent()) &&
- aFrame->IsFrameOfType(nsIFrame::eReplacedSizing)) {
- // A percentage width or max-width on replaced elements means they
- // can shrink to 0.
- result = 0; // let |min| handle padding/border/margin
} else {
// NOTE: We could really do a lot better for percents and for some
// cases of calc() containing percent (certainly including any where
// the coefficient on the percent is positive and there are no max()
// expressions). However, doing better for percents wouldn't be
// backwards compatible.
result = nsLayoutUtils::AddPercents(aType, result, pctTotal);
}