style: Move :-moz-locale-dir matching to rust.

This commit is contained in:
Emilio Cobos Álvarez 2018-01-11 12:37:29 +01:00
parent 1a4df8f876
commit b6a2bff032
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 55 additions and 66 deletions

View file

@ -183,9 +183,23 @@ pub enum Direction {
/// right-to-left semantic directionality
Rtl,
/// Some other provided directionality value
///
/// TODO(emilio): If we atomize we can then unbox in NonTSPseudoClass.
Other(Box<str>),
}
impl Direction {
/// Parse a direction value.
pub fn parse<'i, 't>(parser: &mut CssParser<'i, 't>) -> Result<Self, ParseError<'i>> {
let ident = parser.expect_ident()?;
Ok(match_ignore_ascii_case! { &ident,
"rtl" => Direction::Rtl,
"ltr" => Direction::Ltr,
_ => Direction::Other(Box::from(ident.as_ref())),
})
}
}
impl ToCss for Direction {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: Write {
let dir_str = match *self {