1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use cssparser::Parser;
use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind;
use style_traits::ParseError;
use values::specified::BorderStyle;
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Ord)]
#[derive(PartialEq, PartialOrd, ToComputedValue, ToCss)]
pub enum OutlineStyle {
Auto,
Other(BorderStyle),
}
impl OutlineStyle {
#[inline]
pub fn none() -> OutlineStyle {
OutlineStyle::Other(BorderStyle::None)
}
#[inline]
pub fn none_or_hidden(&self) -> bool {
match *self {
OutlineStyle::Auto => false,
OutlineStyle::Other(ref border_style) => border_style.none_or_hidden()
}
}
}
impl Parse for OutlineStyle {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<OutlineStyle, ParseError<'i>> {
if let Ok(border_style) = input.try(|i| BorderStyle::parse(context, i)) {
if let BorderStyle::Hidden = border_style {
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())));
}
return Ok(OutlineStyle::Other(border_style));
}
input.expect_ident_matching("auto")?;
Ok(OutlineStyle::Auto)
}
}