From b70e7f9f22b283aa324b9e1c4a53471dca340846 Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Tue, 24 Sep 2002 21:02:20 +0000 Subject: [PATCH] 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 git-svn-id: svn://10.0.0.236/trunk@130371 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/src/nsSpaceManager.h | 7 ++- mozilla/layout/generic/nsBlockReflowState.cpp | 4 +- mozilla/layout/generic/nsHTMLReflowState.cpp | 26 ++++---- mozilla/layout/generic/nsInlineFrame.cpp | 1 + mozilla/layout/generic/nsLineLayout.cpp | 5 +- mozilla/layout/generic/nsSpaceManager.h | 7 ++- .../html/base/src/nsBlockReflowState.cpp | 4 +- mozilla/layout/html/base/src/nsHRFrame.cpp | 2 + .../html/base/src/nsHTMLReflowState.cpp | 26 ++++---- .../layout/html/base/src/nsInlineFrame.cpp | 1 + mozilla/layout/html/base/src/nsLineLayout.cpp | 5 +- .../layout/html/tests/block/bugs/169620.html | 62 +++++++++++++++++++ .../html/tests/block/bugs/file_list.txt | 1 + 13 files changed, 113 insertions(+), 38 deletions(-) create mode 100644 mozilla/layout/html/tests/block/bugs/169620.html diff --git a/mozilla/layout/base/src/nsSpaceManager.h b/mozilla/layout/base/src/nsSpaceManager.h index 6c2640b8d49..efbd4cd1154 100644 --- a/mozilla/layout/base/src/nsSpaceManager.h +++ b/mozilla/layout/base/src/nsSpaceManager.h @@ -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) diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 5594984ee2b..1c4ae0200a6 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -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 diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 5900685a1f6..ddd25c9a8aa 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -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; } diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index 2ec7330b5f5..6404150c2fa 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -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); diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index dada250cc5d..b82baf6cdcb 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -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 diff --git a/mozilla/layout/generic/nsSpaceManager.h b/mozilla/layout/generic/nsSpaceManager.h index 6c2640b8d49..efbd4cd1154 100644 --- a/mozilla/layout/generic/nsSpaceManager.h +++ b/mozilla/layout/generic/nsSpaceManager.h @@ -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) diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 5594984ee2b..1c4ae0200a6 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -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 diff --git a/mozilla/layout/html/base/src/nsHRFrame.cpp b/mozilla/layout/html/base/src/nsHRFrame.cpp index baf1e4e4264..8e4124ea414 100644 --- a/mozilla/layout/html/base/src/nsHRFrame.cpp +++ b/mozilla/layout/html/base/src/nsHRFrame.cpp @@ -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; diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index 5900685a1f6..ddd25c9a8aa 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -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; } diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index 2ec7330b5f5..6404150c2fa 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -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); diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index dada250cc5d..b82baf6cdcb 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -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 diff --git a/mozilla/layout/html/tests/block/bugs/169620.html b/mozilla/layout/html/tests/block/bugs/169620.html new file mode 100644 index 00000000000..089f8aea6d2 --- /dev/null +++ b/mozilla/layout/html/tests/block/bugs/169620.html @@ -0,0 +1,62 @@ + + +Page Widening + + + + + + + + +
+ + + + +
+ +

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.

+ +

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.

+ +

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.

+ +

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.

+ +

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.

+
+
+ +
+
+ + diff --git a/mozilla/layout/html/tests/block/bugs/file_list.txt b/mozilla/layout/html/tests/block/bugs/file_list.txt index 5614714b6fc..d42dd0ebc2a 100644 --- a/mozilla/layout/html/tests/block/bugs/file_list.txt +++ b/mozilla/layout/html/tests/block/bugs/file_list.txt @@ -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