Bug 1434478 part 2 - Stop back-computing percentage padding/margin when the percentage basis is indefinite. Treat them as zero sized instead. r=dholbert
This commit is contained in:
@@ -5051,8 +5051,6 @@ GetDefiniteSize(const nsStyleCoord& aStyle,
|
|||||||
nscoord pb = aIsInlineAxis ? aPercentageBasis.value().ISize(wm)
|
nscoord pb = aIsInlineAxis ? aPercentageBasis.value().ISize(wm)
|
||||||
: aPercentageBasis.value().BSize(wm);
|
: aPercentageBasis.value().BSize(wm);
|
||||||
if (pb == NS_UNCONSTRAINEDSIZE) {
|
if (pb == NS_UNCONSTRAINEDSIZE) {
|
||||||
// XXXmats given that we're calculating an intrinsic size here,
|
|
||||||
// maybe we should back-compute the calc-size using AddPercents?
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*aResult = std::max(0, calc->mLength +
|
*aResult = std::max(0, calc->mLength +
|
||||||
@@ -5296,12 +5294,9 @@ AddIntrinsicSizeOffset(gfxContext* aRenderingContext,
|
|||||||
nscoord result = aContentSize;
|
nscoord result = aContentSize;
|
||||||
nscoord min = aContentMinSize;
|
nscoord min = aContentMinSize;
|
||||||
nscoord coordOutsideSize = 0;
|
nscoord coordOutsideSize = 0;
|
||||||
float pctOutsideSize = 0;
|
|
||||||
float pctTotal = 0.0f;
|
|
||||||
|
|
||||||
if (!(aFlags & nsLayoutUtils::IGNORE_PADDING)) {
|
if (!(aFlags & nsLayoutUtils::IGNORE_PADDING)) {
|
||||||
coordOutsideSize += aOffsets.hPadding;
|
coordOutsideSize += aOffsets.hPadding;
|
||||||
pctOutsideSize += aOffsets.hPctPadding;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coordOutsideSize += aOffsets.hBorder;
|
coordOutsideSize += aOffsets.hBorder;
|
||||||
@@ -5309,21 +5304,15 @@ AddIntrinsicSizeOffset(gfxContext* aRenderingContext,
|
|||||||
if (aBoxSizing == StyleBoxSizing::Border) {
|
if (aBoxSizing == StyleBoxSizing::Border) {
|
||||||
min += coordOutsideSize;
|
min += coordOutsideSize;
|
||||||
result = NSCoordSaturatingAdd(result, coordOutsideSize);
|
result = NSCoordSaturatingAdd(result, coordOutsideSize);
|
||||||
pctTotal += pctOutsideSize;
|
|
||||||
|
|
||||||
coordOutsideSize = 0;
|
coordOutsideSize = 0;
|
||||||
pctOutsideSize = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coordOutsideSize += aOffsets.hMargin;
|
coordOutsideSize += aOffsets.hMargin;
|
||||||
pctOutsideSize += aOffsets.hPctMargin;
|
|
||||||
|
|
||||||
min += coordOutsideSize;
|
min += coordOutsideSize;
|
||||||
result = NSCoordSaturatingAdd(result, coordOutsideSize);
|
result = NSCoordSaturatingAdd(result, coordOutsideSize);
|
||||||
pctTotal += pctOutsideSize;
|
|
||||||
|
|
||||||
const bool shouldAddPercent = aType == nsLayoutUtils::PREF_ISIZE ||
|
|
||||||
(aFlags & nsLayoutUtils::ADD_PERCENTS);
|
|
||||||
nscoord size;
|
nscoord size;
|
||||||
if (aType == nsLayoutUtils::MIN_ISIZE &&
|
if (aType == nsLayoutUtils::MIN_ISIZE &&
|
||||||
(((aStyleSize.HasPercent() || aStyleMaxSize.HasPercent()) &&
|
(((aStyleSize.HasPercent() || aStyleMaxSize.HasPercent()) &&
|
||||||
@@ -5341,18 +5330,6 @@ AddIntrinsicSizeOffset(gfxContext* aRenderingContext,
|
|||||||
GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
|
GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
|
||||||
PROP_WIDTH, size)) {
|
PROP_WIDTH, size)) {
|
||||||
result = size + coordOutsideSize;
|
result = size + coordOutsideSize;
|
||||||
if (shouldAddPercent) {
|
|
||||||
result = nsLayoutUtils::AddPercents(result, pctOutsideSize);
|
|
||||||
}
|
|
||||||
} 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.
|
|
||||||
if (shouldAddPercent) {
|
|
||||||
result = nsLayoutUtils::AddPercents(result, pctTotal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord maxSize = aFixedMaxSize ? *aFixedMaxSize : 0;
|
nscoord maxSize = aFixedMaxSize ? *aFixedMaxSize : 0;
|
||||||
@@ -5360,9 +5337,6 @@ AddIntrinsicSizeOffset(gfxContext* aRenderingContext,
|
|||||||
GetIntrinsicCoord(aStyleMaxSize, aRenderingContext, aFrame,
|
GetIntrinsicCoord(aStyleMaxSize, aRenderingContext, aFrame,
|
||||||
PROP_MAX_WIDTH, maxSize)) {
|
PROP_MAX_WIDTH, maxSize)) {
|
||||||
maxSize += coordOutsideSize;
|
maxSize += coordOutsideSize;
|
||||||
if (shouldAddPercent) {
|
|
||||||
maxSize = nsLayoutUtils::AddPercents(maxSize, pctOutsideSize);
|
|
||||||
}
|
|
||||||
if (result > maxSize) {
|
if (result > maxSize) {
|
||||||
result = maxSize;
|
result = maxSize;
|
||||||
}
|
}
|
||||||
@@ -5373,17 +5347,11 @@ AddIntrinsicSizeOffset(gfxContext* aRenderingContext,
|
|||||||
GetIntrinsicCoord(aStyleMinSize, aRenderingContext, aFrame,
|
GetIntrinsicCoord(aStyleMinSize, aRenderingContext, aFrame,
|
||||||
PROP_MIN_WIDTH, minSize)) {
|
PROP_MIN_WIDTH, minSize)) {
|
||||||
minSize += coordOutsideSize;
|
minSize += coordOutsideSize;
|
||||||
if (shouldAddPercent) {
|
|
||||||
minSize = nsLayoutUtils::AddPercents(minSize, pctOutsideSize);
|
|
||||||
}
|
|
||||||
if (result < minSize) {
|
if (result < minSize) {
|
||||||
result = minSize;
|
result = minSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldAddPercent) {
|
|
||||||
min = nsLayoutUtils::AddPercents(min, pctTotal);
|
|
||||||
}
|
|
||||||
if (result < min) {
|
if (result < min) {
|
||||||
result = min;
|
result = min;
|
||||||
}
|
}
|
||||||
@@ -5400,9 +5368,6 @@ AddIntrinsicSizeOffset(gfxContext* aRenderingContext,
|
|||||||
: devSize.width);
|
: devSize.width);
|
||||||
// GetMinimumWidgetSize() returns a border-box width.
|
// GetMinimumWidgetSize() returns a border-box width.
|
||||||
themeSize += aOffsets.hMargin;
|
themeSize += aOffsets.hMargin;
|
||||||
if (shouldAddPercent) {
|
|
||||||
themeSize = nsLayoutUtils::AddPercents(themeSize, aOffsets.hPctMargin);
|
|
||||||
}
|
|
||||||
if (themeSize > result || !canOverride) {
|
if (themeSize > result || !canOverride) {
|
||||||
result = themeSize;
|
result = themeSize;
|
||||||
}
|
}
|
||||||
@@ -5697,9 +5662,7 @@ nsLayoutUtils::MinSizeContributionForAxis(PhysicalAxis aAxis,
|
|||||||
aWM.IsVertical() ? "vertical" : "horizontal");
|
aWM.IsVertical() ? "vertical" : "horizontal");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Note: this method is only meant for grid/flex items which always
|
// Note: this method is only meant for grid/flex items.
|
||||||
// include percentages in their intrinsic size.
|
|
||||||
aFlags |= nsLayoutUtils::ADD_PERCENTS;
|
|
||||||
const nsStylePosition* const stylePos = aFrame->StylePosition();
|
const nsStylePosition* const stylePos = aFrame->StylePosition();
|
||||||
const nsStyleCoord* style = aAxis == eAxisHorizontal ? &stylePos->mMinWidth
|
const nsStyleCoord* style = aAxis == eAxisHorizontal ? &stylePos->mMinWidth
|
||||||
: &stylePos->mMinHeight;
|
: &stylePos->mMinHeight;
|
||||||
|
|||||||
@@ -1423,7 +1423,6 @@ public:
|
|||||||
IGNORE_PADDING = 0x01,
|
IGNORE_PADDING = 0x01,
|
||||||
BAIL_IF_REFLOW_NEEDED = 0x02, // returns NS_INTRINSIC_WIDTH_UNKNOWN if so
|
BAIL_IF_REFLOW_NEEDED = 0x02, // returns NS_INTRINSIC_WIDTH_UNKNOWN if so
|
||||||
MIN_INTRINSIC_ISIZE = 0x04, // use min-width/height instead of width/height
|
MIN_INTRINSIC_ISIZE = 0x04, // use min-width/height instead of width/height
|
||||||
ADD_PERCENTS = 0x08, // apply AddPercents also for MIN_ISIZE
|
|
||||||
};
|
};
|
||||||
static nscoord
|
static nscoord
|
||||||
IntrinsicForAxis(mozilla::PhysicalAxis aAxis,
|
IntrinsicForAxis(mozilla::PhysicalAxis aAxis,
|
||||||
@@ -1464,23 +1463,6 @@ public:
|
|||||||
IntrinsicISizeType aType,
|
IntrinsicISizeType aType,
|
||||||
uint32_t aFlags = 0);
|
uint32_t aFlags = 0);
|
||||||
|
|
||||||
/**
|
|
||||||
* This function increases an initial intrinsic size, 'aCurrent', according
|
|
||||||
* to the given 'aPercent', such that the size-increase makes up exactly
|
|
||||||
* 'aPercent' percent of the returned value. If 'aPercent' or 'aCurrent' are
|
|
||||||
* less than or equal to zero the original 'aCurrent' value is returned.
|
|
||||||
* If 'aPercent' is greater than or equal to 1.0 the value nscoord_MAX is
|
|
||||||
* returned.
|
|
||||||
*/
|
|
||||||
static nscoord AddPercents(nscoord aCurrent, float aPercent)
|
|
||||||
{
|
|
||||||
if (aPercent > 0.0f && aCurrent > 0) {
|
|
||||||
return MOZ_UNLIKELY(aPercent >= 1.0f) ? nscoord_MAX
|
|
||||||
: NSToCoordRound(float(aCurrent) / (1.0f - aPercent));
|
|
||||||
}
|
|
||||||
return aCurrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert nsStyleCoord to nscoord when percentages depend on the
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
||||||
* containing block size.
|
* containing block size.
|
||||||
|
|||||||
@@ -3582,8 +3582,7 @@ ContentContribution(const GridItemInfo& aGridItem,
|
|||||||
PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis));
|
PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis));
|
||||||
nscoord size = nsLayoutUtils::IntrinsicForAxis(axis, aRC, child, aConstraint,
|
nscoord size = nsLayoutUtils::IntrinsicForAxis(axis, aRC, child, aConstraint,
|
||||||
aPercentageBasis,
|
aPercentageBasis,
|
||||||
aFlags | nsLayoutUtils::BAIL_IF_REFLOW_NEEDED |
|
aFlags | nsLayoutUtils::BAIL_IF_REFLOW_NEEDED,
|
||||||
nsLayoutUtils::ADD_PERCENTS,
|
|
||||||
aMinSizeClamp);
|
aMinSizeClamp);
|
||||||
if (size == NS_INTRINSIC_WIDTH_UNKNOWN) {
|
if (size == NS_INTRINSIC_WIDTH_UNKNOWN) {
|
||||||
// We need to reflow the child to find its BSize contribution.
|
// We need to reflow the child to find its BSize contribution.
|
||||||
@@ -3620,15 +3619,7 @@ ContentContribution(const GridItemInfo& aGridItem,
|
|||||||
LogicalSize availableSize(childWM, availISize, availBSize);
|
LogicalSize availableSize(childWM, availISize, availBSize);
|
||||||
size = ::MeasuringReflow(child, aState.mReflowInput, aRC, availableSize,
|
size = ::MeasuringReflow(child, aState.mReflowInput, aRC, availableSize,
|
||||||
cbSize, iMinSizeClamp, bMinSizeClamp);
|
cbSize, iMinSizeClamp, bMinSizeClamp);
|
||||||
nsIFrame::IntrinsicISizeOffsetData offsets = child->IntrinsicBSizeOffsets();
|
size += child->GetLogicalUsedMargin(childWM).BStartEnd(childWM);
|
||||||
size += offsets.hMargin;
|
|
||||||
auto percent = offsets.hPctMargin;
|
|
||||||
if (availBSize == NS_UNCONSTRAINEDSIZE) {
|
|
||||||
// We always want to add in percent padding too, unless we already did so
|
|
||||||
// using a resolved column size above.
|
|
||||||
percent += offsets.hPctPadding;
|
|
||||||
}
|
|
||||||
size = nsLayoutUtils::AddPercents(size, percent);
|
|
||||||
nscoord overflow = size - aMinSizeClamp;
|
nscoord overflow = size - aMinSizeClamp;
|
||||||
if (MOZ_UNLIKELY(overflow > 0)) {
|
if (MOZ_UNLIKELY(overflow > 0)) {
|
||||||
nscoord contentSize = child->ContentBSize(childWM);
|
nscoord contentSize = child->ContentBSize(childWM);
|
||||||
|
|||||||
Reference in New Issue
Block a user