dom/base/nsIScriptContext.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/base/nsIScriptContext.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,141 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsIScriptContext_h__
    1.10 +#define nsIScriptContext_h__
    1.11 +
    1.12 +#include "nscore.h"
    1.13 +#include "nsStringGlue.h"
    1.14 +#include "nsISupports.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsIProgrammingLanguage.h"
    1.17 +#include "jspubtd.h"
    1.18 +#include "js/GCAPI.h"
    1.19 +
    1.20 +class nsIScriptGlobalObject;
    1.21 +class nsIScriptSecurityManager;
    1.22 +class nsIPrincipal;
    1.23 +class nsIAtom;
    1.24 +class nsIArray;
    1.25 +class nsIVariant;
    1.26 +class nsIObjectInputStream;
    1.27 +class nsIObjectOutputStream;
    1.28 +class nsIScriptObjectPrincipal;
    1.29 +class nsIDOMWindow;
    1.30 +class nsIURI;
    1.31 +
    1.32 +#define NS_ISCRIPTCONTEXT_IID \
    1.33 +{ 0x274840b6, 0x7349, 0x4798, \
    1.34 +  { 0xbe, 0x24, 0xbd, 0x75, 0xa6, 0x46, 0x99, 0xb7 } }
    1.35 +
    1.36 +/* This MUST match JSVERSION_DEFAULT.  This version stuff if we don't
    1.37 +   know what language we have is a little silly... */
    1.38 +#define SCRIPTVERSION_DEFAULT JSVERSION_DEFAULT
    1.39 +
    1.40 +class nsIOffThreadScriptReceiver;
    1.41 +
    1.42 +/**
    1.43 + * It is used by the application to initialize a runtime and run scripts.
    1.44 + * A script runtime would implement this interface.
    1.45 + */
    1.46 +class nsIScriptContext : public nsISupports
    1.47 +{
    1.48 +public:
    1.49 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTCONTEXT_IID)
    1.50 +
    1.51 +  /**
    1.52 +   * Return the global object.
    1.53 +   *
    1.54 +   **/
    1.55 +  virtual nsIScriptGlobalObject *GetGlobalObject() = 0;
    1.56 +
    1.57 +  /**
    1.58 +   * Return the native script context
    1.59 +   *
    1.60 +   **/
    1.61 +  virtual JSContext* GetNativeContext() = 0;
    1.62 +
    1.63 +  /**
    1.64 +   * Initialize the context generally. Does not create a global object.
    1.65 +   **/
    1.66 +  virtual nsresult InitContext() = 0;
    1.67 +
    1.68 +  /**
    1.69 +   * Check to see if context is as yet intialized. Used to prevent
    1.70 +   * reentrancy issues during the initialization process.
    1.71 +   *
    1.72 +   * @return true if initialized, false if not
    1.73 +   *
    1.74 +   */
    1.75 +  virtual bool IsContextInitialized() = 0;
    1.76 +
    1.77 +  /**
    1.78 +   * For garbage collected systems, do a synchronous collection pass.
    1.79 +   * May be a no-op on other systems
    1.80 +   *
    1.81 +   * @return NS_OK if the method is successful
    1.82 +   */
    1.83 +  virtual void GC(JS::gcreason::Reason aReason) = 0;
    1.84 +
    1.85 +  // SetProperty is suspect and jst believes should not be needed.  Currenly
    1.86 +  // used only for "arguments".
    1.87 +  virtual nsresult SetProperty(JS::Handle<JSObject*> aTarget,
    1.88 +                               const char* aPropName, nsISupports* aVal) = 0;
    1.89 +  /** 
    1.90 +   * Called to set/get information if the script context is
    1.91 +   * currently processing a script tag
    1.92 +   */
    1.93 +  virtual bool GetProcessingScriptTag() = 0;
    1.94 +  virtual void SetProcessingScriptTag(bool aResult) = 0;
    1.95 +
    1.96 +  /**
    1.97 +   * Initialize DOM classes on aGlobalObj, always call
    1.98 +   * WillInitializeContext() before calling InitContext(), and always
    1.99 +   * call DidInitializeContext() when a context is fully
   1.100 +   * (successfully) initialized.
   1.101 +   */
   1.102 +  virtual nsresult InitClasses(JS::Handle<JSObject*> aGlobalObj) = 0;
   1.103 +
   1.104 +  /**
   1.105 +   * Tell the context we're about to be reinitialize it.
   1.106 +   */
   1.107 +  virtual void WillInitializeContext() = 0;
   1.108 +
   1.109 +  /**
   1.110 +   * Tell the context we're done reinitializing it.
   1.111 +   */
   1.112 +  virtual void DidInitializeContext() = 0;
   1.113 +
   1.114 +  /**
   1.115 +   * Access the Window Proxy. The setter should only be called by nsGlobalWindow.
   1.116 +   */
   1.117 +  virtual void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) = 0;
   1.118 +  virtual JSObject* GetWindowProxy() = 0;
   1.119 +  virtual JSObject* GetWindowProxyPreserveColor() = 0;
   1.120 +};
   1.121 +
   1.122 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContext, NS_ISCRIPTCONTEXT_IID)
   1.123 +
   1.124 +#define NS_IOFFTHREADSCRIPTRECEIVER_IID \
   1.125 +{0x3a980010, 0x878d, 0x46a9,            \
   1.126 +  {0x93, 0xad, 0xbc, 0xfd, 0xd3, 0x8e, 0xa0, 0xc2}}
   1.127 +
   1.128 +class nsIOffThreadScriptReceiver : public nsISupports
   1.129 +{
   1.130 +public:
   1.131 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOFFTHREADSCRIPTRECEIVER_IID)
   1.132 +
   1.133 +  /**
   1.134 +   * Notify this object that a previous CompileScript call specifying this as
   1.135 +   * aOffThreadReceiver has completed. The script being passed in must be
   1.136 +   * rooted before any call which could trigger GC.
   1.137 +   */
   1.138 +  NS_IMETHOD OnScriptCompileComplete(JSScript* aScript, nsresult aStatus) = 0;
   1.139 +};
   1.140 +
   1.141 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIOffThreadScriptReceiver, NS_IOFFTHREADSCRIPTRECEIVER_IID)
   1.142 +
   1.143 +#endif // nsIScriptContext_h__
   1.144 +

mercurial