Bug 1300369 part 2 - Make nsLayoutUtils::IntrinsicForAxis handle margin-box min-size clamping. r=dholbert

This commit is contained in:
Mats Palmgren 2016-11-05 02:57:06 +01:00
Родитель d523cbcf73
Коммит 1ce5803c3a
2 изменённых файлов: 29 добавлений и 6 удалений

Просмотреть файл

@ -4911,7 +4911,8 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis,
nsRenderingContext* aRenderingContext,
nsIFrame* aFrame,
IntrinsicISizeType aType,
uint32_t aFlags)
uint32_t aFlags,
nscoord aMarginBoxMinSizeClamp)
{
NS_PRECONDITION(aFrame, "null frame");
NS_PRECONDITION(aFrame->GetParent(),
@ -4993,11 +4994,22 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis,
// For -moz-max-content and -moz-min-content, we handle them like
// specified widths, but ignore box-sizing.
boxSizing = StyleBoxSizing::Content;
if (aMarginBoxMinSizeClamp != NS_MAXSIZE &&
styleISize.GetIntValue() == NS_STYLE_WIDTH_MIN_CONTENT) {
// We need |result| to be the 'min-content size' for the clamping below.
result = aFrame->GetMinISize(aRenderingContext);
}
} else if (!styleISize.ConvertsToLength() &&
!(haveFixedMinISize && haveFixedMaxISize && maxISize <= minISize)) {
#ifdef DEBUG_INTRINSIC_WIDTH
++gNoiseIndent;
#endif
if (aType != MIN_ISIZE) {
// At this point, |styleISize| is auto/-moz-fit-content/-moz-available or
// has a percentage. The intrinisic size for those under a max-content
// constraint is the max-content contribution which we shouldn't clamp.
aMarginBoxMinSizeClamp = NS_MAXSIZE;
}
if (MOZ_UNLIKELY(aAxis != ourInlineAxis)) {
IntrinsicSize intrinsicSize = aFrame->GetIntrinsicSize();
const nsStyleCoord intrinsicBCoord =
@ -5115,6 +5127,7 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis,
nsIFrame::IntrinsicISizeOffsetData offsets =
MOZ_LIKELY(aAxis == ourInlineAxis) ? aFrame->IntrinsicISizeOffsets()
: aFrame->IntrinsicBSizeOffsets();
nscoord contentBoxSize = result;
result = AddIntrinsicSizeOffset(aRenderingContext, aFrame, offsets, aType,
boxSizing, result, min, styleISize,
haveFixedMinISize ? &minISize : nullptr,
@ -5122,6 +5135,11 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis,
haveFixedMaxISize ? &maxISize : nullptr,
styleMaxISize,
aFlags, aAxis);
nscoord overflow = result - aMarginBoxMinSizeClamp;
if (MOZ_UNLIKELY(overflow > 0)) {
nscoord newContentBoxSize = std::max(nscoord(0), contentBoxSize - overflow);
result -= contentBoxSize - newContentBoxSize;
}
#ifdef DEBUG_INTRINSIC_WIDTH
nsFrame::IndentBy(stderr, gNoiseIndent);

Просмотреть файл

@ -1373,6 +1373,9 @@ public:
* width, its 'width', 'min-width', and 'max-width' properties (or 'height'
* variations if that's what matches aAxis) and its padding, border and margin
* in the corresponding dimension.
* @param aMarginBoxMinSizeClamp make the result fit within this margin-box
* size by reducing the *content size* (flooring at zero). This is used for:
* https://drafts.csswg.org/css-grid/#min-size-auto
*/
enum class IntrinsicISizeType { MIN_ISIZE, PREF_ISIZE };
static const auto MIN_ISIZE = IntrinsicISizeType::MIN_ISIZE;
@ -1383,11 +1386,13 @@ public:
MIN_INTRINSIC_ISIZE = 0x04, // use min-width/height instead of width/height
ADD_PERCENTS = 0x08, // apply AddPercents also for MIN_ISIZE
};
static nscoord IntrinsicForAxis(mozilla::PhysicalAxis aAxis,
nsRenderingContext* aRenderingContext,
nsIFrame* aFrame,
IntrinsicISizeType aType,
uint32_t aFlags = 0);
static nscoord
IntrinsicForAxis(mozilla::PhysicalAxis aAxis,
nsRenderingContext* aRenderingContext,
nsIFrame* aFrame,
IntrinsicISizeType aType,
uint32_t aFlags = 0,
nscoord aMarginBoxMinSizeClamp = NS_MAXSIZE);
/**
* Calls IntrinsicForAxis with aFrame's parent's inline physical axis.
*/