From 07564642ae6f629f318bfd64be1c7a1a067209fb Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Fri, 6 Nov 1998 02:09:21 +0000 Subject: [PATCH] Fixed nowrap support by computing max-element-size better --- layout/generic/nsBlockFrame.cpp | 51 +++++++++++++++------ layout/generic/nsBlockReflowState.cpp | 51 +++++++++++++++------ layout/generic/nsBlockReflowState.h | 51 +++++++++++++++------ layout/html/base/src/nsBlockFrame.cpp | 51 +++++++++++++++------ layout/html/base/src/nsBlockReflowState.cpp | 51 +++++++++++++++------ layout/html/base/src/nsBlockReflowState.h | 51 +++++++++++++++------ 6 files changed, 228 insertions(+), 78 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 1e73d4496a0d..58a348bb9525 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -2088,16 +2088,31 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, aMetrics.ascent = aMetrics.height; aMetrics.descent = 0; - // XXX this needs reworking I suppose + // XXX this needs ALOT OF REWORKING if (aState.mComputeMaxElementSize) { - *aMetrics.maxElementSize = aState.mMaxElementSize; + nscoord maxWidth, maxHeight; - // Add in our border and padding to the max-element-size so that - // we don't shrink too far. - aMetrics.maxElementSize->width += aState.mBorderPadding.left + - aState.mBorderPadding.right; - aMetrics.maxElementSize->height += aState.mBorderPadding.top + - aState.mBorderPadding.bottom; + if (aState.mNoWrap) { + maxWidth = 0; + maxHeight = 0; + LineData* line = mLines; + while (nsnull != line) { + nscoord xm = line->mBounds.XMost(); + if (xm > maxWidth) { + maxWidth = xm; + } + line = line->mNext; + } + // XXX winging it! + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } + else { + maxWidth = aState.mMaxElementSize.width + + aState.mBorderPadding.left + aState.mBorderPadding.right; + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } // Factor in any left and right floaters as well LineData* line = mLines; @@ -2136,13 +2151,23 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } line = line->mNext; } - // XXX what to do??? - if (maxLeft > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxLeft; + + // XXX this part is an approximation + if (aState.mNoWrap) { + maxWidth += maxLeft + maxRight; } - if (maxRight > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxRight; + else { + if (maxLeft > maxWidth) { + maxWidth = maxLeft; + } + if (maxRight > maxWidth) { + maxWidth = maxRight; + } } + + // Store away the final value + aMetrics.maxElementSize->width = maxWidth; + aMetrics.maxElementSize->height = maxHeight; } // Compute the combined area of our children diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 1e73d4496a0d..58a348bb9525 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -2088,16 +2088,31 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, aMetrics.ascent = aMetrics.height; aMetrics.descent = 0; - // XXX this needs reworking I suppose + // XXX this needs ALOT OF REWORKING if (aState.mComputeMaxElementSize) { - *aMetrics.maxElementSize = aState.mMaxElementSize; + nscoord maxWidth, maxHeight; - // Add in our border and padding to the max-element-size so that - // we don't shrink too far. - aMetrics.maxElementSize->width += aState.mBorderPadding.left + - aState.mBorderPadding.right; - aMetrics.maxElementSize->height += aState.mBorderPadding.top + - aState.mBorderPadding.bottom; + if (aState.mNoWrap) { + maxWidth = 0; + maxHeight = 0; + LineData* line = mLines; + while (nsnull != line) { + nscoord xm = line->mBounds.XMost(); + if (xm > maxWidth) { + maxWidth = xm; + } + line = line->mNext; + } + // XXX winging it! + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } + else { + maxWidth = aState.mMaxElementSize.width + + aState.mBorderPadding.left + aState.mBorderPadding.right; + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } // Factor in any left and right floaters as well LineData* line = mLines; @@ -2136,13 +2151,23 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } line = line->mNext; } - // XXX what to do??? - if (maxLeft > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxLeft; + + // XXX this part is an approximation + if (aState.mNoWrap) { + maxWidth += maxLeft + maxRight; } - if (maxRight > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxRight; + else { + if (maxLeft > maxWidth) { + maxWidth = maxLeft; + } + if (maxRight > maxWidth) { + maxWidth = maxRight; + } } + + // Store away the final value + aMetrics.maxElementSize->width = maxWidth; + aMetrics.maxElementSize->height = maxHeight; } // Compute the combined area of our children diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 1e73d4496a0d..58a348bb9525 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -2088,16 +2088,31 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, aMetrics.ascent = aMetrics.height; aMetrics.descent = 0; - // XXX this needs reworking I suppose + // XXX this needs ALOT OF REWORKING if (aState.mComputeMaxElementSize) { - *aMetrics.maxElementSize = aState.mMaxElementSize; + nscoord maxWidth, maxHeight; - // Add in our border and padding to the max-element-size so that - // we don't shrink too far. - aMetrics.maxElementSize->width += aState.mBorderPadding.left + - aState.mBorderPadding.right; - aMetrics.maxElementSize->height += aState.mBorderPadding.top + - aState.mBorderPadding.bottom; + if (aState.mNoWrap) { + maxWidth = 0; + maxHeight = 0; + LineData* line = mLines; + while (nsnull != line) { + nscoord xm = line->mBounds.XMost(); + if (xm > maxWidth) { + maxWidth = xm; + } + line = line->mNext; + } + // XXX winging it! + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } + else { + maxWidth = aState.mMaxElementSize.width + + aState.mBorderPadding.left + aState.mBorderPadding.right; + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } // Factor in any left and right floaters as well LineData* line = mLines; @@ -2136,13 +2151,23 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } line = line->mNext; } - // XXX what to do??? - if (maxLeft > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxLeft; + + // XXX this part is an approximation + if (aState.mNoWrap) { + maxWidth += maxLeft + maxRight; } - if (maxRight > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxRight; + else { + if (maxLeft > maxWidth) { + maxWidth = maxLeft; + } + if (maxRight > maxWidth) { + maxWidth = maxRight; + } } + + // Store away the final value + aMetrics.maxElementSize->width = maxWidth; + aMetrics.maxElementSize->height = maxHeight; } // Compute the combined area of our children diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 1e73d4496a0d..58a348bb9525 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -2088,16 +2088,31 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, aMetrics.ascent = aMetrics.height; aMetrics.descent = 0; - // XXX this needs reworking I suppose + // XXX this needs ALOT OF REWORKING if (aState.mComputeMaxElementSize) { - *aMetrics.maxElementSize = aState.mMaxElementSize; + nscoord maxWidth, maxHeight; - // Add in our border and padding to the max-element-size so that - // we don't shrink too far. - aMetrics.maxElementSize->width += aState.mBorderPadding.left + - aState.mBorderPadding.right; - aMetrics.maxElementSize->height += aState.mBorderPadding.top + - aState.mBorderPadding.bottom; + if (aState.mNoWrap) { + maxWidth = 0; + maxHeight = 0; + LineData* line = mLines; + while (nsnull != line) { + nscoord xm = line->mBounds.XMost(); + if (xm > maxWidth) { + maxWidth = xm; + } + line = line->mNext; + } + // XXX winging it! + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } + else { + maxWidth = aState.mMaxElementSize.width + + aState.mBorderPadding.left + aState.mBorderPadding.right; + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } // Factor in any left and right floaters as well LineData* line = mLines; @@ -2136,13 +2151,23 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } line = line->mNext; } - // XXX what to do??? - if (maxLeft > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxLeft; + + // XXX this part is an approximation + if (aState.mNoWrap) { + maxWidth += maxLeft + maxRight; } - if (maxRight > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxRight; + else { + if (maxLeft > maxWidth) { + maxWidth = maxLeft; + } + if (maxRight > maxWidth) { + maxWidth = maxRight; + } } + + // Store away the final value + aMetrics.maxElementSize->width = maxWidth; + aMetrics.maxElementSize->height = maxHeight; } // Compute the combined area of our children diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index 1e73d4496a0d..58a348bb9525 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -2088,16 +2088,31 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, aMetrics.ascent = aMetrics.height; aMetrics.descent = 0; - // XXX this needs reworking I suppose + // XXX this needs ALOT OF REWORKING if (aState.mComputeMaxElementSize) { - *aMetrics.maxElementSize = aState.mMaxElementSize; + nscoord maxWidth, maxHeight; - // Add in our border and padding to the max-element-size so that - // we don't shrink too far. - aMetrics.maxElementSize->width += aState.mBorderPadding.left + - aState.mBorderPadding.right; - aMetrics.maxElementSize->height += aState.mBorderPadding.top + - aState.mBorderPadding.bottom; + if (aState.mNoWrap) { + maxWidth = 0; + maxHeight = 0; + LineData* line = mLines; + while (nsnull != line) { + nscoord xm = line->mBounds.XMost(); + if (xm > maxWidth) { + maxWidth = xm; + } + line = line->mNext; + } + // XXX winging it! + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } + else { + maxWidth = aState.mMaxElementSize.width + + aState.mBorderPadding.left + aState.mBorderPadding.right; + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } // Factor in any left and right floaters as well LineData* line = mLines; @@ -2136,13 +2151,23 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } line = line->mNext; } - // XXX what to do??? - if (maxLeft > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxLeft; + + // XXX this part is an approximation + if (aState.mNoWrap) { + maxWidth += maxLeft + maxRight; } - if (maxRight > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxRight; + else { + if (maxLeft > maxWidth) { + maxWidth = maxLeft; + } + if (maxRight > maxWidth) { + maxWidth = maxRight; + } } + + // Store away the final value + aMetrics.maxElementSize->width = maxWidth; + aMetrics.maxElementSize->height = maxHeight; } // Compute the combined area of our children diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index 1e73d4496a0d..58a348bb9525 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -2088,16 +2088,31 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, aMetrics.ascent = aMetrics.height; aMetrics.descent = 0; - // XXX this needs reworking I suppose + // XXX this needs ALOT OF REWORKING if (aState.mComputeMaxElementSize) { - *aMetrics.maxElementSize = aState.mMaxElementSize; + nscoord maxWidth, maxHeight; - // Add in our border and padding to the max-element-size so that - // we don't shrink too far. - aMetrics.maxElementSize->width += aState.mBorderPadding.left + - aState.mBorderPadding.right; - aMetrics.maxElementSize->height += aState.mBorderPadding.top + - aState.mBorderPadding.bottom; + if (aState.mNoWrap) { + maxWidth = 0; + maxHeight = 0; + LineData* line = mLines; + while (nsnull != line) { + nscoord xm = line->mBounds.XMost(); + if (xm > maxWidth) { + maxWidth = xm; + } + line = line->mNext; + } + // XXX winging it! + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } + else { + maxWidth = aState.mMaxElementSize.width + + aState.mBorderPadding.left + aState.mBorderPadding.right; + maxHeight = aState.mMaxElementSize.height + + aState.mBorderPadding.top + aState.mBorderPadding.bottom; + } // Factor in any left and right floaters as well LineData* line = mLines; @@ -2136,13 +2151,23 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } line = line->mNext; } - // XXX what to do??? - if (maxLeft > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxLeft; + + // XXX this part is an approximation + if (aState.mNoWrap) { + maxWidth += maxLeft + maxRight; } - if (maxRight > aMetrics.maxElementSize->width) { - aMetrics.maxElementSize->width = maxRight; + else { + if (maxLeft > maxWidth) { + maxWidth = maxLeft; + } + if (maxRight > maxWidth) { + maxWidth = maxRight; + } } + + // Store away the final value + aMetrics.maxElementSize->width = maxWidth; + aMetrics.maxElementSize->height = maxHeight; } // Compute the combined area of our children