Refactor outline-style to accept "auto" value in addition to border-style values.

Fixes https://github.com/servo/servo/issues/15207
This commit is contained in:
Alberto Leal 2017-02-02 01:57:20 -05:00
parent 8b9dc9392b
commit 09d4751054
11 changed files with 164 additions and 26 deletions

View file

@ -16,17 +16,46 @@ ${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::Curr
<%helpers:longhand name="outline-style" need_clone="True" animatable="False"
spec="https://drafts.csswg.org/css-ui/#propdef-outline-style">
pub use values::specified::BorderStyle as SpecifiedValue;
pub fn get_initial_value() -> SpecifiedValue { SpecifiedValue::none }
pub mod computed_value {
pub use values::specified::BorderStyle as T;
}
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
match SpecifiedValue::parse(input) {
Ok(SpecifiedValue::hidden) => Err(()),
result => result
use std::fmt;
use style_traits::ToCss;
use values::specified::BorderStyle;
use values::NoViewportPercentage;
use values::computed::ComputedValueAsSpecified;
pub type SpecifiedValue = Either<Auto, BorderStyle>;
impl SpecifiedValue {
#[inline]
pub fn none_or_hidden(&self) -> bool {
match *self {
Either::First(ref _auto) => false,
Either::Second(ref border_style) => border_style.none_or_hidden()
}
}
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
Either::Second(BorderStyle::none)
}
pub mod computed_value {
pub type T = super::SpecifiedValue;
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
SpecifiedValue::parse(context, input)
.and_then(|result| {
if let Either::Second(BorderStyle::hidden) = result {
// The outline-style property accepts the same values as border-style,
// except that 'hidden' is not a legal outline style.
Err(())
} else {
Ok(result)
}
})
}
</%helpers:longhand>
<%helpers:longhand name="outline-width" animatable="True"