2015-05-03 22:32:37 +03: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 15:12:37 +04: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 22:43:06 +04:00
|
|
|
|
|
|
|
#ifndef nsIScriptGlobalObject_h__
|
|
|
|
#define nsIScriptGlobalObject_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2013-04-04 13:27:06 +04:00
|
|
|
#include "nsIGlobalObject.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2013-09-24 14:04:14 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
1998-06-23 22:43:06 +04:00
|
|
|
|
|
|
|
class nsIScriptContext;
|
2006-06-13 07:07:47 +04:00
|
|
|
class nsIScriptGlobalObject;
|
|
|
|
|
2014-02-23 09:01:12 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
struct ErrorEventInit;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2006-06-13 07:07:47 +04: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 18:59:28 +04:00
|
|
|
// Returns true if HandleDOMEvent was actually called, in which case
|
2006-06-13 07:07:47 +04:00
|
|
|
// aStatus will be filled in with the status.
|
|
|
|
bool NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
|
2014-02-23 09:01:12 +04:00
|
|
|
const mozilla::dom::ErrorEventInit &aErrorEvent,
|
2006-06-13 07:07:47 +04:00
|
|
|
nsEventStatus *aStatus);
|
1998-06-23 22:43:06 +04:00
|
|
|
|
2018-01-05 01:32:15 +03:00
|
|
|
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
|
1998-06-23 22:43:06 +04:00
|
|
|
#define NS_ISCRIPTGLOBALOBJECT_IID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2013-11-09 14:20:22 +04:00
|
|
|
0x876f83bd, 0x6314, 0x460a, { \
|
|
|
|
0xa0, 0x45, 0x1c, 0x8f, 0x46, 0x2f, 0xb8, 0xe1 \
|
|
|
|
} \
|
|
|
|
}
|
1998-06-23 22:43:06 +04:00
|
|
|
|
|
|
|
/**
|
2011-04-14 16:04:08 +04: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 13:27:06 +04:00
|
|
|
* This is a heavyweight interface implemented only by DOM globals, and
|
|
|
|
* it might go away some time in the future.
|
1998-06-23 22:43:06 +04:00
|
|
|
*/
|
|
|
|
|
2013-04-04 13:27:06 +04:00
|
|
|
class nsIScriptGlobalObject : public nsIGlobalObject {
|
1998-06-23 22:43:06 +04:00
|
|
|
public:
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECT_IID)
|
1999-06-30 00:28:56 +04:00
|
|
|
|
2006-06-13 07:07:47 +04: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 21:13:29 +04:00
|
|
|
virtual nsresult EnsureScriptEnvironment() = 0;
|
2006-06-13 07:07:47 +04:00
|
|
|
/**
|
|
|
|
* Get a script context (WITHOUT added reference) for the specified language.
|
|
|
|
*/
|
2012-03-23 21:13:29 +04:00
|
|
|
virtual nsIScriptContext *GetScriptContext() = 0;
|
2006-06-13 07:07:47 +04:00
|
|
|
|
2012-05-05 13:00:04 +04:00
|
|
|
nsIScriptContext *GetContext() { return GetScriptContext(); }
|
2006-06-13 07:07:47 +04:00
|
|
|
|
2009-10-07 04:09:16 +04:00
|
|
|
/**
|
|
|
|
* Handle a script error. Generally called by a script context.
|
2005-07-31 00:57:07 +04:00
|
|
|
*/
|
2018-07-12 00:17:01 +03:00
|
|
|
bool HandleScriptError(const mozilla::dom::ErrorEventInit &aErrorEventInit,
|
|
|
|
nsEventStatus *aEventStatus) {
|
|
|
|
return NS_HandleScriptError(this, aErrorEventInit, aEventStatus);
|
2006-06-13 07:07:47 +04:00
|
|
|
}
|
2012-01-26 19:03:21 +04:00
|
|
|
|
2013-11-24 23:35:34 +04:00
|
|
|
virtual bool IsBlackForCC(bool aTracingNeeded = true) { return false; }
|
2015-05-07 10:05:43 +03: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 21:42:36 +04:00
|
|
|
};
|
1998-06-23 22:43:06 +04:00
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObject, NS_ISCRIPTGLOBALOBJECT_IID)
|
|
|
|
|
1998-06-23 22:43:06 +04:00
|
|
|
#endif
|