~*~ This document is intended for copy/paste into Mozilla source code. ~*~ Indentation, etc., should match up. --fantasai@escape.com ~*~ nsBlockFrame.cpp - line 4343 //Enable Justification ~*- replace: #if XXX_fix_me PRBool allowJustify = PR_TRUE; if (NS_STYLE_TEXT_ALIGN_JUSTIFY == aState.mStyleText->mTextAlign) { allowJustify = ShouldJustifyLine(aState, aLine); } #else PRBool allowJustify = PR_FALSE; #endif ~*+ with: PRBool allowJustify = PR_TRUE; if (NS_STYLE_TEXT_ALIGN_JUSTIFY == aState.mStyleText->mTextAlign) { allowJustify = ShouldJustifyLine(aState, aLine); } ~*~ nsIStyleContext.h - line 179 //Declare JSpacings ~*+ add: nscoord mJWSpacing; //for Justification by word (space) spacing nscoord mJCSpacing; //for Justification by character spacing ~*~ nsStyleContext.cpp - line 950 //reset JSpacings ~*- replace: } } ~*+ with: } mJWSpacing = 0; mJCSpacing = 0; } ~*~ nsTextFrame.cpp - line 461 ~*+ add: PRBool mLetterSpacingIsNormal; ~*~ nsTextFrame.cpp - line 507 //set mJustifying ~*+ add: mJustifying = NS_STYLE_TEXT_ALIGN_JUSTIFY == mText->mTextAlign; ~*~ nsTextFrame.cpp - line 518 //adjust TextStyle ~*- replace: } mNumSpaces = 0; ~*+ with: } else if (eStyleUnit_Normal == unit) mLetterSpacingIsNormal = PR_TRUE; if (mJustifying) { mSpaceWidth += mText->mJWSpacing; mLetterSpacing += mText->mJCSpacing; } mNumSpaces = 0; ~*~ nsTextFrame.cpp - line 3077 //Reduce JSpacings to zero for reflow ~*- replace: nsLineLayout& lineLayout = *aReflowState.mLineLayout; TextStyle ts(aPresContext, *aReflowState.rendContext, mStyleContext); ~*+ with: nsLineLayout& lineLayout = *aReflowState.mLineLayout; TextStyle ts(aPresContext, *aReflowState.rendContext, mStyleContext); if (ts.mJustifying) { ts.mSpaceWidth -= mText->mJWSpacing; ts.mLetterSpacing -= mText->mJCSpacing; mText->mJWSpacing = 0; mText->mJCSpacing = 0; } ~*~ //Count Justifiable Spaces and Characters: ~*~ nsTextFrame.cpp - line 431 (right before "//nsIHTMLReflow") ~*+ add: NS_IMETHOD GetJustifiable(PRInt32* aSpaces, PRInt32* aCharas) { *aSpaces = mNSpaces; *aCharas = mJChar; //Justification by char-spacing only when set to normal } ~*~ nsTextFrame.cpp - line 681 ~*+ add: PRInt32 mNSpaces; PRInt32 mJChar; ~*~ nsTextFrame.cpp - line 2913 ~*+ add: PRInt32 nSpaces = 0; ~*~ nsTextFrame.cpp - line 2955 ~*- replace: else { width = (wordLen * ts.mSpaceWidth) + ts.mWordSpacing;// XXX simplistic } ~*+ with: else { width = (wordLen * ts.mSpaceWidth) + ts.mWordSpacing;// XXX simplistic nSpaces += wordLen; } ~*~ nsTextFrame.cpp - line 3001 ~*- replace: // The text will not fit. ~*+ with: // The text will not fit. // Reduce number of spaces if necessary. if (isWhitespace && '\t' != bp[0]) { nSpaces -= wordLen; } ~*~ nsTextFrame.cpp - line 3196 ~*- replace: if (mState & TEXT_TRIMMED_WS) { // Add back in the width of a space since it was trimmed away last time x += ts.mSpaceWidth; } ~*+ with: if (mState & TEXT_TRIMMED_WS) { // Add back in the width of a space since it was trimmed away last time x += ts.mSpaceWidth; mNSpaces++; } ~*~ nsTextFrame.cpp - line 3353 ~*+ add: if (measureText) mNSpaces = nSpaces; if (ts.mLetterSpacingIsNormal) { mJChar = mContentLength; } else { mJChar = 0; } ~*~ nsTextFrame.cpp - line 3480 ~*- replace: if (0 != dw) { mState |= TEXT_TRIMMED_WS; } ~*+ with: if (0 != dw) { mState |= TEXT_TRIMMED_WS; mNSpaces--; } ~*~ // Apply Justification ~*~ nsLineLayout.h - line 306 ~*+ add: // Text Justification PRInt32 mNSpaces; PRInt32 mNChar; ~*~ nsLineLayout.h - line 407 ~*+ add: nscoord ApplyWSJustification(nscoord extra, nscoord* prem, PerSpanData* psd); ~*~ nsLineLayout.cpp - line 2523 ~*- replace: case NS_STYLE_TEXT_ALIGN_JUSTIFY: // If this is not the last line then go ahead and justify the // frames in the line. If it is the last line then if the // direction is right-to-left then we right-align the frames. if (aAllowJustify) { break; } else if (NS_STYLE_DIRECTION_RTL == psd->mDirection) { // right align the frames dx = remainingWidth; } break; ~*+ with: case NS_STYLE_TEXT_ALIGN_JUSTIFY: if (aShrinkWrap) { // We need to wait until the final width is known return PR_FALSE; } // If this is not the last line then go ahead and justify the // frames in the line. if (aAllowJustify) { PRInt32 tSpaces = 0; PRInt32 tChar = 0; PerSpanData* pfd = mRootSpan->mFirstFrame; while (nsnull != pfd) { if (PR_TRUE = pfd->mIsTextFrame) { PRInt32 spaces; PRInt32 charas; pfd->mFrame->GetJustifiable(&spaces,&charas); pfd->mNSpaces = spaces; tSpaces += spaces; pfd->mNChar = charas; tChar += charas; pfd = pfd->mNext; else { if (nsnull != pfd->mSpan) { pfd = pfd->mSpan->mFirstFrame; } else { if (nsnull != pfd->mNext) { pfd = pfd->mNext; } else { pfd = pfd->mParent->mNext; } } } } // Apply Justification nscoord dwidth = 0; if (0 != tspaces) { nscoord extra = remainingWidth / tspaces; nscoord rem = remainingWidth - extra; dwidth = ApplyWSJustification(extra,&rem,mRootSpan); } else { if (0 != tchar) { //XXX: Apply LetterSpacing Justification } } remainingWidth -= dwidth; } /* Fall through to RTL direction check * - For unused 'rem' * - For lines without text * - For the last line */ if (NS_STYLE_DIRECTION_RTL == psd->mDirection) { // right align the frames dx = remainingWidth; } break; ~*~ nsLineLayout.cpp - line 2578 (right before RelativePositionFrames) ~*+ add: nscoord nsLineLayout::ApplyWSJustification(nscoord extra, nscoord* prem, PerSpanData* psd) { nscoord rem = *prem; nscoord deltaX = 0; PerFrameData* pfd = psd->mFirstFrame; while (nsnull != pfd) { pfd->mBounds.x += deltaX; if (PR_TRUE = pfd->mIsTextFrame) { PRInt32 nSpaces = pfd->mNSpaces; if (0 != nSpaces) { pfd->mFrame->GetStyleData(eStyleStruct_Text,(const nsStyleStruct*&)textStyle); nscoord dw; if (rem >= nSpaces) { textStyle->mJWSpacing = extra + 1; rem -= nSpaces; } else { textStyle->mJWSpacing = extra; } dw = textStyle->mJWSpacing * nSpaces; pfd->mBounds.width += dw; deltaX += dw; } } else { if (nsnull != pfd->mSpan) { nscoord dw = ApplyWSJustification(extra,&rem,pfd->mSpan); pfd->mBounds.width += dw; deltaX += dw; } } pfd->mFrame->SetRect(mPresContext,pfd->mBounds); pfd = pfd->mNext; } *prem = rem; return deltaX; } ~*~ Does this function (above) need to change left and right edges on PerSpanData? ~*~ LAST MODIFIED: 2000-03-25