dom/base/nsIScriptGlobalObject.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 sw=2 et tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsIScriptGlobalObject_h__
michael@0 8 #define nsIScriptGlobalObject_h__
michael@0 9
michael@0 10 #include "nsISupports.h"
michael@0 11 #include "nsIGlobalObject.h"
michael@0 12 #include "js/TypeDecls.h"
michael@0 13 #include "mozilla/EventForwards.h"
michael@0 14
michael@0 15 class nsIScriptContext;
michael@0 16 class nsIScriptGlobalObject;
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 namespace dom {
michael@0 20 struct ErrorEventInit;
michael@0 21 } // namespace dom
michael@0 22 } // namespace mozilla
michael@0 23
michael@0 24 // A helper function for nsIScriptGlobalObject implementations to use
michael@0 25 // when handling a script error. Generally called by the global when a context
michael@0 26 // notifies it of an error via nsIScriptGlobalObject::HandleScriptError.
michael@0 27 // Returns true if HandleDOMEvent was actually called, in which case
michael@0 28 // aStatus will be filled in with the status.
michael@0 29 bool
michael@0 30 NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
michael@0 31 const mozilla::dom::ErrorEventInit &aErrorEvent,
michael@0 32 nsEventStatus *aStatus);
michael@0 33
michael@0 34
michael@0 35 #define NS_ISCRIPTGLOBALOBJECT_IID \
michael@0 36 { 0x876f83bd, 0x6314, 0x460a, \
michael@0 37 { 0xa0, 0x45, 0x1c, 0x8f, 0x46, 0x2f, 0xb8, 0xe1 } }
michael@0 38
michael@0 39 /**
michael@0 40 * The global object which keeps a script context for each supported script
michael@0 41 * language. This often used to store per-window global state.
michael@0 42 * This is a heavyweight interface implemented only by DOM globals, and
michael@0 43 * it might go away some time in the future.
michael@0 44 */
michael@0 45
michael@0 46 class nsIScriptGlobalObject : public nsIGlobalObject
michael@0 47 {
michael@0 48 public:
michael@0 49 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECT_IID)
michael@0 50
michael@0 51 /**
michael@0 52 * Ensure that the script global object is initialized for working with the
michael@0 53 * specified script language ID. This will set up the nsIScriptContext
michael@0 54 * and 'script global' for that language, allowing these to be fetched
michael@0 55 * and manipulated.
michael@0 56 * @return NS_OK if successful; error conditions include that the language
michael@0 57 * has not been registered, as well as 'normal' errors, such as
michael@0 58 * out-of-memory
michael@0 59 */
michael@0 60 virtual nsresult EnsureScriptEnvironment() = 0;
michael@0 61 /**
michael@0 62 * Get a script context (WITHOUT added reference) for the specified language.
michael@0 63 */
michael@0 64 virtual nsIScriptContext *GetScriptContext() = 0;
michael@0 65
michael@0 66 nsIScriptContext* GetContext() {
michael@0 67 return GetScriptContext();
michael@0 68 }
michael@0 69
michael@0 70 /**
michael@0 71 * Handle a script error. Generally called by a script context.
michael@0 72 */
michael@0 73 virtual nsresult HandleScriptError(
michael@0 74 const mozilla::dom::ErrorEventInit &aErrorEventInit,
michael@0 75 nsEventStatus *aEventStatus) {
michael@0 76 NS_ENSURE_STATE(NS_HandleScriptError(this, aErrorEventInit, aEventStatus));
michael@0 77 return NS_OK;
michael@0 78 }
michael@0 79
michael@0 80 virtual bool IsBlackForCC(bool aTracingNeeded = true) { return false; }
michael@0 81 };
michael@0 82
michael@0 83 NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObject,
michael@0 84 NS_ISCRIPTGLOBALOBJECT_IID)
michael@0 85
michael@0 86 #endif

mercurial