LibWeb: Make external StyleValue-parsing methods infallible

This commit is contained in:
Sam Atkins 2023-08-19 15:01:21 +01:00 committed by Andreas Kling
parent 9e1bbfbd37
commit 28c2836c24
Notes: sideshowbarker 2024-07-17 01:12:07 +09:00
13 changed files with 70 additions and 70 deletions

View file

@ -156,7 +156,7 @@ Optional<PropertyID> property_id_from_camel_case_string(StringView);
Optional<PropertyID> property_id_from_string(StringView);
StringView string_from_property_id(PropertyID);
bool is_inherited_property(PropertyID);
ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm&, PropertyID);
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
enum class ValueType {
Angle,
@ -496,7 +496,7 @@ bool property_affects_stacking_context(PropertyID property_id)
}
}
ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
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)])
@ -525,7 +525,7 @@ ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm& context_rea
TRY(member_generator.try_append(
R"~~~( case PropertyID::@name:titlecase@:
{
auto parsed_value = TRY(parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@));
auto parsed_value = 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;