bug 169620 - don't pass in negative avail widths, don't add/subtract from NS_UNCONSTRAINEDSIZE, make HR's desired width at least as big as its me width. sr=kin, r=dbaron

This commit is contained in:
karnaze%netscape.com 2002-09-24 21:02:20 +00:00
Родитель 55ef45b15f
Коммит f7277122ea
13 изменённых файлов: 113 добавлений и 38 удалений

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

@ -104,8 +104,11 @@ inline void nsBandTrapezoid::GetRect(nsRect& aRect) const
{
aRect.x = PR_MIN(mTopLeftX, mBottomLeftX);
aRect.y = mTopY;
aRect.width = PR_MAX(mTopRightX, mBottomRightX) - aRect.x;
aRect.height = mBottomY - mTopY;
aRect.width = PR_MAX(mTopRightX, mBottomRightX);
if (NS_MAXSIZE != aRect.width) {
aRect.width -= aRect.x;
}
aRect.height = (NS_MAXSIZE == mBottomY) ? NS_MAXSIZE : mBottomY - mTopY;
}
inline void nsBandTrapezoid::operator=(const nsRect& aRect)

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

@ -120,7 +120,7 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
}
else {
nscoord lr = borderPadding.left + borderPadding.right;
mContentArea.width = aReflowState.availableWidth - lr;
mContentArea.width = PR_MAX(0, aReflowState.availableWidth - lr);
}
}
mHaveRightFloaters = PR_FALSE;
@ -137,7 +137,7 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
// the bottom border and padding. The content area height doesn't
// include either border or padding edge.
mBottomEdge = aReflowState.availableHeight - borderPadding.bottom;
mContentArea.height = mBottomEdge - borderPadding.top;
mContentArea.height = PR_MAX(0, mBottomEdge - borderPadding.top);
}
else {
// When we are not in a paginated situation then we always use

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

@ -1156,10 +1156,11 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext,
// The width is shrink-to-fit but constrained by the containing block width
mComputedWidth = NS_SHRINKWRAPWIDTH;
PRInt32 maxWidth = containingBlockWidth - mComputedOffsets.left -
mComputedMargin.left - mComputedBorderPadding.left -
mComputedBorderPadding.right - mComputedMargin.right -
mComputedOffsets.right;
PRInt32 maxWidth = containingBlockWidth;
if (NS_UNCONSTRAINEDSIZE != maxWidth) {
maxWidth -= mComputedOffsets.left + mComputedMargin.left + mComputedBorderPadding.left +
mComputedBorderPadding.right + mComputedMargin.right + mComputedOffsets.right;
}
if (maxWidth <= 0) {
maxWidth = 1;
}
@ -1891,9 +1892,11 @@ nsHTMLReflowState::InitConstraints(nsIPresContext* aPresContext,
mComputedWidth = NS_SHRINKWRAPWIDTH;
// Limnit the width to the containing block width
nscoord widthFromCB = aContainingBlockWidth -
mComputedBorderPadding.left - mComputedBorderPadding.right -
mComputedMargin.left - mComputedMargin.right;
nscoord widthFromCB = aContainingBlockWidth;
if (NS_UNCONSTRAINEDSIZE != widthFromCB) {
widthFromCB -= mComputedBorderPadding.left + mComputedBorderPadding.right +
mComputedMargin.left + mComputedMargin.right;
}
if (mComputedMaxWidth > widthFromCB) {
mComputedMaxWidth = widthFromCB;
}
@ -2038,10 +2041,11 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
// Let its content area be as wide as the containing block's max width
// minus any margin and border/padding
nscoord maxWidth = cbrs->mComputedMaxWidth - mComputedMargin.left -
mComputedBorderPadding.left - mComputedMargin.right -
mComputedBorderPadding.right;
nscoord maxWidth = cbrs->mComputedMaxWidth;
if (NS_UNCONSTRAINEDSIZE != maxWidth) {
maxWidth -= mComputedMargin.left + mComputedBorderPadding.left +
mComputedMargin.right + mComputedBorderPadding.right;
}
if (maxWidth < mComputedMaxWidth) {
mComputedMaxWidth = maxWidth;
}

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

@ -495,6 +495,7 @@ nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext,
// Subtract off left and right border+padding from availableWidth
availableWidth -= leftEdge;
availableWidth -= aReflowState.mComputedBorderPadding.right;
availableWidth = PR_MAX(0, availableWidth);
}
lineLayout->BeginSpan(this, &aReflowState, leftEdge, leftEdge + availableWidth);

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

@ -244,13 +244,11 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": Init: bad caller: width WAS %d(0x%x)\n",
aWidth, aWidth);
aWidth = NS_UNCONSTRAINEDSIZE;
}
if ((aHeight != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aHeight)) {
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": Init: bad caller: height WAS %d(0x%x)\n",
aHeight, aHeight);
aHeight = NS_UNCONSTRAINEDSIZE;
}
#endif
#ifdef NOISY_REFLOW
@ -395,13 +393,11 @@ nsLineLayout::UpdateBand(nscoord aX, nscoord aY,
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": UpdateBand: bad caller: width WAS %d(0x%x)\n",
aWidth, aWidth);
aWidth = NS_UNCONSTRAINEDSIZE;
}
if ((aHeight != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aHeight)) {
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": UpdateBand: bad caller: height WAS %d(0x%x)\n",
aHeight, aHeight);
aHeight = NS_UNCONSTRAINEDSIZE;
}
#endif
@ -1654,6 +1650,7 @@ nsLineLayout::PlaceFrame(PerFrameData* pfd, nsHTMLReflowMetrics& aMetrics)
// Advance to next X coordinate
psd->mX = pfd->mBounds.XMost() + pfd->mMargin.right;
psd->mRightEdge = PR_MAX(psd->mRightEdge, psd->mX);
// If the frame is a not aware of white-space and it takes up some
// width, disable leading white-space compression for the next frame

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

