servo: Merge #20224 - Fix counter() and counters() serialization (from emilio:counter-serialization); r=nox
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 14 Mar 2018 13:26:00 -0400
changeset 408164 e8d02073ed5acfe50ee9568ede049ffa96941096
parent 408163 92200efbd20cb186504b1b371e4a2e860c936a39
child 408165 eb12946f24c7f33fbeb139595256ee7ce423c1f3
push id61140
push userservo-vcs-sync@mozilla.com
push dateWed, 14 Mar 2018 19:43:58 +0000
treeherderautoland@e8d02073ed5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
milestone61.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
servo: Merge #20224 - Fix counter() and counters() serialization (from emilio:counter-serialization); r=nox See https://github.com/w3c/csswg-drafts/issues/670 and https://github.com/w3c/web-platform-tests/pull/9862. Source-Repo: https://github.com/servo/servo Source-Revision: 7b326529db64ac27f0b956880b3b63dd12cd0c1a
servo/components/style/values/specified/counters.rs
--- a/servo/components/style/values/specified/counters.rs
+++ b/servo/components/style/values/specified/counters.rs
@@ -71,19 +71,32 @@ fn parse_counters<'i, 't>(
         Ok(counters)
     } else {
         Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
     }
 }
 
 #[cfg(feature = "servo")]
 type CounterStyleType = ListStyleType;
+
 #[cfg(feature = "gecko")]
 type CounterStyleType = CounterStyleOrNone;
 
+#[cfg(feature = "servo")]
+#[inline]
+fn is_decimal(counter_type: &CounterStyleType) -> bool {
+    *counter_type == ListStyleType::Decimal
+}
+
+#[cfg(feature = "gecko")]
+#[inline]
+fn is_decimal(counter_type: &CounterStyleType) -> bool {
+    *counter_type == CounterStyleOrNone::decimal()
+}
+
 /// The specified value for the `content` property.
 ///
 /// https://drafts.csswg.org/css-content/#propdef-content
 #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
 pub enum Content {
     /// `normal` reserved keyword.
     Normal,
     /// `none` reserved keyword.
@@ -97,20 +110,20 @@ pub enum Content {
 
 /// Items for the `content` property.
 #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
 pub enum ContentItem {
     /// Literal string content.
     String(Box<str>),
     /// `counter(name, style)`.
     #[css(comma, function)]
-    Counter(CustomIdent, CounterStyleType),
+    Counter(CustomIdent, #[css(skip_if = "is_decimal")] CounterStyleType),
     /// `counters(name, separator, style)`.
     #[css(comma, function)]
-    Counters(CustomIdent, Box<str>, CounterStyleType),
+    Counters(CustomIdent, Box<str>, #[css(skip_if = "is_decimal")] CounterStyleType),
     /// `open-quote`.
     OpenQuote,
     /// `close-quote`.
     CloseQuote,
     /// `no-open-quote`.
     NoOpenQuote,
     /// `no-close-quote`.
     NoCloseQuote,