mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
style: Move outline-style outside of mako
This commit is contained in:
parent
0fa605d243
commit
b9b91b33be
8 changed files with 87 additions and 56 deletions
|
@ -61,6 +61,7 @@ use values::{self, Auto, CustomIdent, Either, KeyframesName, None_};
|
|||
use values::computed::{NonNegativeLength, ToComputedValue, Percentage};
|
||||
use values::computed::font::{FontSize, SingleFontFamily};
|
||||
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
use values::computed::outline::OutlineStyle;
|
||||
use computed_values::border_style;
|
||||
|
||||
pub mod style_structs {
|
||||
|
@ -2348,10 +2349,10 @@ fn static_assert() {
|
|||
// cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in border_style_keyword.values_for('gecko'):
|
||||
Either::Second(border_style::T::${to_camel_case(value)}) =>
|
||||
OutlineStyle::Other(border_style::T::${to_camel_case(value)}) =>
|
||||
structs::${border_style_keyword.gecko_constant(value)} ${border_style_keyword.maybe_cast("u8")},
|
||||
% endfor
|
||||
Either::First(Auto) =>
|
||||
OutlineStyle::Auto =>
|
||||
structs::${border_style_keyword.gecko_constant('auto')} ${border_style_keyword.maybe_cast("u8")},
|
||||
};
|
||||
${set_gecko_property("mOutlineStyle", "result")}
|
||||
|
@ -2378,10 +2379,10 @@ fn static_assert() {
|
|||
match ${get_gecko_property("mOutlineStyle")} ${border_style_keyword.maybe_cast("u32")} {
|
||||
% for value in border_style_keyword.values_for('gecko'):
|
||||
structs::${border_style_keyword.gecko_constant(value)} => {
|
||||
Either::Second(border_style::T::${to_camel_case(value)})
|
||||
OutlineStyle::Other(border_style::T::${to_camel_case(value)})
|
||||
},
|
||||
% endfor
|
||||
structs::${border_style_keyword.gecko_constant('auto')} => Either::First(Auto),
|
||||
structs::${border_style_keyword.gecko_constant('auto')} => OutlineStyle::Auto,
|
||||
% if border_style_keyword.gecko_inexhaustive:
|
||||
x => panic!("Found unexpected value in style struct for outline_style property: {:?}", x),
|
||||
% endif
|
||||
|
|
|
@ -20,51 +20,14 @@ ${helpers.predefined_type(
|
|||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-color",
|
||||
)}
|
||||
|
||||
<%helpers:longhand name="outline-style" animation_value_type="discrete"
|
||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-style">
|
||||
use values::specified::BorderStyle;
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
Either::Second(BorderStyle::None)
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
pub type T = super::SpecifiedValue;
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
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(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())))
|
||||
} else {
|
||||
Ok(result)
|
||||
}
|
||||
})
|
||||
}
|
||||
</%helpers:longhand>
|
||||
${helpers.predefined_type(
|
||||
"outline-style",
|
||||
"OutlineStyle",
|
||||
"computed::OutlineStyle::none()",
|
||||
initial_specified_value="specified::OutlineStyle::none()",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-style",
|
||||
)}
|
||||
|
||||
${helpers.predefined_type("outline-width",
|
||||
"BorderSideWidth",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue