Bug 1144607 part 2 - Support string value for list-style-tyle. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Fri, 27 Mar 2015 09:48:10 +1100
changeset 264904 0a3c37c82aa08274d413a74c3ef1fef8755ed28c
parent 264903 00b852893926f535c39c2cedf68845099fc9e77e
child 264905 3b8e79ee4339ea97889ddb1fbd7d86f73d8d696a
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1144607
milestone39.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 1144607 part 2 - Support string value for list-style-tyle. r=dbaron
layout/style/CounterStyleManager.cpp
layout/style/CounterStyleManager.h
layout/style/nsCSSParser.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/style/test/property_database.js
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1691,37 +1691,51 @@ CustomCounterStyle::GetExtendsRoot()
         // is shared by multiple counter styles.
         mExtendsRoot = custom->GetExtendsRoot();
       }
     }
   }
   return mExtendsRoot;
 }
 
+AnonymousCounterStyle::AnonymousCounterStyle(const nsSubstring& aContent)
+  : CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM)
+  , mSingleString(true)
+  , mSystem(NS_STYLE_COUNTER_SYSTEM_CYCLIC)
+{
+  mSymbols.SetCapacity(1);
+  mSymbols.AppendElement(aContent);
+}
+
 AnonymousCounterStyle::AnonymousCounterStyle(const nsCSSValue::Array* aParams)
   : CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM)
