aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/Bindings.conf5
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py30
2 files changed, 24 insertions, 11 deletions
diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf
index 3ff7a044b53..5dc9e141ed5 100644
--- a/components/script/dom/bindings/codegen/Bindings.conf
+++ b/components/script/dom/bindings/codegen/Bindings.conf
@@ -134,7 +134,10 @@ DOMInterfaces = {
'XR': {
'inCompartments': ['SupportsSessionMode', 'RequestSession'],
-}
+},
+'GPU': {
+ 'inCompartments': ['RequestAdapter'],
+}
}
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 7610b8442b4..39e8bfa275d 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -6425,7 +6425,8 @@ class CGDictionary(CGThing):
mustRoot = ""
if self.membersNeedTracing():
mustRoot = "#[unrooted_must_root_lint::must_root]\n"
- derive += ["Default"]
+ if not self.hasRequiredFields(self.dictionary):
+ derive += ["Default"]
return (string.Template(
"#[derive(${derive})]\n"
@@ -6485,16 +6486,14 @@ class CGDictionary(CGThing):
selfName = self.makeClassName(d)
if self.membersNeedTracing():
actualType = "RootedTraceableBox<%s>" % selfName
- preInitial = "let mut dictionary = RootedTraceableBox::new(%s::default());\n" % selfName
- initParent = initParent = ("dictionary.parent = %s;\n" % initParent) if initParent else ""
- memberInits = CGList([memberInit(m, False) for m in self.memberInfo])
- postInitial = ""
+ preInitial = "let dictionary = RootedTraceableBox::new(%s {\n" % selfName
+ postInitial = "});\n"
else:
actualType = selfName
preInitial = "let dictionary = %s {\n" % selfName
postInitial = "};\n"
- initParent = ("parent: %s,\n" % initParent) if initParent else ""
- memberInits = CGList([memberInit(m, True) for m in self.memberInfo])
+ initParent = ("parent: %s,\n" % initParent) if initParent else ""
+ memberInits = CGList([memberInit(m, True) for m in self.memberInfo])
return string.Template(
"impl ${selfName} {\n"
@@ -6540,8 +6539,8 @@ class CGDictionary(CGThing):
"initParent": CGIndenter(CGGeneric(initParent), indentLevel=16).define(),
"initMembers": CGIndenter(memberInits, indentLevel=16).define(),
"insertMembers": CGIndenter(memberInserts, indentLevel=8).define(),
- "preInitial": CGIndenter(CGGeneric(preInitial), indentLevel=16).define(),
- "postInitial": CGIndenter(CGGeneric(postInitial), indentLevel=16).define(),
+ "preInitial": CGIndenter(CGGeneric(preInitial), indentLevel=8).define(),
+ "postInitial": CGIndenter(CGGeneric(postInitial), indentLevel=8).define(),
})
def membersNeedTracing(self):
@@ -7409,7 +7408,16 @@ class CGIterableMethodGenerator(CGGeneric):
rooted!(in(*cx) let mut call_arg2 = UndefinedValue());
let mut call_args = vec![UndefinedValue(), UndefinedValue(), ObjectValue(*_obj)];
rooted!(in(*cx) let mut ignoredReturnVal = UndefinedValue());
- for i in 0..(*this).get_iterable_length() {
+
+ // This has to be a while loop since get_iterable_length() may change during
+ // the callback, and we need to avoid iterator invalidation.
+ //
+ // It is possible for this to loop infinitely, but that matches the spec
+ // and other browsers.
+ //
+ // https://heycam.github.io/webidl/#es-forEach
+ let mut i = 0;
+ while i < (*this).get_iterable_length() {
(*this).get_value_at_index(i).to_jsval(*cx, call_arg1.handle_mut());
(*this).get_key_at_index(i).to_jsval(*cx, call_arg2.handle_mut());
call_args[0] = call_arg1.handle().get();
@@ -7419,6 +7427,8 @@ class CGIterableMethodGenerator(CGGeneric):
ignoredReturnVal.handle_mut()) {
return false;
}
+
+ i += 1;
}
let result = ();