style: :dir() pseudo class now represented by enum

Fixes #19195
This commit is contained in:
Michael Wilson 2017-11-10 00:00:48 -08:00
parent e6b05fa204
commit 10f3ef42bb
7 changed files with 73 additions and 27 deletions

View file

@ -8,8 +8,8 @@
use cssparser::{Parser as CssParser, ParserInput};
use selectors::parser::SelectorList;
use std::fmt::{self, Debug};
use style_traits::ParseError;
use std::fmt::{self, Debug, Write};
use style_traits::{ParseError, ToCss};
use stylesheets::{Origin, Namespaces, UrlExtraData};
/// A convenient alias for the type that represents an attribute value used for
@ -173,3 +173,25 @@ impl<T> PerPseudoElementMap<T> {
self.entries.iter()
}
}
/// Values for the :dir() pseudo class
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Direction {
/// left-to-right semantic directionality
Ltr,
/// right-to-left semantic directionality
Rtl,
/// Some other provided directionality value
Other(Box<str>),
}
impl ToCss for Direction {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: Write {
let dir_str = match *self {
Direction::Rtl => "rtl",
Direction::Ltr => "ltr",
Direction::Other(ref other) => other,
};
dest.write_str(dir_str)
}
}