mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Add style_traits::ToCss for AtomIdent
Differential Revision: https://phabricator.services.mozilla.com/D136290
This commit is contained in:
parent
f39ab4ffc1
commit
199f54342c
6 changed files with 20 additions and 20 deletions
|
@ -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) => {
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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(");")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<W>(&self, dest: &mut CssWriter<W>) -> 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
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -293,6 +293,16 @@ impl cssparser::ToCss for AtomIdent {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl style_traits::ToCss for AtomIdent {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
cssparser::ToCss::to_css(self, dest)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl PrecomputedHash for AtomIdent {
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue