summaryrefslogtreecommitdiffstats
path: root/dom/bindings/Codegen.py
diff options
context:
space:
mode:
Diffstat (limited to 'dom/bindings/Codegen.py')
-rw-r--r--dom/bindings/Codegen.py46
1 files changed, 33 insertions, 13 deletions
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index 8985863e8..c9a5e9f41 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -7680,14 +7680,14 @@ class CGPerSignatureCall(CGThing):
if (idlNode.getExtendedAttribute('CEReactions') is not None and
not getter):
- cgThings.append(CGGeneric(fill(
+ cgThings.append(CGGeneric(dedent(
"""
- CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(${obj});
- Maybe<AutoCEReaction> ceReaction;
- if (reactionsStack) {
- ceReaction.emplace(reactionsStack, cx);
+ Maybe<AutoCEReaction> ceReaction;
+ DocGroup* docGroup = self->GetDocGroup();
+ if (docGroup) {
+ ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
}
- """, obj=objectName)))
+ """)))
# If this is a method that was generated by a maplike/setlike
# interface, use the maplike/setlike generator to fill in the body.
@@ -13786,6 +13786,8 @@ class CGForwardDeclarations(CGWrapper):
builder.add(d.nativeType + "Atoms", isStruct=True)
for t in getTypesFromDescriptor(d):
builder.forwardDeclareForType(t, config)
+ if d.hasCEReactions():
+ builder.addInMozillaDom("DocGroup")
for d in dictionaries:
if len(d.members) > 0:
@@ -13857,18 +13859,15 @@ class CGBindingRoot(CGThing):
iface = desc.interface
return any(m.getExtendedAttribute("Deprecated") for m in iface.members + [iface])
- def descriptorHasCEReactions(desc):
- iface = desc.interface
- return any(m.getExtendedAttribute("CEReactions") for m in iface.members + [iface])
-
bindingHeaders["nsIDocument.h"] = any(
descriptorDeprecated(d) for d in descriptors)
bindingHeaders["mozilla/Preferences.h"] = any(
descriptorRequiresPreferences(d) for d in descriptors)
bindingHeaders["mozilla/dom/DOMJSProxyHandler.h"] = any(
d.concrete and d.proxy for d in descriptors)
- bindingHeaders["mozilla/dom/CustomElementRegistry.h"] = any(
- descriptorHasCEReactions(d) for d in descriptors)
+ hasCEReactions = any(d.hasCEReactions() for d in descriptors)
+ bindingHeaders["mozilla/dom/CustomElementRegistry.h"] = hasCEReactions
+ bindingHeaders["mozilla/dom/DocGroup.h"] = hasCEReactions
def descriptorHasChromeOnly(desc):
ctor = desc.interface.ctor()
@@ -14704,6 +14703,12 @@ class CGBindingImplClass(CGClass):
breakAfterReturnDecl=" ",
override=descriptor.wrapperCache,
body=self.getWrapObjectBody()))
+ if descriptor.hasCEReactions():
+ self.methodDecls.insert(0,
+ ClassMethod("GetDocGroup", "DocGroup*", [],
+ const=True,
+ breakAfterReturnDecl=" ",
+ body=self.getGetDocGroupBody()))
if wantGetParent:
self.methodDecls.insert(0,
ClassMethod("GetParentObject",
@@ -14724,6 +14729,9 @@ class CGBindingImplClass(CGClass):
def getGetParentObjectBody(self):
return None
+ def getGetDocGroupBody(self):
+ return None
+
def deps(self):
return self._deps
@@ -14863,6 +14871,8 @@ class CGExampleRoot(CGThing):
self.root = CGNamespace.build(["mozilla", "dom"], self.root)
builder = ForwardDeclarationBuilder()
+ if descriptor.hasCEReactions():
+ builder.addInMozillaDom("DocGroup")
for member in descriptor.interface.members:
if not member.isAttr() and not member.isMethod():
continue
@@ -15174,7 +15184,7 @@ class CGJSImplClass(CGBindingImplClass):
private:
RefPtr<${jsImplName}> mImpl;
- nsCOMPtr<nsISupports> mParent;
+ nsCOMPtr<nsIGlobalObject> mParent;
""",
isupportsDecl=isupportsDecl,
@@ -15253,6 +15263,16 @@ class CGJSImplClass(CGBindingImplClass):
def getGetParentObjectBody(self):
return "return mParent;\n"
+ def getGetDocGroupBody(self):
+ return dedent(
+ """
+ nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mParent);
+ if (!window) {
+ return nullptr;
+ }
+ return window->GetDocGroup();
+ """)
+
def getCreateFromExistingBody(self):
# XXXbz we could try to get parts of this (e.g. the argument
# conversions) auto-generated by somehow creating an IDLMethod and