2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsIScriptGlobalObject_h__
|
|
|
|
#define nsIScriptGlobalObject_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2013-04-04 02:27:06 -07:00
|
|
|
#include "nsIGlobalObject.h"
|
2013-08-27 19:59:14 -07:00
|
|
|
#include "js/TypeDecls.h"
|
2013-09-24 03:04:14 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsIScriptGlobalObject;
|
|
|
|
|
|
|
|
// A helper function for nsIScriptGlobalObject implementations to use
|
|
|
|
// when handling a script error. Generally called by the global when a context
|
|
|
|
// notifies it of an error via nsIScriptGlobalObject::HandleScriptError.
|
2011-10-17 07:59:28 -07:00
|
|
|
// Returns true if HandleDOMEvent was actually called, in which case
|
2007-03-22 10:30:00 -07:00
|
|
|
// aStatus will be filled in with the status.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
|
2013-09-26 23:20:56 -07:00
|
|
|
mozilla::InternalScriptErrorEvent *aErrorEvent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsEventStatus *aStatus);
|
|
|
|
|
|
|
|
|
|
|
|
#define NS_ISCRIPTGLOBALOBJECT_IID \
|
2013-09-08 20:28:48 -07:00
|
|
|
{ 0x214fa2f6, 0xcc0c, 0x42cf, \
|
|
|
|
{ 0x98, 0x4b, 0x45, 0xf5, 0x73, 0x9c, 0x6b, 0x73 } }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2011-04-14 05:04:08 -07:00
|
|
|
* The global object which keeps a script context for each supported script
|
|
|
|
* language. This often used to store per-window global state.
|
2013-04-04 02:27:06 -07:00
|
|
|
* This is a heavyweight interface implemented only by DOM globals, and
|
|
|
|
* it might go away some time in the future.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
2013-04-04 02:27:06 -07:00
|
|
|
class nsIScriptGlobalObject : public nsIGlobalObject
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECT_IID)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure that the script global object is initialized for working with the
|
|
|
|
* specified script language ID. This will set up the nsIScriptContext
|
|
|
|
* and 'script global' for that language, allowing these to be fetched
|
|
|
|
* and manipulated.
|
|
|
|
* @return NS_OK if successful; error conditions include that the language
|
|
|
|
* has not been registered, as well as 'normal' errors, such as
|
|
|
|
* out-of-memory
|
|
|
|
*/
|
2012-03-23 10:13:29 -07:00
|
|
|
virtual nsresult EnsureScriptEnvironment() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get a script context (WITHOUT added reference) for the specified language.
|
|
|
|
*/
|
2012-03-23 10:13:29 -07:00
|
|
|
virtual nsIScriptContext *GetScriptContext() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-05 02:00:04 -07:00
|
|
|
nsIScriptContext* GetContext() {
|
|
|
|
return GetScriptContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the global script for a language is finalized, typically as
|
|
|
|
* part of its GC process. By the time this call is made, the
|
|
|
|
* nsIScriptContext for the language has probably already been removed.
|
|
|
|
* After this call, the passed object is dead - which should generally be the
|
|
|
|
* same object the global is using for a global for that language.
|
|
|
|
*/
|
2011-04-14 05:04:08 -07:00
|
|
|
virtual void OnFinalize(JSObject* aObject) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to enable/disable scripts.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-06 17:09:16 -07:00
|
|
|
/**
|
|
|
|
* Handle a script error. Generally called by a script context.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-09-26 23:20:56 -07:00
|
|
|
virtual nsresult HandleScriptError(
|
|
|
|
mozilla::InternalScriptErrorEvent *aErrorEvent,
|
|
|
|
nsEventStatus *aEventStatus) {
|
2012-07-27 06:51:50 -07:00
|
|
|
NS_ENSURE_STATE(NS_HandleScriptError(this, aErrorEvent, aEventStatus));
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-01-26 07:03:21 -08:00
|
|
|
|
|
|
|
virtual bool IsBlackForCC() { return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObject,
|
|
|
|
NS_ISCRIPTGLOBALOBJECT_IID)
|
|
|
|
|
|
|
|
#endif
|