From 987c2fde4bbecf6b40949630bee5841b07d18766 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Thu, 16 Mar 2017 15:24:56 +0100 Subject: [PATCH] Bug 1335806 part 1 - Move the intrinsic size/ratio calculations up a bit (idempotent patch). r=dholbert MozReview-Commit-ID: 5FWpfyiN0Qa --- layout/generic/nsFrame.cpp | 76 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 4c6511dda5b0..1653a6fe4116 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -5197,6 +5197,43 @@ nsFrame::ComputeSizeWithIntrinsicDimensions(nsRenderingContext* aRenderingConte Stretch stretchI = eNoStretch; // stretch behavior in the inline axis Stretch stretchB = eNoStretch; // stretch behavior in the block axis + const bool isVertical = aWM.IsVertical(); + const nsStyleCoord& isizeCoord = + isVertical ? aIntrinsicSize.height : aIntrinsicSize.width; + const nsStyleCoord& bsizeCoord = + isVertical ? aIntrinsicSize.width : aIntrinsicSize.height; + + bool hasIntrinsicISize, hasIntrinsicBSize; + nscoord intrinsicISize, intrinsicBSize; + + if (isizeCoord.GetUnit() == eStyleUnit_Coord) { + hasIntrinsicISize = true; + intrinsicISize = isizeCoord.GetCoordValue(); + if (intrinsicISize < 0) + intrinsicISize = 0; + } else { + NS_ASSERTION(isizeCoord.GetUnit() == eStyleUnit_None, + "unexpected unit"); + hasIntrinsicISize = false; + intrinsicISize = 0; + } + + if (bsizeCoord.GetUnit() == eStyleUnit_Coord) { + hasIntrinsicBSize = true; + intrinsicBSize = bsizeCoord.GetCoordValue(); + if (intrinsicBSize < 0) + intrinsicBSize = 0; + } else { + NS_ASSERTION(bsizeCoord.GetUnit() == eStyleUnit_None, + "unexpected unit"); + hasIntrinsicBSize = false; + intrinsicBSize = 0; + } + + NS_ASSERTION(aIntrinsicRatio.width >= 0 && aIntrinsicRatio.height >= 0, + "Intrinsic ratio has a negative component!"); + LogicalSize logicalRatio(aWM, aIntrinsicRatio); + if (!isAutoISize) { iSize = ComputeISizeValue(aRenderingContext, aCBSize.ISize(aWM), boxSizingAdjust.ISize(aWM), @@ -5316,48 +5353,9 @@ nsFrame::ComputeSizeWithIntrinsicDimensions(nsRenderingContext* aRenderingConte minBSize = 0; } - // Resolve percentage intrinsic iSize/bSize as necessary: - NS_ASSERTION(aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE, "Our containing block must not have unconstrained inline-size!"); - const bool isVertical = aWM.IsVertical(); - const nsStyleCoord& isizeCoord = - isVertical ? aIntrinsicSize.height : aIntrinsicSize.width; - const nsStyleCoord& bsizeCoord = - isVertical ? aIntrinsicSize.width : aIntrinsicSize.height; - - bool hasIntrinsicISize, hasIntrinsicBSize; - nscoord intrinsicISize, intrinsicBSize; - - if (isizeCoord.GetUnit() == eStyleUnit_Coord) { - hasIntrinsicISize = true; - intrinsicISize = isizeCoord.GetCoordValue(); - if (intrinsicISize < 0) - intrinsicISize = 0; - } else { - NS_ASSERTION(isizeCoord.GetUnit() == eStyleUnit_None, - "unexpected unit"); - hasIntrinsicISize = false; - intrinsicISize = 0; - } - - if (bsizeCoord.GetUnit() == eStyleUnit_Coord) { - hasIntrinsicBSize = true; - intrinsicBSize = bsizeCoord.GetCoordValue(); - if (intrinsicBSize < 0) - intrinsicBSize = 0; - } else { - NS_ASSERTION(bsizeCoord.GetUnit() == eStyleUnit_None, - "unexpected unit"); - hasIntrinsicBSize = false; - intrinsicBSize = 0; - } - - NS_ASSERTION(aIntrinsicRatio.width >= 0 && aIntrinsicRatio.height >= 0, - "Intrinsic ratio has a negative component!"); - LogicalSize logicalRatio(aWM, aIntrinsicRatio); - // Now calculate the used values for iSize and bSize: if (isAutoISize) {