mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
style: Make font-family serialization algorithm a bit more conservative.
So as to avoid serializing as identifiers font-families with spaces as part of the identifier. This avoids serializing confusing escaped sequences if the beginning of the stuff after the space happens to not be a valid ident start. This is an slightly more restrictive version of the existing logic, which happens to also match other browsers in my testing. Differential Revision: https://phabricator.services.mozilla.com/D62376
This commit is contained in:
parent
ef2d934dac
commit
5cedc45858
1 changed files with 4 additions and 1 deletions
|
@ -352,19 +352,22 @@ impl SingleFontFamily {
|
|||
};
|
||||
|
||||
let mut value = first_ident.as_ref().to_owned();
|
||||
let mut serialize_quoted = value.contains(' ');
|
||||
|
||||
// These keywords are not allowed by themselves.
|
||||
// The only way this value can be valid with with another keyword.
|
||||
if reserved {
|
||||
let ident = input.expect_ident()?;
|
||||
serialize_quoted = serialize_quoted || ident.contains(' ');
|
||||
value.push(' ');
|
||||
value.push_str(&ident);
|
||||
}
|
||||
while let Ok(ident) = input.try(|i| i.expect_ident_cloned()) {
|
||||
serialize_quoted = serialize_quoted || ident.contains(' ');
|
||||
value.push(' ');
|
||||
value.push_str(&ident);
|
||||
}
|
||||
let syntax = if value.starts_with(' ') || value.ends_with(' ') || value.contains(" ") {
|
||||
let syntax = if serialize_quoted {
|
||||
// For font family names which contains special white spaces, e.g.
|
||||
// `font-family: \ a\ \ b\ \ c\ ;`, it is tricky to serialize them
|
||||
// as identifiers correctly. Just mark them quoted so we don't need
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue