Improve the CHAR_IS_BIDI macro. Bug 240943, patch from an idea by Peter Kirk, r+sr=roc
git-svn-id: svn://10.0.0.236/trunk@158733 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
cacfecfa8e
commit
90236fac10
@ -221,9 +221,23 @@
|
||||
#define IS_ARABIC_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
|
||||
#define IS_ARABIC_ALPHABETIC(c) (IS_ARABIC_CHAR(c) && \
|
||||
!(IS_HINDI_DIGIT(c) || IS_FARSI_DIGIT(c) || IS_ARABIC_SEPARATOR(c)))
|
||||
#define IS_CYPRIOT_CHAR(c) ((0x10800 <= (c)) && ((c) <=0x1083F))
|
||||
|
||||
#define CHAR_IS_BIDI(c) ( (IS_HINDI_DIGIT(c) ) || (IS_HEBREW_CHAR(c) ) \
|
||||
|| (IS_06_CHAR(c) ) || (IS_FE_CHAR(c) ) \
|
||||
|| (IS_CYPRIOT_CHAR(c) ) )
|
||||
/**
|
||||
* The codepoint ranges in the following macros are based on the blocks
|
||||
* allocated, or planned to be allocated, to right-to-left characters in the
|
||||
* BMP (Basic Multilingual Plane) and SMP (Supplementary Multilingual Plane)
|
||||
* according to
|
||||
* http://unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt and
|
||||
* http://www.unicode.org/roadmaps/
|
||||
*/
|
||||
|
||||
#define IS_IN_BMP_RTL_BLOCK(c) ((0x590 <= (c)) && ((c) <= 0x8ff))
|
||||
#define IS_RTL_PRESENTATION_FORM(c) (((0xfb1d <= (c)) && ((c) <= 0xfdff)) || \
|
||||
((0xfe70 <= (c)) && ((c) <= 0xfefc)))
|
||||
#define IS_IN_SMP_RTL_BLOCK(c) ((0x10800 <= (c)) && ((c) <= 0x10fff))
|
||||
#define UCS2_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
|
||||
(IS_RTL_PRESENTATION_FORM(c)))
|
||||
#define UTF32_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
|
||||
(IS_RTL_PRESENTATION_FORM(c)) || \
|
||||
(IS_IN_SMP_RTL_BLOCK(c)))
|
||||
#endif /* nsBidiUtils_h__ */
|
||||
|
||||
@ -359,7 +359,7 @@ nsTextFragment::SetBidiFlag()
|
||||
PRUnichar ch2 = *cp++;
|
||||
utf32Char = SURROGATE_TO_UCS4(ch1, ch2);
|
||||
}
|
||||
if (CHAR_IS_BIDI(utf32Char) ) {
|
||||
if (UTF32_CHAR_IS_BIDI(utf32Char) ) {
|
||||
mState.mIsBidi = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -221,9 +221,23 @@
|
||||
#define IS_ARABIC_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
|
||||
#define IS_ARABIC_ALPHABETIC(c) (IS_ARABIC_CHAR(c) && \
|
||||
!(IS_HINDI_DIGIT(c) || IS_FARSI_DIGIT(c) || IS_ARABIC_SEPARATOR(c)))
|
||||
#define IS_CYPRIOT_CHAR(c) ((0x10800 <= (c)) && ((c) <=0x1083F))
|
||||
|
||||
#define CHAR_IS_BIDI(c) ( (IS_HINDI_DIGIT(c) ) || (IS_HEBREW_CHAR(c) ) \
|
||||
|| (IS_06_CHAR(c) ) || (IS_FE_CHAR(c) ) \
|
||||
|| (IS_CYPRIOT_CHAR(c) ) )
|
||||
/**
|
||||
* The codepoint ranges in the following macros are based on the blocks
|
||||
* allocated, or planned to be allocated, to right-to-left characters in the
|
||||
* BMP (Basic Multilingual Plane) and SMP (Supplementary Multilingual Plane)
|
||||
* according to
|
||||
* http://unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt and
|
||||
* http://www.unicode.org/roadmaps/
|
||||
*/
|
||||
|
||||
#define IS_IN_BMP_RTL_BLOCK(c) ((0x590 <= (c)) && ((c) <= 0x8ff))
|
||||
#define IS_RTL_PRESENTATION_FORM(c) (((0xfb1d <= (c)) && ((c) <= 0xfdff)) || \
|
||||
((0xfe70 <= (c)) && ((c) <= 0xfefc)))
|
||||
#define IS_IN_SMP_RTL_BLOCK(c) ((0x10800 <= (c)) && ((c) <= 0x10fff))
|
||||
#define UCS2_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
|
||||
(IS_RTL_PRESENTATION_FORM(c)))
|
||||
#define UTF32_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
|
||||
(IS_RTL_PRESENTATION_FORM(c)) || \
|
||||
(IS_IN_SMP_RTL_BLOCK(c)))
|
||||
#endif /* nsBidiUtils_h__ */
|
||||
|
||||
@ -507,12 +507,12 @@ nsTextBoxFrame::CalculateTitleForWidth(nsIPresContext* aPresContext,
|
||||
#ifdef IBMBIDI
|
||||
PRInt32 length = mTitle.Length();
|
||||
for (PRInt32 i = 0; i < length; i++) {
|
||||
if ((CHAR_IS_BIDI(mTitle.CharAt(i)) ) ||
|
||||
if ((UCS2_CHAR_IS_BIDI(mTitle.CharAt(i)) ) ||
|
||||
((IS_HIGH_SURROGATE(mTitle.CharAt(i))) &&
|
||||
(++i < length) &&
|
||||
(IS_LOW_SURROGATE(mTitle.CharAt(i))) &&
|
||||
(CHAR_IS_BIDI(SURROGATE_TO_UCS4(mTitle.CharAt(i-1),
|
||||
mTitle.CharAt(i)))))) {
|
||||
(UTF32_CHAR_IS_BIDI(SURROGATE_TO_UCS4(mTitle.CharAt(i-1),
|
||||
mTitle.CharAt(i)))))) {
|
||||
mState |= NS_FRAME_IS_BIDI;
|
||||
break;
|
||||
}
|
||||
@ -562,7 +562,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsIPresContext* aPresContext,
|
||||
|
||||
twidth += cwidth;
|
||||
#ifdef IBMBIDI
|
||||
if (CHAR_IS_BIDI(ch) ) {
|
||||
if (UCS2_CHAR_IS_BIDI(ch) ) {
|
||||
mState |= NS_FRAME_IS_BIDI;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
@ -592,7 +592,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsIPresContext* aPresContext,
|
||||
|
||||
twidth += cwidth;
|
||||
#ifdef IBMBIDI
|
||||
if (CHAR_IS_BIDI(ch) ) {
|
||||
if (UCS2_CHAR_IS_BIDI(ch) ) {
|
||||
mState |= NS_FRAME_IS_BIDI;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
@ -636,7 +636,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsIPresContext* aPresContext,
|
||||
leftString.Insert(ch, leftString.Length());
|
||||
|
||||
#ifdef IBMBIDI
|
||||
if (CHAR_IS_BIDI(ch))
|
||||
if (UCS2_CHAR_IS_BIDI(ch))
|
||||
mState |= NS_FRAME_IS_BIDI;
|
||||
#endif
|
||||
|
||||
@ -652,7 +652,7 @@ nsTextBoxFrame::CalculateTitleForWidth(nsIPresContext* aPresContext,
|
||||
rightString.Insert(ch, 0);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
if (CHAR_IS_BIDI(ch))
|
||||
if (UCS2_CHAR_IS_BIDI(ch))
|
||||
mState |= NS_FRAME_IS_BIDI;
|
||||
#endif
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user