Bug 1372488 - Make counter style 'disc' not overridable. r?dbaron draft
authorXidorn Quan <me@upsuper.org>
Tue, 13 Jun 2017 16:00:37 +1000
changeset 595318 593d101a7592b298c5a3f6cd4072587690947d7b
parent 595317 957b55528d46e724cdb7e8d697ea88c372a90bec
child 633663 9fcbb75922d2f171b88b104f9b2a84edfe464149
push id64289
push userxquan@mozilla.com
push dateFri, 16 Jun 2017 06:41:33 +0000
reviewersdbaron
bugs1372488
milestone56.0a1
Bug 1372488 - Make counter style 'disc' not overridable. r?dbaron MozReview-Commit-ID: 11ZpZtRQSUF
layout/reftests/counter-style/redefine-attr-mapping-ref.html
layout/reftests/counter-style/redefine-attr-mapping.html
layout/reftests/counter-style/redefine-builtin-ref.html
layout/reftests/counter-style/redefine-builtin.html
layout/style/CounterStyleManager.cpp
layout/style/CounterStyleManager.h
layout/style/nsCSSParser.cpp
layout/style/nsStyleStruct.cpp
--- a/layout/reftests/counter-style/redefine-attr-mapping-ref.html
+++ b/layout/reftests/counter-style/redefine-attr-mapping-ref.html
@@ -10,43 +10,39 @@
   .hiragana { list-style-type: hiragana; }
   .katakana { list-style-type: katakana; }
   .hiragana-iroha { list-style-type: hiragana-iroha; }
   .katakana-iroha { list-style-type: katakana-iroha; }
 </style>
 <ul class="triangle"><li></ul>
 <ul class="triangle"><li></ul>
 <ul class="triangle"><li></ul>
-<ul class="triangle"><li></ul>
-<ul class="triangle"><li></ul>
 <ul class="hiragana"><li></ul>
 <ul class="katakana"><li></ul>
 <ul class="hiragana-iroha"><li></ul>
 <ul class="katakana-iroha"><li></ul>
 <ul class="hiragana"><li></ul>
 <ul class="katakana"><li></ul>
 <ul class="hiragana-iroha"><li></ul>
 <ul class="katakana-iroha"><li></ul>
 
 <ol><li></ol>
 <ol class="triangle"><li></ol>
 <ol class="triangle"><li></ol>
 <ol class="triangle"><li></ol>
-<ol class="triangle"><li></ol>
 <ol class="hiragana"><li></ol>
 <ol class="katakana"><li></ol>
 <ol class="hiragana-iroha"><li></ol>
 <ol class="katakana-iroha"><li></ol>
 <ol class="hiragana"><li></ol>
 <ol class="katakana"><li></ol>
 <ol class="hiragana-iroha"><li></ol>
 <ol class="katakana-iroha"><li></ol>
 
 <ul>
   <li class="triangle">
   <li class="triangle">
   <li class="triangle">
-  <li class="triangle">
   <li class="hiragana">
   <li class="katakana">
   <li class="hiragana-iroha">
   <li class="katakana-iroha">
 </ul>
--- a/layout/reftests/counter-style/redefine-attr-mapping.html
+++ b/layout/reftests/counter-style/redefine-attr-mapping.html
@@ -23,46 +23,42 @@
   }
   @counter-style lower-alpha {
     system: extends hiragana-iroha;
   }
   @counter-style upper-alpha {
     system: extends katakana-iroha;
   }
 </style>
-<ul><li></ul>
-<ul type="disc"><li></ul>
 <ul type="circle"><li></ul>
 <ul type="round"><li></ul>
 <ul type="square"><li></ul>
 <ul type="i"><li></ul>
 <ul type="I"><li></ul>
 <ul type="a"><li></ul>
 <ul type="A"><li></ul>
 <ul type="lower-roman"><li></ul>
 <ul type="upper-roman"><li></ul>
 <ul type="lower-alpha"><li></ul>
 <ul type="upper-alpha"><li></ul>
 
 <ol><li></ol>
-<ol type="disc"><li></ol>
 <ol type="circle"><li></ol>
 <ol type="round"><li></ol>
 <ol type="square"><li></ol>
 <ol type="i"><li></ol>
 <ol type="I"><li></ol>
 <ol type="a"><li></ol>
 <ol type="A"><li></ol>
 <ol type="lower-roman"><li></ol>
 <ol type="upper-roman"><li></ol>
 <ol type="lower-alpha"><li></ol>
 <ol type="upper-alpha"><li></ol>
 
 <ul>
-  <li type="disc">
   <li type="circle">
   <li type="round">
   <li type="square">
   <li type="i">
   <li type="I">
   <li type="a">
   <li type="A">
 </ul>
