1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +00:00

LibWeb: Do not use JS::Handle for TimerHandler

There is no need to use JS::Handle for timer handler because it is
visited from JS::HeapFunction in HTML::Timer.
This commit is contained in:
Aliaksandr Kalenik 2023-09-27 14:55:47 +02:00 committed by Andreas Kling
parent 3a1f617fbf
commit e7a3040c9f
2 changed files with 3 additions and 3 deletions

View file

@ -181,7 +181,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
return { .name = "JS::Handle<FileAPI::File>", .sequence_storage_type = SequenceStorageType::MarkedVector };
if (type.name() == "Function")
return { .name = "JS::Handle<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
return { .name = "JS::NonnullGCPtr<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
if (type.name() == "sequence") {
auto& parameterized_type = verify_cast<ParameterizedType>(type);
@ -1198,7 +1198,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (includes_callable) {
union_generator.append(R"~~~(
if (@js_name@@js_suffix@_object.is_function())
return JS::make_handle(vm.heap().allocate_without_realm<WebIDL::CallbackType>(@js_name@@js_suffix@.as_function(), HTML::incumbent_settings_object()));
return vm.heap().allocate_without_realm<WebIDL::CallbackType>(@js_name@@js_suffix@.as_function(), HTML::incumbent_settings_object());
)~~~");
}

View file

@ -22,7 +22,7 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/#timerhandler
using TimerHandler = Variant<JS::Handle<WebIDL::CallbackType>, String>;
using TimerHandler = Variant<JS::NonnullGCPtr<WebIDL::CallbackType>, String>;
// https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
class WindowOrWorkerGlobalScopeMixin {