mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
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:
parent
8b9dc9392b
commit
09d4751054
11 changed files with 164 additions and 26 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue