diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 35c5a5c454d..8fc0900aece 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -69,7 +69,7 @@ impl ToCss for NonTSPseudoClass { $(NonTSPseudoClass::$name => concat!(":", $css),)* NonTSPseudoClass::Lang(ref s) => { dest.write_str(":lang(")?; - s.to_css(dest)?; + cssparser::ToCss::to_css(s, dest)?; return dest.write_char(')'); }, NonTSPseudoClass::MozLocaleDir(ref dir) => { diff --git a/components/style/stylesheets/layer_rule.rs b/components/style/stylesheets/layer_rule.rs index 3607e9f2ebf..ebff5bb9add 100644 --- a/components/style/stylesheets/layer_rule.rs +++ b/components/style/stylesheets/layer_rule.rs @@ -13,7 +13,7 @@ use crate::values::AtomIdent; use super::CssRules; -use cssparser::{Parser, SourceLocation, ToCss as CssParserToCss, Token}; +use cssparser::{Parser, SourceLocation, Token}; use servo_arc::Arc; use smallvec::SmallVec; use std::fmt::{self, Write}; diff --git a/components/style/stylesheets/namespace_rule.rs b/components/style/stylesheets/namespace_rule.rs index d76703e4f81..c0d017ab78f 100644 --- a/components/style/stylesheets/namespace_rule.rs +++ b/components/style/stylesheets/namespace_rule.rs @@ -7,7 +7,7 @@ use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use crate::str::CssStringWriter; use crate::{Namespace, Prefix}; -use cssparser::{self, SourceLocation}; +use cssparser::SourceLocation; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; @@ -25,15 +25,15 @@ pub struct NamespaceRule { impl ToCssWithGuard for NamespaceRule { // https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSNamespaceRule - fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result { + fn to_css(&self, _guard: &SharedRwLockReadGuard, dest_str: &mut CssStringWriter) -> fmt::Result { + let mut dest = CssWriter::new(dest_str); dest.write_str("@namespace ")?; if let Some(ref prefix) = self.prefix { - let prefix = prefix.to_string(); - cssparser::serialize_identifier(&prefix, dest)?; - dest.write_str(" ")?; + prefix.to_css(&mut dest)?; + dest.write_char(' ')?; } dest.write_str("url(")?; - self.url.to_string().to_css(&mut CssWriter::new(dest))?; + self.url.to_string().to_css(&mut dest)?; dest.write_str(");") } } diff --git a/components/style/stylesheets/page_rule.rs b/components/style/stylesheets/page_rule.rs index 7bf62f5c9e7..ee156cf989e 100644 --- a/components/style/stylesheets/page_rule.rs +++ b/components/style/stylesheets/page_rule.rs @@ -13,7 +13,7 @@ use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use crate::str::CssStringWriter; use crate::values::{AtomIdent, CustomIdent}; use style_traits::{CssWriter, ParseError, ToCss}; -use cssparser::{ToCss as CssParserToCss, Parser, SourceLocation}; +use cssparser::{Parser, SourceLocation}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; use servo_arc::Arc; @@ -23,7 +23,7 @@ use std::fmt::{self, Write}; /// /// We do not support pseudo selectors yet. /// [page-selectors]: https://drafts.csswg.org/css2/page.html#page-selectors -#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToShmem)] +#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)] pub struct PageSelector(pub AtomIdent); impl PageSelector { @@ -46,15 +46,6 @@ impl Parse for PageSelector { } } -impl ToCss for PageSelector { - fn to_css(&self, dest: &mut CssWriter) -> fmt::Result - where - W: Write - { - (&self.0).to_css(dest) - } -} - /// A list of [`@page`][page selectors] /// /// [page-selectors]: https://drafts.csswg.org/css2/page.html#page-selectors diff --git a/components/style/stylesheets/scroll_timeline_rule.rs b/components/style/stylesheets/scroll_timeline_rule.rs index 589814eff20..12b0d2013a6 100644 --- a/components/style/stylesheets/scroll_timeline_rule.rs +++ b/components/style/stylesheets/scroll_timeline_rule.rs @@ -324,7 +324,6 @@ impl ToCss for ScrollTimelineSelector { where W: Write, { - use crate::cssparser::ToCss as CssparserToCss; dest.write_str("selector(")?; dest.write_char('#')?; self.0.to_css(dest)?; diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index ad09320c42b..050efaa8e3e 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -293,6 +293,16 @@ impl cssparser::ToCss for AtomIdent { } } +#[cfg(feature = "gecko")] +impl style_traits::ToCss for AtomIdent { + fn to_css(&self, dest: &mut CssWriter) -> fmt::Result + where + W: Write, + { + cssparser::ToCss::to_css(self, dest) + } +} + #[cfg(feature = "gecko")] impl PrecomputedHash for AtomIdent { #[inline]