aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2018-04-04 08:43:41 +1000
committerXidorn Quan <me@upsuper.org>2018-04-04 08:43:41 +1000
commit03326749091ce562004c52ab75150768de0afc88 (patch)
tree904c181e930d14218f0834dde5b2631ec4552a27
parentd0a9fdb92b1476bc42603b495a01bd10da18d978 (diff)
downloadservo-03326749091ce562004c52ab75150768de0afc88.tar.gz
servo-03326749091ce562004c52ab75150768de0afc88.zip
Implement the correct ToCss for UrlSource.
-rw-r--r--components/style/font_face.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/components/style/font_face.rs b/components/style/font_face.rs
index 7e4b45c2482..31ba80faddc 100644
--- a/components/style/font_face.rs
+++ b/components/style/font_face.rs
@@ -24,6 +24,7 @@ use std::fmt::{self, Write};
use str::CssStringWriter;
use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError};
use style_traits::{StyleParseErrorKind, ToCss};
+use style_traits::values::SequenceWriter;
use values::computed::font::FamilyName;
#[cfg(feature = "gecko")]
use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings};
@@ -49,15 +50,31 @@ impl OneOrMoreSeparated for Source {
///
/// <https://drafts.csswg.org/css-fonts/#src-desc>
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-#[derive(Clone, Debug, Eq, PartialEq, ToCss)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UrlSource {
/// The specified url.
pub url: SpecifiedUrl,
/// The format hints specified with the `format()` function.
- #[css(skip)]
pub format_hints: Vec<String>,
}
+impl ToCss for UrlSource {
+ fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
+ self.url.to_css(dest)?;
+ if !self.format_hints.is_empty() {
+ dest.write_str(" format(")?;
+ {
+ let mut writer = SequenceWriter::new(dest, ", ");
+ for hint in self.format_hints.iter() {
+ writer.item(hint)?;
+ }
+ }
+ dest.write_char(')')?;
+ }
+ Ok(())
+ }
+}
+
/// A font-display value for a @font-face rule.
/// The font-display descriptor determines how a font face is displayed based
/// on whether and when it is downloaded and ready to use.