Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsIScriptContext_h__ |
michael@0 | 7 | #define nsIScriptContext_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nscore.h" |
michael@0 | 10 | #include "nsStringGlue.h" |
michael@0 | 11 | #include "nsISupports.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsIProgrammingLanguage.h" |
michael@0 | 14 | #include "jspubtd.h" |
michael@0 | 15 | #include "js/GCAPI.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsIScriptGlobalObject; |
michael@0 | 18 | class nsIScriptSecurityManager; |
michael@0 | 19 | class nsIPrincipal; |
michael@0 | 20 | class nsIAtom; |
michael@0 | 21 | class nsIArray; |
michael@0 | 22 | class nsIVariant; |
michael@0 | 23 | class nsIObjectInputStream; |
michael@0 | 24 | class nsIObjectOutputStream; |
michael@0 | 25 | class nsIScriptObjectPrincipal; |
michael@0 | 26 | class nsIDOMWindow; |
michael@0 | 27 | class nsIURI; |
michael@0 | 28 | |
michael@0 | 29 | #define NS_ISCRIPTCONTEXT_IID \ |
michael@0 | 30 | { 0x274840b6, 0x7349, 0x4798, \ |
michael@0 | 31 | { 0xbe, 0x24, 0xbd, 0x75, 0xa6, 0x46, 0x99, 0xb7 } } |
michael@0 | 32 | |
michael@0 | 33 | /* This MUST match JSVERSION_DEFAULT. This version stuff if we don't |
michael@0 | 34 | know what language we have is a little silly... */ |
michael@0 | 35 | #define SCRIPTVERSION_DEFAULT JSVERSION_DEFAULT |
michael@0 | 36 | |
michael@0 | 37 | class nsIOffThreadScriptReceiver; |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * It is used by the application to initialize a runtime and run scripts. |
michael@0 | 41 | * A script runtime would implement this interface. |
michael@0 | 42 | */ |
michael@0 | 43 | class nsIScriptContext : public nsISupports |
michael@0 | 44 | { |
michael@0 | 45 | public: |
michael@0 | 46 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTCONTEXT_IID) |
michael@0 | 47 | |
michael@0 | 48 | /** |
michael@0 | 49 | * Return the global object. |
michael@0 | 50 | * |
michael@0 | 51 | **/ |
michael@0 | 52 | virtual nsIScriptGlobalObject *GetGlobalObject() = 0; |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Return the native script context |
michael@0 | 56 | * |
michael@0 | 57 | **/ |
michael@0 | 58 | virtual JSContext* GetNativeContext() = 0; |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Initialize the context generally. Does not create a global object. |
michael@0 | 62 | **/ |
michael@0 | 63 | virtual nsresult InitContext() = 0; |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Check to see if context is as yet intialized. Used to prevent |
michael@0 | 67 | * reentrancy issues during the initialization process. |
michael@0 | 68 | * |
michael@0 | 69 | * @return true if initialized, false if not |
michael@0 | 70 | * |
michael@0 | 71 | */ |
michael@0 | 72 | virtual bool IsContextInitialized() = 0; |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * For garbage collected systems, do a synchronous collection pass. |
michael@0 | 76 | * May be a no-op on other systems |
michael@0 | 77 | * |
michael@0 | 78 | * @return NS_OK if the method is successful |
michael@0 | 79 | */ |
michael@0 | 80 | virtual void GC(JS::gcreason::Reason aReason) = 0; |
michael@0 | 81 | |
michael@0 | 82 | // SetProperty is suspect and jst believes should not be needed. Currenly |
michael@0 | 83 | // used only for "arguments". |
michael@0 | 84 | virtual nsresult SetProperty(JS::Handle<JSObject*> aTarget, |
michael@0 | 85 | const char* aPropName, nsISupports* aVal) = 0; |
michael@0 | 86 | /** |
michael@0 | 87 | * Called to set/get information if the script context is |
michael@0 | 88 | * currently processing a script tag |
michael@0 | 89 | */ |
michael@0 | 90 | virtual bool GetProcessingScriptTag() = 0; |
michael@0 | 91 | virtual void SetProcessingScriptTag(bool aResult) = 0; |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * Initialize DOM classes on aGlobalObj, always call |
michael@0 | 95 | * WillInitializeContext() before calling InitContext(), and always |
michael@0 | 96 | * call DidInitializeContext() when a context is fully |
michael@0 | 97 | * (successfully) initialized. |
michael@0 | 98 | */ |
michael@0 | 99 | virtual nsresult InitClasses(JS::Handle<JSObject*> aGlobalObj) = 0; |
michael@0 | 100 | |
michael@0 | 101 | /** |
michael@0 | 102 | * Tell the context we're about to be reinitialize it. |
michael@0 | 103 | */ |
michael@0 | 104 | virtual void WillInitializeContext() = 0; |
michael@0 | 105 | |
michael@0 | 106 | /** |
michael@0 | 107 | * Tell the context we're done reinitializing it. |
michael@0 | 108 | */ |
michael@0 | 109 | virtual void DidInitializeContext() = 0; |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * Access the Window Proxy. The setter should only be called by nsGlobalWindow. |
michael@0 | 113 | */ |
michael@0 | 114 | virtual void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) = 0; |
michael@0 | 115 | virtual JSObject* GetWindowProxy() = 0; |
michael@0 | 116 | virtual JSObject* GetWindowProxyPreserveColor() = 0; |
michael@0 | 117 | }; |
michael@0 | 118 | |
michael@0 | 119 | NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContext, NS_ISCRIPTCONTEXT_IID) |
michael@0 | 120 | |
michael@0 | 121 | #define NS_IOFFTHREADSCRIPTRECEIVER_IID \ |
michael@0 | 122 | {0x3a980010, 0x878d, 0x46a9, \ |
michael@0 | 123 | {0x93, 0xad, 0xbc, 0xfd, 0xd3, 0x8e, 0xa0, 0xc2}} |
michael@0 | 124 | |
michael@0 | 125 | class nsIOffThreadScriptReceiver : public nsISupports |
michael@0 | 126 | { |
michael@0 | 127 | public: |
michael@0 | 128 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOFFTHREADSCRIPTRECEIVER_IID) |
michael@0 | 129 | |
michael@0 | 130 | /** |
michael@0 | 131 | * Notify this object that a previous CompileScript call specifying this as |
michael@0 | 132 | * aOffThreadReceiver has completed. The script being passed in must be |
michael@0 | 133 | * rooted before any call which could trigger GC. |
michael@0 | 134 | */ |
michael@0 | 135 | NS_IMETHOD OnScriptCompileComplete(JSScript* aScript, nsresult aStatus) = 0; |
michael@0 | 136 | }; |
michael@0 | 137 | |
michael@0 | 138 | NS_DEFINE_STATIC_IID_ACCESSOR(nsIOffThreadScriptReceiver, NS_IOFFTHREADSCRIPTRECEIVER_IID) |
michael@0 | 139 | |
michael@0 | 140 | #endif // nsIScriptContext_h__ |
michael@0 | 141 |