From 7fa52c38842f0d49c521ef19b2946ee05506f086 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Tue, 16 Jun 2015 11:21:03 +0000 Subject: [PATCH] Bug 1174450 part 5 - Remove the duplicated min/max calculation in AddIntrinsicSizeOffset, pass a pointer to the calculated absolute values, if any, from IntrinsicForContainer instead. r=jfkthame --- layout/base/nsLayoutUtils.cpp | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 140781a026d8..24d1b8b85e4a 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4328,7 +4328,9 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext, nscoord aContentSize, nscoord aContentMinSize, const nsStyleCoord& aStyleSize, + const nscoord* aFixedMinSize, const nsStyleCoord& aStyleMinSize, + const nscoord* aFixedMaxSize, const nsStyleCoord& aStyleMaxSize, uint32_t aFlags, WritingMode aContainerWM) @@ -4402,24 +4404,8 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext, result = AddPercents(aType, result, pctTotal); } - nscoord maxSize; - bool haveFixedMaxSize = GetAbsoluteCoord(aStyleMaxSize, maxSize); - nscoord minSize; - - // Treat "min-width: auto" as 0. - bool haveFixedMinSize; - if (eStyleUnit_Auto == aStyleMinSize.GetUnit()) { - // NOTE: Technically, "auto" is supposed to behave like "min-content" on - // flex items. However, we don't need to worry about that here, because - // flex items' min-sizes are intentionally ignored until the flex - // container explicitly considers them during space distribution. - minSize = 0; - haveFixedMinSize = true; - } else { - haveFixedMinSize = GetAbsoluteCoord(aStyleMinSize, minSize); - } - - if (haveFixedMaxSize || + nscoord maxSize = aFixedMaxSize ? *aFixedMaxSize : 0; + if (aFixedMaxSize || GetIntrinsicCoord(aStyleMaxSize, aRenderingContext, aFrame, PROP_MAX_WIDTH, maxSize)) { maxSize = AddPercents(aType, maxSize + coordOutsideSize, pctOutsideSize); @@ -4427,7 +4413,8 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext, result = maxSize; } - if (haveFixedMinSize || + nscoord minSize = aFixedMinSize ? *aFixedMinSize : 0; + if (aFixedMinSize || GetIntrinsicCoord(aStyleMinSize, aRenderingContext, aFrame, PROP_MIN_WIDTH, minSize)) { minSize = AddPercents(aType, minSize + coordOutsideSize, pctOutsideSize); @@ -4655,8 +4642,11 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext, aFrame->IntrinsicISizeOffsets(aRenderingContext); result = AddIntrinsicSizeOffset(aRenderingContext, aFrame, offsets, aType, boxSizing, result, min, styleISize, - styleMinISize, styleMaxISize, aFlags, - wm); + haveFixedMinISize ? &minISize : nullptr, + styleMinISize, + haveFixedMaxISize ? &maxISize : nullptr, + styleMaxISize, + aFlags, wm); #ifdef DEBUG_INTRINSIC_WIDTH nsFrame::IndentBy(stderr, gNoiseIndent);