Have shorthand parsing functions return values

Shorthands are responsible to set all its longhands to a proper value,
rather than returning None.

Fixes #15380.
This commit is contained in:
Xidorn Quan 2017-02-28 15:21:17 +11:00
parent 2e07ce7e84
commit f33b0b4ea3
18 changed files with 240 additions and 259 deletions

View file

@ -88,6 +88,12 @@ pub mod longhands {
<%include file="/longhand/xul.mako.rs" />
}
macro_rules! unwrap_or_initial {
($prop: ident) => (unwrap_or_initial!($prop, $prop));
($prop: ident, $expr: expr) =>
($expr.unwrap_or_else(|| $prop::get_initial_specified_value()));
}
/// A module with code for all the shorthand css properties, and a few
/// serialization helpers.
#[allow(missing_docs)]
@ -343,13 +349,12 @@ impl PropertyDeclarationIdSet {
% if property in shorthand.sub_properties:
Some(ShorthandId::${shorthand.camel_case}) => {
shorthands::${shorthand.ident}::parse_value(&context, input)
.map(|result| match result.${property.ident} {
.map(|result| {
% if property.boxed:
Some(value) => DeclaredValue::Value(Box::new(value)),
DeclaredValue::Value(Box::new(result.${property.ident}))
% else:
Some(value) => DeclaredValue::Value(value),
DeclaredValue::Value(result.${property.ident})
% endif
None => DeclaredValue::Initial,
})
}
% endif