mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:07:35 +00:00
LibWeb: Allow font-family names to start with -
We achieve this by making properties that accept a custom-ident value skip the "someone else's vendor prefix" check for values that start with a `-` character. This fixes an issue where e.g `font-family: Arial, -apple-system` would be rejected by the parser completely. We now treat `-apple-system` like an identifier in such cases. Also add `valid-types` metadata for the `font-family` property so this actually works. :^)
This commit is contained in:
parent
dfdb31f5b0
commit
5955a504e0
4 changed files with 17 additions and 2 deletions
|
@ -0,0 +1 @@
|
||||||
|
serif, -apple-system
|
|
@ -0,0 +1,9 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const e = document.createElement("div");
|
||||||
|
e.style.fontFamily = 'sans-serif';
|
||||||
|
e.style.fontFamily = 'serif, -apple-system';
|
||||||
|
println(e.style.fontFamily);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -7928,6 +7928,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
m_context.set_current_property_id(property_id);
|
m_context.set_current_property_id(property_id);
|
||||||
Vector<ComponentValue> component_values;
|
Vector<ComponentValue> component_values;
|
||||||
bool contains_var_or_attr = false;
|
bool contains_var_or_attr = false;
|
||||||
|
bool const property_accepts_custom_ident = property_accepts_type(property_id, ValueType::CustomIdent);
|
||||||
|
|
||||||
while (tokens.has_next_token()) {
|
while (tokens.has_next_token()) {
|
||||||
auto const& token = tokens.next_token();
|
auto const& token = tokens.next_token();
|
||||||
|
@ -7941,7 +7942,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
if (token.is(Token::Type::Whitespace))
|
if (token.is(Token::Type::Whitespace))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (token.is(Token::Type::Ident) && has_ignored_vendor_prefix(token.token().ident()))
|
if (!property_accepts_custom_ident && token.is(Token::Type::Ident) && has_ignored_vendor_prefix(token.token().ident()))
|
||||||
return ParseError::IncludesIgnoredVendorPrefix;
|
return ParseError::IncludesIgnoredVendorPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -851,7 +851,11 @@
|
||||||
},
|
},
|
||||||
"font-family": {
|
"font-family": {
|
||||||
"inherited": true,
|
"inherited": true,
|
||||||
"initial": "sans-serif"
|
"initial": "sans-serif",
|
||||||
|
"valid-types": [
|
||||||
|
"custom-ident",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"font-size": {
|
"font-size": {
|
||||||
"inherited": true,
|
"inherited": true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue