bug 763982 - update and optimize Arabic char processing in TransformText. r=smontagu

This commit is contained in:
Jonathan Kew 2012-06-20 20:58:19 +01:00
parent 8d1e2dedbe
commit ced6b24af7
2 changed files with 12 additions and 8 deletions

View File

@ -183,7 +183,9 @@ typedef enum nsCharType nsCharType;
* U+066C;ARABIC THOUSANDS SEPARATOR
* U+06DD;ARABIC END OF AYAH
*/
#define IS_ARABIC_SEPARATOR(u) ( ( (u) == 0x0600 ) || ( (u) == 0x0601 ) || ( (u) == 0x0602 ) || ( (u) == 0x0603 ) || ( (u) == 0x066A ) || ( (u) == 0x066B ) || ( (u) == 0x066C ) || ( (u) == 0x06DD ) )
#define IS_ARABIC_SEPARATOR(u) ( ( /*(u) >= 0x0600 &&*/ (u) <= 0x0603 ) || \
( (u) >= 0x066A && (u) <= 0x066C ) || \
( (u) == 0x06DD ) )
#define IS_BIDI_DIACRITIC(u) ( \
( (u) >= 0x0591 && (u) <= 0x05A1) || ( (u) >= 0x05A3 && (u) <= 0x05B9) \
@ -193,11 +195,14 @@ typedef enum nsCharType nsCharType;
|| ( (u) >= 0x06D7 && (u) <= 0x06E4) || ( (u) == 0x06E7) || ( (u) == 0x06E8) \
|| ( (u) >= 0x06EA && (u) <= 0x06ED) )
#define IS_HEBREW_CHAR(c) (((0x0590 <= (c)) && ((c)<= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))
#define IS_ARABIC_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
#define IS_HEBREW_CHAR(c) (((0x0590 <= (c)) && ((c) <= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))
#define IS_ARABIC_CHAR(c) ( (0x0600 <= (c) && (c) <= 0x08FF) && \
( (c) <= 0x06ff || \
((c) >= 0x0750 && (c) <= 0x077f) || \
(c) >= 0x08a0 ) )
#define IS_ARABIC_ALPHABETIC(c) (IS_ARABIC_CHAR(c) && \
!(IS_HINDI_DIGIT(c) || IS_FARSI_DIGIT(c) || IS_ARABIC_SEPARATOR(c)))
#define IS_BIDI_CONTROL_CHAR(c) (((0x202a <= (c)) && ((c)<= 0x202e)) \
#define IS_BIDI_CONTROL_CHAR(c) (((0x202a <= (c)) && ((c) <= 0x202e)) \
|| ((c) == 0x200e) || ((c) == 0x200f))
/**

View File

@ -68,11 +68,10 @@ nsTextFrameUtils::TransformText(const PRUnichar* aText, PRUint32 aLength,
aSkipChars->SkipChar();
} else {
aSkipChars->KeepChar();
if (ch == '\t') {
flags |= TEXT_HAS_TAB;
} else if (ch != ' ' && ch != '\n') {
// we already know it's not a tab from the previous check
if (ch > ' ') {
lastCharArabic = IS_ARABIC_CHAR(ch);
} else if (ch == '\t') {
flags |= TEXT_HAS_TAB;
}
*aOutput++ = ch;
}