From ad7adee882694151a9e99a1492848e0cf3b7d725 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 2 Mar 2018 21:02:03 +0100 Subject: [PATCH] Use CustomIdent in Symbol::Ident The former code was not following the spec. --- components/style/counter_style/mod.rs | 14 +++++++---- components/style/gecko/rules.rs | 2 +- tests/wpt/metadata/MANIFEST.json | 25 +++++++++++++++++++ .../css-counter-styles/broken-symbols-ref.htm | 3 +++ .../css/css-counter-styles/broken-symbols.htm | 13 ++++++++++ 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols-ref.htm create mode 100644 tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols.htm diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs index 65f570ffa9d..570ef06ab1b 100644 --- a/components/style/counter_style/mod.rs +++ b/components/style/counter_style/mod.rs @@ -8,7 +8,7 @@ use Atom; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser}; -use cssparser::{Parser, Token, serialize_identifier, CowRcStr}; +use cssparser::{Parser, Token, CowRcStr}; use error_reporting::{ContextualParseError, ParseErrorReporter}; #[cfg(feature = "gecko")] use gecko::rules::CounterStyleDescriptors; #[cfg(feature = "gecko")] use gecko_bindings::structs::{ nsCSSCounterDesc, nsCSSValue }; @@ -395,8 +395,8 @@ impl ToCss for System { pub enum Symbol { /// String(String), - /// - Ident(String), + /// + Ident(CustomIdent), // Not implemented: // /// // Image(Image), @@ -407,7 +407,11 @@ impl Parse for Symbol { let location = input.current_source_location(); match *input.next()? { Token::QuotedString(ref s) => Ok(Symbol::String(s.as_ref().to_owned())), - Token::Ident(ref s) => Ok(Symbol::Ident(s.as_ref().to_owned())), + Token::Ident(ref s) => { + Ok(Symbol::Ident( + CustomIdent::from_ident(location, s, &[])?, + )) + } ref t => Err(location.new_unexpected_token_error(t.clone())), } } @@ -420,7 +424,7 @@ impl ToCss for Symbol { { match *self { Symbol::String(ref s) => s.to_css(dest), - Symbol::Ident(ref s) => serialize_identifier(s, dest), + Symbol::Ident(ref s) => s.to_css(dest), } } } diff --git a/components/style/gecko/rules.rs b/components/style/gecko/rules.rs index ce448cddfd7..f231f2a7dfe 100644 --- a/components/style/gecko/rules.rs +++ b/components/style/gecko/rules.rs @@ -313,7 +313,7 @@ impl ToNsCssValue for counter_style::Symbol { fn convert(self, nscssvalue: &mut nsCSSValue) { match self { counter_style::Symbol::String(s) => nscssvalue.set_string(&s), - counter_style::Symbol::Ident(s) => nscssvalue.set_ident(&s), + counter_style::Symbol::Ident(s) => nscssvalue.set_ident_from_atom(&s.0), } } } diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index f28b9134840..77e7a64addc 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -106113,6 +106113,18 @@ {} ] ], + "css/css-counter-styles/broken-symbols.htm": [ + [ + "/css/css-counter-styles/broken-symbols.htm", + [ + [ + "/css/css-counter-styles/broken-symbols-ref.htm", + "==" + ] + ], + {} + ] + ], "css/css-display/display-contents-alignment-001.html": [ [ "/css/css-display/display-contents-alignment-001.html", @@ -237304,6 +237316,11 @@ {} ] ], + "css/css-counter-styles/broken-symbols-ref.htm": [ + [ + {} + ] + ], "css/css-display/OWNERS": [ [ {} @@ -484992,6 +485009,14 @@ "dbfaae0538c8cd1e759b59712f53cd17388e7c48", "manual" ], + "css/css-counter-styles/broken-symbols-ref.htm": [ + "c794c4b6846212f4ed27e618cdd32a28b8ce013c", + "support" + ], + "css/css-counter-styles/broken-symbols.htm": [ + "23cb132e8efcdd1020e12c89c9d30a333708b72e", + "reftest" + ], "css/css-counter-styles/cambodian/css3-counter-styles-158.html": [ "a334bd087e7a808567daeeae419a80466a377ef3", "manual" diff --git a/tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols-ref.htm b/tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols-ref.htm new file mode 100644 index 00000000000..0247f65d3e0 --- /dev/null +++ b/tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols-ref.htm @@ -0,0 +1,3 @@ + + +
  1. Should have "1." as bullet point.
diff --git a/tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols.htm b/tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols.htm new file mode 100644 index 00000000000..d449161b1d4 --- /dev/null +++ b/tests/wpt/web-platform-tests/css/css-counter-styles/broken-symbols.htm @@ -0,0 +1,13 @@ + + +CSS Test: invalid counter-style symbols + + + + +
  1. Should have "1." as bullet point.