@ -104,8 +104,11 @@ inline void nsBandTrapezoid::GetRect(nsRect& aRect) const
{
aRect.x = PR_MIN(mTopLeftX, mBottomLeftX);
aRect.y = mTopY;
aRect.width = PR_MAX(mTopRightX, mBottomRightX) - aRect.x;
aRect.height = mBottomY - mTopY;
aRect.width = PR_MAX(mTopRightX, mBottomRightX);
if (NS_MAXSIZE != aRect.width) {
aRect.width -= aRect.x;
}
aRect.height = (NS_MAXSIZE == mBottomY) ? NS_MAXSIZE : mBottomY - mTopY;
}
inline void nsBandTrapezoid::operator=(const nsRect& aRect)

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

@ -120,7 +120,7 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
}
else {
nscoord lr = borderPadding.left + borderPadding.right;
mContentArea.width = aReflowState.availableWidth - lr;
mContentArea.width = PR_MAX(0, aReflowState.availableWidth - lr);
}
}
mHaveRightFloaters = PR_FALSE;
@ -137,7 +137,7 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
// the bottom border and padding. The content area height doesn't
// include either border or padding edge.
mBottomEdge = aReflowState.availableHeight - borderPadding.bottom;
mContentArea.height = mBottomEdge - borderPadding.top;
mContentArea.height = PR_MAX(0, mBottomEdge - borderPadding.top);
}
else {
// When we are not in a paginated situation then we always use

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

@ -319,6 +319,7 @@ HRuleFrame::Reflow(nsIPresContext* aPresContext,
// When the HR is using an 'auto' or percentage width, make sure it
// remains springy.
aDesiredSize.maxElementSize->width = onePixel;
aDesiredSize.width = PR_MAX(aDesiredSize.width, onePixel);
}
else {
aDesiredSize.maxElementSize->width = aReflowState.mComputedWidth;
@ -326,6 +327,7 @@ HRuleFrame::Reflow(nsIPresContext* aPresContext,
}
else {
aDesiredSize.maxElementSize->width = onePixel;
aDesiredSize.width = PR_MAX(aDesiredSize.width, onePixel);
}
NS_ASSERTION(aDesiredSize.maxElementSize->width <= aDesiredSize.width, "bad max-element-size width");
aDesiredSize.maxElementSize->height = aDesiredSize.height;

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

@ -1156,10 +1156,11 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext,
// The width is shrink-to-fit but constrained by the containing block width
mComputedWidth = NS_SHRINKWRAPWIDTH;
PRInt32 maxWidth = containingBlockWidth - mComputedOffsets.left -
mComputedMargin.left - mComputedBorderPadding.left -
mComputedBorderPadding.right - mComputedMargin.right -
mComputedOffsets.right;
PRInt32 maxWidth = containingBlockWidth;
if (NS_UNCONSTRAINEDSIZE != maxWidth) {
maxWidth -= mComputedOffsets.left + mComputedMargin.left + mComputedBorderPadding.left +
mComputedBorderPadding.right + mComputedMargin.right + mComputedOffsets.right;
}
if (maxWidth <= 0) {
maxWidth = 1;
}
@ -1891,9 +1892,11 @@ nsHTMLReflowState::InitConstraints(nsIPresContext* aPresContext,
mComputedWidth = NS_SHRINKWRAPWIDTH;
// Limnit the width to the containing block width
nscoord widthFromCB = aContainingBlockWidth -
mComputedBorderPadding.left - mComputedBorderPadding.right -
mComputedMargin.left - mComputedMargin.right;
nscoord widthFromCB = aContainingBlockWidth;
if (NS_UNCONSTRAINEDSIZE != widthFromCB) {
widthFromCB -= mComputedBorderPadding.left + mComputedBorderPadding.right +
mComputedMargin.left + mComputedMargin.right;
}
if (mComputedMaxWidth > widthFromCB) {
mComputedMaxWidth = widthFromCB;
}
@ -2038,10 +2041,11 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
// Let its content area be as wide as the containing block's max width
// minus any margin and border/padding
nscoord maxWidth = cbrs->mComputedMaxWidth - mComputedMargin.left -
mComputedBorderPadding.left - mComputedMargin.right -
mComputedBorderPadding.right;
nscoord maxWidth = cbrs->mComputedMaxWidth;
if (NS_UNCONSTRAINEDSIZE != maxWidth) {
maxWidth -= mComputedMargin.left + mComputedBorderPadding.left +
mComputedMargin.right + mComputedBorderPadding.right;
}
if (maxWidth < mComputedMaxWidth) {
mComputedMaxWidth = maxWidth;
}

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

@ -495,6 +495,7 @@ nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext,
// Subtract off left and right border+padding from availableWidth
availableWidth -= leftEdge;
availableWidth -= aReflowState.mComputedBorderPadding.right;
availableWidth = PR_MAX(0, availableWidth);
}
lineLayout->BeginSpan(this, &aReflowState, leftEdge, leftEdge + availableWidth);

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

@ -244,13 +244,11 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": Init: bad caller: width WAS %d(0x%x)\n",
aWidth, aWidth);
aWidth = NS_UNCONSTRAINEDSIZE;
}
if ((aHeight != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aHeight)) {
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": Init: bad caller: height WAS %d(0x%x)\n",
aHeight, aHeight);
aHeight = NS_UNCONSTRAINEDSIZE;
}
#endif
#ifdef NOISY_REFLOW
@ -395,13 +393,11 @@ nsLineLayout::UpdateBand(nscoord aX, nscoord aY,
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": UpdateBand: bad caller: width WAS %d(0x%x)\n",
aWidth, aWidth);
aWidth = NS_UNCONSTRAINEDSIZE;
}
if ((aHeight != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aHeight)) {
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": UpdateBand: bad caller: height WAS %d(0x%x)\n",
aHeight, aHeight);
aHeight = NS_UNCONSTRAINEDSIZE;
}
#endif
@ -1654,6 +1650,7 @@ nsLineLayout::PlaceFrame(PerFrameData* pfd, nsHTMLReflowMetrics& aMetrics)
// Advance to next X coordinate
psd->mX = pfd->mBounds.XMost() + pfd->mMargin.right;
psd->mRightEdge = PR_MAX(psd->mRightEdge, psd->mX);
// If the frame is a not aware of white-space and it takes up some
// width, disable leading white-space compression for the next frame

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

