use crate::parser::{Parse, ParserContext};
use crate::values::specified::BorderStyle;
use cssparser::Parser;
use selectors::parser::SelectorParseErrorKind;
use style_traits::ParseError;
#[derive(
Clone,
Copy,
Debug,
Eq,
MallocSizeOf,
Ord,
PartialEq,
PartialOrd,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C, u8)]
pub enum OutlineStyle {
Auto,
BorderStyle(BorderStyle),
}
impl OutlineStyle {
#[inline]
pub fn none() -> OutlineStyle {
OutlineStyle::BorderStyle(BorderStyle::None)
}
#[inline]
pub fn none_or_hidden(&self) -> bool {
match *self {
OutlineStyle::Auto => false,
OutlineStyle::BorderStyle(ref style) => 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_parse(BorderStyle::parse) {
if let BorderStyle::Hidden = border_style {
return Err(input
.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())));
}
return Ok(OutlineStyle::BorderStyle(border_style));
}
input.expect_ident_matching("auto")?;
Ok(OutlineStyle::Auto)
}
}