--- a/layout/reftests/counter-style/redefine-builtin-ref.html
+++ b/layout/reftests/counter-style/redefine-builtin-ref.html
@@ -1,7 +1,8 @@
 <!DOCTYPE html>
 <link rel="stylesheet" href="test-common.css">
 <ol>
   <li style="list-style-type: none">foo
   <li style="list-style-type: decimal">bar
+  <li style="list-style-type: disc">baz
   <li style="list-style-type: cjk-decimal">
 </ol>
--- a/layout/reftests/counter-style/redefine-builtin.html
+++ b/layout/reftests/counter-style/redefine-builtin.html
@@ -2,17 +2,21 @@
 <link rel="stylesheet" href="test-common.css">
 <style type="text/css">
   @counter-style none {
     system: extends lower-roman;
   }
   @counter-style decimal {
     system: extends upper-roman;
   }
+  @counter-style disc {
+    system: extends decimal;
+  }
   @counter-style hebrew {
     system: extends cjk-decimal;
   }
 </style>
 <ol>
   <li style="list-style-type: none">foo
   <li style="list-style-type: decimal">bar
+  <li style="list-style-type: disc">baz
   <li style="list-style-type: hebrew">
 </ol>
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1972,16 +1972,17 @@ CounterStyle::CallFallbackStyle(CounterV
 static BuiltinCounterStyle gBuiltinStyleTable[NS_STYLE_LIST_STYLE__MAX];
 
 CounterStyleManager::CounterStyleManager(nsPresContext* aPresContext)
   : mPresContext(aPresContext)
 {
   // Insert the static styles into cache table
   mStyles.Put(nsGkAtoms::none, GetNoneStyle());
   mStyles.Put(nsGkAtoms::decimal, GetDecimalStyle());
+  mStyles.Put(nsGkAtoms::disc, GetDiscStyle());
 }
 
 CounterStyleManager::~CounterStyleManager()
 {
   MOZ_ASSERT(!mPresContext, "Disconnect should have been called");
 }
 
 /* static */ void
--- a/layout/style/CounterStyleManager.h
+++ b/layout/style/CounterStyleManager.h
@@ -315,31 +315,35 @@ public:
   explicit CounterStyleManager(nsPresContext* aPresContext);
 
   static void InitializeBuiltinCounterStyles();
 
   void Disconnect();
 
   bool IsInitial() const
   {
-    // only 'none' and 'decimal'
-    return mStyles.Count() == 2;
+    // only 'none', 'decimal', and 'disc'
+    return mStyles.Count() == 3;
   }
 
   CounterStyle* BuildCounterStyle(nsIAtom* aName);
 
   static CounterStyle* GetBuiltinStyle(int32_t aStyle);
   static CounterStyle* GetNoneStyle()
   {
     return GetBuiltinStyle(NS_STYLE_LIST_STYLE_NONE);
   }
   static CounterStyle* GetDecimalStyle()
   {
     return GetBuiltinStyle(NS_STYLE_LIST_STYLE_DECIMAL);
   }
+  static CounterStyle* GetDiscStyle()
+  {
+    return GetBuiltinStyle(NS_STYLE_LIST_STYLE_DISC);
+  }
 
   // This method will scan all existing counter styles generated by this
   // manager, and remove or mark data dirty accordingly. It returns true
   // if any counter style is changed, false elsewise. This method should
   // be called when any counter style may be affected.
   bool NotifyRuleChanged();
   // NotifyRuleChanged will evict no longer needed counter styles into
   // mRetiredStyles, and this function destroys all objects listed there.
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -4933,16 +4933,17 @@ CSSParserImpl::ParseCounterStyleName(boo
   if (mToken.mType != eCSSToken_Ident) {
     UngetToken();
     return nullptr;
   }
 
   static const nsCSSKeyword kReservedNames[] = {
     eCSSKeyword_none,
     eCSSKeyword_decimal,
+    eCSSKeyword_disc,
     eCSSKeyword_UNKNOWN
   };
 
   nsCSSValue value; // we don't actually care about the value
   if (!ParseCustomIdent(value, mToken.mIdent,
                         aForDefinition ? kReservedNames : nullptr)) {
     REPORT_UNEXPECTED_TOKEN(PECounterStyleBadName);
     UngetToken();
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -597,22 +597,17 @@ nsStyleOutline::CalcDifference(const nsS
 
 // --------------------
 // nsStyleList
 //
 nsStyleList::nsStyleList(const nsPresContext* aContext)
   : mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
 {
   MOZ_COUNT_CTOR(nsStyleList);
-  if (aContext->StyleSet()->IsServo()) {
-    mCounterStyle = do_AddRef(nsGkAtoms::disc);
-  } else {
-    mCounterStyle = aContext->
-      CounterStyleManager()->BuildCounterStyle(nsGkAtoms::disc);
-  }
+  mCounterStyle = CounterStyleManager::GetDiscStyle();
   SetQuotesInitial();
 }
 
 nsStyleList::~nsStyleList()
 {
   MOZ_COUNT_DTOR(nsStyleList);
 }