+  , mSingleString(false)
+  , mSystem(aParams->Item(0).GetIntValue())
 {
-  mSystem = aParams->Item(0).GetIntValue();
   for (const nsCSSValueList* item = aParams->Item(1).GetListValue();
        item; item = item->mNext) {
     item->mValue.GetStringValue(*mSymbols.AppendElement());
   }
   mSymbols.Compact();
 }
 
 /* virtual */ void
 AnonymousCounterStyle::GetPrefix(nsAString& aResult)
 {
   aResult.Truncate();
 }
 
 /* virtual */ void
 AnonymousCounterStyle::GetSuffix(nsAString& aResult)
 {
-  aResult = ' ';
+  if (IsSingleString()) {
+    aResult.Truncate();
+  } else {
+    aResult = ' ';
+  }
 }
 
 /* virtual */ bool
 AnonymousCounterStyle::IsBullet()
 {
   switch (mSystem) {
     case NS_STYLE_COUNTER_SYSTEM_CYCLIC:
       // Only use ::-moz-list-bullet for cyclic system
--- a/layout/style/CounterStyleManager.h
+++ b/layout/style/CounterStyleManager.h
@@ -101,16 +101,17 @@ public:
 
 protected:
   int32_t mStyle;
 };
 
 class AnonymousCounterStyle final : public CounterStyle
 {
 public:
+  explicit AnonymousCounterStyle(const nsSubstring& aContent);
   explicit AnonymousCounterStyle(const nsCSSValue::Array* aValue);
 
   virtual void GetPrefix(nsAString& aResult) override;
   virtual void GetSuffix(nsAString& aResult) override;
   virtual bool IsBullet() override;
 
   virtual void GetNegative(NegativeType& aResult) override;
   virtual bool IsOrdinalInRange(CounterValue aOrdinal) override;
@@ -122,24 +123,26 @@ public:
 
   virtual bool GetInitialCounterText(CounterValue aOrdinal,
                                      WritingMode aWritingMode,
                                      nsSubstring& aResult,
                                      bool& aIsRTL) override;
 
   virtual AnonymousCounterStyle* AsAnonymous() override { return this; }
 
+  bool IsSingleString() const { return mSingleString; }
   uint8_t GetSystem() const { return mSystem; }
   const nsTArray<nsString>& GetSymbols() const { return mSymbols; }
 
   NS_INLINE_DECL_REFCOUNTING(AnonymousCounterStyle, override)
 
 private:
   ~AnonymousCounterStyle() {}
 
+  bool mSingleString;
   uint8_t mSystem;
   nsTArray<nsString> mSymbols;
 };
 
 class CounterStyleManager final
 {
 private:
   ~CounterStyleManager();
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -13046,17 +13046,17 @@ CSSParserImpl::ParseListStyle()
     AppendValue(listStyleIDs[index], values[index]);
   }
   return true;
 }
 
 bool
 CSSParserImpl::ParseListStyleType(nsCSSValue& aValue)
 {
-  if (ParseVariant(aValue, VARIANT_INHERIT, nullptr)) {
+  if (ParseVariant(aValue, VARIANT_INHERIT | VARIANT_STRING, nullptr)) {
     return true;
   }
 
   if (ParseCounterStyleNameValue(aValue) || ParseSymbols(aValue)) {
     return true;
   }
 
   return false;
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -3092,25 +3092,27 @@ nsComputedDOMStyle::DoGetListStylePositi
 }
 
 CSSValue*
 nsComputedDOMStyle::DoGetListStyleType()
 {
   nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
   CounterStyle* style = StyleList()->GetCounterStyle();
   AnonymousCounterStyle* anonymous = style->AsAnonymous();
+  nsString tmp;
   if (!anonymous) {
     // want SetIdent
     nsString type;
     StyleList()->GetListStyleType(type);
-    nsString value;
-    nsStyleUtil::AppendEscapedCSSIdent(type, value);
-    val->SetString(value);
+    nsStyleUtil::AppendEscapedCSSIdent(type, tmp);
+  } else if (anonymous->IsSingleString()) {
+    const nsTArray<nsString>& symbols = anonymous->GetSymbols();
+    MOZ_ASSERT(symbols.Length() == 1);
+    nsStyleUtil::AppendEscapedCSSString(symbols[0], tmp);
   } else {
-    nsAutoString tmp;
     tmp.AppendLiteral("symbols(");
 
     uint8_t system = anonymous->GetSystem();
     NS_ASSERTION(system == NS_STYLE_COUNTER_SYSTEM_CYCLIC ||
                  system == NS_STYLE_COUNTER_SYSTEM_NUMERIC ||
                  system == NS_STYLE_COUNTER_SYSTEM_ALPHABETIC ||
                  system == NS_STYLE_COUNTER_SYSTEM_SYMBOLIC ||
                  system == NS_STYLE_COUNTER_SYSTEM_FIXED,
@@ -3124,18 +3126,18 @@ nsComputedDOMStyle::DoGetListStyleType()
     const nsTArray<nsString>& symbols = anonymous->GetSymbols();
     NS_ASSERTION(symbols.Length() > 0,
                  "No symbols in the anonymous counter style");
     for (size_t i = 0, iend = symbols.Length(); i < iend; i++) {
       nsStyleUtil::AppendEscapedCSSString(symbols[i], tmp);
       tmp.Append(' ');
     }
     tmp.Replace(tmp.Length() - 1, 1, char16_t(')'));
-    val->SetString(tmp);
-  }
+  }
+  val->SetString(tmp);
   return val;
 }
 
 CSSValue*
 nsComputedDOMStyle::DoGetImageRegion()
 {
   nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -7186,16 +7186,23 @@ nsRuleNode::ComputeListData(void* aStart
       list->SetListStyleType(NS_LITERAL_STRING("disc"), mPresContext);
       break;
     case eCSSUnit_Ident: {
       nsString typeIdent;
       typeValue->GetStringValue(typeIdent);
       list->SetListStyleType(typeIdent, mPresContext);
       break;
     }
+    case eCSSUnit_String: {
+      nsString str;
+      typeValue->GetStringValue(str);
+      list->SetListStyleType(NS_LITERAL_STRING(""),
+                             new AnonymousCounterStyle(str));
+      break;
+    }
     case eCSSUnit_Enumerated: {
       // For compatibility with html attribute map.
       // This branch should never be called for value from CSS.
       int32_t intValue = typeValue->GetIntValue();
       nsAutoString name;
       switch (intValue) {
         case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
           name.AssignLiteral(MOZ_UTF16("lower-roman"));
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -2755,16 +2755,17 @@ var gCSSProperties = {
   },
   "list-style": {
     domProp: "listStyle",
     inherited: true,
     type: CSS_TYPE_TRUE_SHORTHAND,
     subproperties: [ "list-style-type", "list-style-position", "list-style-image" ],
     initial_values: [ "outside", "disc", "disc outside", "outside disc", "disc none", "none disc", "none disc outside", "none outside disc", "disc none outside", "disc outside none", "outside none disc", "outside disc none" ],
     other_values: [ "inside none", "none inside", "none none inside", "square", "none", "none none", "outside none none", "none outside none", "none none outside", "none outside", "outside none", "outside outside", "outside inside", "\\32 style", "\\32 style inside",
+      '"-"', "'-'", "inside '-'", "'-' outside", "none '-'", "inside none '-'",
       "symbols(\"*\" \"\\2020\" \"\\2021\" \"\\A7\")",
       "symbols(cyclic \"*\" \"\\2020\" \"\\2021\" \"\\A7\")",
       "inside symbols(\"*\" \"\\2020\" \"\\2021\" \"\\A7\")",
       "symbols(\"*\" \"\\2020\" \"\\2021\" \"\\A7\") outside",
       "none symbols(\"*\" \"\\2020\" \"\\2021\" \"\\A7\")",
       "inside none symbols(\"*\" \"\\2020\" \"\\2021\" \"\\A7\")",
       'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==")',
       'none url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==")',
@@ -2832,16 +2833,17 @@ var gCSSProperties = {
       "-moz-oriya", "-moz-kannada", "-moz-malayalam", "-moz-bengali",
       "-moz-tamil", "-moz-telugu", "-moz-thai", "-moz-lao",
       "-moz-myanmar", "-moz-khmer",
       "-moz-hangul", "-moz-hangul-consonant",
       "-moz-ethiopic-halehame", "-moz-ethiopic-numeric",
       "-moz-ethiopic-halehame-am",
       "-moz-ethiopic-halehame-ti-er", "-moz-ethiopic-halehame-ti-et",
       "other-style", "inside", "outside", "\\32 style",
+      '"-"', "'-'",
       "symbols(\"*\" \"\\2020\" \"\\2021\" \"\\A7\")",
       "symbols(cyclic '*' '\\2020' '\\2021' '\\A7')"
     ],
     invalid_values: []
   },
   "margin": {
     domProp: "margin",
     inherited: false,