1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

LibWeb: Propagate errors from parse_css_value and property_initial_value

This commit is contained in:
Sam Atkins 2023-05-02 15:09:46 +01:00 committed by Andreas Kling
parent 294f5b109f
commit f4d8a24fe4
12 changed files with 68 additions and 66 deletions

View file

@ -107,7 +107,7 @@ PropertyID property_id_from_camel_case_string(StringView);
PropertyID property_id_from_string(StringView);
StringView string_from_property_id(PropertyID);
bool is_inherited_property(PropertyID);
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm&, PropertyID);
bool property_accepts_value(PropertyID, StyleValue&);
size_t property_maximum_value_count(PropertyID);
@ -310,7 +310,7 @@ bool property_affects_stacking_context(PropertyID property_id)
}
}
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
{
static Array<RefPtr<StyleValue>, to_underlying(last_property_id) + 1> initial_values;
if (auto initial_value = initial_values[to_underlying(property_id)])
@ -339,7 +339,7 @@ NonnullRefPtr<StyleValue> property_initial_value(JS::Realm& context_realm, Prope
member_generator.append(
R"~~~( case PropertyID::@name:titlecase@:
{
auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@);
auto parsed_value = TRY(parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@));
VERIFY(!parsed_value.is_null());
auto initial_value = parsed_value.release_nonnull();
initial_values[to_underlying(PropertyID::@name:titlecase@)] = initial_value;