mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Pass through [EnforceRange] and [Clamp] extended attributes
To the 'convert to int' AO. Nothing actually makes use of the [Clamp] attribute yet in our implementation, but we may as well add support for it now since it is trivial to do do.
This commit is contained in:
parent
56b0066485
commit
a09849072e
Notes:
sideshowbarker
2024-07-17 05:05:51 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/a09849072e Pull-request: https://github.com/SerenityOS/serenity/pull/23764 Reviewed-by: https://github.com/kennethmyhra ✅
1 changed files with 3 additions and 2 deletions
|
@ -397,6 +397,8 @@ static void generate_to_integral(SourceGenerator& scoped_generator, ParameterTyp
|
|||
|
||||
VERIFY(it != idl_type_map.end());
|
||||
scoped_generator.set("cpp_type"sv, it->cpp_type);
|
||||
scoped_generator.set("enforce_range", parameter.extended_attributes.contains("EnforceRange") ? "Yes" : "No");
|
||||
scoped_generator.set("clamp", parameter.extended_attributes.contains("Clamp") ? "Yes" : "No");
|
||||
|
||||
if ((!optional && !parameter.type->is_nullable()) || optional_default_value.has_value()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
@ -418,14 +420,13 @@ static void generate_to_integral(SourceGenerator& scoped_generator, ParameterTyp
|
|||
)~~~");
|
||||
}
|
||||
|
||||
// FIXME: pass through [EnforceRange] and [Clamp] extended attributes
|
||||
if (it->cpp_type == "bool"sv) {
|
||||
scoped_generator.append(R"~~~(
|
||||
@cpp_name@ = @js_name@@js_suffix@.to_boolean();
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
@cpp_name@ = TRY(WebIDL::convert_to_int<@cpp_type@>(vm, @js_name@@js_suffix@));
|
||||
@cpp_name@ = TRY(WebIDL::convert_to_int<@cpp_type@>(vm, @js_name@@js_suffix@, WebIDL::EnforceRange::@enforce_range@, WebIDL::Clamp::@clamp@));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue