From d014c6818a5332946a55c027f6eb5600659ec54f Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 26 Sep 2025 12:44:56 +0100 Subject: [PATCH] LibWeb/CSS: Use PropertyNameAndID in CSSSV::parse_a_css_style_value() --- Libraries/LibWeb/CSS/CSSStyleValue.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.cpp b/Libraries/LibWeb/CSS/CSSStyleValue.cpp index 8a6e18a87f..6b86bdda3d 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace Web::CSS { @@ -61,29 +61,26 @@ WebIDL::ExceptionOr>> CSSStyleValue::parse } // https://drafts.css-houdini.org/css-typed-om-1/#parse-a-cssstylevalue -WebIDL::ExceptionOr, GC::RootVector>>> CSSStyleValue::parse_a_css_style_value(JS::VM& vm, FlyString property, String css_text, ParseMultiple parse_multiple) +WebIDL::ExceptionOr, GC::RootVector>>> CSSStyleValue::parse_a_css_style_value(JS::VM& vm, FlyString property_name, String css_text, ParseMultiple parse_multiple) { // 1. If property is not a custom property name string, set property to property ASCII lowercased. - if (!is_a_custom_property_name_string(property)) - property = property.to_ascii_lowercase(); - // 2. If property is not a valid CSS property, throw a TypeError. - if (!is_a_valid_css_property(property)) - return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("'{}' is not a valid CSS property", property)) }; + auto property = PropertyNameAndID::from_name(property_name); + if (!property.has_value()) + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("'{}' is not a valid CSS property", property_name)) }; // 3. Attempt to parse cssText according to property’s grammar. // If this fails, throw a TypeError. // Otherwise, let whole value be the parsed result. - auto property_id = property_id_from_string(property).release_value(); - auto whole_value = parse_css_value(Parser::ParsingParams {}, css_text, property_id); + auto whole_value = parse_css_value(Parser::ParsingParams {}, css_text, property->id()); if (!whole_value) - return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Failed to parse '{}' as a value for '{}' property", css_text, property)) }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Failed to parse '{}' as a value for '{}' property", css_text, property->name())) }; // FIXME: 4. Subdivide into iterations whole value, according to property, and let values be the result. // 5. For each value in values, replace it with the result of reifying value for property. GC::RootVector> reified_values { vm.heap() }; - reified_values.append(whole_value->reify(*vm.current_realm(), property)); + reified_values.append(whole_value->reify(*vm.current_realm(), property->name())); // 6. If parseMultiple is false, return values[0]. Otherwise, return values. if (parse_multiple == ParseMultiple::No)