зеркало из https://github.com/mozilla/gecko-dev.git
Bug 467672 - need additional bidi.numerals setting for Persian (eastern Arabic-Indic) numerals; r=roc,jfkthame sr=roc
This commit is contained in:
Родитель
c10937e604
Коммит
3b6cf03f73
|
@ -280,14 +280,26 @@ static nsCharType cc2ucd[5] = {
|
|||
};
|
||||
|
||||
#define ARABIC_TO_HINDI_DIGIT_INCREMENT (START_HINDI_DIGITS - START_ARABIC_DIGITS)
|
||||
#define PERSIAN_TO_HINDI_DIGIT_INCREMENT (START_HINDI_DIGITS - START_FARSI_DIGITS)
|
||||
#define ARABIC_TO_PERSIAN_DIGIT_INCREMENT (START_FARSI_DIGITS - START_ARABIC_DIGITS)
|
||||
#define NUM_TO_ARABIC(c) \
|
||||
((((c)>=START_HINDI_DIGITS) && ((c)<=END_HINDI_DIGITS)) ? \
|
||||
((c) - (PRUint16)ARABIC_TO_HINDI_DIGIT_INCREMENT) : \
|
||||
(c))
|
||||
((((c)>=START_FARSI_DIGITS) && ((c)<=END_FARSI_DIGITS)) ? \
|
||||
((c) - (PRUint16)ARABIC_TO_PERSIAN_DIGIT_INCREMENT) : \
|
||||
(c)))
|
||||
#define NUM_TO_HINDI(c) \
|
||||
((((c)>=START_ARABIC_DIGITS) && ((c)<=END_ARABIC_DIGITS)) ? \
|
||||
((c) + (PRUint16)ARABIC_TO_HINDI_DIGIT_INCREMENT): \
|
||||
(c))
|
||||
((((c)>=START_FARSI_DIGITS) && ((c)<=END_FARSI_DIGITS)) ? \
|
||||
((c) + (PRUint16)PERSIAN_TO_HINDI_DIGIT_INCREMENT) : \
|
||||
(c)))
|
||||
#define NUM_TO_PERSIAN(c) \
|
||||
((((c)>=START_HINDI_DIGITS) && ((c)<=END_HINDI_DIGITS)) ? \
|
||||
((c) - (PRUint16)PERSIAN_TO_HINDI_DIGIT_INCREMENT) : \
|
||||
((((c)>=START_ARABIC_DIGITS) && ((c)<=END_ARABIC_DIGITS)) ? \
|
||||
((c) + (PRUint16)ARABIC_TO_PERSIAN_DIGIT_INCREMENT) : \
|
||||
(c)))
|
||||
|
||||
// helper function to reverse a PRUnichar buffer
|
||||
static void ReverseString(PRUnichar* aBuffer, PRUint32 aLen)
|
||||
|
@ -560,13 +572,20 @@ PRUnichar HandleNumberInChar(PRUnichar aChar, PRBool aPrevCharArabic, PRUint32 a
|
|||
return NUM_TO_HINDI(aChar);
|
||||
case IBMBIDI_NUMERAL_ARABIC:
|
||||
return NUM_TO_ARABIC(aChar);
|
||||
case IBMBIDI_NUMERAL_PERSIAN:
|
||||
return NUM_TO_PERSIAN(aChar);
|
||||
case IBMBIDI_NUMERAL_REGULAR:
|
||||
case IBMBIDI_NUMERAL_HINDICONTEXT:
|
||||
case IBMBIDI_NUMERAL_PERSIANCONTEXT:
|
||||
// for clipboard handling
|
||||
//XXX do we really want to convert numerals when copying text?
|
||||
if (aPrevCharArabic)
|
||||
return NUM_TO_HINDI(aChar);
|
||||
else
|
||||
if (aPrevCharArabic) {
|
||||
if (aNumFlag == IBMBIDI_NUMERAL_PERSIANCONTEXT)
|
||||
return NUM_TO_PERSIAN(aChar);
|
||||
else
|
||||
return NUM_TO_HINDI(aChar);
|
||||
}
|
||||
else
|
||||
return NUM_TO_ARABIC(aChar);
|
||||
case IBMBIDI_NUMERAL_NOMINAL:
|
||||
default:
|
||||
|
@ -581,8 +600,10 @@ nsresult HandleNumbers(PRUnichar* aBuffer, PRUint32 aSize, PRUint32 aNumFlag)
|
|||
switch (aNumFlag) {
|
||||
case IBMBIDI_NUMERAL_HINDI:
|
||||
case IBMBIDI_NUMERAL_ARABIC:
|
||||
case IBMBIDI_NUMERAL_PERSIAN:
|
||||
case IBMBIDI_NUMERAL_REGULAR:
|
||||
case IBMBIDI_NUMERAL_HINDICONTEXT:
|
||||
case IBMBIDI_NUMERAL_PERSIANCONTEXT:
|
||||
for (i=0;i<aSize;i++)
|
||||
aBuffer[i] = HandleNumberInChar(aBuffer[i], !!(i>0 ? aBuffer[i-1] : 0), aNumFlag);
|
||||
break;
|
||||
|
@ -593,12 +614,6 @@ nsresult HandleNumbers(PRUnichar* aBuffer, PRUint32 aSize, PRUint32 aNumFlag)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult HandleNumbers(const nsString& aSrc, nsString& aDst)
|
||||
{
|
||||
aDst = aSrc;
|
||||
return HandleNumbers((PRUnichar *)aDst.get(),aDst.Length(), IBMBIDI_NUMERAL_REGULAR);
|
||||
}
|
||||
|
||||
PRUint32 SymmSwap(PRUint32 aChar)
|
||||
{
|
||||
return Mirrored(aChar);
|
||||
|
|
|
@ -181,13 +181,6 @@ typedef enum nsCharType nsCharType;
|
|||
*/
|
||||
nsresult HandleNumbers(PRUnichar* aBuffer, PRUint32 aSize, PRUint32 aNumFlag);
|
||||
|
||||
/**
|
||||
* Scan an nsString, converting numerals to Arabic or Hindi forms
|
||||
* @param aSrc is the input string
|
||||
* @param aDst is the output string
|
||||
*/
|
||||
nsresult HandleNumbers(const nsString& aSrc, nsString& aDst);
|
||||
|
||||
/**
|
||||
* Give a Unicode character, return the symmetric equivalent
|
||||
*/
|
||||
|
@ -277,6 +270,8 @@ typedef enum nsCharType nsCharType;
|
|||
#define IBMBIDI_NUMERAL_HINDICONTEXT 2 // 2 = hindicontextnumeralBidi
|
||||
#define IBMBIDI_NUMERAL_ARABIC 3 // 3 = arabicnumeralBidi
|
||||
#define IBMBIDI_NUMERAL_HINDI 4 // 4 = hindinumeralBidi
|
||||
#define IBMBIDI_NUMERAL_PERSIANCONTEXT 5 // 5 = persiancontextnumeralBidi
|
||||
#define IBMBIDI_NUMERAL_PERSIAN 6 // 6 = persiannumeralBidi
|
||||
// ------------------
|
||||
// Support Mode
|
||||
// ------------------
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Contributor(s):
|
||||
* Uri Bernstein <uriber@gmail.com>
|
||||
* Haamed Gheibi <gheibi@metanetworking.com>
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -1187,6 +1188,10 @@ nsBidiPresUtils::FormatUnicodeText(nsPresContext* aPresContext,
|
|||
HandleNumbers(aText,aTextLength,IBMBIDI_NUMERAL_ARABIC);
|
||||
break;
|
||||
|
||||
case IBMBIDI_NUMERAL_PERSIAN:
|
||||
HandleNumbers(aText,aTextLength,IBMBIDI_NUMERAL_PERSIAN);
|
||||
break;
|
||||
|
||||
case IBMBIDI_NUMERAL_REGULAR:
|
||||
|
||||
switch (aCharType) {
|
||||
|
@ -1203,7 +1208,7 @@ nsBidiPresUtils::FormatUnicodeText(nsPresContext* aPresContext,
|
|||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IBMBIDI_NUMERAL_HINDICONTEXT:
|
||||
if ( ( (GET_BIDI_OPTION_DIRECTION(bidiOptions)==IBMBIDI_TEXTDIRECTION_RTL) && (IS_ARABIC_DIGIT (aText[0])) ) || (eCharType_ArabicNumber == aCharType) )
|
||||
HandleNumbers(aText,aTextLength,IBMBIDI_NUMERAL_HINDI);
|
||||
|
@ -1211,6 +1216,13 @@ nsBidiPresUtils::FormatUnicodeText(nsPresContext* aPresContext,
|
|||
HandleNumbers(aText,aTextLength,IBMBIDI_NUMERAL_ARABIC);
|
||||
break;
|
||||
|
||||
case IBMBIDI_NUMERAL_PERSIANCONTEXT:
|
||||
if ( ( (GET_BIDI_OPTION_DIRECTION(bidiOptions)==IBMBIDI_TEXTDIRECTION_RTL) && (IS_ARABIC_DIGIT (aText[0])) ) || (eCharType_ArabicNumber == aCharType) )
|
||||
HandleNumbers(aText,aTextLength,IBMBIDI_NUMERAL_PERSIAN);
|
||||
else if (eCharType_EuropeanNumber == aCharType)
|
||||
HandleNumbers(aText,aTextLength,IBMBIDI_NUMERAL_ARABIC);
|
||||
break;
|
||||
|
||||
case IBMBIDI_NUMERAL_NOMINAL:
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -90,6 +90,16 @@ _TEST_FILES += \
|
|||
bug441782-4-ref.html \
|
||||
bug441782-5.html \
|
||||
bug441782-5-ref.html \
|
||||
bug467672-1.html \
|
||||
bug467672-1-ref.html \
|
||||
bug467672-2.html \
|
||||
bug467672-2-ref.html \
|
||||
bug467672-3.html \
|
||||
bug467672-3-ref.html \
|
||||
bug467672-4.html \
|
||||
bug467672-4-ref.html \
|
||||
bug467672-5.html \
|
||||
bug467672-5-ref.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
۳۴۵
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
345
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
متن۳۴۵
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
متن345
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
text۳۴۵
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
text345
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
متن ۳۴۵
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
متن 345
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
text ۳۴۵
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
text 345
|
||||
</body>
|
||||
</html>
|
|
@ -85,31 +85,68 @@ function bidiNumeral(val) {
|
|||
var bidiNumeralDefault = bidiNumeral();
|
||||
|
||||
var passes = [
|
||||
{file: 1, bidiNumeralValue: 0, op: "!="},
|
||||
{file: 1, bidiNumeralValue: 1, op: "=="},
|
||||
{file: 1, bidiNumeralValue: 2, op: "=="},
|
||||
{file: 1, bidiNumeralValue: 3, op: "=="},
|
||||
{file: 1, bidiNumeralValue: 4, op: "=="},
|
||||
{file: 2, bidiNumeralValue: 0, op: "!="},
|
||||
{file: 2, bidiNumeralValue: 1, op: "=="},
|
||||
{file: 2, bidiNumeralValue: 2, op: "=="},
|
||||
{file: 2, bidiNumeralValue: 3, op: "=="},
|
||||
{file: 2, bidiNumeralValue: 4, op: "=="},
|
||||
{file: 3, bidiNumeralValue: 0, op: "!="},
|
||||
{file: 3, bidiNumeralValue: 1, op: "=="},
|
||||
{file: 3, bidiNumeralValue: 2, op: "=="},
|
||||
{file: 3, bidiNumeralValue: 3, op: "=="},
|
||||
{file: 3, bidiNumeralValue: 4, op: "=="},
|
||||
{file: 4, bidiNumeralValue: 0, op: "!="},
|
||||
{file: 4, bidiNumeralValue: 1, op: "=="},
|
||||
{file: 4, bidiNumeralValue: 2, op: "=="},
|
||||
{file: 4, bidiNumeralValue: 3, op: "=="},
|
||||
{file: 4, bidiNumeralValue: 4, op: "=="},
|
||||
{file: 5, bidiNumeralValue: 0, op: "!="},
|
||||
{file: 5, bidiNumeralValue: 1, op: "=="},
|
||||
{file: 5, bidiNumeralValue: 2, op: "=="},
|
||||
{file: 5, bidiNumeralValue: 3, op: "=="},
|
||||
{file: 5, bidiNumeralValue: 4, op: "=="},
|
||||
// bug 441782 tests (Arabic)
|
||||
{prefix: "bug441782", file: 1, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug441782", file: 1, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug441782", file: 1, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug441782", file: 1, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug441782", file: 1, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug441782", file: 2, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug441782", file: 2, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug441782", file: 2, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug441782", file: 2, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug441782", file: 2, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug441782", file: 3, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug441782", file: 3, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug441782", file: 3, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug441782", file: 3, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug441782", file: 3, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug441782", file: 4, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug441782", file: 4, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug441782", file: 4, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug441782", file: 4, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug441782", file: 4, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug441782", file: 5, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug441782", file: 5, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug441782", file: 5, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug441782", file: 5, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug441782", file: 5, bidiNumeralValue: 4, op: "=="},
|
||||
// bug 467672 tests (Arabic and Persian)
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 5, op: "=="},
|
||||
{prefix: "bug467672", file: 1, bidiNumeralValue: 6, op: "=="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 5, op: "=="},
|
||||
{prefix: "bug467672", file: 2, bidiNumeralValue: 6, op: "=="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 5, op: "=="},
|
||||
{prefix: "bug467672", file: 3, bidiNumeralValue: 6, op: "=="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 5, op: "=="},
|
||||
{prefix: "bug467672", file: 4, bidiNumeralValue: 6, op: "=="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 0, op: "!="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 1, op: "=="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 2, op: "=="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 3, op: "=="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 4, op: "=="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 5, op: "=="},
|
||||
{prefix: "bug467672", file: 5, bidiNumeralValue: 6, op: "=="},
|
||||
];
|
||||
var currentPass = 0;
|
||||
|
||||
|
@ -131,10 +168,10 @@ function do_test()
|
|||
var img_1 = canvases[0].getCanvas().toDataURL("image/png", "");
|
||||
var img_2 = canvases[1].getCanvas().toDataURL("image/png", "");
|
||||
if (passes[currentPass].op == "==") {
|
||||
ok(img_1 == img_2, "Rendering of reftest " + passes[currentPass].file +
|
||||
ok(img_1 == img_2, "Rendering of reftest " + fileprefix + passes[currentPass].file +
|
||||
" is different with bidi.numeral == " + passes[currentPass].bidiNumeralValue);
|
||||
} else if (passes[currentPass].op == "!=") {
|
||||
ok(img_1 != img_2, "Rendering of reftest " + passes[currentPass].file +
|
||||
ok(img_1 != img_2, "Rendering of reftest " + fileprefix + passes[currentPass].file +
|
||||
" is not different with bidi.numeral == " + passes[currentPass].bidiNumeralValue);
|
||||
}
|
||||
|
||||
|
@ -149,19 +186,21 @@ function do_test()
|
|||
}
|
||||
}
|
||||
|
||||
var fileprefix = passes[currentPass].prefix + "-";
|
||||
var file = passes[currentPass].file;
|
||||
|
||||
var header = document.createElement("p");
|
||||
header.appendChild(document.createTextNode("Testing reftest " + file +
|
||||
" with bidi.numeral == " + passes[currentPass].bidiNumeralValue));
|
||||
header.appendChild(document.createTextNode("Testing reftest " + fileprefix + file +
|
||||
" with bidi.numeral == " + passes[currentPass].bidiNumeralValue +
|
||||
" expecting " + passes[currentPass].op));
|
||||
document.body.appendChild(header);
|
||||
|
||||
bidiNumeral(passes[currentPass].bidiNumeralValue);
|
||||
|
||||
var testCanvas = new RemoteCanvas("bug441782-" + file + ".html", "test-" + currentPass);
|
||||
var testCanvas = new RemoteCanvas(fileprefix + file + ".html", "test-" + currentPass);
|
||||
testCanvas.load(callbackTestCanvas);
|
||||
|
||||
var refCanvas = new RemoteCanvas("bug441782-" + file + "-ref.html", "ref-" + currentPass);
|
||||
var refCanvas = new RemoteCanvas(fileprefix + file + "-ref.html", "ref-" + currentPass);
|
||||
refCanvas.load(callbackTestCanvas);
|
||||
}
|
||||
|
||||
|
|
|
@ -1018,6 +1018,8 @@ pref("bidi.controlstextmode", 1);
|
|||
// 2 = hindicontextnumeralBidi
|
||||
// 3 = arabicnumeralBidi
|
||||
// 4 = hindinumeralBidi
|
||||
// 5 = persiancontextnumeralBidi
|
||||
// 6 = persiannumeralBidi
|
||||
pref("bidi.numeral", 0);
|
||||
// ------------------
|
||||
// Support Mode
|
||||
|
|
Загрузка…
Ссылка в новой задаче