mirror of
https://github.com/servo/servo.git
synced 2025-06-25 17:44:33 +01:00
style: Allow CSS wide-keywords in custom property fallback.
Differential Revision: https://phabricator.services.mozilla.com/D28349
This commit is contained in:
parent
e5b5cd78a9
commit
07c0c1e53f
1 changed files with 77 additions and 59 deletions
|
@ -1085,6 +1085,8 @@ impl LonghandId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(emilio): Should we use a function table like CASCADE_PROPERTY does
|
||||||
|
// to avoid blowing up code-size here?
|
||||||
fn parse_value<'i, 't>(
|
fn parse_value<'i, 't>(
|
||||||
&self,
|
&self,
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
|
@ -1532,12 +1534,28 @@ impl UnparsedValue {
|
||||||
quirks_mode: QuirksMode,
|
quirks_mode: QuirksMode,
|
||||||
environment: &::custom_properties::CssEnvironment,
|
environment: &::custom_properties::CssEnvironment,
|
||||||
) -> PropertyDeclaration {
|
) -> PropertyDeclaration {
|
||||||
crate::custom_properties::substitute(
|
let invalid_at_computed_value_time = || {
|
||||||
|
let keyword = if longhand_id.inherited() {
|
||||||
|
CSSWideKeyword::Inherit
|
||||||
|
} else {
|
||||||
|
CSSWideKeyword::Initial
|
||||||
|
};
|
||||||
|
PropertyDeclaration::CSSWideKeyword(WideKeywordDeclaration {
|
||||||
|
id: longhand_id,
|
||||||
|
keyword,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let css = match crate::custom_properties::substitute(
|
||||||
&self.css,
|
&self.css,
|
||||||
self.first_token_type,
|
self.first_token_type,
|
||||||
custom_properties,
|
custom_properties,
|
||||||
environment,
|
environment,
|
||||||
).ok().and_then(|css| {
|
) {
|
||||||
|
Ok(css) => css,
|
||||||
|
Err(..) => return invalid_at_computed_value_time(),
|
||||||
|
};
|
||||||
|
|
||||||
// As of this writing, only the base URL is used for property
|
// As of this writing, only the base URL is used for property
|
||||||
// values.
|
// values.
|
||||||
//
|
//
|
||||||
|
@ -1559,12 +1577,21 @@ impl UnparsedValue {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut input = ParserInput::new(&css);
|
let mut input = ParserInput::new(&css);
|
||||||
Parser::new(&mut input).parse_entirely(|input| {
|
let mut input = Parser::new(&mut input);
|
||||||
|
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||||
|
if let Ok(keyword) = input.try(CSSWideKeyword::parse) {
|
||||||
|
return PropertyDeclaration::CSSWideKeyword(WideKeywordDeclaration {
|
||||||
|
id: longhand_id,
|
||||||
|
keyword,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let declaration = input.parse_entirely(|input| {
|
||||||
match self.from_shorthand {
|
match self.from_shorthand {
|
||||||
None => longhand_id.parse_value(&context, input),
|
None => longhand_id.parse_value(&context, input),
|
||||||
Some(ShorthandId::All) => {
|
Some(ShorthandId::All) => {
|
||||||
// No need to parse the 'all' shorthand as anything other than a CSS-wide
|
// No need to parse the 'all' shorthand as anything other
|
||||||
// keyword, after variable substitution.
|
// than a CSS-wide keyword, after variable substitution.
|
||||||
Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("all".into())))
|
Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("all".into())))
|
||||||
}
|
}
|
||||||
% for shorthand in data.shorthands_except_all():
|
% for shorthand in data.shorthands_except_all():
|
||||||
|
@ -1585,21 +1612,12 @@ impl UnparsedValue {
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.ok()
|
|
||||||
})
|
match declaration {
|
||||||
.unwrap_or_else(|| {
|
Ok(decl) => decl,
|
||||||
// Invalid at computed-value time.
|
Err(..) => invalid_at_computed_value_time(),
|
||||||
let keyword = if longhand_id.inherited() {
|
}
|
||||||
CSSWideKeyword::Inherit
|
|
||||||
} else {
|
|
||||||
CSSWideKeyword::Initial
|
|
||||||
};
|
|
||||||
PropertyDeclaration::CSSWideKeyword(WideKeywordDeclaration {
|
|
||||||
id: longhand_id,
|
|
||||||
keyword,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue