2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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/. */
|
1998-06-23 18:43:06 +00:00
|
|
|
|
|
|
|
#ifndef nsIScriptGlobalObject_h__
|
|
|
|
#define nsIScriptGlobalObject_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2013-04-04 09:27:06 +00:00
|
|
|
#include "nsIGlobalObject.h"
|
2013-08-28 02:59:14 +00:00
|
|
|
#include "js/TypeDecls.h"
|
2013-09-24 10:04:14 +00:00
|
|
|
#include "mozilla/EventForwards.h"
|
1998-06-23 18:43:06 +00:00
|
|
|
|
|
|
|
class nsIScriptContext;
|
2006-06-13 03:07:47 +00:00
|
|
|
class nsIScriptGlobalObject;
|
|
|
|
|
2014-02-23 05:01:12 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
struct ErrorEventInit;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
// 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 14:59:28 +00:00
|
|
|
// Returns true if HandleDOMEvent was actually called, in which case
|
2006-06-13 03:07:47 +00:00
|
|
|
// aStatus will be filled in with the status.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-06-13 03:07:47 +00:00
|
|
|
NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
|
2014-02-23 05:01:12 +00:00
|
|
|
const mozilla::dom::ErrorEventInit &aErrorEvent,
|
2006-06-13 03:07:47 +00:00
|
|
|
nsEventStatus *aStatus);
|
|
|
|
|
1998-06-23 18:43:06 +00:00
|
|
|
|
|
|
|
#define NS_ISCRIPTGLOBALOBJECT_IID \
|
2013-11-09 10:20:22 +00:00
|
|
|
{ 0x876f83bd, 0x6314, 0x460a, \
|
|
|
|
{ 0xa0, 0x45, 0x1c, 0x8f, 0x46, 0x2f, 0xb8, 0xe1 } }
|
1998-06-23 18:43:06 +00:00
|
|
|
|
|
|
|
/**
|
2011-04-14 12:04:08 +00: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 09:27:06 +00:00
|
|
|
* This is a heavyweight interface implemented only by DOM globals, and
|
|
|
|
* it might go away some time in the future.
|
1998-06-23 18:43:06 +00:00
|
|
|
*/
|
|
|
|
|
2013-04-04 09:27:06 +00:00
|
|
|
class nsIScriptGlobalObject : public nsIGlobalObject
|
2004-02-09 22:48:53 +00:00
|
|
|
{
|
1998-06-23 18:43:06 +00:00
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECT_IID)
|
1999-06-29 20:28:56 +00:00
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
/**
|
|
|
|
* 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 17:13:29 +00:00
|
|
|
virtual nsresult EnsureScriptEnvironment() = 0;
|
2006-06-13 03:07:47 +00:00
|
|
|
/**
|
|
|
|
* Get a script context (WITHOUT added reference) for the specified language.
|
|
|
|
*/
|
2012-03-23 17:13:29 +00:00
|
|
|
virtual nsIScriptContext *GetScriptContext() = 0;
|
2006-06-13 03:07:47 +00:00
|
|
|
|
2012-05-05 09:00:04 +00:00
|
|
|
nsIScriptContext* GetContext() {
|
|
|
|
return GetScriptContext();
|
2006-06-13 03:07:47 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 00:09:16 +00:00
|
|
|
/**
|
|
|
|
* Handle a script error. Generally called by a script context.
|
2005-07-30 20:57:07 +00:00
|
|
|
*/
|
2013-09-27 06:20:56 +00:00
|
|
|
virtual nsresult HandleScriptError(
|
2014-02-23 05:01:12 +00:00
|
|
|
const mozilla::dom::ErrorEventInit &aErrorEventInit,
|
2013-09-27 06:20:56 +00:00
|
|
|
nsEventStatus *aEventStatus) {
|
2014-02-23 05:01:12 +00:00
|
|
|
NS_ENSURE_STATE(NS_HandleScriptError(this, aErrorEventInit, aEventStatus));
|
2012-07-27 13:51:50 +00:00
|
|
|
return NS_OK;
|
2006-06-13 03:07:47 +00:00
|
|
|
}
|
2012-01-26 15:03:21 +00:00
|
|
|
|
2013-11-24 19:35:34 +00:00
|
|
|
virtual bool IsBlackForCC(bool aTracingNeeded = true) { return false; }
|
2015-05-07 07:05:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsIScriptGlobalObject() {}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
};
|
1998-06-23 18:43:06 +00:00
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObject,
|
|
|
|
NS_ISCRIPTGLOBALOBJECT_IID)
|
|
|
|
|
1998-06-23 18:43:06 +00:00
|
|
|
#endif
|