From 6602beaac64e6cdeaca11c7051cfe68e16b5e01c Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Thu, 17 Mar 2016 18:07:43 +0100 Subject: [PATCH] Bug 1257030 - Add support for supplying preexisting stack instead of capturing one for use as the async parent stack of CallbackObject. r=bz,tromey --- dom/bindings/CallbackFunction.h | 8 ++++++++ dom/bindings/CallbackInterface.h | 8 ++++++++ dom/bindings/CallbackObject.h | 10 ++++++++++ dom/bindings/Codegen.py | 34 +++++++++++++++++++++----------- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/dom/bindings/CallbackFunction.h b/dom/bindings/CallbackFunction.h index b4a72661e7c3..81e7f101665a 100644 --- a/dom/bindings/CallbackFunction.h +++ b/dom/bindings/CallbackFunction.h @@ -32,6 +32,14 @@ public: { } + // See CallbackObject for an explanation of the arguments. + explicit CallbackFunction(JS::Handle aCallable, + JS::Handle aAsyncStack, + nsIGlobalObject* aIncumbentGlobal) + : CallbackObject(aCallable, aAsyncStack, aIncumbentGlobal) + { + } + JS::Handle Callable() const { return Callback(); diff --git a/dom/bindings/CallbackInterface.h b/dom/bindings/CallbackInterface.h index 2b616c8d4758..274c85ade3f8 100644 --- a/dom/bindings/CallbackInterface.h +++ b/dom/bindings/CallbackInterface.h @@ -31,6 +31,14 @@ public: { } + // See CallbackObject for an explanation of the arguments. + explicit CallbackInterface(JS::Handle aCallback, + JS::Handle aAsyncStack, + nsIGlobalObject* aIncumbentGlobal) + : CallbackObject(aCallback, aAsyncStack, aIncumbentGlobal) + { + } + protected: bool GetCallableProperty(JSContext* cx, JS::Handle aPropId, JS::MutableHandle aCallable); diff --git a/dom/bindings/CallbackObject.h b/dom/bindings/CallbackObject.h index 40a5be8b4bbb..d8ca634ebccc 100644 --- a/dom/bindings/CallbackObject.h +++ b/dom/bindings/CallbackObject.h @@ -67,6 +67,16 @@ public: } } + // Instead of capturing the current stack to use as an async parent when the + // callback is invoked, the caller can use this overload to pass in a stack + // for that purpose. + explicit CallbackObject(JS::Handle aCallback, + JS::Handle aAsyncStack, + nsIGlobalObject *aIncumbentGlobal) + { + Init(aCallback, aAsyncStack, aIncumbentGlobal); + } + JS::Handle Callback() const { JS::ExposeObjectToActiveJS(mCallback); diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index b98cadc20537..59680b814e27 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -14687,17 +14687,29 @@ class CGCallback(CGClass): # Not much we can assert about it, other than not being null, and # CallbackObject does that already. body = "" - return [ClassConstructor( - [Argument("JSContext*", "aCx"), - Argument("JS::Handle", "aCallback"), - Argument("nsIGlobalObject*", "aIncumbentGlobal")], - bodyInHeader=True, - visibility="public", - explicit=True, - baseConstructors=[ - "%s(aCx, aCallback, aIncumbentGlobal)" % self.baseName, - ], - body=body)] + return [ + ClassConstructor( + [Argument("JSContext*", "aCx"), + Argument("JS::Handle", "aCallback"), + Argument("nsIGlobalObject*", "aIncumbentGlobal")], + bodyInHeader=True, + visibility="public", + explicit=True, + baseConstructors=[ + "%s(aCx, aCallback, aIncumbentGlobal)" % self.baseName, + ], + body=body), + ClassConstructor( + [Argument("JS::Handle", "aCallback"), + Argument("JS::Handle", "aAsyncStack"), + Argument("nsIGlobalObject*", "aIncumbentGlobal")], + bodyInHeader=True, + visibility="public", + explicit=True, + baseConstructors=[ + "%s(aCallback, aAsyncStack, aIncumbentGlobal)" % self.baseName, + ], + body=body)] def getMethodImpls(self, method): assert method.needThisHandling