Bug 1428771 - Make UCS2_CHAR_IS_BIDI check for lead surrogates corresponding to U+1E800...U+1EFFF and rename to UTF16_CODE_UNIT_IS_BIDI. r=jfkthame

MozReview-Commit-ID: 9ZKF6SaN79n

--HG--
extra : rebase_source : 406f2647e65e2bdb97190b12564bafa6df39e6a8
This commit is contained in:
Henri Sivonen 2018-01-08 16:18:32 +02:00
Родитель fdcbd7477c
Коммит 381880a0e0
4 изменённых файлов: 22 добавлений и 14 удалений

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

@ -7484,11 +7484,11 @@ var gIdentityHandler = {
// If the organization name starts with an RTL character, then
// swap the positions of the organization and country code labels.
// The Unicode ranges reflect the definition of the UCS2_CHAR_IS_BIDI
// The Unicode ranges reflect the definition of the UTF16_CODE_UNIT_IS_BIDI
// macro in intl/unicharutil/util/nsBidiUtils.h. When bug 218823 gets
// fixed, this test should be replaced by one adhering to the
// Unicode Bidirectional Algorithm proper (at the paragraph level).
icon_labels_dir = /^[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/.test(icon_label) ?
icon_labels_dir = /^[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc\ud802\ud803\ud83a\ud83b]/.test(icon_label) ?
"rtl" : "ltr";
}
} else if (this._pageExtensionPolicy) {

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

@ -263,9 +263,17 @@ typedef enum nsCharType nsCharType;
((0xfe70 <= (c)) && ((c) <= 0xfefc)))
#define IS_IN_SMP_RTL_BLOCK(c) (((0x10800 <= (c)) && ((c) <= 0x10fff)) || \
((0x1e800 <= (c)) && ((c) <= 0x1eFFF)))
#define UCS2_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
(IS_RTL_PRESENTATION_FORM(c)) || \
(c) == 0xD802 || (c) == 0xD803)
// Due to the supplementary-plane RTL blocks being identifiable from the
// high surrogate without examining the low surrogate, it is correct to
// use this by-code-unit check on potentially astral text without doing
// the math to decode surrogate pairs into code points. However, unpaired
// high surrogates that are RTL high surrogates then count as RTL even
// though, if replaced by the REPLACEMENT CHARACTER, it would not be
// RTL.
#define UTF16_CODE_UNIT_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
(IS_RTL_PRESENTATION_FORM(c)) || \
(c) == 0xD802 || (c) == 0xD803 || \
(c) == 0xD83A || (c) == 0xD83B)
#define UTF32_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
(IS_RTL_PRESENTATION_FORM(c)) || \
(IS_IN_SMP_RTL_BLOCK(c)))

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

@ -701,7 +701,7 @@ nsTextBoxFrame::CalculateTitleForWidth(gfxContext& aRenderingContext,
break;
}
if (UCS2_CHAR_IS_BIDI(*pos)) {
if (UTF16_CODE_UNIT_IS_BIDI(*pos)) {
AddStateBits(NS_FRAME_IS_BIDI);
}
pos = nextPos;
@ -738,7 +738,7 @@ nsTextBoxFrame::CalculateTitleForWidth(gfxContext& aRenderingContext,
break;
}
if (UCS2_CHAR_IS_BIDI(*pos)) {
if (UTF16_CODE_UNIT_IS_BIDI(*pos)) {
AddStateBits(NS_FRAME_IS_BIDI);
}
prevPos = pos;
@ -790,7 +790,7 @@ nsTextBoxFrame::CalculateTitleForWidth(gfxContext& aRenderingContext,
break;
}
if (UCS2_CHAR_IS_BIDI(*leftPos)) {
if (UTF16_CODE_UNIT_IS_BIDI(*leftPos)) {
AddStateBits(NS_FRAME_IS_BIDI);
}
@ -812,7 +812,7 @@ nsTextBoxFrame::CalculateTitleForWidth(gfxContext& aRenderingContext,
break;
}
if (UCS2_CHAR_IS_BIDI(*pos)) {
if (UTF16_CODE_UNIT_IS_BIDI(*pos)) {
AddStateBits(NS_FRAME_IS_BIDI);
}

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

@ -744,7 +744,7 @@ TISInputSourceWrapper::IsForRTLLanguage()
bool ret = TranslateToString(kVK_ANSI_A, 0, eKbdType_ANSI, str);
NS_ENSURE_TRUE(ret, ret);
char16_t ch = str.IsEmpty() ? char16_t(0) : str.CharAt(0);
mIsRTL = UCS2_CHAR_IS_BIDI(ch);
mIsRTL = UTF16_CODE_UNIT_IS_BIDI(ch);
}
return mIsRTL != 0;
}