style: Make the fixed generic family a parse-time alias to monospace.

As discussed on IRC, fixed is only used for prefs right now, and:

 * We already copy the fixed size to the monospace font.
 * We already serialize the fixed family as "monospace" in the style system.

So it already works somewhat inconsistently. Making it an alias makes it
work consistently.

Differential Revision: https://phabricator.services.mozilla.com/D24288
This commit is contained in:
Emilio Cobos Álvarez 2019-04-01 21:48:08 +00:00
parent 2184e3f2e5
commit 0406be7b68

View file

@ -303,39 +303,16 @@ pub enum GenericFontFamily {
None,
Serif,
SansSerif,
#[parse(aliases = "-moz-fixed")]
Monospace,
Cursive,
Fantasy,
/// This is basically monospace, but with different font prefs. We should
/// consider removing it in favor of just using the monospace.* prefs, since
/// in practice we don't override the monospace prefs at all.
#[cfg(feature = "gecko")]
MozFixed,
/// An internal value for emoji font selection.
#[css(skip)]
#[cfg(feature = "gecko")]
MozEmoji,
}
// TODO(emilio): Derive this when we make -moz-fixed a parse alias of Monospace.
impl ToCss for GenericFontFamily {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: fmt::Write,
{
dest.write_str(match *self {
GenericFontFamily::MozEmoji |
GenericFontFamily::Default => return Ok(()),
GenericFontFamily::MozFixed |
GenericFontFamily::Monospace => "monospace",
GenericFontFamily::Serif => "serif",
GenericFontFamily::SansSerif => "sans-serif",
GenericFontFamily::Cursive => "cursive",
GenericFontFamily::Fantasy => "fantasy",
})
}
}
impl SingleFontFamily {
/// Parse a font-family value.
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {