Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / dom / public / nsDOMJSUtils.h
blob5ff7cc68d807c067aed037e73264f6f25a358cd6
2 #ifndef nsDOMJSUtils_h__
3 #define nsDOMJSUtils_h__
5 #include "jsapi.h"
6 #include "nsIScriptContext.h"
8 // seems like overkill for just this 1 function - but let's see what else
9 // falls out first.
10 inline nsIScriptContext *
11 GetScriptContextFromJSContext(JSContext *cx)
13 if (!(::JS_GetOptions(cx) & JSOPTION_PRIVATE_IS_NSISUPPORTS)) {
14 return nsnull;
17 nsCOMPtr<nsIScriptContext> scx =
18 do_QueryInterface(static_cast<nsISupports *>
19 (::JS_GetContextPrivate(cx)));
21 // This will return a pointer to something that's about to be
22 // released, but that's ok here.
23 return scx;
26 // A factory function for turning a jsval argv into an nsIArray
27 // but also supports an effecient way of extracting the original argv.
28 // Bug 312003 describes why this must be "void *", but argv will be cast to
29 // jsval* and the args are found at:
30 // ((jsval*)aArgv)[0], ..., ((jsval*)aArgv)[aArgc - 1]
31 // The resulting object will take a copy of the array, and ensure each
32 // element is rooted.
33 // Optionally, aArgv may be NULL, in which case the array is allocated and
34 // rooted, but all items remain NULL. This presumably means the caller will
35 // then QI us for nsIJSArgArray, and set our array elements.
36 nsresult NS_CreateJSArgv(JSContext *aContext, PRUint32 aArgc, void *aArgv,
37 nsIArray **aArray);
39 #endif // nsDOMJSUtils_h__