Bug 934072 - Part 2: Add counter style cjk-decimal. r=jfkthame

This commit is contained in:
Xidorn Quan 2013-12-02 12:51:26 -05:00
parent 98b1f89681
commit 8dbe908ce9
4 changed files with 42 additions and 5 deletions

View File

@ -347,6 +347,7 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
case NS_STYLE_LIST_STYLE_DECIMAL:
case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
@ -744,6 +745,25 @@ static bool CharListToText(int32_t ordinal, nsString& result, const PRUnichar* c
return true;
}
static const PRUnichar gCJKDecimalChars[10] =
{
0x3007, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
};
static bool CharListDecimalToText(int32_t ordinal, nsString& result, const PRUnichar* chars)
{
if (ordinal < 0) {
return false;
}
PRUnichar buf[NUM_BUF_SIZE];
int32_t idx = NUM_BUF_SIZE;
do {
buf[--idx] = chars[ordinal % 10];
ordinal /= 10;
} while (ordinal > 0);
result.Append(buf + idx, NUM_BUF_SIZE - idx);
return true;
}
static const PRUnichar gCJKIdeographicDigit1[10] =
{
@ -1087,6 +1107,10 @@ nsBulletFrame::AppendCounterText(int32_t aListStyleType,
success = DecimalLeadingZeroToText(aOrdinal, result);
break;
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
success = CharListDecimalToText(aOrdinal, result, gCJKDecimalChars);
break;
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
success = RomanToText(aOrdinal, result,
gLowerRomanCharsA, gLowerRomanCharsB);
@ -1131,36 +1155,42 @@ nsBulletFrame::AppendCounterText(int32_t aListStyleType,
case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CJKIdeographicToText(aOrdinal, result, gCJKIdeographicDigit1,
gCJKIdeographicUnit1,
gCJKIdeographic10KUnit1);
break;
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CJKIdeographicToText(aOrdinal, result, gCJKIdeographicDigit2,
gCJKIdeographicUnit2,
gCJKIdeographic10KUnit1);
break;
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CJKIdeographicToText(aOrdinal, result, gCJKIdeographicDigit1,
gCJKIdeographicUnit1,
gCJKIdeographic10KUnit2);
break;
case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CJKIdeographicToText(aOrdinal, result, gCJKIdeographicDigit3,
gCJKIdeographicUnit2,
gCJKIdeographic10KUnit2);
break;
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CJKIdeographicToText(aOrdinal, result, gCJKIdeographicDigit1,
gCJKIdeographicUnit1,
gCJKIdeographic10KUnit3);
break;
case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CJKIdeographicToText(aOrdinal, result, gCJKIdeographicDigit2,
gCJKIdeographicUnit2,
gCJKIdeographic10KUnit3);
@ -1241,11 +1271,13 @@ nsBulletFrame::AppendCounterText(int32_t aListStyleType,
break;
case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CharListToText(aOrdinal, result, gCJKHeavenlyStemChars,
CJK_HEAVENLY_STEM_CHARS_SIZE);
break;
case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
success = CharListToText(aOrdinal, result, gCJKEarthlyBranchChars,
CJK_EARTHLY_BRANCH_CHARS_SIZE);
break;
@ -1304,6 +1336,7 @@ nsBulletFrame::GetListItemSuffix(int32_t aListStyleType,
aResult.Truncate();
break;
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
@ -1417,6 +1450,7 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
default:
case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
case NS_STYLE_LIST_STYLE_DECIMAL:
case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:

View File

@ -205,6 +205,7 @@ CSS_KEY(center, center)
CSS_KEY(ch, ch)
CSS_KEY(character-variant, character_variant)
CSS_KEY(circle, circle)
CSS_KEY(cjk-decimal, cjk_decimal)
CSS_KEY(cjk-ideographic, cjk_ideographic)
CSS_KEY(clip, clip)
CSS_KEY(close-quote, close_quote)

View File

@ -1231,6 +1231,7 @@ const int32_t nsCSSProps::kListStyleKTable[] = {
eCSSKeyword_hebrew, NS_STYLE_LIST_STYLE_HEBREW,
eCSSKeyword_armenian, NS_STYLE_LIST_STYLE_ARMENIAN,
eCSSKeyword_georgian, NS_STYLE_LIST_STYLE_GEORGIAN,
eCSSKeyword_cjk_decimal, NS_STYLE_LIST_STYLE_CJK_DECIMAL,
eCSSKeyword_cjk_ideographic, NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC,
eCSSKeyword_hiragana, NS_STYLE_LIST_STYLE_HIRAGANA,
eCSSKeyword_katakana, NS_STYLE_LIST_STYLE_KATAKANA,

View File

@ -601,11 +601,12 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_LIST_STYLE_HEBREW 11
#define NS_STYLE_LIST_STYLE_ARMENIAN 12
#define NS_STYLE_LIST_STYLE_GEORGIAN 13
#define NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC 14
#define NS_STYLE_LIST_STYLE_HIRAGANA 15
#define NS_STYLE_LIST_STYLE_KATAKANA 16
#define NS_STYLE_LIST_STYLE_HIRAGANA_IROHA 17
#define NS_STYLE_LIST_STYLE_KATAKANA_IROHA 18
#define NS_STYLE_LIST_STYLE_CJK_DECIMAL 14
#define NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC 15
#define NS_STYLE_LIST_STYLE_HIRAGANA 16
#define NS_STYLE_LIST_STYLE_KATAKANA 17
#define NS_STYLE_LIST_STYLE_HIRAGANA_IROHA 18
#define NS_STYLE_LIST_STYLE_KATAKANA_IROHA 19
#define NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM 24
#define NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH 25
#define NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL 26