mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Derive ToCss for ContentItem
This commit is contained in:
parent
a4d3a8d74a
commit
91ed0b0aa5
2 changed files with 4 additions and 39 deletions
|
@ -9,8 +9,7 @@ use computed_values::list_style_type::T as ListStyleType;
|
|||
use cssparser::{Parser, Token};
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
use values::CustomIdent;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::generics::CounterStyleOrNone;
|
||||
|
@ -148,39 +147,3 @@ impl Parse for Content {
|
|||
Ok(Content::Items(content.into_boxed_slice()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for ContentItem {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where W: Write,
|
||||
{
|
||||
match *self {
|
||||
ContentItem::String(ref s) => s.to_css(dest),
|
||||
ContentItem::Counter(ref s, ref counter_style) => {
|
||||
dest.write_str("counter(")?;
|
||||
s.to_css(dest)?;
|
||||
dest.write_str(", ")?;
|
||||
counter_style.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
}
|
||||
ContentItem::Counters(ref s, ref separator, ref counter_style) => {
|
||||
dest.write_str("counters(")?;
|
||||
s.to_css(dest)?;
|
||||
dest.write_str(", ")?;
|
||||
separator.to_css(dest)?;
|
||||
dest.write_str(", ")?;
|
||||
counter_style.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
}
|
||||
ContentItem::OpenQuote => dest.write_str("open-quote"),
|
||||
ContentItem::CloseQuote => dest.write_str("close-quote"),
|
||||
ContentItem::NoOpenQuote => dest.write_str("no-open-quote"),
|
||||
ContentItem::NoCloseQuote => dest.write_str("no-close-quote"),
|
||||
#[cfg(feature = "gecko")]
|
||||
ContentItem::Attr(ref attr) => {
|
||||
attr.to_css(dest)
|
||||
}
|
||||
#[cfg(feature = "gecko")]
|
||||
ContentItem::Url(ref url) => url.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,13 +97,15 @@ pub enum Content {
|
|||
}
|
||||
|
||||
/// Items for the `content` property.
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[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),
|
||||
/// `counters(name, separator, style)`.
|
||||
#[css(comma, function)]
|
||||
Counters(CustomIdent, Box<str>, CounterStyleType),
|
||||
/// `open-quote`.
|
||||
OpenQuote,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue