Bug 966166 - Part 4: Rewrite some builtin counter styles. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 11 Jun 2014 21:12:00 -0400
changeset 188454 bffb0b2f7c2f
parent 188453 fffcb4bbc8b1
child 188455 6576396848f1
push id26956
push userkwierso@gmail.com
push dateFri, 13 Jun 2014 00:23:52 +0000
treeherdermozilla-central@adcf3f05f813 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs966166
milestone33.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 966166 - Part 4: Rewrite some builtin counter styles. r=dbaron
content/svg/document/src/SVGDocument.cpp
layout/base/nsDocumentViewer.cpp
layout/generic/nsBulletFrame.cpp
layout/style/CounterStyleManager.cpp
layout/style/counterstyles.css
layout/style/jar.mn
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
layout/style/nsLayoutStylesheetCache.cpp
layout/style/nsLayoutStylesheetCache.h
layout/style/nsStyleConsts.h
--- a/content/svg/document/src/SVGDocument.cpp
+++ b/content/svg/document/src/SVGDocument.cpp
@@ -156,16 +156,17 @@ SVGDocument::EnsureNonSVGUserAgentStyleS
   }
 
   nsCSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet();
   if (sheet) {
     // number-control.css can be behind a pref
     EnsureOnDemandBuiltInUASheet(sheet);
   }
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::FormsSheet());
+  EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::CounterStylesSheet());
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::HTMLSheet());
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::UASheet());
 }
 
 JSObject*
 SVGDocument::WrapNode(JSContext *aCx)
 {
   return SVGDocumentBinding::Wrap(aCx, this);
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2327,16 +2327,21 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
 
     sheet = nsLayoutStylesheetCache::MinimalXULSheet();
     if (sheet) {
       // Load the minimal XUL rules for scrollbars and a few other XUL things
       // that non-XUL (typically HTML) documents commonly use.
       styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
     }
 
+    sheet = nsLayoutStylesheetCache::CounterStylesSheet();
+    if (sheet) {
+      styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
+    }
+
     sheet = nsLayoutStylesheetCache::HTMLSheet();
     if (sheet) {
       styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
     }
 
     styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet,
                                 nsLayoutStylesheetCache::UASheet());
   } else {
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -401,55 +401,28 @@ nsBulletFrame::SetListItemOrdinal(int32_
   }
 
   *aChanged = oldOrdinal != mOrdinal;
 
   return nsCounterManager::IncrementCounter(mOrdinal, aIncrement);
 }
 
 
-// XXX change roman/alpha to use unsigned math so that maxint and
-// maxnegint will work
-
 /**
  * For all functions below, a return value of true means that we
  * could represent mOrder in the desired numbering system.  false
  * means we had to fall back to decimal
  */
 static bool DecimalToText(int32_t ordinal, nsString& result)
 {
    char cbuf[40];
    PR_snprintf(cbuf, sizeof(cbuf), "%ld", ordinal);
    result.AppendASCII(cbuf);
    return true;
 }
-static bool DecimalLeadingZeroToText(int32_t ordinal, nsString& result)
-{
-   char cbuf[40];
-   PR_snprintf(cbuf, sizeof(cbuf), "%02ld", ordinal);
-   result.AppendASCII(cbuf);
-   return true;
-}
-static bool OtherDecimalToText(int32_t ordinal, char16_t zeroChar, nsString& result)
-{
-   char16_t diff = zeroChar - char16_t('0');
-   // We're going to be appending to whatever is in "result" already, so make
-   // sure to only munge the new bits.  Note that we can't just grab the pointer
-   // to the new stuff here, since appending to the string can realloc.
-   size_t offset = result.Length();
-   DecimalToText(ordinal, result);
-   char16_t* p = result.BeginWriting() + offset;
-   if (ordinal < 0) {
-     // skip the leading '-'
-     ++p;
-   }     
-   for(; '\0' != *p ; p++) 
-      *p += diff;
-   return true;
-}
 static bool TamilToText(int32_t ordinal,  nsString& result)
 {
    if (ordinal < 1 || ordinal > 9999) {
      // Can't do those in this system.
      return false;
    }
    char16_t diff = 0x0BE6 - char16_t('0');
    // We're going to be appending to whatever is in "result" already, so make
@@ -459,285 +432,23 @@ static bool TamilToText(int32_t ordinal,
    DecimalToText(ordinal, result); 
    char16_t* p = result.BeginWriting() + offset;
    for(; '\0' != *p ; p++) 
       if(*p != char16_t('0'))
          *p += diff;
    return true;
 }
 
-
-static const char gLowerRomanCharsA[] = "ixcm";
-static const char gUpperRomanCharsA[] = "IXCM";
-static const char gLowerRomanCharsB[] = "vld";
-static const char gUpperRomanCharsB[] = "VLD";
-
-static bool RomanToText(int32_t ordinal, nsString& result, const char* achars, const char* bchars)
-{
-  if (ordinal < 1 || ordinal > 3999) {
-    return false;
-  }
-  nsAutoString addOn, decStr;
-  decStr.AppendInt(ordinal, 10);
-  int len = decStr.Length();
-  const char16_t* dp = decStr.get();
-  const char16_t* end = dp + len;
-  int romanPos = len;
-  int n;
-
-  for (; dp < end; dp++) {
-    romanPos--;
-    addOn.SetLength(0);
-    switch(*dp) {
-      case '3':
-        addOn.Append(char16_t(achars[romanPos]));
-        // FALLTHROUGH
-      case '2':
-        addOn.Append(char16_t(achars[romanPos]));
-        // FALLTHROUGH
-      case '1':
-        addOn.Append(char16_t(achars[romanPos]));
-        break;
-      case '4':
-        addOn.Append(char16_t(achars[romanPos]));
-        // FALLTHROUGH
-      case '5': case '6':
-      case '7': case '8':
-        addOn.Append(char16_t(bchars[romanPos]));
-        for(n=0;'5'+n<*dp;n++) {
-          addOn.Append(char16_t(achars[romanPos]));
-        }
-        break;
-      case '9':
-        addOn.Append(char16_t(achars[romanPos]));
-        addOn.Append(char16_t(achars[romanPos+1]));
-        break;
-      default:
-        break;
-    }
-    result.Append(addOn);
-  }
-  return true;
-}
-
-#define ALPHA_SIZE 26
-static const char16_t gLowerAlphaChars[ALPHA_SIZE]  = 
-{
-0x0061, 0x0062, 0x0063, 0x0064, 0x0065, // A   B   C   D   E
-0x0066, 0x0067, 0x0068, 0x0069, 0x006A, // F   G   H   I   J
-0x006B, 0x006C, 0x006D, 0x006E, 0x006F, // K   L   M   N   O
-0x0070, 0x0071, 0x0072, 0x0073, 0x0074, // P   Q   R   S   T
-0x0075, 0x0076, 0x0077, 0x0078, 0x0079, // U   V   W   X   Y
-0x007A                                  // Z
-};
-
-static const char16_t gUpperAlphaChars[ALPHA_SIZE]  = 
-{
-0x0041, 0x0042, 0x0043, 0x0044, 0x0045, // A   B   C   D   E
-0x0046, 0x0047, 0x0048, 0x0049, 0x004A, // F   G   H   I   J
-0x004B, 0x004C, 0x004D, 0x004E, 0x004F, // K   L   M   N   O
-0x0050, 0x0051, 0x0052, 0x0053, 0x0054, // P   Q   R   S   T
-0x0055, 0x0056, 0x0057, 0x0058, 0x0059, // U   V   W   X   Y
-0x005A                                  // Z
-};
-
-
-#define KATAKANA_CHARS_SIZE 48
-// Page 94 Writing Systems of The World
-// after modification by momoi
-static const char16_t gKatakanaChars[KATAKANA_CHARS_SIZE] =
-{
-0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, //  a    i   u    e    o
-0x30AB, 0x30AD, 0x30AF, 0x30B1, 0x30B3, // ka   ki  ku   ke   ko
-0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, // sa  shi  su   se   so
-0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, // ta  chi tsu   te   to
-0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, // na   ni  nu   ne   no
-0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, // ha   hi  hu   he   ho
-0x30DE, 0x30DF, 0x30E0, 0x30E1, 0x30E2, // ma   mi  mu   me   mo
-0x30E4,         0x30E6,         0x30E8, // ya       yu        yo 
-0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, // ra   ri  ru   re   ro
-0x30EF, 0x30F0,         0x30F1, 0x30F2, // wa (w)i     (w)e (w)o
-0x30F3                                  //  n
-};
-
-#define HIRAGANA_CHARS_SIZE 48 
-static const char16_t gHiraganaChars[HIRAGANA_CHARS_SIZE] =
-{
-0x3042, 0x3044, 0x3046, 0x3048, 0x304A, //  a    i    u    e    o
-0x304B, 0x304D, 0x304F, 0x3051, 0x3053, // ka   ki   ku   ke   ko
-0x3055, 0x3057, 0x3059, 0x305B, 0x305D, // sa  shi   su   se   so
-0x305F, 0x3061, 0x3064, 0x3066, 0x3068, // ta  chi  tsu   te   to
-0x306A, 0x306B, 0x306C, 0x306D, 0x306E, // na   ni   nu   ne   no
-0x306F, 0x3072, 0x3075, 0x3078, 0x307B, // ha   hi   hu   he   ho
-0x307E, 0x307F, 0x3080, 0x3081, 0x3082, // ma   mi   mu   me   mo
-0x3084,         0x3086,         0x3088, // ya        yu       yo 
-0x3089, 0x308A, 0x308B, 0x308C, 0x308D, // ra   ri   ru   re   ro
-0x308F, 0x3090,         0x3091, 0x3092, // wa (w)i      (w)e (w)o
-0x3093                                  // n
-};
-
-
-#define HIRAGANA_IROHA_CHARS_SIZE 47
-// Page 94 Writing Systems of The World
-static const char16_t gHiraganaIrohaChars[HIRAGANA_IROHA_CHARS_SIZE] =
-{
-0x3044, 0x308D, 0x306F, 0x306B, 0x307B, //  i   ro   ha   ni   ho
-0x3078, 0x3068, 0x3061, 0x308A, 0x306C, // he   to  chi   ri   nu
-0x308B, 0x3092, 0x308F, 0x304B, 0x3088, // ru (w)o   wa   ka   yo
-0x305F, 0x308C, 0x305D, 0x3064, 0x306D, // ta   re   so  tsu   ne
-0x306A, 0x3089, 0x3080, 0x3046, 0x3090, // na   ra   mu    u (w)i
-0x306E, 0x304A, 0x304F, 0x3084, 0x307E, // no    o   ku   ya   ma
-0x3051, 0x3075, 0x3053, 0x3048, 0x3066, // ke   hu   ko    e   te
-0x3042, 0x3055, 0x304D, 0x3086, 0x3081, //  a   sa   ki   yu   me
-0x307F, 0x3057, 0x3091, 0x3072, 0x3082, // mi  shi (w)e   hi   mo 
-0x305B, 0x3059                          // se   su
-};
-
-#define KATAKANA_IROHA_CHARS_SIZE 47
-static const char16_t gKatakanaIrohaChars[KATAKANA_IROHA_CHARS_SIZE] =
-{
-0x30A4, 0x30ED, 0x30CF, 0x30CB, 0x30DB, //  i   ro   ha   ni   ho
-0x30D8, 0x30C8, 0x30C1, 0x30EA, 0x30CC, // he   to  chi   ri   nu
-0x30EB, 0x30F2, 0x30EF, 0x30AB, 0x30E8, // ru (w)o   wa   ka   yo
-0x30BF, 0x30EC, 0x30BD, 0x30C4, 0x30CD, // ta   re   so  tsu   ne
-0x30CA, 0x30E9, 0x30E0, 0x30A6, 0x30F0, // na   ra   mu    u (w)i
-0x30CE, 0x30AA, 0x30AF, 0x30E4, 0x30DE, // no    o   ku   ya   ma
-0x30B1, 0x30D5, 0x30B3, 0x30A8, 0x30C6, // ke   hu   ko    e   te
-0x30A2, 0x30B5, 0x30AD, 0x30E6, 0x30E1, //  a   sa   ki   yu   me
-0x30DF, 0x30B7, 0x30F1, 0x30D2, 0x30E2, // mi  shi (w)e   hi   mo 
-0x30BB, 0x30B9                          // se   su
-};
-
-#define LOWER_GREEK_CHARS_SIZE 24
-// Note: 0x03C2 GREEK FINAL SIGMA is not used in here....
-static const char16_t gLowerGreekChars[LOWER_GREEK_CHARS_SIZE] =
-{
-0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, // alpha  beta  gamma  delta  epsilon
-0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, // zeta   eta   theta  iota   kappa   
-0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, // lamda  mu    nu     xi     omicron 
-0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, // pi     rho   sigma  tau    upsilon 
-0x03C6, 0x03C7, 0x03C8, 0x03C9          // phi    chi   psi    omega    
-};
-
-#define CJK_HEAVENLY_STEM_CHARS_SIZE 10 
-static const char16_t gCJKHeavenlyStemChars[CJK_HEAVENLY_STEM_CHARS_SIZE] =
-{
-0x7532, 0x4e59, 0x4e19, 0x4e01, 0x620a,
-0x5df1, 0x5e9a, 0x8f9b, 0x58ec, 0x7678
-};
-#define CJK_EARTHLY_BRANCH_CHARS_SIZE 12 
-static const char16_t gCJKEarthlyBranchChars[CJK_EARTHLY_BRANCH_CHARS_SIZE] =
-{
-0x5b50, 0x4e11, 0x5bc5, 0x536f, 0x8fb0, 0x5df3,
-0x5348, 0x672a, 0x7533, 0x9149, 0x620c, 0x4ea5
-};
-#define HANGUL_CHARS_SIZE 14 
-static const char16_t gHangulChars[HANGUL_CHARS_SIZE] =
-{
-0xac00, 0xb098, 0xb2e4, 0xb77c, 0xb9c8, 0xbc14,
-0xc0ac, 0xc544, 0xc790, 0xcc28, 0xce74, 0xd0c0,
-0xd30c, 0xd558
-};
-#define HANGUL_CONSONANT_CHARS_SIZE 14 
-static const char16_t gHangulConsonantChars[HANGUL_CONSONANT_CHARS_SIZE] =
-{                                      
-0x3131, 0x3134, 0x3137, 0x3139, 0x3141, 0x3142,
-0x3145, 0x3147, 0x3148, 0x314a, 0x314b, 0x314c,
-0x314d, 0x314e
-};
-
-// Ge'ez set of Ethiopic ordered list. There are other locale-dependent sets.
-// For the time being, let's implement two Ge'ez sets only
-// per Momoi san's suggestion in bug 102252. 
-// For details, refer to http://www.ethiopic.org/Collation/OrderedLists.html.
-#define ETHIOPIC_HALEHAME_CHARS_SIZE 26
-static const char16_t gEthiopicHalehameChars[ETHIOPIC_HALEHAME_CHARS_SIZE] =
-{                                      
-0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228,
-0x1230, 0x1240, 0x1260, 0x1270, 0x1280, 0x1290,
-0x12a0, 0x12a8, 0x12c8, 0x12d0, 0x12d8, 0x12e8,
-0x12f0, 0x1308, 0x1320, 0x1330, 0x1338, 0x1340,
-0x1348, 0x1350
-};
-#define ETHIOPIC_HALEHAME_AM_CHARS_SIZE 33
-static const char16_t gEthiopicHalehameAmChars[ETHIOPIC_HALEHAME_AM_CHARS_SIZE] =
-{                                      
-0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228,
-0x1230, 0x1238, 0x1240, 0x1260, 0x1270, 0x1278,
-0x1280, 0x1290, 0x1298, 0x12a0, 0x12a8, 0x12b8,
-0x12c8, 0x12d0, 0x12d8, 0x12e0, 0x12e8, 0x12f0,
-0x1300, 0x1308, 0x1320, 0x1328, 0x1330, 0x1338,
-0x1340, 0x1348, 0x1350
-};
-#define ETHIOPIC_HALEHAME_TI_ER_CHARS_SIZE 31
-static const char16_t gEthiopicHalehameTiErChars[ETHIOPIC_HALEHAME_TI_ER_CHARS_SIZE] =
-{                                      
-0x1200, 0x1208, 0x1210, 0x1218, 0x1228, 0x1230,
-0x1238, 0x1240, 0x1250, 0x1260, 0x1270, 0x1278,
-0x1290, 0x1298, 0x12a0, 0x12a8, 0x12b8, 0x12c8,
-0x12d0, 0x12d8, 0x12e0, 0x12e8, 0x12f0, 0x1300,
-0x1308, 0x1320, 0x1328, 0x1330, 0x1338, 0x1348,
-0x1350
-};
-#define ETHIOPIC_HALEHAME_TI_ET_CHARS_SIZE 34
-static const char16_t gEthiopicHalehameTiEtChars[ETHIOPIC_HALEHAME_TI_ET_CHARS_SIZE] =
-{                                      
-0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228,
-0x1230, 0x1238, 0x1240, 0x1250, 0x1260, 0x1270,
-0x1278, 0x1280, 0x1290, 0x1298, 0x12a0, 0x12a8,
-0x12b8, 0x12c8, 0x12d0, 0x12d8, 0x12e0, 0x12e8,
-0x12f0, 0x1300, 0x1308, 0x1320, 0x1328, 0x1330,
-0x1338, 0x1340, 0x1348, 0x1350
-};
-
-
 // We know cjk-ideographic need 31 characters to display 99,999,999,999,999,999
 // georgian needs 6 at most
 // armenian needs 12 at most
 // hebrew may need more...
 
 #define NUM_BUF_SIZE 34 
 
-static bool CharListToText(int32_t ordinal, nsString& result, const char16_t* chars, int32_t aBase)
-{
-  char16_t buf[NUM_BUF_SIZE];
-  int32_t idx = NUM_BUF_SIZE;
-  if (ordinal < 1) {
-    return false;
-  }
-  do {
-    ordinal--; // a == 0
-    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 char16_t gCJKDecimalChars[10] =
-{
-  0x3007, 0x4e00, 0x4e8c, 0x4e09, 0x56db,
-  0x4e94, 0x516d, 0x4e03, 0x516b, 0x4e5d
-};
-static bool CharListDecimalToText(int32_t ordinal, nsString& result, const char16_t* chars)
-{
-  if (ordinal < 0) {
-    return false;
-  }
-  char16_t 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;
-}
-
 enum CJKIdeographicLang {
   CHINESE, KOREAN, JAPANESE
 };
 struct CJKIdeographicData {
   const char16_t *negative;
   char16_t digit[10];
   char16_t unit[3];
   char16_t unit10K[2];
@@ -994,76 +705,16 @@ static bool HebrewToText(int32_t ordinal
     ordinal /= 1000;
     outputSep = true;
   } while (ordinal >= 1);
 
   result.Append(allText);
   return true;
 }
 
-
-static bool ArmenianToText(int32_t ordinal, nsString& result)
-{
-  if (ordinal < 1 || ordinal > 9999) { // zero or reach the limit of Armenian numbering system
-    return false;
-  }
-
-  char16_t buf[NUM_BUF_SIZE];
-  int32_t idx = NUM_BUF_SIZE;
-  int32_t d = 0;
-  do {
-    int32_t cur = ordinal % 10;
-    if (cur > 0)
-    {
-      char16_t u = 0x0530 + (d * 9) + cur;
-      buf[--idx] = u;
-    }
-    ++d;
-    ordinal /= 10;
-  } while (ordinal > 0);
-  result.Append(buf + idx, NUM_BUF_SIZE - idx);
-  return true;
-}
-
-
-static const char16_t gGeorgianValue [ 37 ] = { // 4 * 9 + 1 = 37
-//      1       2       3       4       5       6       7       8       9
-   0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10F1, 0x10D7,
-//     10      20      30      40      50      60      70      80      90
-   0x10D8, 0x10D9, 0x10DA, 0x10DB, 0x10DC, 0x10F2, 0x10DD, 0x10DE, 0x10DF,
-//    100     200     300     400     500     600     700     800     900
-   0x10E0, 0x10E1, 0x10E2, 0x10F3, 0x10E4, 0x10E5, 0x10E6, 0x10E7, 0x10E8,
-//   1000    2000    3000    4000    5000    6000    7000    8000    9000
-   0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10F4, 0x10EF, 0x10F0,
-//  10000
-   0x10F5
-};
-static bool GeorgianToText(int32_t ordinal, nsString& result)
-{
-  if (ordinal < 1 || ordinal > 19999) { // zero or reach the limit of Georgian numbering system
-    return false;
-  }
-
-  char16_t buf[NUM_BUF_SIZE];
-  int32_t idx = NUM_BUF_SIZE;
-  int32_t d = 0;
-  do {
-    int32_t cur = ordinal % 10;
-    if (cur > 0)
-    {
-      char16_t u = gGeorgianValue[(d * 9 ) + ( cur - 1)];
-      buf[--idx] = u;
-    }
-    ++d;
-    ordinal /= 10;
-  } while (ordinal > 0);
-  result.Append(buf + idx, NUM_BUF_SIZE - idx);
-  return true;
-}
-
 // Convert ordinal to Ethiopic numeric representation.
 // The detail is available at http://www.ethiopic.org/Numerals/
 // The algorithm used here is based on the pseudo-code put up there by
 // Daniel Yacob <yacob@geez.org>.
 // Another reference is Unicode 3.0 standard section 11.1.
 #define ETHIOPIC_ONE             0x1369
 #define ETHIOPIC_TEN             0x1372
 #define ETHIOPIC_HUNDRED         0x137B
@@ -1164,240 +815,68 @@ nsBulletFrame::AppendCounterText(int32_t
 
     case NS_STYLE_LIST_STYLE_DECIMAL:
     default: // CSS2 say "A users  agent that does not recognize a numbering system
       // should use 'decimal'
       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;
-
-    case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
-      success = CharListToText(aOrdinal, result, gLowerAlphaChars, ALPHA_SIZE);
-      break;
-
-    case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
-      success = CharListToText(aOrdinal, result, gUpperAlphaChars, ALPHA_SIZE);
-      break;
-
-    case NS_STYLE_LIST_STYLE_KATAKANA:
-      success = CharListToText(aOrdinal, result, gKatakanaChars,
-                               KATAKANA_CHARS_SIZE);
-      break;
-
-    case NS_STYLE_LIST_STYLE_HIRAGANA:
-      success = CharListToText(aOrdinal, result, gHiraganaChars,
-                               HIRAGANA_CHARS_SIZE);
-      break;
-    
-    case NS_STYLE_LIST_STYLE_KATAKANA_IROHA:
-      success = CharListToText(aOrdinal, result, gKatakanaIrohaChars,
-                               KATAKANA_IROHA_CHARS_SIZE);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_HIRAGANA_IROHA:
-      success = CharListToText(aOrdinal, result, gHiraganaIrohaChars,
-                               HIRAGANA_IROHA_CHARS_SIZE);
-      break;
-
-    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_TRAD_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL: 
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success =
         CJKIdeographicToText(aOrdinal, result, gDataTradChineseInformal);
       break;
 
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL: 
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success = CJKIdeographicToText(aOrdinal, result, gDataTradChineseFormal);
       break;
 
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL: 
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success =
         CJKIdeographicToText(aOrdinal, result, gDataSimpChineseInformal);
       break;
 
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL: 
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success = CJKIdeographicToText(aOrdinal, result, gDataSimpChineseFormal);
       break;
 
     case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL: 
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success = CJKIdeographicToText(aOrdinal, result, gDataJapaneseInformal);
       break;
 
     case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL: 
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success = CJKIdeographicToText(aOrdinal, result, gDataJapaneseFormal);
       break;
 
     case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success =
         CJKIdeographicToText(aOrdinal, result, gDataKoreanHangulFormal);
       break;
 
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success =
         CJKIdeographicToText(aOrdinal, result, gDataKoreanHanjaInformal);
       break;
 
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
-      fallback = NS_STYLE_LIST_STYLE_CJK_DECIMAL;
       success = CJKIdeographicToText(aOrdinal, result, gDataKoreanHanjaFormal);
       break;
 
     case NS_STYLE_LIST_STYLE_HEBREW: 
       isRTL = true;
       success = HebrewToText(aOrdinal, result);
       break;
-
-    case NS_STYLE_LIST_STYLE_ARMENIAN: 
-      success = ArmenianToText(aOrdinal, result);
-      break;
-
-    case NS_STYLE_LIST_STYLE_GEORGIAN: 
-      success = GeorgianToText(aOrdinal, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC:
-      success = OtherDecimalToText(aOrdinal, 0x0660, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_PERSIAN:
-    case NS_STYLE_LIST_STYLE_MOZ_URDU:
-      success = OtherDecimalToText(aOrdinal, 0x06f0, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI:
-      success = OtherDecimalToText(aOrdinal, 0x0966, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_GURMUKHI:
-      success = OtherDecimalToText(aOrdinal, 0x0a66, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_GUJARATI:
-      success = OtherDecimalToText(aOrdinal, 0x0AE6, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_ORIYA:
-      success = OtherDecimalToText(aOrdinal, 0x0B66, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_KANNADA:
-      success = OtherDecimalToText(aOrdinal, 0x0CE6, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_MALAYALAM:
-      success = OtherDecimalToText(aOrdinal, 0x0D66, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_THAI:
-      success = OtherDecimalToText(aOrdinal, 0x0E50, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_LAO:
-      success = OtherDecimalToText(aOrdinal, 0x0ED0, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_MYANMAR:
-      success = OtherDecimalToText(aOrdinal, 0x1040, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_KHMER:
-      success = OtherDecimalToText(aOrdinal, 0x17E0, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_BENGALI:
-      success = OtherDecimalToText(aOrdinal, 0x09E6, result);
-      break;
- 
-    case NS_STYLE_LIST_STYLE_MOZ_TELUGU:
-      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;
-
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
-      success = CharListToText(aOrdinal, result, gHangulConsonantChars,
-                               HANGUL_CONSONANT_CHARS_SIZE);
-      break;
-
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
-      success = CharListToText(aOrdinal, result, gEthiopicHalehameChars,
-                               ETHIOPIC_HALEHAME_CHARS_SIZE);
-      break;
-
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
       success = EthiopicToText(aOrdinal, result);
       break;
-
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
-      success = CharListToText(aOrdinal, result, gEthiopicHalehameAmChars,
-                               ETHIOPIC_HALEHAME_AM_CHARS_SIZE);
-      break;
-
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
-      success = CharListToText(aOrdinal, result, gEthiopicHalehameTiErChars,
-                               ETHIOPIC_HALEHAME_TI_ER_CHARS_SIZE);
-      break;
-
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
-      success = CharListToText(aOrdinal, result, gEthiopicHalehameTiEtChars,
-                               ETHIOPIC_HALEHAME_TI_ET_CHARS_SIZE);
-      break;
   }
   if (!success) {
     AppendCounterText(fallback, aOrdinal, result, isRTL);
   }
 }
 
 /* static */ void
 nsBulletFrame::GetListItemSuffix(int32_t aListStyleType,
@@ -1408,40 +887,28 @@ 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 = ' ';
       break;
 
-    case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
-    case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
-    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:
-    case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
       aResult = 0x3001;
       break;
 
     case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
       aResult.AssignLiteral(MOZ_UTF16(", "));
       break;
   }
 }
 
 void
 nsBulletFrame::GetListItemText(nsAString& aResult)
 {
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -322,39 +322,32 @@ BuiltinCounterStyle::IsBullet()
 }
 
 /* virtual */ void
 BuiltinCounterStyle::GetNegative(NegativeType& aResult)
 {
   switch (mStyle) {
     case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
     case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
       aResult.before = gJapaneseNegative;
       break;
 
     case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
       aResult.before = gKoreanNegative;
       break;
 
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
       aResult.before = gSimpChineseNegative;
       break;
 
-    case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
       aResult.before = gTradChineseNegative;
       break;
 
     default:
       aResult.before.AssignLiteral(MOZ_UTF16("-"));
   }
   aResult.after.Truncate();
 }
@@ -366,195 +359,84 @@ BuiltinCounterStyle::IsOrdinalInRange(Co
     default:
     // cyclic
     case NS_STYLE_LIST_STYLE_NONE:
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
     case NS_STYLE_LIST_STYLE_SQUARE:
     // use DecimalToText
     case NS_STYLE_LIST_STYLE_DECIMAL:
-    case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
     // use CJKIdeographicToText
-    case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
     case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
     case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
-    // use OtherDecimalToText
-    case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC:
-    case NS_STYLE_LIST_STYLE_MOZ_PERSIAN:
-    case NS_STYLE_LIST_STYLE_MOZ_URDU:
-    case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI:
-    case NS_STYLE_LIST_STYLE_MOZ_GURMUKHI:
-    case NS_STYLE_LIST_STYLE_MOZ_GUJARATI:
-    case NS_STYLE_LIST_STYLE_MOZ_ORIYA:
-    case NS_STYLE_LIST_STYLE_MOZ_KANNADA:
-    case NS_STYLE_LIST_STYLE_MOZ_MALAYALAM:
-    case NS_STYLE_LIST_STYLE_MOZ_THAI:
-    case NS_STYLE_LIST_STYLE_MOZ_LAO:
-    case NS_STYLE_LIST_STYLE_MOZ_MYANMAR:
-    case NS_STYLE_LIST_STYLE_MOZ_KHMER:
-    case NS_STYLE_LIST_STYLE_MOZ_BENGALI:
-    case NS_STYLE_LIST_STYLE_MOZ_TELUGU:
       return true;
 
-    // use CharListDecimalToText
-    case NS_STYLE_LIST_STYLE_CJK_DECIMAL:
-      return aOrdinal >= 0;
-
-    // use RomanToText
-    case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
-    case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
-      return aOrdinal >= 1 && aOrdinal <= 3999;
-
-    // use CharListToText
-    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:
-    case NS_STYLE_LIST_STYLE_LOWER_GREEK:
-    case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
-    case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
     // use EthiopicToText
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
       return aOrdinal >= 1;
 
     // use HebrewToText
     case NS_STYLE_LIST_STYLE_HEBREW:
       return aOrdinal >= 1 && aOrdinal <= 999999;
 
-    // use ArmenianToText
-    case NS_STYLE_LIST_STYLE_ARMENIAN:
     // use TamilToText
     case NS_STYLE_LIST_STYLE_MOZ_TAMIL:
       return aOrdinal >= 1 && aOrdinal <= 9999;
-
-    // use GeorgianToText
-    case NS_STYLE_LIST_STYLE_GEORGIAN:
-      return aOrdinal >= 1 && aOrdinal <= 19999;
   }
 }
 
 /* virtual */ bool
 BuiltinCounterStyle::IsOrdinalInAutoRange(CounterValue aOrdinal)
 {
   switch (mStyle) {
     // cyclic:
     case NS_STYLE_LIST_STYLE_NONE:
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
     case NS_STYLE_LIST_STYLE_SQUARE:
     // numeric:
     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_MOZ_ARABIC_INDIC:
-    case NS_STYLE_LIST_STYLE_MOZ_PERSIAN:
-    case NS_STYLE_LIST_STYLE_MOZ_URDU:
-    case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI:
-    case NS_STYLE_LIST_STYLE_MOZ_GURMUKHI:
-    case NS_STYLE_LIST_STYLE_MOZ_GUJARATI:
-    case NS_STYLE_LIST_STYLE_MOZ_ORIYA:
-    case NS_STYLE_LIST_STYLE_MOZ_KANNADA:
-    case NS_STYLE_LIST_STYLE_MOZ_MALAYALAM:
-    case NS_STYLE_LIST_STYLE_MOZ_THAI:
-    case NS_STYLE_LIST_STYLE_MOZ_LAO:
-    case NS_STYLE_LIST_STYLE_MOZ_MYANMAR:
-    case NS_STYLE_LIST_STYLE_MOZ_KHMER:
-    case NS_STYLE_LIST_STYLE_MOZ_BENGALI:
-    case NS_STYLE_LIST_STYLE_MOZ_TELUGU:
-    // fixed: no predefined counter style
       return true;
 
-    // alphabetic:
-    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_KATAKANA:
-    case NS_STYLE_LIST_STYLE_HIRAGANA:
-    case NS_STYLE_LIST_STYLE_KATAKANA_IROHA:
-    case NS_STYLE_LIST_STYLE_HIRAGANA_IROHA:
-    case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM:
-    case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH:
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
-    case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
-    case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
-    // symbolic: no predefined counter style
-      return aOrdinal >= 1;
-
     // additive:
-    case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
-    case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
-    case NS_STYLE_LIST_STYLE_ARMENIAN:
-    case NS_STYLE_LIST_STYLE_GEORGIAN:
     case NS_STYLE_LIST_STYLE_HEBREW:
       return aOrdinal >= 0;
 
     // complex predefined:
-    case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC:
     case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
     case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
     case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
     case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL:
-    case NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL:
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
     case NS_STYLE_LIST_STYLE_MOZ_TAMIL:
       return IsOrdinalInRange(aOrdinal);
 
     default:
       NS_NOTREACHED("Unknown counter style");
       return false;
   }
 }
 
 /* virtual */ void
 BuiltinCounterStyle::GetPad(PadType& aResult)
 {
-  switch (mStyle) {
-    case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO:
-      aResult.width = 2;
-      aResult.symbol.AssignLiteral(MOZ_UTF16("0"));
-      break;
-    default:
-      aResult.width = 0;
-      aResult.symbol.Truncate();
-      break;
-  }
+  aResult.width = 0;
+  aResult.symbol.Truncate();
 }
 
 /* virtual */ CounterStyle*
 BuiltinCounterStyle::GetFallback()
 {
   // Fallback of dependent builtin counter styles are handled in class
   // DependentBuiltinCounterStyle.
   return CounterStyleManager::GetDecimalStyle();
@@ -564,24 +446,16 @@ BuiltinCounterStyle::GetFallback()
 BuiltinCounterStyle::GetSpeakAs()
 {
   switch (mStyle) {
     case NS_STYLE_LIST_STYLE_NONE:
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
     case NS_STYLE_LIST_STYLE_SQUARE:
       return NS_STYLE_COUNTER_SPEAKAS_BULLETS;
-    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:
-    case NS_STYLE_LIST_STYLE_LOWER_GREEK:
-      return NS_STYLE_COUNTER_SPEAKAS_SPELL_OUT;
     default:
       return NS_STYLE_COUNTER_SPEAKAS_NUMBERS;
   }
 }
 
 /* virtual */ bool
 BuiltinCounterStyle::UseNegativeSign()
 {
@@ -1541,16 +1415,21 @@ CounterStyleManager::BuildCounterStyle(c
 
 /* static */ CounterStyle*
 CounterStyleManager::GetBuiltinStyle(int32_t aStyle)
 {
   NS_ABORT_IF_FALSE(0 <= aStyle && aStyle < NS_STYLE_LIST_STYLE__MAX,
                     "Require a valid builtin style constant");
   NS_ABORT_IF_FALSE(!gBuiltinStyleTable[aStyle].IsDependentStyle(),
                     "Cannot get dependent builtin style");
+  NS_ASSERTION(aStyle != NS_STYLE_LIST_STYLE_LOWER_ROMAN &&
+               aStyle != NS_STYLE_LIST_STYLE_UPPER_ROMAN &&
+               aStyle != NS_STYLE_LIST_STYLE_LOWER_ALPHA &&
+               aStyle != NS_STYLE_LIST_STYLE_UPPER_ALPHA,
+               "lower/upper-roman/alpha should be custom counter style");
   return &gBuiltinStyleTable[aStyle];
 }
 
 struct InvalidateOldStyleData
 {
   explicit InvalidateOldStyleData(nsPresContext* aPresContext)
     : mPresContext(aPresContext),
       mChanged(false)
new file mode 100644
--- /dev/null
+++ b/layout/style/counterstyles.css
@@ -0,0 +1,265 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Defined in CSS Counter Styles Level 3 */
+
+/* 6 Simple Predefined Counter Styles */
+
+/* 6.1 Numeric */
+
+@counter-style decimal-leading-zero {
+  system: extends decimal;
+  pad: 2 '0';
+}
+
+@counter-style cjk-decimal {
+  system: numeric;
+  range: 0 infinite;
+  symbols: \3007  \4E00  \4E8C  \4E09  \56DB  \4E94  \516D  \4E03  \516B  \4E5D;
+  suffix: '\3001';
+}
+
+/* Though {lower,upper}-roman have been defined as builtin styles, they
+ * are redefined here to allow the correct extending behavior. */
+
+@counter-style lower-roman {
+  system: additive;
+  range: 1 3999;
+  additive-symbols: 1000 m, 900 cm, 500 d, 400 cd, 100 c, 90 xc, 50 l, 40 xl, 10 x, 9 ix, 5 v, 4 iv, 1 i;
+}
+
+@counter-style upper-roman {
+  system: additive;
+  range: 1 3999;
+  additive-symbols: 1000 M, 900 CM, 500 D, 400 CD, 100 C, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I;
+}
+
+@counter-style armenian {
+  system: additive;
+  range: 1 9999;
+  additive-symbols: 9000 \554, 8000 \553, 7000 \552, 6000 \551, 5000 \550, 4000 \54F, 3000 \54E, 2000 \54D, 1000 \54C, 900 \54B, 800 \54A, 700 \549, 600 \548, 500 \547, 400 \546, 300 \545, 200 \544, 100 \543, 90 \542, 80 \541, 70 \540, 60 \53F, 50 \53E, 40 \53D, 30 \53C, 20 \53B, 10 \53A, 9 \539, 8 \538, 7 \537, 6 \536, 5 \535, 4 \534, 3 \533, 2 \532, 1 \531;
+}
+
+@counter-style georgian {
+  system: additive;
+  range: 1 19999;
+  additive-symbols: 10000 \10F5, 9000 \10F0, 8000 \10EF, 7000 \10F4, 6000 \10EE, 5000 \10ED, 4000 \10EC, 3000 \10EB, 2000 \10EA, 1000 \10E9, 900 \10E8, 800 \10E7, 700 \10E6, 600 \10E5, 500 \10E4, 400 \10F3, 300 \10E2, 200 \10E1, 100 \10E0, 90 \10DF, 80 \10DE, 70 \10DD, 60 \10F2, 50 \10DC, 40 \10DB, 30 \10DA, 20 \10D9, 10 \10D8, 9 \10D7, 8 \10F1, 7 \10D6, 6 \10D5, 5 \10D4, 4 \10D3, 3 \10D2, 2 \10D1, 1 \10D0;
+}
+
+/* hebrew is not included because our builtin algorithm can generate a wider
+ * range of number in this style than what the spec defines. */
+
+/* 6.2 Alphabetic */
+
+@counter-style lower-alpha {
+  system: alphabetic;
+  symbols: a b c d e f g h i j k l m n o p q r s t u v w x y z;
+}
+
+@counter-style lower-latin {
+  system: extends lower-alpha;
+}
+
+@counter-style upper-alpha {
+  system: alphabetic;
+  symbols: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z;
+}
+
+@counter-style upper-latin {
+  system: extends upper-alpha;
+}
+
+@counter-style lower-greek {
+  system: alphabetic;
+  symbols: \3B1  \3B2  \3B3  \3B4  \3B5  \3B6  \3B7  \3B8  \3B9  \3BA  \3BB  \3BC  \3BD  \3BE  \3BF  \3C0  \3C1  \3C3  \3C4  \3C5  \3C6  \3C7  \3C8  \3C9;
+}
+
+@counter-style hiragana {
+  system: alphabetic;
+  symbols: \3042  \3044  \3046  \3048  \304A  \304B  \304D  \304F  \3051  \3053  \3055  \3057  \3059  \305B  \305D  \305F  \3061  \3064  \3066  \3068  \306A  \306B  \306C  \306D  \306E  \306F  \3072  \3075  \3078  \307B  \307E  \307F  \3080  \3081  \3082  \3084  \3086  \3088  \3089  \308A  \308B  \308C  \308D  \308F  \3090  \3091  \3092  \3093;
+  suffix: '\3001';
+}
+
+@counter-style hiragana-iroha {
+  system: alphabetic;
+  symbols: \3044  \308D  \306F  \306B  \307B  \3078  \3068  \3061  \308A  \306C  \308B  \3092  \308F  \304B  \3088  \305F  \308C  \305D  \3064  \306D  \306A  \3089  \3080  \3046  \3090  \306E  \304A  \304F  \3084  \307E  \3051  \3075  \3053  \3048  \3066  \3042  \3055  \304D  \3086  \3081  \307F  \3057  \3091  \3072  \3082  \305B  \3059;
+  suffix: '\3001';
+}
+
+@counter-style katakana {
+  system: alphabetic;
+  symbols: \30A2  \30A4  \30A6  \30A8  \30AA  \30AB  \30AD  \30AF  \30B1  \30B3  \30B5  \30B7  \30B9  \30BB  \30BD  \30BF  \30C1  \30C4  \30C6  \30C8  \30CA  \30CB  \30CC  \30CD  \30CE  \30CF  \30D2  \30D5  \30D8  \30DB  \30DE  \30DF  \30E0  \30E1  \30E2  \30E4  \30E6  \30E8  \30E9  \30EA  \30EB  \30EC  \30ED  \30EF  \30F0  \30F1  \30F2  \30F3;
+  suffix: '\3001';
+}
+
+@counter-style katakana-iroha {
+  system: alphabetic;
+  symbols: \30A4  \30ED  \30CF  \30CB  \30DB  \30D8  \30C8  \30C1  \30EA  \30CC  \30EB  \30F2  \30EF  \30AB  \30E8  \30BF  \30EC  \30BD  \30C4  \30CD  \30CA  \30E9  \30E0  \30A6  \30F0  \30CE  \30AA  \30AF  \30E4  \30DE  \30B1  \30D5  \30B3  \30A8  \30C6  \30A2  \30B5  \30AD  \30E6  \30E1  \30DF  \30B7  \30F1  \30D2  \30E2  \30BB  \30B9;
+  suffix: '\3001';
+}
+
+/* 6.3 Symbolic */
+
+/* symbolic counter styles are not included because they will be drew directly
+ * by the program instead of use alternative symbols defined in the spec */
+
+/* 7 Complex Predefined Counter Styles */
+
+/* only alias is included as other complex counter styles will be generated by
+ * specific algorithms to support the extended range. */
+
+@counter-style cjk-ideographic {
+  system: extends trad-chinese-informal;
+}
+
+/* Mozilla-specific counter styles */
+
+/* Numeric */
+
+@counter-style -moz-arabic-indic {
+  system: numeric;
+  symbols: \660  \661  \662  \663  \664  \665  \666  \667  \668  \669;
+}
+
+@counter-style -moz-persian {
+  system: numeric;
+  symbols: \6F0  \6F1  \6F2  \6F3  \6F4  \6F5  \6F6  \6F7  \6F8  \6F9;
+}
+
+@counter-style -moz-urdu {
+  system: extends -moz-persian;
+}
+
+@counter-style -moz-devanagari {
+  system: numeric;
+  symbols: \966  \967  \968  \969  \96A  \96B  \96C  \96D  \96F  \970;
+}
+
+@counter-style -moz-bengali {
+  system: numeric;
+  symbols: \9E6  \9E7  \9E8  \9E9  \9EA  \9EB  \9EC  \9ED  \9EF  \9F0;
+}
+
+@counter-style -moz-gurmukhi {
+  system: numeric;
+  symbols: \A66  \A67  \A68  \A69  \A6A  \A6B  \A6C  \A6D  \A6F  \A70;
+}
+
+@counter-style -moz-gujarati {
+  system: numeric;
+  symbols: \AE6  \AE7  \AE8  \AE9  \AEA  \AEB  \AEC  \AED  \AEF  \AF0;
+}
+
+@counter-style -moz-oriya {
+  system: numeric;
+  symbols: \B66  \B67  \B68  \B69  \B6A  \B6B  \B6C  \B6D  \B6F  \B70;
+}
+
+@counter-style -moz-telugu {
+  system: numeric;
+  symbols: \C66  \C67  \C68  \C69  \C6A  \C6B  \C6C  \C6D  \C6F  \C70;
+}
+
+@counter-style -moz-kannada {
+  system: numeric;
+  symbols: \CE6  \CE7  \CE8  \CE9  \CEA  \CEB  \CEC  \CED  \CEF  \CF0;
+}
+
+@counter-style -moz-malayalam {
+  system: numeric;
+  symbols: \D66  \D67  \D68  \D69  \D6A  \D6B  \D6C  \D6D  \D6F  \D70;
+}
+
+@counter-style -moz-thai {
+  system: numeric;
+  symbols: \E50  \E51  \E52  \E53  \E54  \E55  \E56  \E57  \E58  \E59;
+}
+
+@counter-style -moz-lao {
+  system: numeric;
+  symbols: \ED0  \ED1  \ED2  \ED3  \ED4  \ED5  \ED6  \ED7  \ED8  \ED9;
+}
+
+@counter-style -moz-myanmar {
+  system: numeric;
+  symbols: \1040  \1041  \1042  \1043  \1044  \1045  \1046  \1047  \1048  \1049;
+}
+
+@counter-style -moz-khmer {
+  system: numeric;
+  symbols: \17E0  \17E1  \17E2  \17E3  \17E4  \17E5  \17E6  \17E7  \17E8  \17E9;
+}
+
+/* Alphabetic */
+
+@counter-style -moz-cjk-heavenly-stem {
+  system: alphabetic;
+  symbols: \7532  \4E59  \4E19  \4E01  \620A  \5DF1  \5E9A  \8F9B  \58EC  \7678;
+  fallback: cjk-decimal;
+  suffix: '\3001';
+}
+@counter-style -moz-cjk-earthly-branch {
+  system: alphabetic;
+  symbols: \5B50  \4E11  \5BC5  \536F  \8FB0  \5DF3  \5348  \672A  \7533  \9149  \620C  \4EA5;
+  fallback: cjk-decimal;
+  suffix: '\3001';
+}
+
+@counter-style -moz-hangul {
+  system: alphabetic;
+  symbols: \AC00  \B098  \B2E4  \B77C  \B9C8  \BC14  \C0AC  \C544  \C790  \CC28  \CE74  \D0C0  \D30C  \D558;
+  suffix: ',';
+}
+@counter-style -moz-hangul-consonant {
+  system: alphabetic;
+  symbols: \3131  \3134  \3137  \3139  \3141  \3142  \3145  \3147  \3148  \314A  \314B  \314C  \314D  \314E;
+  suffix: ',';
+}
+
+/* Ge'ez set of Ethiopic ordered list. There are other locale-dependent sets.
+ * For the time being, let's implement two Ge'ez sets only
+ * per Momoi san's suggestion in bug 102252. 
+ * For details, refer to http://www.ethiopic.org/Collation/OrderedLists.html. */
+@counter-style -moz-ethiopic-halehame {
+  system: alphabetic;
+  symbols: \1200  \1208  \1210  \1218  \1220  \1228  \1230  \1240  \1260  \1270  \1280  \1290  \12A0  \12A8  \12C8  \12D0  \12D8  \12E8  \12F0  \1308  \1320  \1330  \1338  \1340  \1348  \1350;
+}
+@counter-style -moz-ethiopic-halehame-am {
+  system: alphabetic;
+  symbols: \1200  \1208  \1210  \1218  \1220  \1228  \1230  \1238  \1240  \1260  \1270  \1278  \1280  \1290  \1298  \12A0  \12A8  \12B8  \12C8  \12D0  \12D8  \12E0  \12E8  \12F0  \1300  \1308  \1320  \1328  \1330  \1338  \1340  \1348  \1350;
+}
+@counter-style -moz-ethiopic-halehame-ti-er {
+  system: alphabetic;
+  symbols: \1200  \1208  \1210  \1218  \1228  \1230  \1238  \1240  \1250  \1260  \1270  \1278  \1290  \1298  \12A0  \12A8  \12B8  \12C8  \12D0  \12D8  \12E0  \12E8  \12F0  \1300  \1308  \1320  \1328  \1330  \1338  \1348  \1350;
+}
+@counter-style -moz-ethiopic-halehame-ti-et {
+  system: alphabetic;
+  symbols: \1200  \1208  \1210  \1218  \1220  \1228  \1230  \1238  \1240  \1250  \1260  \1270  \1278  \1280  \1290  \1298  \12A0  \12A8  \12B8  \12C8  \12D0  \12D8  \12E0  \12E8  \12F0  \1300  \1308  \1320  \1328  \1330  \1338  \1340  \1348  \1350;
+}
+
+/* Alias */
+
+@counter-style -moz-trad-chinese-informal {
+  system: extends trad-chinese-informal;
+}
+
+@counter-style -moz-trad-chinese-formal {
+  system: extends trad-chinese-formal;
+}
+
+@counter-style -moz-simp-chinese-informal {
+  system: extends simp-chinese-informal;
+}
+
+@counter-style -moz-simp-chinese-formal {
+  system: extends simp-chinese-formal;
+}
+
+@counter-style -moz-japanese-informal {
+  system: extends japanese-informal;
+}
+
+@counter-style -moz-japanese-formal {
+  system: extends japanese-formal;
+}
--- a/layout/style/jar.mn
+++ b/layout/style/jar.mn
@@ -4,14 +4,15 @@
 
 toolkit.jar:
 *  res/ua.css    (ua.css)
    res/html.css    (html.css)
    res/quirk.css    (quirk.css)
    res/full-screen-override.css    (full-screen-override.css)
    res/plaintext.css     (plaintext.css)
    res/viewsource.css    (viewsource.css)
+   res/counterstyles.css (counterstyles.css)
 *  res/forms.css    (forms.css)
    res/number-control.css    (number-control.css)
    res/arrow.gif    (arrow.gif)
    res/arrowd.gif   (arrowd.gif)
 
 % resource gre-resources %res/
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -34,122 +34,93 @@
 
 // OUTPUT_CLASS=nsCSSKeywords
 // MACRO_NAME=CSS_KEY
 
 CSS_KEY(-moz-activehyperlinktext, _moz_activehyperlinktext)
 CSS_KEY(-moz-all, _moz_all)
 CSS_KEY(-moz-alt-content, _moz_alt_content)
 CSS_KEY(-moz-anchor-decoration, _moz_anchor_decoration)
-CSS_KEY(-moz-arabic-indic, _moz_arabic_indic)
 CSS_KEY(-moz-available, _moz_available)
-CSS_KEY(-moz-bengali, _moz_bengali)
 CSS_KEY(-moz-box, _moz_box)
 CSS_KEY(-moz-button, _moz_button)
 CSS_KEY(-moz-buttondefault, _moz_buttondefault)
 CSS_KEY(-moz-buttonhoverface, _moz_buttonhoverface)
 CSS_KEY(-moz-buttonhovertext, _moz_buttonhovertext)
 CSS_KEY(-moz-cellhighlight, _moz_cellhighlight)
 CSS_KEY(-moz-cellhighlighttext, _moz_cellhighlighttext)
 CSS_KEY(-moz-center, _moz_center)
-CSS_KEY(-moz-cjk-earthly-branch, _moz_cjk_earthly_branch)
-CSS_KEY(-moz-cjk-heavenly-stem, _moz_cjk_heavenly_stem)
 CSS_KEY(-moz-combobox, _moz_combobox)
 CSS_KEY(-moz-comboboxtext, _moz_comboboxtext)
 CSS_KEY(-moz-block-height, _moz_block_height)
 CSS_KEY(-moz-deck, _moz_deck)
 CSS_KEY(-moz-default-background-color, _moz_default_background_color)
 CSS_KEY(-moz-default-color, _moz_default_color)
 CSS_KEY(-moz-desktop, _moz_desktop)
-CSS_KEY(-moz-devanagari, _moz_devanagari)
 CSS_KEY(-moz-dialog, _moz_dialog)
 CSS_KEY(-moz-dialogtext, _moz_dialogtext)
 CSS_KEY(-moz-document, _moz_document)
 CSS_KEY(-moz-dragtargetzone, _moz_dragtargetzone)
 CSS_KEY(-moz-element, _moz_element)
 CSS_KEY(-moz-eventreerow, _moz_eventreerow)
-CSS_KEY(-moz-ethiopic-halehame, _moz_ethiopic_halehame)
 CSS_KEY(-moz-ethiopic-numeric, _moz_ethiopic_numeric)
-CSS_KEY(-moz-ethiopic-halehame-am, _moz_ethiopic_halehame_am)
-CSS_KEY(-moz-ethiopic-halehame-ti-er, _moz_ethiopic_halehame_ti_er)
-CSS_KEY(-moz-ethiopic-halehame-ti-et, _moz_ethiopic_halehame_ti_et)
 CSS_KEY(-moz-field, _moz_field)
 CSS_KEY(-moz-fieldtext, _moz_fieldtext)
 CSS_KEY(-moz-fit-content, _moz_fit_content)
 CSS_KEY(-moz-fixed, _moz_fixed)
 CSS_KEY(-moz-grabbing, _moz_grabbing)
 CSS_KEY(-moz-grab, _moz_grab)
 CSS_KEY(-moz-grid-group, _moz_grid_group)
 CSS_KEY(-moz-grid-line, _moz_grid_line)
 CSS_KEY(-moz-grid, _moz_grid)
 CSS_KEY(-moz-groupbox, _moz_groupbox)
-CSS_KEY(-moz-gujarati, _moz_gujarati)
-CSS_KEY(-moz-gurmukhi, _moz_gurmukhi)
-CSS_KEY(-moz-hangul-consonant, _moz_hangul_consonant)
 CSS_KEY(-moz-hidden-unscrollable, _moz_hidden_unscrollable)
-CSS_KEY(-moz-hangul, _moz_hangul)
 CSS_KEY(-moz-hyperlinktext, _moz_hyperlinktext)
 CSS_KEY(-moz-html-cellhighlight, _moz_html_cellhighlight)
 CSS_KEY(-moz-html-cellhighlighttext, _moz_html_cellhighlighttext)
 CSS_KEY(-moz-image-rect, _moz_image_rect)
 CSS_KEY(-moz-info, _moz_info)
 CSS_KEY(-moz-inline-box, _moz_inline_box)
 CSS_KEY(-moz-inline-grid, _moz_inline_grid)
 CSS_KEY(-moz-inline-stack, _moz_inline_stack)
 CSS_KEY(-moz-isolate, _moz_isolate)
 CSS_KEY(-moz-isolate-override, _moz_isolate_override)
-CSS_KEY(-moz-japanese-formal, _moz_japanese_formal)
-CSS_KEY(-moz-japanese-informal, _moz_japanese_informal)
-CSS_KEY(-moz-kannada, _moz_kannada)
-CSS_KEY(-moz-khmer, _moz_khmer)
-CSS_KEY(-moz-lao, _moz_lao)
 CSS_KEY(-moz-left, _moz_left)
 CSS_KEY(-moz-list, _moz_list)
 CSS_KEY(-moz-mac-chrome-active, _moz_mac_chrome_active)
 CSS_KEY(-moz-mac-chrome-inactive, _moz_mac_chrome_inactive)
 CSS_KEY(-moz-mac-focusring, _moz_mac_focusring)
 CSS_KEY(-moz-mac-fullscreen-button, _moz_mac_fullscreen_button)
 CSS_KEY(-moz-mac-menuselect, _moz_mac_menuselect)
 CSS_KEY(-moz-mac-menushadow, _moz_mac_menushadow)
 CSS_KEY(-moz-mac-menutextdisable, _moz_mac_menutextdisable)
 CSS_KEY(-moz-mac-menutextselect, _moz_mac_menutextselect)
 CSS_KEY(-moz-mac-disabledtoolbartext, _moz_mac_disabledtoolbartext)
 CSS_KEY(-moz-mac-secondaryhighlight, _moz_mac_secondaryhighlight)
-CSS_KEY(-moz-malayalam, _moz_malayalam)
 CSS_KEY(-moz-max-content, _moz_max_content)
 CSS_KEY(-moz-menuhover, _moz_menuhover)
 CSS_KEY(-moz-menuhovertext, _moz_menuhovertext)
 CSS_KEY(-moz-menubartext, _moz_menubartext)
 CSS_KEY(-moz-menubarhovertext, _moz_menubarhovertext)
 CSS_KEY(-moz-middle-with-baseline, _moz_middle_with_baseline)
 CSS_KEY(-moz-min-content, _moz_min_content)
-CSS_KEY(-moz-myanmar, _moz_myanmar)
 CSS_KEY(-moz-nativehyperlinktext, _moz_nativehyperlinktext)
 CSS_KEY(-moz-none, _moz_none)
 CSS_KEY(-moz-oddtreerow, _moz_oddtreerow)
-CSS_KEY(-moz-oriya, _moz_oriya)
-CSS_KEY(-moz-persian, _moz_persian)
 CSS_KEY(-moz-plaintext, _moz_plaintext)
 CSS_KEY(-moz-popup, _moz_popup)
 CSS_KEY(-moz-pre-space, _moz_pre_space)
 CSS_KEY(-moz-pull-down-menu, _moz_pull_down_menu)
 CSS_KEY(-moz-right, _moz_right)
 CSS_KEY(-moz-scrollbars-horizontal, _moz_scrollbars_horizontal)
 CSS_KEY(-moz-scrollbars-none, _moz_scrollbars_none)
 CSS_KEY(-moz-scrollbars-vertical, _moz_scrollbars_vertical)
 CSS_KEY(-moz-show-background, _moz_show_background)
-CSS_KEY(-moz-simp-chinese-formal, _moz_simp_chinese_formal)
-CSS_KEY(-moz-simp-chinese-informal, _moz_simp_chinese_informal)
 CSS_KEY(-moz-stack, _moz_stack)
 CSS_KEY(-moz-tamil, _moz_tamil)
-CSS_KEY(-moz-telugu, _moz_telugu)
-CSS_KEY(-moz-thai, _moz_thai)
-CSS_KEY(-moz-trad-chinese-formal, _moz_trad_chinese_formal)
-CSS_KEY(-moz-trad-chinese-informal, _moz_trad_chinese_informal)
-CSS_KEY(-moz-urdu, _moz_urdu)
 CSS_KEY(-moz-use-system-font, _moz_use_system_font)
 CSS_KEY(-moz-use-text-color, _moz_use_text_color)
 CSS_KEY(-moz-visitedhyperlinktext, _moz_visitedhyperlinktext)
 CSS_KEY(-moz-window, _moz_window)
 CSS_KEY(-moz-workspace, _moz_workspace)
 CSS_KEY(-moz-zoom-in, _moz_zoom_in)
 CSS_KEY(-moz-zoom-out, _moz_zoom_out)
 CSS_KEY(absolute, absolute)
@@ -163,17 +134,16 @@ CSS_KEY(all-petite-caps, all_petite_caps
 CSS_KEY(all-scroll, all_scroll)
 CSS_KEY(all-small-caps, all_small_caps)
 CSS_KEY(alpha, alpha)
 CSS_KEY(alternate, alternate)
 CSS_KEY(alternate-reverse, alternate_reverse)
 CSS_KEY(always, always)
 CSS_KEY(annotation, annotation)
 CSS_KEY(appworkspace, appworkspace)
-CSS_KEY(armenian, armenian)
 CSS_KEY(auto, auto)
 CSS_KEY(avoid, avoid)
 CSS_KEY(background, background)
 CSS_KEY(backwards, backwards)
 CSS_KEY(balance, balance)
 CSS_KEY(baseline, baseline)
 CSS_KEY(bidi-override, bidi_override)
 CSS_KEY(blink, blink)
@@ -203,17 +173,16 @@ 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(clone, clone)
 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)
@@ -242,17 +211,16 @@ CSS_KEY(cross, cross)
 CSS_KEY(crosshair, crosshair)
 CSS_KEY(currentcolor, currentcolor)
 CSS_KEY(cursive, cursive)
 CSS_KEY(cyclic, cyclic)
 CSS_KEY(darken, darken)
 CSS_KEY(dashed, dashed)
 CSS_KEY(dense, dense)
 CSS_KEY(decimal, decimal)
-CSS_KEY(decimal-leading-zero, decimal_leading_zero)
 CSS_KEY(default, default)
 CSS_KEY(deg, deg)
 CSS_KEY(diagonal-fractions, diagonal_fractions)
 CSS_KEY(dialog, dialog)
 CSS_KEY(difference, difference)
 CSS_KEY(digits, digits)
 CSS_KEY(disabled, disabled)
 CSS_KEY(disc, disc)
@@ -290,33 +258,30 @@ CSS_KEY(flat, flat)
 CSS_KEY(flex, flex)
 CSS_KEY(flex-end, flex_end)
 CSS_KEY(flex-start, flex_start)
 CSS_KEY(flip, flip)
 CSS_KEY(forwards, forwards)
 CSS_KEY(fraktur, fraktur)
 CSS_KEY(from-image, from_image)
 CSS_KEY(full-width, full_width)
-CSS_KEY(georgian, georgian)
 CSS_KEY(grab, grab)
 CSS_KEY(grabbing, grabbing)
 CSS_KEY(grad, grad)
 CSS_KEY(grayscale, grayscale)
 CSS_KEY(graytext, graytext)
 CSS_KEY(grid, grid)
 CSS_KEY(groove, groove)
 CSS_KEY(hard-light, hard_light)
 CSS_KEY(hebrew, hebrew)
 CSS_KEY(help, help)
 CSS_KEY(hidden, hidden)
 CSS_KEY(hide, hide)
 CSS_KEY(highlight, highlight)
 CSS_KEY(highlighttext, highlighttext)
-CSS_KEY(hiragana, hiragana)
-CSS_KEY(hiragana-iroha, hiragana_iroha)
 CSS_KEY(historical-forms, historical_forms)
 CSS_KEY(historical-ligatures, historical_ligatures)
 CSS_KEY(horizontal, horizontal)
 CSS_KEY(horizontal-tb, horizontal_tb)
 CSS_KEY(hue, hue)
 CSS_KEY(hue-rotate, hue_rotate)
 CSS_KEY(hz, hz)
 CSS_KEY(icon, icon)
@@ -345,18 +310,16 @@ CSS_KEY(invert, invert)
 CSS_KEY(italic, italic)
 CSS_KEY(japanese-formal, japanese_formal)
 CSS_KEY(japanese-informal, japanese_informal)
 CSS_KEY(jis78, jis78)
 CSS_KEY(jis83, jis83)
 CSS_KEY(jis90, jis90)
 CSS_KEY(jis04, jis04)
 CSS_KEY(justify, justify)
-CSS_KEY(katakana, katakana)
-CSS_KEY(katakana-iroha, katakana_iroha)
 CSS_KEY(keep-all, keep_all)
 CSS_KEY(khz, khz)
 CSS_KEY(korean-hangul-formal, korean_hangul_formal)
 CSS_KEY(korean-hanja-formal, korean_hanja_formal)
 CSS_KEY(korean-hanja-informal, korean_hanja_informal)
 CSS_KEY(landscape, landscape)
 CSS_KEY(large, large)
 CSS_KEY(larger, larger)
@@ -366,18 +329,16 @@ CSS_KEY(lighter, lighter)
 CSS_KEY(line-through, line_through)
 CSS_KEY(linear, linear)
 CSS_KEY(lining-nums, lining_nums)
 CSS_KEY(list-item, list_item)
 CSS_KEY(local, local)
 CSS_KEY(logical, logical)
 CSS_KEY(looped, looped)
 CSS_KEY(lower-alpha, lower_alpha)
-CSS_KEY(lower-greek, lower_greek)
-CSS_KEY(lower-latin, lower_latin)
 CSS_KEY(lower-roman, lower_roman)
 CSS_KEY(lowercase, lowercase)
 CSS_KEY(ltr, ltr)
 CSS_KEY(luminance, luminance)
 CSS_KEY(luminosity, luminosity)
 CSS_KEY(manipulation, manipulation)
 CSS_KEY(manual, manual)
 CSS_KEY(margin-box, margin_box)
@@ -575,17 +536,16 @@ CSS_KEY(transparent, transparent) // for
 CSS_KEY(tri-state, tri_state)
 CSS_KEY(true, true)
 CSS_KEY(ultra-condensed, ultra_condensed)
 CSS_KEY(ultra-expanded, ultra_expanded)
 CSS_KEY(underline, underline)
 CSS_KEY(unicase, unicase)
 CSS_KEY(unset, unset)
 CSS_KEY(upper-alpha, upper_alpha)
-CSS_KEY(upper-latin, upper_latin)
 CSS_KEY(upper-roman, upper_roman)
 CSS_KEY(uppercase, uppercase)
 CSS_KEY(upright, upright)
 CSS_KEY(vertical, vertical)
 CSS_KEY(vertical-lr, vertical_lr)
 CSS_KEY(vertical-rl, vertical_rl)
 CSS_KEY(vertical-text, vertical_text)
 CSS_KEY(visible, visible)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1357,78 +1357,41 @@ const KTableValue nsCSSProps::kLineHeigh
 
 const KTableValue nsCSSProps::kListStylePositionKTable[] = {
   eCSSKeyword_inside, NS_STYLE_LIST_STYLE_POSITION_INSIDE,
   eCSSKeyword_outside, NS_STYLE_LIST_STYLE_POSITION_OUTSIDE,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const KTableValue nsCSSProps::kListStyleKTable[] = {
+  // none and decimal are not redefinable, so they should not be moved.
   eCSSKeyword_none, NS_STYLE_LIST_STYLE_NONE,
+  eCSSKeyword_decimal, NS_STYLE_LIST_STYLE_DECIMAL,
+  // the following graphic styles are processed in a different way.
   eCSSKeyword_disc, NS_STYLE_LIST_STYLE_DISC,
   eCSSKeyword_circle, NS_STYLE_LIST_STYLE_CIRCLE,
   eCSSKeyword_square, NS_STYLE_LIST_STYLE_SQUARE,
-  eCSSKeyword_decimal, NS_STYLE_LIST_STYLE_DECIMAL,
-  eCSSKeyword_decimal_leading_zero, NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO,
+  // {lower,upper}-{roman,alpha} are also used by html attribute map.
   eCSSKeyword_lower_roman, NS_STYLE_LIST_STYLE_LOWER_ROMAN,
   eCSSKeyword_upper_roman, NS_STYLE_LIST_STYLE_UPPER_ROMAN,
-  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,
+  // the following counter styles require specific algorithms to generate.
   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_japanese_informal, NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL,
   eCSSKeyword_japanese_formal, NS_STYLE_LIST_STYLE_JAPANESE_FORMAL,
   eCSSKeyword_korean_hangul_formal, NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL,
   eCSSKeyword_korean_hanja_informal, NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL,
   eCSSKeyword_korean_hanja_formal, NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL,
   eCSSKeyword_simp_chinese_informal, NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL,
   eCSSKeyword_simp_chinese_formal, NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL,
   eCSSKeyword_trad_chinese_informal, NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL,
   eCSSKeyword_trad_chinese_formal, NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL,
-  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,
-  eCSSKeyword__moz_trad_chinese_formal, NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL,
-  eCSSKeyword__moz_simp_chinese_informal, NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL,
-  eCSSKeyword__moz_simp_chinese_formal, NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL,
-  eCSSKeyword__moz_japanese_informal, NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL,
-  eCSSKeyword__moz_japanese_formal, NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL,
-  eCSSKeyword__moz_arabic_indic, NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC,
-  eCSSKeyword__moz_persian, NS_STYLE_LIST_STYLE_MOZ_PERSIAN,
-  eCSSKeyword__moz_urdu, NS_STYLE_LIST_STYLE_MOZ_URDU,
-  eCSSKeyword__moz_devanagari, NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI,
-  eCSSKeyword__moz_gurmukhi, NS_STYLE_LIST_STYLE_MOZ_GURMUKHI,
-  eCSSKeyword__moz_gujarati, NS_STYLE_LIST_STYLE_MOZ_GUJARATI,
-  eCSSKeyword__moz_oriya, NS_STYLE_LIST_STYLE_MOZ_ORIYA,
-  eCSSKeyword__moz_kannada, NS_STYLE_LIST_STYLE_MOZ_KANNADA,
-  eCSSKeyword__moz_malayalam, NS_STYLE_LIST_STYLE_MOZ_MALAYALAM,
-  eCSSKeyword__moz_bengali, NS_STYLE_LIST_STYLE_MOZ_BENGALI,
   eCSSKeyword__moz_tamil, NS_STYLE_LIST_STYLE_MOZ_TAMIL,
-  eCSSKeyword__moz_telugu, NS_STYLE_LIST_STYLE_MOZ_TELUGU,
-  eCSSKeyword__moz_thai, NS_STYLE_LIST_STYLE_MOZ_THAI,
-  eCSSKeyword__moz_lao, NS_STYLE_LIST_STYLE_MOZ_LAO,
-  eCSSKeyword__moz_myanmar, NS_STYLE_LIST_STYLE_MOZ_MYANMAR,
-  eCSSKeyword__moz_khmer, NS_STYLE_LIST_STYLE_MOZ_KHMER,
-  eCSSKeyword__moz_hangul, NS_STYLE_LIST_STYLE_MOZ_HANGUL,
-  eCSSKeyword__moz_hangul_consonant, NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT,
-  eCSSKeyword__moz_ethiopic_halehame, NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME,
   eCSSKeyword__moz_ethiopic_numeric, NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC,
-  eCSSKeyword__moz_ethiopic_halehame_am, NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM,
-  eCSSKeyword__moz_ethiopic_halehame_ti_er, NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER,
-  eCSSKeyword__moz_ethiopic_halehame_ti_et, NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const KTableValue nsCSSProps::kMathVariantKTable[] = {
   eCSSKeyword_none, NS_MATHML_MATHVARIANT_NONE,
   eCSSKeyword_normal, NS_MATHML_MATHVARIANT_NORMAL,
   eCSSKeyword_bold, NS_MATHML_MATHVARIANT_BOLD,
   eCSSKeyword_italic, NS_MATHML_MATHVARIANT_ITALIC,
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -222,16 +222,26 @@ nsLayoutStylesheetCache::MathMLSheet()
       LoadSheet(uri, gStyleCache->mMathMLSheet, true);
     }
     NS_ASSERTION(gStyleCache->mMathMLSheet, "Could not load mathml.css");
   }
 
   return gStyleCache->mMathMLSheet;
 }
 
+nsCSSStyleSheet*
+nsLayoutStylesheetCache::CounterStylesSheet()
+{
+  EnsureGlobal();
+  if (!gStyleCache)
+    return nullptr;
+
+  return gStyleCache->mCounterStylesSheet;
+}
+
 void
 nsLayoutStylesheetCache::Shutdown()
 {
   NS_IF_RELEASE(gCSSLoader);
   NS_IF_RELEASE(gStyleCache);
 }
 
 MOZ_DEFINE_MALLOC_SIZE_OF(LayoutStylesheetCacheMallocSizeOf)
@@ -261,16 +271,17 @@ nsLayoutStylesheetCache::SizeOfIncluding
   MEASURE(mUserChromeSheet);
   MEASURE(mUASheet);
   MEASURE(mHTMLSheet);
   MEASURE(mMinimalXULSheet);
   MEASURE(mXULSheet);
   MEASURE(mQuirkSheet);
   MEASURE(mFullScreenOverrideSheet);
   MEASURE(mSVGSheet);
+  MEASURE(mCounterStylesSheet);
   if (mMathMLSheet) {
     MEASURE(mMathMLSheet);
   }
 
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - gCSSLoader
 
@@ -332,16 +343,22 @@ nsLayoutStylesheetCache::nsLayoutStylesh
   NS_ASSERTION(mFullScreenOverrideSheet, "Could not load full-screen-override.css");
 
   NS_NewURI(getter_AddRefs(uri), "resource://gre/res/svg.css");
   if (uri) {
     LoadSheet(uri, mSVGSheet, true);
   }
   NS_ASSERTION(mSVGSheet, "Could not load svg.css");
 
+  NS_NewURI(getter_AddRefs(uri), "resource://gre-resources/counterstyles.css");
+  if (uri) {
+    LoadSheet(uri, mCounterStylesSheet, true);
+  }
+  NS_ASSERTION(mCounterStylesSheet, "Could not load counterstyles.css");
+
   // mMathMLSheet is created on-demand since its use is rare. This helps save
   // memory for Firefox OS apps.
 }
 
 nsLayoutStylesheetCache::~nsLayoutStylesheetCache()
 {
   mozilla::UnregisterWeakMemoryReporter(this);
   gStyleCache = nullptr;
--- a/layout/style/nsLayoutStylesheetCache.h
+++ b/layout/style/nsLayoutStylesheetCache.h
@@ -41,16 +41,17 @@ class nsLayoutStylesheetCache MOZ_FINAL
   static nsCSSStyleSheet* UASheet();
   static nsCSSStyleSheet* HTMLSheet();
   static nsCSSStyleSheet* MinimalXULSheet();
   static nsCSSStyleSheet* XULSheet();
   static nsCSSStyleSheet* QuirkSheet();
   static nsCSSStyleSheet* FullScreenOverrideSheet();
   static nsCSSStyleSheet* SVGSheet();
   static nsCSSStyleSheet* MathMLSheet();
+  static nsCSSStyleSheet* CounterStylesSheet();
 
   static void Shutdown();
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private:
   nsLayoutStylesheetCache();
   ~nsLayoutStylesheetCache();
@@ -72,11 +73,12 @@ private:
   nsRefPtr<nsCSSStyleSheet> mUASheet;
   nsRefPtr<nsCSSStyleSheet> mHTMLSheet;
   nsRefPtr<nsCSSStyleSheet> mMinimalXULSheet;
   nsRefPtr<nsCSSStyleSheet> mXULSheet;
   nsRefPtr<nsCSSStyleSheet> mQuirkSheet;
   nsRefPtr<nsCSSStyleSheet> mFullScreenOverrideSheet;
   nsRefPtr<nsCSSStyleSheet> mSVGSheet;
   nsRefPtr<nsCSSStyleSheet> mMathMLSheet;
+  nsRefPtr<nsCSSStyleSheet> mCounterStylesSheet;
 };
 
 #endif
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -635,74 +635,33 @@ static inline mozilla::css::Side operato
 
 // See nsStyleList
 #define NS_STYLE_LIST_STYLE_CUSTOM                -1 // for @counter-style
 #define NS_STYLE_LIST_STYLE_NONE                  0
 #define NS_STYLE_LIST_STYLE_DISC                  1
 #define NS_STYLE_LIST_STYLE_CIRCLE                2
 #define NS_STYLE_LIST_STYLE_SQUARE                3
 #define NS_STYLE_LIST_STYLE_DECIMAL               4
-#define NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO  5
-#define NS_STYLE_LIST_STYLE_LOWER_ROMAN           6
-#define NS_STYLE_LIST_STYLE_UPPER_ROMAN           7
-#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_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_JAPANESE_INFORMAL     20
-#define NS_STYLE_LIST_STYLE_JAPANESE_FORMAL       21
-#define NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL  22
-#define NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL 23
-#define NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL   24
-#define NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL 25
-#define NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL   26
-#define NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL 27
-#define NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL   28
-#define NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM     124
-#define NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH    125
-#define NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL 126
-#define NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL   127
-#define NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL 128
-#define NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL   129
-#define NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL     130
-#define NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL       131
-#define NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC          132
-#define NS_STYLE_LIST_STYLE_MOZ_PERSIAN               133
-#define NS_STYLE_LIST_STYLE_MOZ_URDU                  134
-#define NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI            135
-#define NS_STYLE_LIST_STYLE_MOZ_GURMUKHI              136
-#define NS_STYLE_LIST_STYLE_MOZ_GUJARATI              137
-#define NS_STYLE_LIST_STYLE_MOZ_ORIYA                 138
-#define NS_STYLE_LIST_STYLE_MOZ_KANNADA               139
-#define NS_STYLE_LIST_STYLE_MOZ_MALAYALAM             140
-#define NS_STYLE_LIST_STYLE_MOZ_BENGALI               141
-#define NS_STYLE_LIST_STYLE_MOZ_TAMIL                 142
-#define NS_STYLE_LIST_STYLE_MOZ_TELUGU                143
-#define NS_STYLE_LIST_STYLE_MOZ_THAI                  144
-#define NS_STYLE_LIST_STYLE_MOZ_LAO                   145
-#define NS_STYLE_LIST_STYLE_MOZ_MYANMAR               146
-#define NS_STYLE_LIST_STYLE_MOZ_KHMER                 147
-#define NS_STYLE_LIST_STYLE_MOZ_HANGUL                148
-#define NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT      149
-#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME     150
-#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC      151
-#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM  152
-#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER  153
-#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET  154
-#define NS_STYLE_LIST_STYLE__MAX                         155
+#define NS_STYLE_LIST_STYLE_LOWER_ROMAN           5
+#define NS_STYLE_LIST_STYLE_UPPER_ROMAN           6
+#define NS_STYLE_LIST_STYLE_LOWER_ALPHA           7
+#define NS_STYLE_LIST_STYLE_UPPER_ALPHA           8
+#define NS_STYLE_LIST_STYLE_HEBREW                9
+#define NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL     10
+#define NS_STYLE_LIST_STYLE_JAPANESE_FORMAL       11
+#define NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL  12
+#define NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL 13
+#define NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL   14
+#define NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL 15
+#define NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL   16
+#define NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL 17
+#define NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL   18
+#define NS_STYLE_LIST_STYLE_MOZ_TAMIL             19
+#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC  20
+#define NS_STYLE_LIST_STYLE__MAX                  21
 
 // See nsStyleList
 #define NS_STYLE_LIST_STYLE_POSITION_INSIDE     0
 #define NS_STYLE_LIST_STYLE_POSITION_OUTSIDE    1
 
 // See nsStyleMargin
 #define NS_STYLE_MARGIN_SIZE_AUTO               0