diff options
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 6 | ||||
-rw-r--r-- | components/script/dom/testbinding.rs | 4 | ||||
-rw-r--r-- | components/script/dom/webidls/TestBinding.webidl | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b184cce76b2..73dfb4294f1 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -722,6 +722,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, if type.nullable(): declType = CGWrapper(declType, pre="Option<", post=" >") + if isMember != "Dictionary" and type_needs_tracing(type): + declType = CGTemplatedType("RootedTraceableBox", declType) + templateBody = ("match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n" " Ok(ConversionResult::Success(value)) => value,\n" " Ok(ConversionResult::Failure(error)) => {\n" @@ -6196,6 +6199,9 @@ def type_needs_tracing(t): if t.isSequence(): return type_needs_tracing(t.inner) + if t.isUnion(): + return any(type_needs_tracing(member) for member in t.flatMemberTypes) + return False if t.isDictionary(): diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 1582647ca33..d9defc53770 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -435,7 +435,9 @@ impl TestBindingMethods for TestBinding { fn PassUnion6(&self, _: UnsignedLongOrBoolean) {} fn PassUnion7(&self, _: StringSequenceOrUnsignedLong) {} fn PassUnion8(&self, _: ByteStringSequenceOrLong) {} - fn PassUnion9(&self, _: UnionTypes::TestDictionaryOrLong) {} + fn PassUnion9(&self, _: RootedTraceableBox<UnionTypes::TestDictionaryOrLong>) {} + #[allow(unsafe_code)] + unsafe fn PassUnion10(&self, _: *mut JSContext, _: RootedTraceableBox<UnionTypes::StringOrObject>) {} fn PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {} fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {} #[allow(unsafe_code)] diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index fc6d4771366..74216947917 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -246,6 +246,7 @@ interface TestBinding { void passUnion7((sequence<DOMString> or unsigned long) arg); void passUnion8((sequence<ByteString> or long) arg); void passUnion9((TestDictionary or long) arg); + void passUnion10((DOMString or object) arg); void passUnionWithTypedef((Document or TestTypedef) arg); void passUnionWithTypedef2((sequence<long> or TestTypedef) arg); void passAny(any arg); |