Procházet zdrojové kódy

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.
Aliaksandr Kalenik před 1 rokem
rodič
revize
e7a3040c9f

+ 2 - 2
Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp

@@ -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 };
         return { .name = "JS::Handle<FileAPI::File>", .sequence_storage_type = SequenceStorageType::MarkedVector };
 
 
     if (type.name() == "Function")
     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") {
     if (type.name() == "sequence") {
         auto& parameterized_type = verify_cast<ParameterizedType>(type);
         auto& parameterized_type = verify_cast<ParameterizedType>(type);
@@ -1198,7 +1198,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
         if (includes_callable) {
         if (includes_callable) {
             union_generator.append(R"~~~(
             union_generator.append(R"~~~(
             if (@js_name@@js_suffix@_object.is_function())
             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());
 )~~~");
 )~~~");
         }
         }
 
 

+ 1 - 1
Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h

@@ -22,7 +22,7 @@
 namespace Web::HTML {
 namespace Web::HTML {
 
 
 // https://html.spec.whatwg.org/#timerhandler
 // 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
 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
 class WindowOrWorkerGlobalScopeMixin {
 class WindowOrWorkerGlobalScopeMixin {