Bumping manifests a=b2g-bump
[gecko.git] / dom / base / nsIScriptContext.h
blobd2bad832ce64d96cf2d8e1501fe03a5f655261c9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIScriptContext_h__
7 #define nsIScriptContext_h__
9 #include "nscore.h"
10 #include "nsStringGlue.h"
11 #include "nsISupports.h"
12 #include "nsCOMPtr.h"
13 #include "nsIProgrammingLanguage.h"
14 #include "jspubtd.h"
15 #include "js/GCAPI.h"
17 class nsIScriptGlobalObject;
18 class nsIScriptSecurityManager;
19 class nsIPrincipal;
20 class nsIAtom;
21 class nsIArray;
22 class nsIVariant;
23 class nsIObjectInputStream;
24 class nsIObjectOutputStream;
25 class nsIScriptObjectPrincipal;
26 class nsIDOMWindow;
27 class nsIURI;
29 #define NS_ISCRIPTCONTEXT_IID \
30 { 0x274840b6, 0x7349, 0x4798, \
31 { 0xbe, 0x24, 0xbd, 0x75, 0xa6, 0x46, 0x99, 0xb7 } }
33 class nsIOffThreadScriptReceiver;
35 /**
36 * It is used by the application to initialize a runtime and run scripts.
37 * A script runtime would implement this interface.
39 class nsIScriptContext : public nsISupports
41 public:
42 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTCONTEXT_IID)
44 /**
45 * Return the global object.
47 **/
48 virtual nsIScriptGlobalObject *GetGlobalObject() = 0;
50 /**
51 * Return the native script context
53 **/
54 virtual JSContext* GetNativeContext() = 0;
56 /**
57 * Initialize the context generally. Does not create a global object.
58 **/
59 virtual nsresult InitContext() = 0;
61 /**
62 * Check to see if context is as yet intialized. Used to prevent
63 * reentrancy issues during the initialization process.
65 * @return true if initialized, false if not
68 virtual bool IsContextInitialized() = 0;
70 /**
71 * For garbage collected systems, do a synchronous collection pass.
72 * May be a no-op on other systems
74 * @return NS_OK if the method is successful
76 virtual void GC(JS::gcreason::Reason aReason) = 0;
78 // SetProperty is suspect and jst believes should not be needed. Currenly
79 // used only for "arguments".
80 virtual nsresult SetProperty(JS::Handle<JSObject*> aTarget,
81 const char* aPropName, nsISupports* aVal) = 0;
82 /**
83 * Called to set/get information if the script context is
84 * currently processing a script tag
86 virtual bool GetProcessingScriptTag() = 0;
87 virtual void SetProcessingScriptTag(bool aResult) = 0;
89 /**
90 * Initialize DOM classes on aGlobalObj, always call
91 * WillInitializeContext() before calling InitContext(), and always
92 * call DidInitializeContext() when a context is fully
93 * (successfully) initialized.
95 virtual nsresult InitClasses(JS::Handle<JSObject*> aGlobalObj) = 0;
97 /**
98 * Tell the context we're about to be reinitialize it.
100 virtual void WillInitializeContext() = 0;
103 * Tell the context we're done reinitializing it.
105 virtual void DidInitializeContext() = 0;
108 * Access the Window Proxy. The setter should only be called by nsGlobalWindow.
110 virtual void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) = 0;
111 virtual JSObject* GetWindowProxy() = 0;
112 virtual JSObject* GetWindowProxyPreserveColor() = 0;
115 NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContext, NS_ISCRIPTCONTEXT_IID)
117 #define NS_IOFFTHREADSCRIPTRECEIVER_IID \
118 {0x3a980010, 0x878d, 0x46a9, \
119 {0x93, 0xad, 0xbc, 0xfd, 0xd3, 0x8e, 0xa0, 0xc2}}
121 class nsIOffThreadScriptReceiver : public nsISupports
123 public:
124 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOFFTHREADSCRIPTRECEIVER_IID)
127 * Notify this object that a previous CompileScript call specifying this as
128 * aOffThreadReceiver has completed. The script being passed in must be
129 * rooted before any call which could trigger GC.
131 NS_IMETHOD OnScriptCompileComplete(JSScript* aScript, nsresult aStatus) = 0;
134 NS_DEFINE_STATIC_IID_ACCESSOR(nsIOffThreadScriptReceiver, NS_IOFFTHREADSCRIPTRECEIVER_IID)
136 #endif // nsIScriptContext_h__