diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 0a8910b215c..c24dbb42988 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -182,6 +182,7 @@ public: nscolor mSelectionBGColor; nscoord mSpaceWidth; PRBool mJustifying; + PRBool mPreformatted; PRIntn mNumSpaces; nscoord mExtraSpacePerSpace; nscoord mRemainingExtraSpace; @@ -221,19 +222,19 @@ public: // Get the word and letter spacing mWordSpacing = 0; mLetterSpacing = 0; - if (NS_STYLE_WHITESPACE_PRE != mText->mWhiteSpace) { - PRIntn unit = mText->mWordSpacing.GetUnit(); - if (eStyleUnit_Coord == unit) { - mWordSpacing = mText->mWordSpacing.GetCoordValue(); - } - unit = mText->mLetterSpacing.GetUnit(); - if (eStyleUnit_Coord == unit) { - mLetterSpacing = mText->mLetterSpacing.GetCoordValue(); - } + PRIntn unit = mText->mWordSpacing.GetUnit(); + if (eStyleUnit_Coord == unit) { + mWordSpacing = mText->mWordSpacing.GetCoordValue(); + } + unit = mText->mLetterSpacing.GetUnit(); + if (eStyleUnit_Coord == unit) { + mLetterSpacing = mText->mLetterSpacing.GetCoordValue(); } mNumSpaces = 0; mRemainingExtraSpace = 0; mExtraSpacePerSpace = 0; + mPreformatted = (NS_STYLE_WHITESPACE_PRE == mText->mWhiteSpace) || + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == mText->mWhiteSpace); } ~TextStyle() { @@ -682,6 +683,7 @@ TextFrame::PrepareUnicodeText(nsTextTransformer& aTX, return numSpaces; } + // // This should be commented out, but some gfx changes on the weekend of // 4/20-21/1999 broke caret rendering on Unix, so in a vain effort to @@ -2193,13 +2195,14 @@ TextFrame::Reflow(nsIPresContext& aPresContext, } } - PRBool wrapping = NS_STYLE_WHITESPACE_NORMAL == ts.mText->mWhiteSpace; + PRBool wrapping = (NS_STYLE_WHITESPACE_NORMAL == ts.mText->mWhiteSpace) || + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == ts.mText->mWhiteSpace); PRBool firstLetterOK = lineLayout.GetFirstLetterStyleOK(); PRBool justDidFirstLetter = PR_FALSE; // Set whitespace skip flag PRBool skipWhitespace = PR_FALSE; - if (NS_STYLE_WHITESPACE_PRE != ts.mText->mWhiteSpace) { + if (!ts.mPreformatted) { if (lineLayout.GetEndsInWhiteSpace()) { skipWhitespace = PR_TRUE; } @@ -2265,7 +2268,7 @@ TextFrame::Reflow(nsIPresContext& aPresContext, prevOffset = offset; offset++; endsInWhitespace = PR_TRUE; - if (NS_STYLE_WHITESPACE_PRE == ts.mText->mWhiteSpace) { + if (ts.mPreformatted) { endsInNewline = PR_TRUE; } break; @@ -2434,7 +2437,7 @@ TextFrame::Reflow(nsIPresContext& aPresContext, // Setup metrics for caller; store final max-element-size information aMetrics.width = x; mComputedWidth = x; - if ((0 == x) && (NS_STYLE_WHITESPACE_PRE != ts.mText->mWhiteSpace)) { + if ((0 == x) && !ts.mPreformatted) { aMetrics.height = 0; aMetrics.ascent = 0; aMetrics.descent = 0; @@ -2538,7 +2541,8 @@ TextFrame::TrimTrailingWhiteSpace(nsIPresContext& aPresContext, nscoord dw = 0; const nsStyleText* textStyle = (const nsStyleText*) mStyleContext->GetStyleData(eStyleStruct_Text); - if (NS_STYLE_WHITESPACE_PRE != textStyle->mWhiteSpace) { + if ((NS_STYLE_WHITESPACE_PRE != textStyle->mWhiteSpace) && + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP != textStyle->mWhiteSpace)) { // Get font metrics for a space so we can adjust the width by the // right amount. const nsStyleFont* fontStyle = (const nsStyleFont*) diff --git a/mozilla/layout/generic/nsTextTransformer.cpp b/mozilla/layout/generic/nsTextTransformer.cpp index ca19f2afefe..86c8073ce0a 100644 --- a/mozilla/layout/generic/nsTextTransformer.cpp +++ b/mozilla/layout/generic/nsTextTransformer.cpp @@ -117,7 +117,8 @@ nsTextTransformer::Init(/*nsTextRun& aTextRun, XXX*/ // Get the frames style and choose a transform proc const nsStyleText* styleText; aFrame->GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&) styleText); - mWhiteSpace = styleText->mWhiteSpace; + mPreformatted = (NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) || + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace); mTextTransform = styleText->mTextTransform; if(NS_STYLE_TEXT_TRANSFORM_NONE != mTextTransform) @@ -192,7 +193,7 @@ nsTextTransformer::GetNextWord(PRBool aInWord, PRBool isWhitespace = XP_IS_SPACE(firstChar); offset++; if (isWhitespace) { - if (NS_STYLE_WHITESPACE_PRE == mWhiteSpace) { + if (mPreformatted) { if ('\t' == firstChar) { // Leave tab alone so that caller can expand it } @@ -219,7 +220,7 @@ nsTextTransformer::GetNextWord(PRBool aInWord, offset = 0; } mCurrentFragOffset = offset; - if (isWhitespace && (NS_STYLE_WHITESPACE_PRE == mWhiteSpace)) { + if (isWhitespace && mPreformatted) { goto really_done; } @@ -425,7 +426,7 @@ nsTextTransformer::GetPrevWord(PRBool aInWord, PRBool isWhitespace = XP_IS_SPACE(firstChar); offset--; if (isWhitespace) { - if (NS_STYLE_WHITESPACE_PRE == mWhiteSpace) { + if (mPreformatted) { if ('\t' == firstChar) { // Leave tab alone so that caller can expand it } @@ -454,7 +455,7 @@ nsTextTransformer::GetPrevWord(PRBool aInWord, mCurrentFrag = --frag; offset = mCurrentFrag->GetLength()-1; } - if (isWhitespace && (NS_STYLE_WHITESPACE_PRE == mWhiteSpace)) { + if (isWhitespace && mPreformatted) { goto really_done; } diff --git a/mozilla/layout/generic/nsTextTransformer.h b/mozilla/layout/generic/nsTextTransformer.h index 42ef32b2912..754ff6c0778 100644 --- a/mozilla/layout/generic/nsTextTransformer.h +++ b/mozilla/layout/generic/nsTextTransformer.h @@ -95,7 +95,7 @@ protected: PRInt32 mCurrentFragOffset; PRUint8 mTextTransform; - PRUint8 mWhiteSpace; + PRUint8 mPreformatted; nsILineBreaker* mLineBreaker; }; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 0a8910b215c..c24dbb42988 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -182,6 +182,7 @@ public: nscolor mSelectionBGColor; nscoord mSpaceWidth; PRBool mJustifying; + PRBool mPreformatted; PRIntn mNumSpaces; nscoord mExtraSpacePerSpace; nscoord mRemainingExtraSpace; @@ -221,19 +222,19 @@ public: // Get the word and letter spacing mWordSpacing = 0; mLetterSpacing = 0; - if (NS_STYLE_WHITESPACE_PRE != mText->mWhiteSpace) { - PRIntn unit = mText->mWordSpacing.GetUnit(); - if (eStyleUnit_Coord == unit) { - mWordSpacing = mText->mWordSpacing.GetCoordValue(); - } - unit = mText->mLetterSpacing.GetUnit(); - if (eStyleUnit_Coord == unit) { - mLetterSpacing = mText->mLetterSpacing.GetCoordValue(); - } + PRIntn unit = mText->mWordSpacing.GetUnit(); + if (eStyleUnit_Coord == unit) { + mWordSpacing = mText->mWordSpacing.GetCoordValue(); + } + unit = mText->mLetterSpacing.GetUnit(); + if (eStyleUnit_Coord == unit) { + mLetterSpacing = mText->mLetterSpacing.GetCoordValue(); } mNumSpaces = 0; mRemainingExtraSpace = 0; mExtraSpacePerSpace = 0; + mPreformatted = (NS_STYLE_WHITESPACE_PRE == mText->mWhiteSpace) || + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == mText->mWhiteSpace); } ~TextStyle() { @@ -682,6 +683,7 @@ TextFrame::PrepareUnicodeText(nsTextTransformer& aTX, return numSpaces; } + // // This should be commented out, but some gfx changes on the weekend of // 4/20-21/1999 broke caret rendering on Unix, so in a vain effort to @@ -2193,13 +2195,14 @@ TextFrame::Reflow(nsIPresContext& aPresContext, } } - PRBool wrapping = NS_STYLE_WHITESPACE_NORMAL == ts.mText->mWhiteSpace; + PRBool wrapping = (NS_STYLE_WHITESPACE_NORMAL == ts.mText->mWhiteSpace) || + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == ts.mText->mWhiteSpace); PRBool firstLetterOK = lineLayout.GetFirstLetterStyleOK(); PRBool justDidFirstLetter = PR_FALSE; // Set whitespace skip flag PRBool skipWhitespace = PR_FALSE; - if (NS_STYLE_WHITESPACE_PRE != ts.mText->mWhiteSpace) { + if (!ts.mPreformatted) { if (lineLayout.GetEndsInWhiteSpace()) { skipWhitespace = PR_TRUE; } @@ -2265,7 +2268,7 @@ TextFrame::Reflow(nsIPresContext& aPresContext, prevOffset = offset; offset++; endsInWhitespace = PR_TRUE; - if (NS_STYLE_WHITESPACE_PRE == ts.mText->mWhiteSpace) { + if (ts.mPreformatted) { endsInNewline = PR_TRUE; } break; @@ -2434,7 +2437,7 @@ TextFrame::Reflow(nsIPresContext& aPresContext, // Setup metrics for caller; store final max-element-size information aMetrics.width = x; mComputedWidth = x; - if ((0 == x) && (NS_STYLE_WHITESPACE_PRE != ts.mText->mWhiteSpace)) { + if ((0 == x) && !ts.mPreformatted) { aMetrics.height = 0; aMetrics.ascent = 0; aMetrics.descent = 0; @@ -2538,7 +2541,8 @@ TextFrame::TrimTrailingWhiteSpace(nsIPresContext& aPresContext, nscoord dw = 0; const nsStyleText* textStyle = (const nsStyleText*) mStyleContext->GetStyleData(eStyleStruct_Text); - if (NS_STYLE_WHITESPACE_PRE != textStyle->mWhiteSpace) { + if ((NS_STYLE_WHITESPACE_PRE != textStyle->mWhiteSpace) && + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP != textStyle->mWhiteSpace)) { // Get font metrics for a space so we can adjust the width by the // right amount. const nsStyleFont* fontStyle = (const nsStyleFont*) diff --git a/mozilla/layout/html/base/src/nsTextTransformer.cpp b/mozilla/layout/html/base/src/nsTextTransformer.cpp index ca19f2afefe..86c8073ce0a 100644 --- a/mozilla/layout/html/base/src/nsTextTransformer.cpp +++ b/mozilla/layout/html/base/src/nsTextTransformer.cpp @@ -117,7 +117,8 @@ nsTextTransformer::Init(/*nsTextRun& aTextRun, XXX*/ // Get the frames style and choose a transform proc const nsStyleText* styleText; aFrame->GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&) styleText); - mWhiteSpace = styleText->mWhiteSpace; + mPreformatted = (NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) || + (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace); mTextTransform = styleText->mTextTransform; if(NS_STYLE_TEXT_TRANSFORM_NONE != mTextTransform) @@ -192,7 +193,7 @@ nsTextTransformer::GetNextWord(PRBool aInWord, PRBool isWhitespace = XP_IS_SPACE(firstChar); offset++; if (isWhitespace) { - if (NS_STYLE_WHITESPACE_PRE == mWhiteSpace) { + if (mPreformatted) { if ('\t' == firstChar) { // Leave tab alone so that caller can expand it } @@ -219,7 +220,7 @@ nsTextTransformer::GetNextWord(PRBool aInWord, offset = 0; } mCurrentFragOffset = offset; - if (isWhitespace && (NS_STYLE_WHITESPACE_PRE == mWhiteSpace)) { + if (isWhitespace && mPreformatted) { goto really_done; } @@ -425,7 +426,7 @@ nsTextTransformer::GetPrevWord(PRBool aInWord, PRBool isWhitespace = XP_IS_SPACE(firstChar); offset--; if (isWhitespace) { - if (NS_STYLE_WHITESPACE_PRE == mWhiteSpace) { + if (mPreformatted) { if ('\t' == firstChar) { // Leave tab alone so that caller can expand it } @@ -454,7 +455,7 @@ nsTextTransformer::GetPrevWord(PRBool aInWord, mCurrentFrag = --frag; offset = mCurrentFrag->GetLength()-1; } - if (isWhitespace && (NS_STYLE_WHITESPACE_PRE == mWhiteSpace)) { + if (isWhitespace && mPreformatted) { goto really_done; } diff --git a/mozilla/layout/html/base/src/nsTextTransformer.h b/mozilla/layout/html/base/src/nsTextTransformer.h index 42ef32b2912..754ff6c0778 100644 --- a/mozilla/layout/html/base/src/nsTextTransformer.h +++ b/mozilla/layout/html/base/src/nsTextTransformer.h @@ -95,7 +95,7 @@ protected: PRInt32 mCurrentFragOffset; PRUint8 mTextTransform; - PRUint8 mWhiteSpace; + PRUint8 mPreformatted; nsILineBreaker* mLineBreaker; };