Bug 1792883 - Stop requiring a mutable handle for converting to a WebIDL union. r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D158360
This commit is contained in:
Peter Van der Beken 2022-09-30 06:40:26 +00:00
parent 5a37b5b0bc
commit f8868855ed
2 changed files with 5 additions and 16 deletions

View File

@ -12357,11 +12357,6 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider, isMember=False
jsConversion=jsConversion,
)
if ownsMembers:
handleType = "JS::Handle<JS::Value>"
else:
handleType = "JS::MutableHandle<JS::Value>"
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<JS::Value>", "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<JS::Value>", "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<JS::Value>"
else:
handleType = "JS::MutableHandle<JS::Value>"
return [
ClassMethod(
"Init",
"bool",
[
Argument("BindingCallContext&", "cx"),
Argument(handleType, "value"),
Argument("JS::Handle<JS::Value>", "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<JS::Value>", "value"),
Argument("const char*", "sourceDescription", default='"Value"'),
Argument("bool", "passedToJSImpl", default="false"),
],

View File

@ -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<JS::Value> chunk(aCx, aChunk);
if (!chunkUnion.Init(aCx, &chunk)) {
if (!chunkUnion.Init(aCx, aChunk)) {
aRv.MightThrowJSException();
aRv.StealExceptionFromJSContext(aCx);
return nullptr;