@ -0,0 +1,62 @@
<html>
<head>
<title>Page Widening</title>
</head>
<body>
<table>
<tr>
<td>
<script>
document;
</script>
<script src="http://nowhere.tld/"></script>
<div style="padding-right:10px;">
<p>Four score and seven years ago, our fathers brought
forth upon this continent a new nation: conceived in
liberty, and dedicated to the proposition that all men
are created equal.</p>
<p>Now we are engaged in a great civil war. . .testing
whether that nation, or any nation so conceived and so
dedicated. . . can long endure. We are met on a great
battlefield of that war.</p>
<p>We have come to dedicate a portion of that field as
a final resting place for those who here gave their
lives that that nation might live. It is altogether
fitting and proper that we should do this.</p>
<p>But, in a larger sense, we cannot dedicate. . .we
cannot consecrate. . . we cannot hallow this ground.
The brave men, living and dead, who struggled here have
consecrated it, far above our poor power to add or
detract. The world will little note, nor long remember,
what we say here, but it can never forget what they did
here.</p>
<p>It is for us the living, rather, to be dedicated
here to the unfinished work which they who fought here
have thus far so nobly advanced. It is rather for us to
be here dedicated to the great task remaining before
us. . .that from these honored dead we take increased
devotion to that cause for which they gave the last
full measure of devotion. . . that we here highly
resolve that these dead shall not have died in vain. .
. that this nation, under God, shall have a new birth
of freedom. . . and that government of the people. .
.by the people. . .for the people. . . shall not perish
from the earth.</p>
<hr>
</div>
</td>
<td>
</td>
</tr>
</table>
</body>
</html>

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

@ -194,4 +194,5 @@ file:///s:/mozilla/layout/html/tests/block/bugs/126213-2.html
file:///s:/mozilla/layout/html/tests/block/bugs/148245.html
file:///s:/mozilla/layout/html/tests/block/bugs/151620.html
file:///s:/mozilla/layout/html/tests/block/bugs/154741.html
file:///s:/mozilla/layout/html/tests/block/bugs/169620.html