diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 5aeabe529c6f..8e13a568557a 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -2144,6 +2144,8 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) spanFrame->GetPrevInFlow(&spanPrevInFlow); PRBool emptyContinuation = spanPrevInFlow && !spanNextInFlow && (0 == spanFramePFD->mBounds.width) && (0 == spanFramePFD->mBounds.height); + NS_ASSERTION(!emptyContinuation, + "we shouldn't have empty continuations anymore"); #ifdef NOISY_VERTICAL_ALIGN printf("[%sSpan]", (psd == mRootSpan)?"Root":""); @@ -2219,25 +2221,19 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) // mode) we don't want big line heights for things like //

Text

- // Don't include any initial whitespace, unless we're preformatted. - // See bug 134580. - PRUint32 flag = preMode ? PFD_ISTEXTFRAME : PFD_ISNONWHITESPACETEXTFRAME; + // We shouldn't include any whitespace that collapses, unless we're + // preformatted (in which case it shouldn't, but the width=0 test is + // perhaps incorrect). This includes whitespace at the beginning of + // a line and whitespace preceded (?) by other whitespace. + // See bug 134580 and bug 155333. zeroEffectiveSpanBox = PR_TRUE; for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) { - if (pfd->GetFlag(flag)) { + if (pfd->GetFlag(PFD_ISTEXTFRAME) && + (pfd->GetFlag(PFD_ISNONWHITESPACETEXTFRAME) || preMode || + pfd->mBounds.width != 0)) { zeroEffectiveSpanBox = PR_FALSE; break; } - // The line could begin with multiple all-whitespace text frames, - // and we need to ignore all of them, including those contained - // within other inline frames. - if (flag != PFD_ISTEXTFRAME) { - PRBool empty; - pfd->mFrame->IsEmpty(mCompatMode, preMode, &empty); - if (!empty) { - flag = PFD_ISTEXTFRAME; - } - } } } psd->mZeroEffectiveSpanBox = zeroEffectiveSpanBox; diff --git a/layout/html/base/src/nsLineLayout.cpp b/layout/html/base/src/nsLineLayout.cpp index 5aeabe529c6f..8e13a568557a 100644 --- a/layout/html/base/src/nsLineLayout.cpp +++ b/layout/html/base/src/nsLineLayout.cpp @@ -2144,6 +2144,8 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) spanFrame->GetPrevInFlow(&spanPrevInFlow); PRBool emptyContinuation = spanPrevInFlow && !spanNextInFlow && (0 == spanFramePFD->mBounds.width) && (0 == spanFramePFD->mBounds.height); + NS_ASSERTION(!emptyContinuation, + "we shouldn't have empty continuations anymore"); #ifdef NOISY_VERTICAL_ALIGN printf("[%sSpan]", (psd == mRootSpan)?"Root":""); @@ -2219,25 +2221,19 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) // mode) we don't want big line heights for things like //

Text

- // Don't include any initial whitespace, unless we're preformatted. - // See bug 134580. - PRUint32 flag = preMode ? PFD_ISTEXTFRAME : PFD_ISNONWHITESPACETEXTFRAME; + // We shouldn't include any whitespace that collapses, unless we're + // preformatted (in which case it shouldn't, but the width=0 test is + // perhaps incorrect). This includes whitespace at the beginning of + // a line and whitespace preceded (?) by other whitespace. + // See bug 134580 and bug 155333. zeroEffectiveSpanBox = PR_TRUE; for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) { - if (pfd->GetFlag(flag)) { + if (pfd->GetFlag(PFD_ISTEXTFRAME) && + (pfd->GetFlag(PFD_ISNONWHITESPACETEXTFRAME) || preMode || + pfd->mBounds.width != 0)) { zeroEffectiveSpanBox = PR_FALSE; break; } - // The line could begin with multiple all-whitespace text frames, - // and we need to ignore all of them, including those contained - // within other inline frames. - if (flag != PFD_ISTEXTFRAME) { - PRBool empty; - pfd->mFrame->IsEmpty(mCompatMode, preMode, &empty); - if (!empty) { - flag = PFD_ISTEXTFRAME; - } - } } } psd->mZeroEffectiveSpanBox = zeroEffectiveSpanBox;