aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/selector_parser.rs
diff options
context:
space:
mode:
authorMichael Wilson <wilsoniya@gmail.com>2017-11-10 00:00:48 -0800
committerMichael Wilson <wilsoniya@gmail.com>2017-11-15 18:12:44 -0800
commit10f3ef42bba3e0123badf3c06426488128ae9f14 (patch)
tree10048218297b603f681f15dfdae0f42c1794245a /components/style/selector_parser.rs
parente6b05fa204758a26fa15cd73aa9b23cab0e9d944 (diff)
downloadservo-10f3ef42bba3e0123badf3c06426488128ae9f14.tar.gz
servo-10f3ef42bba3e0123badf3c06426488128ae9f14.zip
style: :dir() pseudo class now represented by enum
Fixes #19195
Diffstat (limited to 'components/style/selector_parser.rs')
-rw-r--r--components/style/selector_parser.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs
index 62d88f2bf3b..d2f86092c8a 100644
--- a/components/style/selector_parser.rs
+++ b/components/style/selector_parser.rs
@@ -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)
+ }
+}