Bug 164700 css word-spacing applies at   at paint time but not at layout (reflow) time r+sr=rbs

This commit is contained in:
masayuki%d-toybox.com 2006-03-08 03:30:57 +00:00
Родитель 4a3e2f516f
Коммит 2dfb698e3d
3 изменённых файлов: 46 добавлений и 9 удалений

Просмотреть файл

@ -3453,7 +3453,7 @@ nsTextFrame::GetTextDimensionsOrLength(nsIRenderingContext& aRenderingContext,
if (ch == kSZLIG)
glyphDimensions.width += glyphDimensions.width;
}
else if (ch == ' ') {
else if (ch == ' ' || ch == CH_NBSP) {
glyphDimensions.width = aStyle.mSpaceWidth + aStyle.mLetterSpacing
+ aStyle.mWordSpacing;
}
@ -5432,6 +5432,12 @@ nsTextFrame::MeasureText(nsPresContext* aPresContext,
// since we didn't add the trailing space width, set this flag so that
// we will not trim this non-existing space
aTextData.mTrailingSpaceTrimmed = PR_TRUE;
// Note: word-spacing or letter-spacing can make the "space" really
// wide. But since this space is left out from our width, linelayout
// may still try to fit something narrower at the end of the line.
// So on return (see below), we flag a break-after status to ensure
// that linelayout doesn't place something where the "space" should
// be.
break;
}
}
@ -5504,6 +5510,20 @@ nsTextFrame::MeasureText(nsPresContext* aPresContext,
if (aTs.mLetterSpacing) {
dimensions.width += aTs.mLetterSpacing * wordLen;
}
if (aTs.mWordSpacing) {
if (aTx.TransformedTextIsAscii()) {
for (char* bp = bp1; bp < bp1 + wordLen; bp++) {
if (*bp == ' ') // || *bp == CH_CJKSP)
dimensions.width += aTs.mWordSpacing;
}
} else {
for (PRUnichar* bp = bp2; bp < bp2 + wordLen; bp++) {
if (*bp == ' ') // || *bp == CH_CJKSP)
dimensions.width += aTs.mWordSpacing;
}
}
}
}
lastWordDimensions = dimensions;
@ -5762,6 +5782,13 @@ nsTextFrame::MeasureText(nsPresContext* aPresContext,
if (aTs.mLetterSpacing) {
lastWordDimensions.width += aTs.mLetterSpacing * lastWordLen;
}
if (aTs.mWordSpacing) {
for (PRUnichar* bp = pWordBuf;
bp < pWordBuf + lastWordLen; bp++) {
if (*bp == ' ') // || *bp == CH_CJKSP)
lastWordDimensions.width += aTs.mWordSpacing;
}
}
}
}
nsTextDimensions wordDimensions = ComputeTotalWordDimensions(aPresContext,
@ -5845,9 +5872,11 @@ nsTextFrame::MeasureText(nsPresContext* aPresContext,
#endif // IBMBIDI
? NS_FRAME_COMPLETE
: NS_FRAME_NOT_COMPLETE;
if (endsInNewline) {
if (endsInNewline || aTextData.mTrailingSpaceTrimmed) {
rs = NS_INLINE_LINE_BREAK_AFTER(rs);
lineLayout.SetLineEndsInBR(PR_TRUE);
if (endsInNewline) {
lineLayout.SetLineEndsInBR(PR_TRUE);
}
}
else if ((aTextData.mOffset != contentLength) && (aTextData.mOffset == startingOffset)) {
// Break-before a long-word that doesn't fit here
@ -6487,6 +6516,12 @@ nsTextFrame::ComputeWordFragmentDimensions(nsPresContext* aPresContext,
rc.GetTextDimensions(bp, wordLen, dimensions);
// NOTE: Don't forget to add letter spacing for the word fragment!
dimensions.width += wordLen*ts.mLetterSpacing;
if (ts.mWordSpacing) {
for (PRUnichar* bp2 = bp; bp2 < bp + wordLen; bp2++) {
if (*bp2 == CH_NBSP) // || *bp2 == CH_CJKSP)
dimensions.width += ts.mWordSpacing;
}
}
}
rc.SetFont(oldfm);

Просмотреть файл

@ -594,6 +594,7 @@ nsTextTransformer::ScanNormalUnicodeText_F(PRBool aForLineBreak,
PRUnichar ch = *cp++;
if (CH_NBSP == ch) {
ch = ' ';
*aWasTransformed = PR_TRUE;
}
else if (IS_DISCARDED(ch) || (ch == 0x0a) || (ch == 0x0d)) {
// Strip discarded characters from the transformed output

Просмотреть файл

@ -52,12 +52,13 @@ class nsILineBreaker;
class nsIWordBreaker;
// XXX I'm sure there are other special characters
#define CH_NBSP 160
#define CH_ENSP 8194 //<!ENTITY ensp CDATA "&#8194;" -- en space, U+2002 ISOpub -->
#define CH_EMSP 8195 //<!ENTITY emsp CDATA "&#8195;" -- em space, U+2003 ISOpub -->
#define CH_THINSP 8291 //<!ENTITY thinsp CDATA "&#8201;" -- thin space, U+2009 ISOpub -->
#define CH_ZWNJ 8204 //<!ENTITY zwnj CDATA "&#8204;" -- zero width non-joiner, U+200C NEW RFC 2070
#define CH_SHY 173
#define CH_NBSP 160
#define CH_ENSP 8194 //<!ENTITY ensp CDATA "&#8194;" -- en space, U+2002 ISOpub -->
#define CH_EMSP 8195 //<!ENTITY emsp CDATA "&#8195;" -- em space, U+2003 ISOpub -->
#define CH_THINSP 8291 //<!ENTITY thinsp CDATA "&#8201;" -- thin space, U+2009 ISOpub -->
#define CH_ZWNJ 8204 //<!ENTITY zwnj CDATA "&#8204;" -- zero width non-joiner, U+200C NEW RFC 2070
#define CH_SHY 173
#define CH_CJKSP 12288 // U+3000 IDEOGRAPHIC SPACE (CJK Full-Width Space)
#ifdef IBMBIDI
#define CH_ZWJ 8205 //<!ENTITY zwj CDATA "&#8205;" -- zero width joiner, U+200D NEW RFC 2070 -->