Bug 534071 - Treat carriage returns as tab-like whitespace in layout. r=roc.

This commit is contained in:
Henri Sivonen 2010-05-12 10:57:12 +03:00
parent 1f6582fa3c
commit 2250d7a27c
2 changed files with 8 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class nsCString;
// XXX these need I18N spankage
#define XP_IS_SPACE(_ch) \
(((_ch) == ' ') || ((_ch) == '\t') || ((_ch) == '\n'))
(((_ch) == ' ') || ((_ch) == '\t') || ((_ch) == '\n') || ((_ch) == '\r'))
#define XP_IS_UPPERCASE(_ch) \
(((_ch) >= 'A') && ((_ch) <= 'Z'))

View File

@ -538,6 +538,7 @@ static PRBool IsCSSWordSpacingSpace(const nsTextFragment* aFrag,
case ' ':
case CH_NBSP:
return !IsSpaceCombiningSequenceTail(aFrag, aPos + 1);
case '\r':
case '\t': return !aStyleText->WhiteSpaceIsSignificant();
case '\n': return !aStyleText->NewlineIsSignificant();
default: return PR_FALSE;
@ -553,14 +554,14 @@ static PRBool IsTrimmableSpace(const PRUnichar* aChars, PRUint32 aLength)
PRUnichar ch = *aChars;
if (ch == ' ')
return !nsTextFrameUtils::IsSpaceCombiningSequenceTail(aChars + 1, aLength - 1);
return ch == '\t' || ch == '\f' || ch == '\n';
return ch == '\t' || ch == '\f' || ch == '\n' || ch == '\r';
}
// Check whether the character aCh is trimmable according to CSS
// 'white-space:normal/nowrap'
static PRBool IsTrimmableSpace(char aCh)
{
return aCh == ' ' || aCh == '\t' || aCh == '\f' || aCh == '\n';
return aCh == ' ' || aCh == '\t' || aCh == '\f' || aCh == '\n' || aCh == '\r';
}
static PRBool IsTrimmableSpace(const nsTextFragment* aFrag, PRUint32 aPos,
@ -573,6 +574,7 @@ static PRBool IsTrimmableSpace(const nsTextFragment* aFrag, PRUint32 aPos,
!IsSpaceCombiningSequenceTail(aFrag, aPos + 1);
case '\n': return !aStyleText->NewlineIsSignificant();
case '\t':
case '\r':
case '\f': return !aStyleText->WhiteSpaceIsSignificant();
default: return PR_FALSE;
}
@ -584,7 +586,7 @@ static PRBool IsSelectionSpace(const nsTextFragment* aFrag, PRUint32 aPos)
PRUnichar ch = aFrag->CharAt(aPos);
if (ch == ' ' || ch == CH_NBSP)
return !IsSpaceCombiningSequenceTail(aFrag, aPos + 1);
return ch == '\t' || ch == '\n' || ch == '\f';
return ch == '\t' || ch == '\n' || ch == '\f' || ch == '\r';
}
// Count the amount of trimmable whitespace (as per CSS
@ -627,7 +629,7 @@ IsAllWhitespace(const nsTextFragment* aFrag, PRBool aAllowNewline)
const char* str = aFrag->Get1b();
for (PRInt32 i = 0; i < len; ++i) {
char ch = str[i];
if (ch == ' ' || ch == '\t' || (ch == '\n' && aAllowNewline))
if (ch == ' ' || ch == '\t' || ch == '\r' || (ch == '\n' && aAllowNewline))
continue;
return PR_FALSE;
}
@ -2108,7 +2110,7 @@ static PRBool IsJustifiableCharacter(const nsTextFragment* aFrag, PRInt32 aPos,
PRBool aLangIsCJ)
{
PRUnichar ch = aFrag->CharAt(aPos);
if (ch == '\n' || ch == '\t')
if (ch == '\n' || ch == '\t' || ch == '\r')
return PR_TRUE;
if (ch == ' ' || ch == CH_NBSP) {
// Don't justify spaces that are combined with diacriticals