1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:07:34 +00:00

LibWeb: Ignore CSS properties with other people's vendor prefixes

This removes some `Property '-webkit-foo' has no value.` log spam. :^)
This commit is contained in:
Sam Atkins 2021-09-12 16:49:09 +01:00 committed by Andreas Kling
parent de31603028
commit 7817c681d0
2 changed files with 22 additions and 5 deletions

View file

@ -1312,13 +1312,17 @@ Optional<StyleProperty> Parser::convert_to_style_property(StyleDeclarationRule&
auto& property_name = declaration.m_name;
auto property_id = property_id_from_string(property_name);
if (property_id == PropertyID::Invalid && property_name.starts_with("--"))
property_id = PropertyID::Custom;
if (property_id == PropertyID::Invalid && !property_name.starts_with("-")) {
if (property_id == PropertyID::Invalid) {
if (property_name.starts_with("--")) {
property_id = PropertyID::Custom;
} else if (has_ignored_vendor_prefix(property_name)) {
return {};
} else if (!property_name.starts_with("-")) {
dbgln("Parser::convert_to_style_property(): Unrecognized property '{}'", property_name);
return {};
}
}
auto value_token_stream = TokenStream(declaration.m_values);
auto value = parse_css_value(property_id, value_token_stream);
@ -3475,6 +3479,17 @@ OwnPtr<CalculatedStyleValue::CalcSum> Parser::parse_calc_sum(ParsingContext cons
return make<CalculatedStyleValue::CalcSum>(parsed_calc_product.release_nonnull(), move(additional));
}
bool Parser::has_ignored_vendor_prefix(StringView const& string)
{
if (!string.starts_with('-'))
return false;
if (string.starts_with("--"))
return false;
if (string.starts_with("-libweb-"))
return false;
return true;
}
}
namespace Web {

View file

@ -216,6 +216,8 @@ private:
Optional<Selector::Combinator> parse_selector_combinator(TokenStream<StyleComponentValueRule>&);
Result<Selector::SimpleSelector, SelectorParsingResult> parse_simple_selector(TokenStream<StyleComponentValueRule>&);
static bool has_ignored_vendor_prefix(StringView const&);
ParsingContext m_context;
Tokenizer m_tokenizer;