Bug 363390 IS_LOW_SURROGATE conflicts with winnls.h

r=darin
This commit is contained in:
timeless%mozdev.org 2006-12-21 07:03:23 +00:00
parent 24ff8b5b51
commit 05804e5bfe
34 changed files with 108 additions and 108 deletions

View File

@ -449,8 +449,8 @@ ConvertAndWrite(const nsAString& aString,
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString entString("&#");
if (IS_HIGH_SURROGATE(unicodeBuf[unicodeLength - 1]) &&
unicodeLength < startLength && IS_LOW_SURROGATE(unicodeBuf[unicodeLength])) {
if (NS_IS_HIGH_SURROGATE(unicodeBuf[unicodeLength - 1]) &&
unicodeLength < startLength && NS_IS_LOW_SURROGATE(unicodeBuf[unicodeLength])) {
entString.AppendInt(SURROGATE_TO_UCS4(unicodeBuf[unicodeLength - 1],
unicodeBuf[unicodeLength]));
unicodeLength += 1;

View File

@ -963,9 +963,9 @@ nsHTMLContentSerializer::AppendToString(const nsAString& aStr,
else if (val > 127 &&
mFlags & nsIDocumentEncoder::OutputEncodeW3CEntities &&
mEntityConverter) {
if (IS_HIGH_SURROGATE(val) &&
if (NS_IS_HIGH_SURROGATE(val) &&
c + 1 < fragmentEnd &&
IS_LOW_SURROGATE(*(c + 1))) {
NS_IS_LOW_SURROGATE(*(c + 1))) {
PRUint32 valUTF32 = SURROGATE_TO_UCS4(val, *(++c));
if (NS_SUCCEEDED(mEntityConverter->ConvertUTF32ToEntity(valUTF32,
nsIEntityConverter::entityW3C, &fullEntityText))) {

View File

@ -394,9 +394,9 @@ nsTextFragment::SetBidiFlag()
while (cp < end) {
PRUnichar ch1 = *cp++;
PRUint32 utf32Char = ch1;
if (IS_HIGH_SURROGATE(ch1) &&
if (NS_IS_HIGH_SURROGATE(ch1) &&
cp < end &&
IS_LOW_SURROGATE(*cp)) {
NS_IS_LOW_SURROGATE(*cp)) {
PRUnichar ch2 = *cp++;
utf32Char = SURROGATE_TO_UCS4(ch1, ch2);
}

View File

@ -4885,17 +4885,17 @@ nsEditor::CreateTxnForDeleteCharacter(nsIDOMCharacterData *aData,
PRUint32 segOffset, segLength = 1;
if (aDirection == eNext) {
segOffset = aOffset;
if (IS_HIGH_SURROGATE(data[segOffset]) &&
if (NS_IS_HIGH_SURROGATE(data[segOffset]) &&
segOffset + 1 < data.Length() &&
IS_LOW_SURROGATE(data[segOffset+1])) {
NS_IS_LOW_SURROGATE(data[segOffset+1])) {
// delete both halves of the surrogate pair
++segLength;
}
} else {
segOffset = aOffset - 1;
if (IS_LOW_SURROGATE(data[segOffset]) &&
if (NS_IS_LOW_SURROGATE(data[segOffset]) &&
segOffset > 0 &&
IS_HIGH_SURROGATE(data[segOffset-1])) {
NS_IS_HIGH_SURROGATE(data[segOffset-1])) {
++segLength;
--segOffset;
}

View File

@ -2079,7 +2079,7 @@ nsFontMetricsGTK::ResolveForwards(const PRUnichar *aString,
count = mLoadedFontsCount;
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -2100,7 +2100,7 @@ nsFontMetricsGTK::ResolveForwards(const PRUnichar *aString,
return NS_OK;
// continue with the next substring, re-using the available loaded fonts
firstChar = currChar;
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -2113,7 +2113,7 @@ nsFontMetricsGTK::ResolveForwards(const PRUnichar *aString,
// see if we can keep the same font for adjacent characters
PRInt32 lastCharLen;
while (currChar < lastChar) {
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
nextFont = LocateFont(SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
lastCharLen = 2;
}
@ -3676,7 +3676,7 @@ nsFontMetricsGTK::GetWidth (const PRUnichar* aString, PRUint32 aLength,
PRUint32 c = aString[i];
extraSurrogateLength=0;
if(i < aLength-1 && IS_HIGH_SURROGATE(c) && IS_LOW_SURROGATE(aString[i+1])) {
if(i < aLength-1 && NS_IS_HIGH_SURROGATE(c) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] and
// low surrogate aString[i+1]
c = SURROGATE_TO_UCS4(c, aString[i+1]);
@ -3835,7 +3835,7 @@ nsFontMetricsGTK::DrawString(const PRUnichar* aString, PRUint32 aLength,
for (i = 0; i < aLength; i+=1+extraSurrogateLength) {
PRUint32 c = aString[i];
extraSurrogateLength=0;
if(i < aLength-1 && IS_HIGH_SURROGATE(c) && IS_LOW_SURROGATE(aString[i+1])) {
if(i < aLength-1 && NS_IS_HIGH_SURROGATE(c) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] and
// low surrogate aString[i+1]
c = SURROGATE_TO_UCS4(c, aString[i+1]);
@ -4012,7 +4012,7 @@ nsFontMetricsGTK::GetBoundingMetrics(const PRUnichar *aString,
for (i = 0; i < aLength; i+=1+extraSurrogateLength) {
PRUint32 c = aString[i];
extraSurrogateLength=0;
if(i < aLength-1 && IS_HIGH_SURROGATE(c) && IS_LOW_SURROGATE(aString[i+1])) {
if(i < aLength-1 && NS_IS_HIGH_SURROGATE(c) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] and
// low surrogate aString[i+1]
c = SURROGATE_TO_UCS4(c, aString[i+1]);
@ -4106,7 +4106,7 @@ nsFontMetricsGTK::GetTextDimensions (const PRUnichar* aString,
for (i = 0; i < aLength; i+=1+extraSurrogateLength) {
PRUint32 c = aString[i];
extraSurrogateLength=0;
if(i < aLength-1 && IS_HIGH_SURROGATE(c) && IS_LOW_SURROGATE(aString[i+1])) {
if(i < aLength-1 && NS_IS_HIGH_SURROGATE(c) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] and
// low surrogate aString[i+1]
c = SURROGATE_TO_UCS4(c, aString[i+1]);

View File

@ -645,7 +645,7 @@ nsFontMetricsPango::GetTextDimensions(const PRUnichar* aString,
curBreak++;
}
if (IS_HIGH_SURROGATE(aString[curOffset]))
if (NS_IS_HIGH_SURROGATE(aString[curOffset]))
curOffset++;
}
@ -925,7 +925,7 @@ nsFontMetricsPango::GetClusterInfo(const PRUnichar *aText,
pango_layout_get_log_attrs(layout, &attrs, &n_attrs);
for (PRUint32 pos = 0; pos < aLength; pos++) {
if (IS_HIGH_SURROGATE(aText[pos])) {
if (NS_IS_HIGH_SURROGATE(aText[pos])) {
aClusterStarts[pos] = 1;
pos++;
}
@ -991,7 +991,7 @@ nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
break;
}
if (IS_HIGH_SURROGATE(aText[curOffset]))
if (NS_IS_HIGH_SURROGATE(aText[curOffset]))
curOffset++;
}
@ -1001,7 +1001,7 @@ nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
retval++;
// Yes, this can make aInx > length to indicate the end of the
// string.
if (retval < (PRInt32)aLength && IS_HIGH_SURROGATE(aText[retval]))
if (retval < (PRInt32)aLength && NS_IS_HIGH_SURROGATE(aText[retval]))
retval++;
trailing--;
}
@ -1051,7 +1051,7 @@ nsFontMetricsPango::GetRangeWidth(const PRUnichar *aText,
if (curOffset == aEnd)
utf8End = curChar - text;
if (IS_HIGH_SURROGATE(aText[curOffset]))
if (NS_IS_HIGH_SURROGATE(aText[curOffset]))
curOffset++;
}
@ -1316,7 +1316,7 @@ nsFontMetricsPango::DrawStringSlowly(const gchar *aText,
curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
utf8spacing[curChar - aText] = aSpacing[curOffset];
if (IS_HIGH_SURROGATE(aOrigString[curOffset]))
if (NS_IS_HIGH_SURROGATE(aOrigString[curOffset]))
curOffset++;
}
}

View File

@ -2403,8 +2403,8 @@ ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,
if (IS_NON_SURROGATE(c)) {
outBuffer[outLen] = c;
}
else if (IS_HIGH_SURROGATE(aString[i])) {
if (i + 1 < aLength && IS_LOW_SURROGATE(aString[i+1])) {
else if (NS_IS_HIGH_SURROGATE(aString[i])) {
if (i + 1 < aLength && NS_IS_LOW_SURROGATE(aString[i+1])) {
outBuffer[outLen] = SURROGATE_TO_UCS4(c, aString[i + 1]);
++i;
}
@ -2412,7 +2412,7 @@ ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,
outBuffer[outLen] = UCS2_REPLACEMENT;
}
}
else if (IS_LOW_SURROGATE(aString[i])) { // Unpaired low surrogate?
else if (NS_IS_LOW_SURROGATE(aString[i])) { // Unpaired low surrogate?
outBuffer[outLen] = UCS2_REPLACEMENT;
}

View File

@ -1301,9 +1301,9 @@ nsUnicodeRenderingToolkit::GetTextSegmentDimensions(
PRBool fallbackDone = PR_FALSE;
segDim.Clear();
if (IS_HIGH_SURROGATE(*aString) &&
if (NS_IS_HIGH_SURROGATE(*aString) &&
((processLen+1) < aLength) &&
IS_LOW_SURROGATE(*(aString+1)))
NS_IS_LOW_SURROGATE(*(aString+1)))
{
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = SurrogateGetDimensions(aString, segDim, fontNum,
@ -1486,9 +1486,9 @@ nsUnicodeRenderingToolkit::GetTextSegmentBoundingMetrics(
PRBool fallbackDone = PR_FALSE;
segBoundingMetrics.Clear();
if (IS_HIGH_SURROGATE(*aString) &&
if (NS_IS_HIGH_SURROGATE(*aString) &&
((processLen+1) < aLength) &&
IS_LOW_SURROGATE(*(aString+1)) )
NS_IS_LOW_SURROGATE(*(aString+1)) )
{
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = SurrogateGetBoundingMetrics(aString, segBoundingMetrics, fontNum,
@ -1626,9 +1626,9 @@ nsresult nsUnicodeRenderingToolkit :: DrawTextSegment(
{
PRBool fallbackDone = PR_FALSE;
if (IS_HIGH_SURROGATE(*aString) &&
if (NS_IS_HIGH_SURROGATE(*aString) &&
((processLen+1) < aLength) &&
IS_LOW_SURROGATE(*(aString+1)) )
NS_IS_LOW_SURROGATE(*(aString+1)) )
{
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = SurrogateDrawChar(aString, x, y, thisWidth, fontNum,

View File

@ -2194,7 +2194,7 @@ nsFontMetricsOS2FT::ResolveForwards(HPS aPS,
count = mLoadedFonts.Count();
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(aPS, SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -2215,7 +2215,7 @@ nsFontMetricsOS2FT::ResolveForwards(HPS aPS,
return NS_OK;
// continue with the next substring, re-using the available loaded fonts
firstChar = currChar;
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(aPS, SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -2228,7 +2228,7 @@ nsFontMetricsOS2FT::ResolveForwards(HPS aPS,
// see if we can keep the same font for adjacent characters
PRInt32 lastCharLen;
while (currChar < lastChar) {
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
nextFont = LocateFont(aPS, SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
lastCharLen = 2;
}
@ -2278,7 +2278,7 @@ nsFontMetricsOS2FT::ResolveBackwards(HPS aPS,
count = mLoadedFonts.Count();
// see if one of our loaded fonts can represent the current character
if (IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && IS_HIGH_SURROGATE(*(currChar-1))) {
if (NS_IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && NS_IS_HIGH_SURROGATE(*(currChar-1))) {
currFont = LocateFont(aPS, SURROGATE_TO_UCS4(*(currChar-1), *currChar), count);
currChar -= 2;
}
@ -2299,7 +2299,7 @@ nsFontMetricsOS2FT::ResolveBackwards(HPS aPS,
return NS_OK;
// continue with the next substring, re-using the available loaded fonts
firstChar = currChar;
if (IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && IS_HIGH_SURROGATE(*(currChar-1))) {
if (NS_IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && NS_IS_HIGH_SURROGATE(*(currChar-1))) {
currFont = LocateFont(aPS, SURROGATE_TO_UCS4(*(currChar-1), *currChar), count);
currChar -= 2;
}
@ -2314,7 +2314,7 @@ nsFontMetricsOS2FT::ResolveBackwards(HPS aPS,
PRUint32 codepoint;
while (currChar > lastChar) {
if (IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && IS_HIGH_SURROGATE(*(currChar-1))) {
if (NS_IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && NS_IS_HIGH_SURROGATE(*(currChar-1))) {
codepoint = SURROGATE_TO_UCS4(*(currChar-1), *currChar);
nextFont = LocateFont(aPS, codepoint, count);
lastCharLen = 2;

View File

@ -2040,9 +2040,9 @@ do_DrawString(const nsFontSwitch* aFontSwitch,
x = data->mX;
y = data->mY;
data->mTranMatrix->TransformCoord(&x, &y);
if (IS_HIGH_SURROGATE(*str) &&
if (NS_IS_HIGH_SURROGATE(*str) &&
((str+1)<end) &&
IS_LOW_SURROGATE(*(str+1)))
NS_IS_LOW_SURROGATE(*(str+1)))
{
// special case for surrogate pair
font->DrawString(data->mPS, data->mSurface, x, y, str, 2);

View File

@ -527,7 +527,7 @@ static PRInt32 FindSafeLength(nsRenderingContextImpl* aContext,
// Ensure that we don't break inside a cluster or inside a surrogate pair
while (len > 0 &&
(IS_LOW_SURROGATE(aString[len]) || (clusterHint && !buffer[len]))) {
(NS_IS_LOW_SURROGATE(aString[len]) || (clusterHint && !buffer[len]))) {
len--;
}
if (len == 0) {

View File

@ -4028,7 +4028,7 @@ nsFontMetricsWin::ResolveForwards(HDC aDC,
count = mLoadedFonts.Count();
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(aDC, SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -4054,7 +4054,7 @@ nsFontMetricsWin::ResolveForwards(HDC aDC,
return NS_OK;
// continue with the next substring, re-using the available loaded fonts
firstChar = currChar;
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(aDC, SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -4067,7 +4067,7 @@ nsFontMetricsWin::ResolveForwards(HDC aDC,
// see if we can keep the same font for adjacent characters
PRInt32 lastCharLen;
while (currChar < lastChar) {
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
nextFont = LocateFont(aDC, SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
lastCharLen = 2;
}
@ -4117,7 +4117,7 @@ nsFontMetricsWin::ResolveBackwards(HDC aDC,
count = mLoadedFonts.Count();
// see if one of our loaded fonts can represent the current character
if (IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && IS_HIGH_SURROGATE(*(currChar-1))) {
if (NS_IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && NS_IS_HIGH_SURROGATE(*(currChar-1))) {
currFont = LocateFont(aDC, SURROGATE_TO_UCS4(*(currChar-1), *currChar), count);
currChar -= 2;
}
@ -4144,7 +4144,7 @@ nsFontMetricsWin::ResolveBackwards(HDC aDC,
return NS_OK;
// continue with the next substring, re-using the available loaded fonts
firstChar = currChar;
if (IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && IS_HIGH_SURROGATE(*(currChar-1))) {
if (NS_IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && NS_IS_HIGH_SURROGATE(*(currChar-1))) {
currFont = LocateFont(aDC, SURROGATE_TO_UCS4(*(currChar-1), *currChar), count);
currChar -= 2;
}
@ -4159,7 +4159,7 @@ nsFontMetricsWin::ResolveBackwards(HDC aDC,
PRUint32 codepoint;
while (currChar > lastChar) {
if (IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && IS_HIGH_SURROGATE(*(currChar-1))) {
if (NS_IS_LOW_SURROGATE(*currChar) && (currChar-1) > lastChar && NS_IS_HIGH_SURROGATE(*(currChar-1))) {
codepoint = SURROGATE_TO_UCS4(*(currChar-1), *currChar);
nextFont = LocateFont(aDC, codepoint, count);
lastCharLen = 2;
@ -4291,8 +4291,8 @@ VerifyFontHasGlyph(nsFontWin* aFont, const PRUnichar* aString, PRInt32 aLength)
const PRUnichar* last = aString + aLength;
PRUint32 ch;
while (curr < last) {
if (IS_HIGH_SURROGATE(*curr) && (curr+1) < last &&
IS_LOW_SURROGATE(*(curr+1))) {
if (NS_IS_HIGH_SURROGATE(*curr) && (curr+1) < last &&
NS_IS_LOW_SURROGATE(*(curr+1))) {
ch = SURROGATE_TO_UCS4(*curr, *(curr+1));
curr += 2;
}

View File

@ -2267,9 +2267,9 @@ do_DrawString(const nsFontSwitch* aFontSwitch,
x = data->mX;
y = data->mY;
data->mTranMatrix->TransformCoord(&x, &y);
if (IS_HIGH_SURROGATE(*str) &&
if (NS_IS_HIGH_SURROGATE(*str) &&
((str+1)<end) &&
IS_LOW_SURROGATE(*(str+1)))
NS_IS_LOW_SURROGATE(*(str+1)))
{
// special case for surrogate pair
fontWin->DrawString(data->mDC, x, y, str, 2);

View File

@ -327,7 +327,7 @@ nsFreeTypeFont::doGetBoundingMetrics(const PRUnichar* aString, PRUint32 aLength,
extraSurrogateLength=0;
FT_ULong code_point = aString[i];
if(i<aLength-1 && IS_HIGH_SURROGATE(code_point) && IS_LOW_SURROGATE(aString[i+1])) {
if(i<aLength-1 && NS_IS_HIGH_SURROGATE(code_point) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] surrogate and
// low surrogate aString[i+1]
code_point = SURROGATE_TO_UCS4(code_point, aString[i+1]);
@ -410,7 +410,7 @@ nsFreeTypeFont::GetWidth(const PRUnichar* aString, PRUint32 aLength)
for (i=0; i<aLength; i+=1+extraSurrogateLength) {
extraSurrogateLength=0;
FT_ULong code_point = aString[i];
if(i<aLength-1 && IS_HIGH_SURROGATE(code_point) && IS_LOW_SURROGATE(aString[i+1])) {
if(i<aLength-1 && NS_IS_HIGH_SURROGATE(code_point) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] surrogate and
// low surrogate aString[i+1]
code_point = SURROGATE_TO_UCS4(code_point, aString[i+1]);
@ -741,7 +741,7 @@ nsFreeTypeXImage::DrawString(nsRenderingContextGTK* aContext,
FT_ULong code_point = aString[i];
extraSurrogateLength = 0;
if(i<aLength-1 && IS_HIGH_SURROGATE(code_point) && IS_LOW_SURROGATE(aString[i+1])) {
if(i<aLength-1 && NS_IS_HIGH_SURROGATE(code_point) && NS_IS_LOW_SURROGATE(aString[i+1])) {
// if surrogate, make UCS4 code point from high aString[i] surrogate and
// low surrogate aString[i+1]
code_point = SURROGATE_TO_UCS4(code_point, aString[i+1]);

View File

@ -2433,7 +2433,7 @@ nsFontMetricsXlib::ResolveForwards(const PRUnichar* aString,
count = mLoadedFontsCount;
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -2454,7 +2454,7 @@ nsFontMetricsXlib::ResolveForwards(const PRUnichar* aString,
return NS_OK;
// continue with the next substring, re-using the available loaded fonts
firstChar = currChar;
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
currFont = LocateFont(SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
currChar += 2;
}
@ -2467,7 +2467,7 @@ nsFontMetricsXlib::ResolveForwards(const PRUnichar* aString,
// see if we can keep the same font for adjacent characters
PRInt32 lastCharLen;
while (currChar < lastChar) {
if (IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && IS_LOW_SURROGATE(*(currChar+1))) {
if (NS_IS_HIGH_SURROGATE(*currChar) && (currChar+1) < lastChar && NS_IS_LOW_SURROGATE(*(currChar+1))) {
nextFont = LocateFont(SURROGATE_TO_UCS4(*currChar, *(currChar+1)), count);
lastCharLen = 2;
}

View File

@ -777,7 +777,7 @@ gfxXftTextRun::SetSpacing(const nsTArray<gfxFloat>& spacingArray)
for (; prevChar + 1 < curChar; prevChar++)
mUTF8Spacing.AppendElement(0);
mUTF8Spacing.AppendElement((PRInt32)NSToCoordRound(mSpacing[i]));
if (IS_HIGH_SURROGATE(mWString[i]))
if (NS_IS_HIGH_SURROGATE(mWString[i]))
i++;
prevChar = curChar;
curChar = g_utf8_find_next_char(curChar, NULL);
@ -1488,7 +1488,7 @@ gfxPangoTextRun::SetSpacing(const nsTArray<gfxFloat> &spacingArray)
for (; prevChar + 1 < curChar; prevChar++)
mUTF8Spacing.AppendElement(0);
mUTF8Spacing.AppendElement((PRInt32)NSToCoordRound(mSpacing[i] * FLOAT_PANGO_SCALE));
if (IS_HIGH_SURROGATE(mString[i]))
if (NS_IS_HIGH_SURROGATE(mString[i]))
i++;
prevChar = curChar;
curChar = g_utf8_find_next_char(curChar, NULL);

View File

@ -1256,7 +1256,7 @@ TRY_AGAIN_HOPE_FOR_THE_BEST_2:
for (PRUint32 la = 0; la < mLength; la++) {
PRUint32 ch = mString[la];
if ((la+1 < mLength) && IS_HIGH_SURROGATE(ch) && IS_LOW_SURROGATE(mString[la+1])) {
if ((la+1 < mLength) && NS_IS_HIGH_SURROGATE(ch) && NS_IS_LOW_SURROGATE(mString[la+1])) {
la++;
ch = SURROGATE_TO_UCS4(ch, mString[la]);
}
@ -1395,7 +1395,7 @@ private:
memcpy((void *)mAlternativeString, (const void *)mString,
mLength * sizeof(PRUnichar));
for (PRUint32 i = 0; i < mLength; i++) {
if (IS_HIGH_SURROGATE(mString[i]) || IS_LOW_SURROGATE(mString[i]))
if (NS_IS_HIGH_SURROGATE(mString[i]) || NS_IS_LOW_SURROGATE(mString[i]))
mAlternativeString[i] = PRUnichar(0xFFFD);
}
}

View File

@ -359,7 +359,7 @@ gfxWindowsPlatform::FindOtherFonts(const PRUnichar* aString, PRUint32 aLength, c
for (PRUint32 z = 0; z < aLength; ++z) {
PRUint32 ch = aString[z];
if ((z+1 < aLength) && IS_HIGH_SURROGATE(ch) && IS_LOW_SURROGATE(aString[z+1])) {
if ((z+1 < aLength) && NS_IS_HIGH_SURROGATE(ch) && NS_IS_LOW_SURROGATE(aString[z+1])) {
z++;
ch = SURROGATE_TO_UCS4(ch, aString[z]);
surrogates = PR_TRUE;

View File

@ -402,8 +402,8 @@ PRBool nsJISx4051LineBreaker::BreakInBetween(
const PRUnichar* aText2 , PRUint32 aTextLen2)
{
if(!aText1 || !aText2 || (0 == aTextLen1) || (0==aTextLen2) ||
IS_HIGH_SURROGATE(aText1[aTextLen1-1]) &&
IS_LOW_SURROGATE(aText2[0]) ) //Do not separate a surrogate pair
NS_IS_HIGH_SURROGATE(aText1[aTextLen1-1]) &&
NS_IS_LOW_SURROGATE(aText2[0]) ) //Do not separate a surrogate pair
{
return PR_FALSE;
}

View File

@ -118,8 +118,8 @@ PRBool nsUnicodeToGB18030::EncodeSurrogate(
PRUnichar aSurrogateLow,
char* aOut)
{
if( IS_HIGH_SURROGATE(aSurrogateHigh) &&
IS_LOW_SURROGATE(aSurrogateLow) )
if( NS_IS_HIGH_SURROGATE(aSurrogateHigh) &&
NS_IS_LOW_SURROGATE(aSurrogateLow) )
{
// notice that idx does not include the 0x10000
PRUint32 idx = ((aSurrogateHigh - (PRUnichar)0xD800) << 10 ) |
@ -337,8 +337,8 @@ PRBool nsUnicodeToGBK::TryExtensionEncoder(
PRInt32 *aOutLen
)
{
if( IS_HIGH_SURROGATE(aChar) ||
IS_LOW_SURROGATE(aChar) )
if( NS_IS_HIGH_SURROGATE(aChar) ||
NS_IS_LOW_SURROGATE(aChar) )
{
// performance tune for surrogate characters
return PR_FALSE;
@ -362,8 +362,8 @@ PRBool nsUnicodeToGBK::Try4BytesEncoder(
PRInt32 *aOutLen
)
{
if( IS_HIGH_SURROGATE(aChar) ||
IS_LOW_SURROGATE(aChar) )
if( NS_IS_HIGH_SURROGATE(aChar) ||
NS_IS_LOW_SURROGATE(aChar) )
{
// performance tune for surrogate characters
return PR_FALSE;
@ -449,7 +449,7 @@ NS_IMETHODIMP nsUnicodeToGBK::ConvertNoBuff(
// we still cannot map. Let's try to
// call the delegated GB18030 4 byte converter
aOutLen = 4;
if( IS_HIGH_SURROGATE(unicode) )
if( NS_IS_HIGH_SURROGATE(unicode) )
{
if((iSrcLength+1) < *aSrcLength ) {
if(EncodeSurrogate(aSrc[0],aSrc[1], aDest)) {
@ -469,9 +469,9 @@ NS_IMETHODIMP nsUnicodeToGBK::ConvertNoBuff(
break; // this will go to afterwhileloop
}
} else {
if( IS_LOW_SURROGATE(unicode) )
if( NS_IS_LOW_SURROGATE(unicode) )
{
if(IS_HIGH_SURROGATE(mSurrogateHigh)) {
if(NS_IS_HIGH_SURROGATE(mSurrogateHigh)) {
if(EncodeSurrogate(mSurrogateHigh, aSrc[0], aDest)) {
iDestLength += aOutLen;
aDest += aOutLen;

View File

@ -233,9 +233,9 @@ nsEntityConverter::ConvertToEntities(const PRUnichar *inString, PRUint32 entityV
PRUint32 len = nsCRT::strlen(inString);
for (PRUint32 i = 0; i < len; i++) {
nsAutoString key(NS_LITERAL_STRING("entity."));
if (IS_HIGH_SURROGATE(inString[i]) &&
if (NS_IS_HIGH_SURROGATE(inString[i]) &&
i + 2 < len &&
IS_LOW_SURROGATE(inString[i + 1])) {
NS_IS_LOW_SURROGATE(inString[i + 1])) {
key.AppendInt(SURROGATE_TO_UCS4(inString[i], inString[i+1]), 10);
++i;
}

View File

@ -252,8 +252,8 @@ nsSaveAsCharset::DoCharsetConversion(const PRUnichar *inString, char **outString
// do the fallback
if (!ATTR_NO_FALLBACK(mAttribute)) {
PRUint32 unMappedChar;
if (IS_HIGH_SURROGATE(inString[pos1-1]) &&
inStringLength > pos1 && IS_LOW_SURROGATE(inString[pos1])) {
if (NS_IS_HIGH_SURROGATE(inString[pos1-1]) &&
inStringLength > pos1 && NS_IS_LOW_SURROGATE(inString[pos1])) {
unMappedChar = SURROGATE_TO_UCS4(inString[pos1-1], inString[pos1]);
pos1++;
} else {

View File

@ -392,7 +392,7 @@ mdn_normalize(PRBool do_composition, PRBool compat,
*/
curChar= *start++;
if (IS_HIGH_SURROGATE(curChar) && start != end && IS_LOW_SURROGATE(*(start)) ) {
if (NS_IS_HIGH_SURROGATE(curChar) && start != end && NS_IS_LOW_SURROGATE(*(start)) ) {
c = SURROGATE_TO_UCS4(curChar, *start);
++start;
} else {

View File

@ -161,8 +161,8 @@ PRUint32 UTF32CodepointFromTestcase(testcaseLine* testLine)
if (!IS_SURROGATE(testLine->c1[0]))
return testLine->c1[0];
NS_ASSERTION(IS_HIGH_SURROGATE(testLine->c1[0]) &&
IS_LOW_SURROGATE(testLine->c1[1]),
NS_ASSERTION(NS_IS_HIGH_SURROGATE(testLine->c1[0]) &&
NS_IS_LOW_SURROGATE(testLine->c1[1]),
"Test data neither in BMP nor legal surrogate pair");
return SURROGATE_TO_UCS4(testLine->c1[0], testLine->c1[1]);
}

View File

@ -914,7 +914,7 @@ nsLayoutUtils::BinarySearchForPosition(nsIRenderingContext* aRendContext,
PRInt32& aTextWidth)
{
PRInt32 range = aEndInx - aStartInx;
if ((range == 1) || (range == 2 && IS_HIGH_SURROGATE(aText[aStartInx]))) {
if ((range == 1) || (range == 2 && NS_IS_HIGH_SURROGATE(aText[aStartInx]))) {
aIndex = aStartInx + aBaseInx;
aRendContext->GetWidth(aText, aIndex, aTextWidth);
return PR_TRUE;
@ -923,7 +923,7 @@ nsLayoutUtils::BinarySearchForPosition(nsIRenderingContext* aRendContext,
PRInt32 inx = aStartInx + (range / 2);
// Make sure we don't leave a dangling low surrogate
if (IS_HIGH_SURROGATE(aText[inx-1]))
if (NS_IS_HIGH_SURROGATE(aText[inx-1]))
inx++;
PRInt32 textWidth = 0;

View File

@ -3245,7 +3245,7 @@ nsTextFrame::GetPositionSlowly(nsIRenderingContext* aRendContext,
PRInt32* ip = indexBuffer.mBuffer;
for (i = 0;i <= mContentLength; i ++){
if ((ip[i] >= aOffset) && //reverse mapping
(! IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i]-mContentOffset]))) {
(! NS_IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i]-mContentOffset]))) {
aOffset = i + mContentOffset;
break;
}
@ -3369,8 +3369,8 @@ nsTextFrame::RenderString(nsIRenderingContext& aRenderingContext,
else if (ch == ' ') {
glyphWidth += aTextStyle.mSpaceWidth + aTextStyle.mWordSpacing + aTextStyle.mLetterSpacing;
}
else if (IS_HIGH_SURROGATE(ch) && aLength > 0 &&
IS_LOW_SURROGATE(*(aBuffer+1))) {
else if (NS_IS_HIGH_SURROGATE(ch) && aLength > 0 &&
NS_IS_LOW_SURROGATE(*(aBuffer+1))) {
// special handling for surrogate pair
aRenderingContext.GetWidth(aBuffer, 2, charWidth);
@ -3499,8 +3499,8 @@ nsTextFrame::GetTextDimensionsOrLength(nsIRenderingContext& aRenderingContext,
lastFont = aStyle.mNormalFont;
aRenderingContext.SetFont(lastFont);
}
if (IS_HIGH_SURROGATE(ch) && length > 0 &&
IS_LOW_SURROGATE(*inBuffer)) {
if (NS_IS_HIGH_SURROGATE(ch) && length > 0 &&
NS_IS_LOW_SURROGATE(*inBuffer)) {
aRenderingContext.GetTextDimensions(inBuffer-1, (PRUint32)2, glyphDimensions);
length--;
inBuffer++;
@ -4152,7 +4152,7 @@ nsTextFrame::GetPositionHelper(const nsPoint& aPoint,
#endif // IBMBIDI
if (found) {
PRInt32 charWidth;
if (IS_HIGH_SURROGATE(text[indx]))
if (NS_IS_HIGH_SURROGATE(text[indx]))
rendContext->GetWidth(&text[indx], 2, charWidth);
else
rendContext->GetWidth(text[indx], charWidth);
@ -4177,7 +4177,7 @@ nsTextFrame::GetPositionHelper(const nsPoint& aPoint,
PRInt32 i;
for (i = 0; i < mContentLength; i ++){
if ((ip[i] >= aContentOffset) && //reverse mapping
(! IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i]-mContentOffset]))) {
(! NS_IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i]-mContentOffset]))) {
break;
}
}
@ -4542,7 +4542,7 @@ nsTextFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
for (i = startOffset-1; i >= 0; i--){
if ((ip[i] < ip[startOffset]) &&
(clusterBuffer.mBuffer[ip[i] - mContentOffset]) &&
(! IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i]-mContentOffset])))
(! NS_IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i]-mContentOffset])))
{
*aOffset = i;
break;
@ -4592,7 +4592,7 @@ nsTextFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
for (i = startOffset; i <= mContentLength; i++) {
if ((ip[i] > ip[startOffset]) &&
((i == mContentLength) ||
(!IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i] - mContentOffset])) &&
(!NS_IS_LOW_SURROGATE(paintBuffer.mBuffer[ip[i] - mContentOffset])) &&
(clusterBuffer.mBuffer[ip[i] - mContentOffset]))) {
*aOffset = i;
break;

View File

@ -542,9 +542,9 @@ nsTextBoxFrame::CalculateTitleForWidth(nsPresContext* aPresContext,
PRInt32 length = mTitle.Length();
for (PRInt32 i = 0; i < length; i++) {
if ((UCS2_CHAR_IS_BIDI(mTitle.CharAt(i)) ) ||
((IS_HIGH_SURROGATE(mTitle.CharAt(i))) &&
((NS_IS_HIGH_SURROGATE(mTitle.CharAt(i))) &&
(++i < length) &&
(IS_LOW_SURROGATE(mTitle.CharAt(i))) &&
(NS_IS_LOW_SURROGATE(mTitle.CharAt(i))) &&
(UTF32_CHAR_IS_BIDI(SURROGATE_TO_UCS4(mTitle.CharAt(i-1),
mTitle.CharAt(i)))))) {
mState |= NS_FRAME_IS_BIDI;

View File

@ -386,7 +386,7 @@ nsresult NS_MsgHashIfNecessary(nsAutoString &name)
{
keptLength = MAX_LEN-8;
// To avoid keeping only the high surrogate of a surrogate pair
if (IS_HIGH_SURROGATE(name.CharAt(keptLength-1)))
if (NS_IS_HIGH_SURROGATE(name.CharAt(keptLength-1)))
--keptLength;
}

View File

@ -296,8 +296,8 @@ static void utf16ToUcs4(const nsAString& in, PRUint32 *out, PRUint32 outBufLen,
curChar= *start++;
if (start != end &&
IS_HIGH_SURROGATE(curChar) &&
IS_LOW_SURROGATE(*start)) {
NS_IS_HIGH_SURROGATE(curChar) &&
NS_IS_LOW_SURROGATE(*start)) {
out[i] = SURROGATE_TO_UCS4(curChar, *start);
++start;
}

View File

@ -1129,7 +1129,7 @@ nsGlobalHistory::SetPageTitle(nsIURI *aURI, const nsAString& aTitle)
nsAutoString titleString(StringHead(aTitle, HISTORY_TITLE_LENGTH_MAX));
if (titleString.Length() < aTitle.Length() &&
IS_HIGH_SURROGATE(titleString.Last()))
NS_IS_HIGH_SURROGATE(titleString.Last()))
titleString.Truncate(titleString.Length()-1);
// skip about: URIs to avoid reading in the db (about:blank, especially)

View File

@ -1245,14 +1245,14 @@ PRBool nsExternalHelperAppService::promptForScheme(nsIURI* aURI,
while (charIdx < uri.Length()) {
// Don't insert characters in the middle of a surrogate pair.
if (IS_LOW_SURROGATE(uri[charIdx]))
if (NS_IS_LOW_SURROGATE(uri[charIdx]))
--charIdx;
if (numCharsToCrop > 0 && lineIdx == maxLines / 2) {
NS_NAMED_LITERAL_STRING(ellipsis, "\n...\n");
// Don't end the crop in the middle of a surrogate pair.
if (IS_HIGH_SURROGATE(uri[charIdx + numCharsToCrop - 1]))
if (NS_IS_HIGH_SURROGATE(uri[charIdx + numCharsToCrop - 1]))
++numCharsToCrop;
uri.Replace(charIdx, numCharsToCrop, ellipsis);

View File

@ -252,7 +252,7 @@ PRUint32 nsCRT::HashCodeAsUTF8(const PRUnichar* str, PRUint32* resultingStrLen)
else
code_length = 3;
}
else if ( IS_HIGH_SURROGATE(W) )
else if ( NS_IS_HIGH_SURROGATE(W) )
W1 = W;
#ifdef DEBUG
else NS_ERROR("Got low surrogate but no previous high surrogate");
@ -263,7 +263,7 @@ PRUint32 nsCRT::HashCodeAsUTF8(const PRUnichar* str, PRUint32* resultingStrLen)
// as required by the standard, this code is careful to
// throw out illegal sequences
if ( IS_LOW_SURROGATE(W) )
if ( NS_IS_LOW_SURROGATE(W) )
{
U = SURROGATE_TO_UCS4(W1, W);
NS_ASSERTION(IS_VALID_CHAR(U), "How did this happen?");

View File

@ -291,7 +291,7 @@ public:
*buffer = p;
return c;
}
else if (IS_HIGH_SURROGATE(c)) // U+D800 - U+DBFF
else if (NS_IS_HIGH_SURROGATE(c)) // U+D800 - U+DBFF
{
if (*buffer == end)
{
@ -307,7 +307,7 @@ public:
c = *p++;
if (IS_LOW_SURROGATE(c))
if (NS_IS_LOW_SURROGATE(c))
{
// DC00- DFFF - Low Surrogate
// N = (H - D800) *400 + 10000 + (L - DC00)
@ -355,7 +355,7 @@ public:
*err = PR_FALSE;
return c;
}
else if (IS_HIGH_SURROGATE(c)) // U+D800 - U+DBFF
else if (NS_IS_HIGH_SURROGATE(c)) // U+D800 - U+DBFF
{
if (iter == end)
{
@ -370,7 +370,7 @@ public:
c = *iter++;
if (IS_LOW_SURROGATE(c))
if (NS_IS_LOW_SURROGATE(c))
{
// DC00- DFFF - Low Surrogate
// N = (H - D800) *400 + 10000 + ( L - DC00 )
@ -594,7 +594,7 @@ class ConvertUTF16toUTF8
*out++ = 0x80 | (char)(0x003F & (c >> 6));
*out++ = 0x80 | (char)(0x003F & c );
}
else if (IS_HIGH_SURROGATE(c)) // U+D800 - U+DBFF
else if (NS_IS_HIGH_SURROGATE(c)) // U+D800 - U+DBFF
{
// D800- DBFF - High Surrogate
value_type h = c;
@ -608,7 +608,7 @@ class ConvertUTF16toUTF8
}
c = *p;
if (IS_LOW_SURROGATE(c))
if (NS_IS_LOW_SURROGATE(c))
{
// DC00- DFFF - Low Surrogate
// N = (H - D800) *400 + 10000 + ( L - DC00 )

View File

@ -1070,7 +1070,7 @@ nsGlobalHistory::SetPageTitle(nsIURI *aURI, const nsAString& aTitle)
nsAutoString titleString(StringHead(aTitle, HISTORY_TITLE_LENGTH_MAX));
if (titleString.Length() < aTitle.Length() &&
IS_HIGH_SURROGATE(titleString.Last()))
NS_IS_HIGH_SURROGATE(titleString.Last()))
titleString.Truncate(titleString.Length()-1);
// skip about: URIs to avoid reading in the db (about:blank, especially)