зеркало из https://github.com/mozilla/gecko-dev.git
bug 605021 - handle surrogates in text-run transformations. r=smontagu
This commit is contained in:
Родитель
1bd194a3d5
Коммит
f5315343c3
|
@ -290,9 +290,11 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
isLowercase = runIsLowercase;
|
||||
} else {
|
||||
if (styles[i]->GetStyleFont()->mFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS) {
|
||||
PRUnichar ch = str[i];
|
||||
PRUnichar ch2;
|
||||
ch2 = ToUpperCase(ch);
|
||||
PRUint32 ch = str[i];
|
||||
if (NS_IS_HIGH_SURROGATE(ch) && i < length - 1 && NS_IS_LOW_SURROGATE(str[i + 1])) {
|
||||
ch = SURROGATE_TO_UCS4(ch, str[i + 1]);
|
||||
}
|
||||
PRUint32 ch2 = ToUpperCase(ch);
|
||||
isLowercase = ch != ch2 || ch == SZLIG;
|
||||
} else {
|
||||
// Don't transform the character! I.e., pretend that it's not lowercase
|
||||
|
@ -357,7 +359,7 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
PRUnichar ch = str[i];
|
||||
PRUint32 ch = str[i];
|
||||
|
||||
charsToMergeArray.AppendElement(false);
|
||||
styleArray.AppendElement(styles[i]);
|
||||
|
@ -367,6 +369,10 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
: styles[i]->GetStyleText()->mTextTransform;
|
||||
bool extraChar = false;
|
||||
|
||||
if (NS_IS_HIGH_SURROGATE(ch) && i < length - 1 && NS_IS_LOW_SURROGATE(str[i + 1])) {
|
||||
ch = SURROGATE_TO_UCS4(ch, str[i + 1]);
|
||||
}
|
||||
|
||||
switch (style) {
|
||||
case NS_STYLE_TEXT_TRANSFORM_LOWERCASE:
|
||||
ch = ToLowerCase(ch);
|
||||
|
@ -395,7 +401,17 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
|||
break;
|
||||
}
|
||||
|
||||
convertedString.Append(ch);
|
||||
if (IS_IN_BMP(ch)) {
|
||||
convertedString.Append(ch);
|
||||
} else {
|
||||
convertedString.Append(H_SURROGATE(ch));
|
||||
convertedString.Append(L_SURROGATE(ch));
|
||||
i++;
|
||||
charsToMergeArray.AppendElement(true);
|
||||
styleArray.AppendElement(styles[i]);
|
||||
canBreakBeforeArray.AppendElement(false);
|
||||
}
|
||||
|
||||
if (extraChar) {
|
||||
++extraCharsCount;
|
||||
charsToMergeArray.AppendElement(true);
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
== all-upper.html all-upper-ref.html
|
||||
== all-lower.html all-lower-ref.html
|
||||
== all-title.html all-title-ref.html
|
||||
!= smtp-upper.html smtp-upper-ref.html # bug 210501
|
||||
!= smtp-lower.html smtp-lower-ref.html # bug 210501
|
||||
!= smtp-title.html smtp-title-ref.html # bug 210501
|
||||
== smtp-upper.html smtp-upper-ref.html
|
||||
== smtp-lower.html smtp-lower-ref.html
|
||||
== smtp-title.html smtp-title-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче