From ec54a400d5ea52ebc067942cb15de18af108d67a Mon Sep 17 00:00:00 2001 From: CanadaHonk Date: Sat, 23 Sep 2023 21:13:18 +0000 Subject: [PATCH] Bug 1854809 - Include quotes in AtomString CSS serialization r=emilio The serialization of `AtomString` should include quotes itself rather than users of it having to do so themselves. Differential Revision: https://phabricator.services.mozilla.com/D189050 --- servo/components/selectors/CHANGES.md | 1 + servo/components/selectors/parser.rs | 4 ---- servo/components/style/values/mod.rs | 7 +++++-- servo/components/style/values/specified/mod.rs | 4 +--- 4 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 servo/components/selectors/CHANGES.md diff --git a/servo/components/selectors/CHANGES.md b/servo/components/selectors/CHANGES.md new file mode 100644 index 000000000000..b1e9511dca30 --- /dev/null +++ b/servo/components/selectors/CHANGES.md @@ -0,0 +1 @@ +- `parser.rs` no longer wraps values in quotes (`"..."`) but expects their `to_css` impl to already wrap it ([Gecko Bug 1854809](https://bugzilla.mozilla.org/show_bug.cgi?id=1854809)) diff --git a/servo/components/selectors/parser.rs b/servo/components/selectors/parser.rs index a66649da8431..ee0fecbe772b 100644 --- a/servo/components/selectors/parser.rs +++ b/servo/components/selectors/parser.rs @@ -2291,9 +2291,7 @@ impl ToCss for Component { dest.write_char('[')?; local_name.to_css(dest)?; operator.to_css(dest)?; - dest.write_char('"')?; value.to_css(dest)?; - dest.write_char('"')?; match case_sensitivity { ParsedCaseSensitivity::CaseSensitive | ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument => {}, @@ -2397,9 +2395,7 @@ impl ToCss for AttrSelectorWithOptionalNamespace { ref value, } => { operator.to_css(dest)?; - dest.write_char('"')?; value.to_css(dest)?; - dest.write_char('"')?; match case_sensitivity { ParsedCaseSensitivity::CaseSensitive | ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument => {}, diff --git a/servo/components/style/values/mod.rs b/servo/components/style/values/mod.rs index 7f3fab9ff5f1..fa9b1f1c106b 100644 --- a/servo/components/style/values/mod.rs +++ b/servo/components/style/values/mod.rs @@ -177,15 +177,18 @@ impl cssparser::ToCss for AtomString { where W: Write, { + // Wrap in quotes to form a string literal + dest.write_char('"')?; #[cfg(feature = "servo")] { - cssparser::CssStringWriter::new(dest).write_str(self.as_ref()) + cssparser::CssStringWriter::new(dest).write_str(self.as_ref())?; } #[cfg(feature = "gecko")] { self.0 - .with_str(|s| cssparser::CssStringWriter::new(dest).write_str(s)) + .with_str(|s| cssparser::CssStringWriter::new(dest).write_str(s))?; } + dest.write_char('"') } } diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index b5e04ded53c2..8453407febea 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -966,10 +966,8 @@ impl ToCss for Attr { serialize_atom_identifier(&self.attribute, dest)?; if !self.fallback.is_empty() { - // Fallback will always be a string value for now, so always wrap in "..." - dest.write_str(", \"")?; + dest.write_str(", ")?; self.fallback.to_css(dest)?; - dest.write_char('"')?; } dest.write_char(')')