From f8868855edbf81e83a9bc036c19028e64c1e52e5 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Fri, 30 Sep 2022 06:40:26 +0000 Subject: [PATCH] Bug 1792883 - Stop requiring a mutable handle for converting to a WebIDL union. r=edgar Differential Revision: https://phabricator.services.mozilla.com/D158360 --- dom/bindings/Codegen.py | 18 ++++-------------- dom/fs/api/FileSystemWritableFileStream.cpp | 3 +-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 501650ebbf1b..b151bc694125 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -12357,11 +12357,6 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider, isMember=False jsConversion=jsConversion, ) - if ownsMembers: - handleType = "JS::Handle" - else: - handleType = "JS::MutableHandle" - needCallContext = idlTypeNeedsCallContext(type) if needCallContext: cxType = "BindingCallContext&" @@ -12373,7 +12368,7 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider, isMember=False "bool", [ Argument(cxType, "cx"), - Argument(handleType, "value"), + Argument("JS::Handle", "value"), Argument("bool&", "tryNext"), Argument("bool", "passedToJSImpl", default="false"), ], @@ -12398,7 +12393,7 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider, isMember=False "bool", [ Argument("JSContext*", "cx_"), - Argument(handleType, "value"), + Argument("JS::Handle", "value"), Argument("bool&", "tryNext"), Argument("bool", "passedToJSImpl", default="false"), ], @@ -12674,18 +12669,13 @@ def getUnionInitMethods(type, isOwningUnion=False): conversion=string.Template(template).substitute(replacements), ) - if isOwningUnion: - handleType = "JS::Handle" - else: - handleType = "JS::MutableHandle" - return [ ClassMethod( "Init", "bool", [ Argument("BindingCallContext&", "cx"), - Argument(handleType, "value"), + Argument("JS::Handle", "value"), Argument("const char*", "sourceDescription", default='"Value"'), Argument("bool", "passedToJSImpl", default="false"), ], @@ -12697,7 +12687,7 @@ def getUnionInitMethods(type, isOwningUnion=False): "bool", [ Argument("JSContext*", "cx_"), - Argument(handleType, "value"), + Argument("JS::Handle", "value"), Argument("const char*", "sourceDescription", default='"Value"'), Argument("bool", "passedToJSImpl", default="false"), ], diff --git a/dom/fs/api/FileSystemWritableFileStream.cpp b/dom/fs/api/FileSystemWritableFileStream.cpp index 34eaca562e8d..2b8f24cabc0a 100644 --- a/dom/fs/api/FileSystemWritableFileStream.cpp +++ b/dom/fs/api/FileSystemWritableFileStream.cpp @@ -31,8 +31,7 @@ FileSystemWritableFileStream::StreamAlgorithms::WriteCallback( // https://fs.spec.whatwg.org/#create-a-new-filesystemwritablefilestream // Step 3. Let writeAlgorithm be an algorithm which takes a chunk argument ... ArrayBufferViewOrArrayBufferOrBlobOrUSVStringOrWriteParams chunkUnion; - JS::Rooted chunk(aCx, aChunk); - if (!chunkUnion.Init(aCx, &chunk)) { + if (!chunkUnion.Init(aCx, aChunk)) { aRv.MightThrowJSException(); aRv.StealExceptionFromJSContext(aCx); return nullptr;