mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
IDLGenerators: Allow DOMString? reflection on non-enumerated attributes
Corresponds to ef2fba2a3b
This commit is contained in:
parent
d970748eed
commit
a11848f163
Notes:
github-actions[bot]
2025-03-04 16:46:00 +00:00
Author: https://github.com/AtkinsSJ
Commit: a11848f163
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3779
Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 37 additions and 24 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue