IDLGenerators: Allow DOMString? reflection on non-enumerated attributes

Corresponds to ef2fba2a3b
This commit is contained in:
Sam Atkins 2025-03-03 12:40:01 +00:00 committed by Tim Ledbetter
commit a11848f163
Notes: github-actions[bot] 2025-03-04 16:46:00 +00:00

View file

@ -3731,23 +3731,29 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.getter_callback@)
// NOTE: this is "impl" above
// 2. Let contentAttributeValue be the result of running this's get the content attribute.
// 8. Return the canonical keyword for the state of attributeDefinition that contentAttributeValue corresponds to.
// NOTE: We run step 8 here to have a field to assign to
attribute_generator.append(R"~~~(
auto retval = impl->attribute("@attribute.reflect_name@"_fly_string);
auto content_attribute_value = impl->attribute("@attribute.reflect_name@"_fly_string);
)~~~");
// 3. Let attributeDefinition be the attribute definition of element's content attribute whose namespace is null
// and local name is the reflected content attribute name.
// NOTE: this is "attribute" above
// 4. Assert: attributeDefinition indicates it is an enumerated attribute.
// 5. Assert: the reflected IDL attribute is limited to only known values.
// NOTE: This is checked by the "Enumerated" extended attribute
// 4. If attributeDefinition indicates it is an enumerated attribute:
auto is_enumerated = attribute.extended_attributes.contains("Enumerated");
VERIFY(is_enumerated);
if (is_enumerated) {
// 6. Assert: contentAttributeValue corresponds to a state of attributeDefinition.
// NOTE: We run step 4 here to have a field to assign to
// 4. Return the canonical keyword for the state of attributeDefinition that contentAttributeValue corresponds to.
attribute_generator.append(R"~~~(
auto retval = impl->attribute("@attribute.reflect_name@"_fly_string);
)~~~");
// 1. Assert: the reflected IDL attribute is limited to only known values.
// NOTE: This is checked by the "Enumerated" extended attribute, so there's nothing additional to assert.
// 2. Assert: contentAttributeValue corresponds to a state of attributeDefinition.
auto valid_enumerations_type = attribute.extended_attributes.get("Enumerated").value();
auto valid_enumerations = interface.enumerations.get(valid_enumerations_type).value();
@ -3790,7 +3796,14 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.getter_callback@)
attribute_generator.append(R"~~~(
VERIFY(!retval.has_value() || valid_values.contains_slow(retval.value()));
)~~~");
// FIXME: 7. If contentAttributeValue corresponds to a state of attributeDefinition with no associated keyword value, then return null.
// FIXME: 3. If contentAttributeValue corresponds to a state of attributeDefinition with no associated keyword value, then return null.
} else {
// 5. Return contentAttributeValue.
attribute_generator.append(R"~~~(
auto retval = move(content_attribute_value);
)~~~");
}
}
}
// If a reflected IDL attribute has the type boolean: