style: Avoid dropping a parse error on the floor when checking whether a prop is enabled.

This commit is contained in:
Emilio Cobos Álvarez 2017-08-28 21:03:34 +02:00
parent 3b11145ef7
commit 8a0a690384
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -1073,7 +1073,7 @@ impl PropertyId {
}, },
None => return Err(()), None => return Err(()),
}; };
id.check_allowed_in(alias, context).map_err(|_| ())?; id.check_allowed_in(alias, context)?;
Ok(id) Ok(id)
} }
@ -1156,8 +1156,11 @@ impl PropertyId {
} }
} }
fn check_allowed_in(&self, alias: Option<AliasId>, context: &PropertyParserContext) fn check_allowed_in(
-> Result<(), PropertyDeclarationParseError<'static>> { &self,
alias: Option<AliasId>,
context: &PropertyParserContext,
) -> Result<(), ()> {
let id: NonCustomPropertyId; let id: NonCustomPropertyId;
if let Some(alias_id) = alias { if let Some(alias_id) = alias {
id = alias_id.into(); id = alias_id.into();
@ -1177,10 +1180,10 @@ impl PropertyId {
${id_set("DISALLOWED_IN_PAGE_RULE", lambda p: not p.allowed_in_page_rule)} ${id_set("DISALLOWED_IN_PAGE_RULE", lambda p: not p.allowed_in_page_rule)}
match context.rule_type { match context.rule_type {
CssRuleType::Keyframe if DISALLOWED_IN_KEYFRAME_BLOCK.contains(id) => { CssRuleType::Keyframe if DISALLOWED_IN_KEYFRAME_BLOCK.contains(id) => {
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock) return Err(());
} }
CssRuleType::Page if DISALLOWED_IN_PAGE_RULE.contains(id) => { CssRuleType::Page if DISALLOWED_IN_PAGE_RULE.contains(id) => {
return Err(PropertyDeclarationParseError::NotAllowedInPageRule) return Err(())
} }
_ => {} _ => {}
} }
@ -1245,15 +1248,15 @@ impl PropertyId {
if context.stylesheet_origin != Origin::UserAgent { if context.stylesheet_origin != Origin::UserAgent {
if EXPERIMENTAL.contains(id) { if EXPERIMENTAL.contains(id) {
if !passes_pref_check() { if !passes_pref_check() {
return Err(PropertyDeclarationParseError::ExperimentalProperty); return Err(())
} }
} else { } else {
return Err(PropertyDeclarationParseError::UnknownProperty(self.name().into())); return Err(())
} }
} }
} else { } else {
if EXPERIMENTAL.contains(id) && !passes_pref_check() { if EXPERIMENTAL.contains(id) && !passes_pref_check() {
return Err(PropertyDeclarationParseError::ExperimentalProperty); return Err(());
} }
} }