Bug 934072 - Part 2: Add counter style cjk-decimal. r=jfkthame
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 02 Dec 2013 12:51:26 -0500
changeset 173967 7580aeb129c65bb01a3dfb68934abcfbd6491b12
parent 173966 0ec4cc06f49f80deaaafcfd0260f126dbd94a8ce
child 173968 b88dfa4ac80cd7cf0d45243ee7e7b586b7f60a97
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs934072
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 934072 - Part 2: Add counter style cjk-decimal. r=jfkthame
layout/generic/nsBulletFrame.cpp
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
layout/style/nsStyleConsts.h
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -342,16 +342,17 @@ nsBulletFrame::PaintBullet(nsRenderingCo
                       (rect.height - snapRect.height) / 2);
       aRenderingContext.FillRect(snapRect.x, snapRect.y,
                                  snapRect.width, snapRect.height);
     }
     break;
 
   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:
   case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
   case NS_STYLE_LIST_STYLE_LOWER_GREEK:
   case NS_STYLE_LIST_STYLE_HEBREW:
   case NS_STYLE_LIST_STYLE_ARMENIAN:
   case NS_STYLE_LIST_STYLE_GEORGIAN:
@@ -739,16 +740,35 @@ static bool CharListToText(int32_t ordin
     int32_t cur = ordinal % aBase;
     buf[--idx] = chars[cur];
     ordinal /= aBase ;
   } while ( ordinal > 0);
   result.Append(buf+idx,NUM_BUF_SIZE-idx);
   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] =
 {
   0x96f6, 0x4e00, 0x4e8c, 0x4e09, 0x56db,  // 0 - 4
   0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d   // 5 - 9
 };
 static const PRUnichar gCJKIdeographicDigit2[10] =
 {
@@ -1082,16 +1102,20 @@ nsBulletFrame::AppendCounterText(int32_t
       success = DecimalToText(aOrdinal, result);
       NS_ASSERTION(success, "DecimalToText must never fail");
       break;
 
     case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
       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);
       break;
     case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
       success = RomanToText(aOrdinal, result,
                             gUpperRomanCharsA, gUpperRomanCharsB);
       break;
@@ -1126,46 +1150,52 @@ nsBulletFrame::AppendCounterText(int32_t
 
     case NS_STYLE_LIST_STYLE_LOWER_GREEK:
       success = CharListToText(aOrdinal, result, gLowerGreekChars ,
                                LOWER_GREEK_CHARS_SIZE);
       break;
 
     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);
       break;
 
     case NS_STYLE_LIST_STYLE_HEBREW: 
       isRTL = true;
       success = HebrewToText(aOrdinal, result);
@@ -1236,21 +1266,23 @@ nsBulletFrame::AppendCounterText(int32_t
       success = OtherDecimalToText(aOrdinal, 0x0C66, result);
       break;
  
     case NS_STYLE_LIST_STYLE_MOZ_TAMIL:
       success = TamilToText(aOrdinal, result);
       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;
 
     case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
       success = CharListToText(aOrdinal, result, gHangulChars, HANGUL_CHARS_SIZE);
       break;
 
@@ -1299,16 +1331,17 @@ nsBulletFrame::GetListItemSuffix(int32_t
   switch (aListStyleType) {
     case NS_STYLE_LIST_STYLE_NONE: // used by counters code only
     case NS_STYLE_LIST_STYLE_DISC: // used by counters code only
     case NS_STYLE_LIST_STYLE_CIRCLE: // used by counters code only
     case NS_STYLE_LIST_STYLE_SQUARE: // used by counters code only
       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:
     case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
     case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
@@ -1412,16 +1445,17 @@ nsBulletFrame::GetDesiredSize(nsPresCont
       mPadding.bottom = NSToCoordRound(float(ascent) / 8.0f);
       aMetrics.width = aMetrics.height = bulletSize;
       aMetrics.ascent = bulletSize + mPadding.bottom;
       break;
 
     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:
     case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
     case NS_STYLE_LIST_STYLE_KATAKANA:
     case NS_STYLE_LIST_STYLE_HIRAGANA:
     case NS_STYLE_LIST_STYLE_KATAKANA_IROHA:
     case NS_STYLE_LIST_STYLE_HIRAGANA_IROHA:
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -200,16 +200,17 @@ CSS_KEY(buttontext, buttontext)
 CSS_KEY(capitalize, capitalize)
 CSS_KEY(caption, caption)
 CSS_KEY(captiontext, captiontext)
 CSS_KEY(cell, cell)
 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)
 CSS_KEY(closest-corner, closest_corner)
 CSS_KEY(closest-side, closest_side)
 CSS_KEY(cm, cm)
 CSS_KEY(col-resize, col_resize)
 CSS_KEY(collapse, collapse)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1226,16 +1226,17 @@ const int32_t nsCSSProps::kListStyleKTab
   eCSSKeyword_lower_greek, NS_STYLE_LIST_STYLE_LOWER_GREEK,
   eCSSKeyword_lower_alpha, NS_STYLE_LIST_STYLE_LOWER_ALPHA,
   eCSSKeyword_lower_latin, NS_STYLE_LIST_STYLE_LOWER_LATIN,
   eCSSKeyword_upper_alpha, NS_STYLE_LIST_STYLE_UPPER_ALPHA,
   eCSSKeyword_upper_latin, NS_STYLE_LIST_STYLE_UPPER_LATIN,
   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,
   eCSSKeyword_hiragana_iroha, NS_STYLE_LIST_STYLE_HIRAGANA_IROHA,
   eCSSKeyword_katakana_iroha, NS_STYLE_LIST_STYLE_KATAKANA_IROHA,
   eCSSKeyword__moz_cjk_heavenly_stem, NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM,
   eCSSKeyword__moz_cjk_earthly_branch, NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH,
   eCSSKeyword__moz_trad_chinese_informal, NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL,
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -596,21 +596,22 @@ static inline mozilla::css::Side operato
 #define NS_STYLE_LIST_STYLE_LOWER_GREEK           8
 #define NS_STYLE_LIST_STYLE_LOWER_ALPHA           9
 #define NS_STYLE_LIST_STYLE_LOWER_LATIN           9   // == ALPHA
 #define NS_STYLE_LIST_STYLE_UPPER_ALPHA           10
 #define NS_STYLE_LIST_STYLE_UPPER_LATIN           10  // == ALPHA
 #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
 #define NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL   27
 #define NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL 28
 #define NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL   29
 #define NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL     30
 #define NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL       31