Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
nsXBLDocGlobalObject Class Reference
Inheritance diagram for nsXBLDocGlobalObject:
Inheritance graph
[legend]
Collaboration diagram for nsXBLDocGlobalObject:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsXBLDocGlobalObject ()
virtual NS_DECL_ISUPPORTS void SetContext (nsIScriptContext *aContext)
virtual nsIScriptContextGetContext ()
virtual nsresult SetNewDocument (nsIDOMDocument *aDocument, nsISupports *aState, PRBool aRemoveEventListeners, PRBool aClearScope)
virtual void SetDocShell (nsIDocShell *aDocShell)
virtual nsIDocShellGetDocShell ()
virtual void SetOpenerWindow (nsIDOMWindowInternal *aOpener)
virtual void SetGlobalObjectOwner (nsIScriptGlobalObjectOwner *aOwner)
 Let the script global object know who its owner is.
virtual
nsIScriptGlobalObjectOwner
GetGlobalObjectOwner ()
 Get the owner of the script global object.
virtual nsresult HandleDOMEvent (nsPresContext *aPresContext, nsEvent *aEvent, nsIDOMEvent **aDOMEvent, PRUint32 aFlags, nsEventStatus *aEventStatus)
virtual JSObjectGetGlobalJSObject ()
virtual void OnFinalize (JSObject *aObject)
 Called when the global JSObject is finalized.
virtual void SetScriptsEnabled (PRBool aEnabled, PRBool aFireTimeouts)
 Called to enable/disable scripts.
virtual nsresult SetNewArguments (PRUint32 aArgc, void *aArgv)
 Set a new arguments array for this window.
virtual nsIPrincipalGetPrincipal ()

Static Public Member Functions

static JSBool doCheckAccess (JSContext *cx, JSObject *obj, jsval id, PRUint32 accessType)

Protected Member Functions

virtual ~nsXBLDocGlobalObject ()

Protected Attributes

nsCOMPtr< nsIScriptContextmScriptContext
JSObjectmJSObject
nsIScriptGlobalObjectOwnermGlobalObjectOwner

Static Protected Attributes

static JSClass gSharedGlobalClass

Detailed Description

Definition at line 60 of file nsXBLDocumentInfo.cpp.


Constructor & Destructor Documentation

Definition at line 199 of file nsXBLDocumentInfo.cpp.

Definition at line 206 of file nsXBLDocumentInfo.cpp.

{}

Member Function Documentation

JSBool nsXBLDocGlobalObject::doCheckAccess ( JSContext cx,
JSObject obj,
jsval  id,
PRUint32  accessType 
) [static]

Definition at line 108 of file nsXBLDocumentInfo.cpp.

{
  nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager();
  if (!ssm) {
    ::JS_ReportError(cx, "Unable to verify access to a global object property.");
    return JS_FALSE;
  }

  // Make sure to actually operate on our object, and not some object further
  // down on the proto chain.
  while (JS_GET_CLASS(cx, obj) != &nsXBLDocGlobalObject::gSharedGlobalClass) {
    obj = ::JS_GetPrototype(cx, obj);
    if (!obj) {
      ::JS_ReportError(cx, "Invalid access to a global object property.");
      return JS_FALSE;
    }
  }

  nsresult rv = ssm->CheckPropertyAccess(cx, obj, JS_GET_CLASS(cx, obj)->name,
                                         id, accessType);
  return NS_SUCCEEDED(rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIScriptGlobalObject.

Definition at line 255 of file nsXBLDocumentInfo.cpp.

{
  // This whole fragile mess is predicated on the fact that
  // GetContext() will be called before GetScriptObject() is.
  if (! mScriptContext) {
    nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
    NS_ENSURE_TRUE(factory, nsnull);

    nsresult rv =  factory->NewScriptContext(nsnull, getter_AddRefs(mScriptContext));
    if (NS_FAILED(rv))
        return nsnull;

    JSContext *cx = (JSContext *)mScriptContext->GetNativeContext();

    JS_SetErrorReporter(cx, XBL_ProtoErrorReporter);
    mJSObject = ::JS_NewObject(cx, &gSharedGlobalClass, nsnull, nsnull);
    if (!mJSObject)
        return nsnull;

    ::JS_SetGlobalObject(cx, mJSObject);

    // Add an owning reference from JS back to us. This'll be
    // released when the JSObject is finalized.
    ::JS_SetPrivate(cx, mJSObject, this);
    NS_ADDREF(this);
  }

  return mScriptContext;
}

Here is the call graph for this function:

Implements nsIScriptGlobalObject.

Definition at line 305 of file nsXBLDocumentInfo.cpp.

{
  NS_WARNING("waaah!");
  return nsnull;
}

Implements nsIScriptGlobalObject.

Definition at line 345 of file nsXBLDocumentInfo.cpp.

{
  // The prototype document has its own special secret script object
  // that can be used to compile scripts and event handlers.

  if (!mScriptContext)
    return nsnull;

  JSContext* cx = NS_REINTERPRET_CAST(JSContext*,
                                      mScriptContext->GetNativeContext());
  if (!cx)
    return nsnull;

  return ::JS_GetGlobalObject(cx);
}

Here is the call graph for this function:

Get the owner of the script global object.

The method addrefs the returned reference according to regular XPCOM rules, even though the internal reference itself is a "weak" reference.

Implements nsIScriptGlobalObject.

Definition at line 327 of file nsXBLDocumentInfo.cpp.

{
  return mGlobalObjectOwner;
}

Implements nsIScriptObjectPrincipal.

Definition at line 388 of file nsXBLDocumentInfo.cpp.

{
  nsresult rv = NS_OK;
  if (!mGlobalObjectOwner) {
    return nsnull;
  }

  nsCOMPtr<nsIXBLDocumentInfo> docInfo = do_QueryInterface(mGlobalObjectOwner, &rv);
  NS_ENSURE_SUCCESS(rv, nsnull);

  nsCOMPtr<nsIDocument> document;
  rv = docInfo->GetDocument(getter_AddRefs(document));
  NS_ENSURE_SUCCESS(rv, nsnull);

  return document->GetPrincipal();
}

Here is the call graph for this function:

nsresult nsXBLDocGlobalObject::HandleDOMEvent ( nsPresContext aPresContext,
nsEvent aEvent,
nsIDOMEvent **  aDOMEvent,
PRUint32  aFlags,
nsEventStatus aEventStatus 
) [virtual]

Implements nsIScriptGlobalObject.

Definition at line 334 of file nsXBLDocumentInfo.cpp.

{
  NS_NOTREACHED("waaah!");
  return NS_ERROR_UNEXPECTED;
}
void nsXBLDocGlobalObject::OnFinalize ( JSObject aJSObject) [virtual]

Called when the global JSObject is finalized.

Implements nsIScriptGlobalObject.

Definition at line 362 of file nsXBLDocumentInfo.cpp.

{
  NS_ASSERTION(aObject == mJSObject, "Wrong object finalized!");

  mJSObject = nsnull;
}

Implements nsIScriptGlobalObject.

Definition at line 244 of file nsXBLDocumentInfo.cpp.

Here is the call graph for this function:

Implements nsIScriptGlobalObject.

Definition at line 298 of file nsXBLDocumentInfo.cpp.

{
  NS_NOTREACHED("waaah!");
}

Let the script global object know who its owner is.

The script global object should not addref the owner. It will be told when the owner goes away.

Returns:
NS_OK if the method is successful

Implements nsIScriptGlobalObject.

Definition at line 320 of file nsXBLDocumentInfo.cpp.

{
  mGlobalObjectOwner = aOwner; // weak reference
}
nsresult nsXBLDocGlobalObject::SetNewArguments ( PRUint32  aArgc,
void aArgv 
) [virtual]

Set a new arguments array for this window.

This will be set on the window right away (if there's an existing document) and it will also be installed on the window when the next document is loaded. If argc is nonzero, argv must be non-null.

Parameters:
aArgcthe number of args
aArgvthe pointer to the args. This may be cast to jsval* and the args are found at ((jsval*)aArgv)[0], ..., ((jsval*)aArgv)[aArgc - 1]

Implements nsIScriptGlobalObject.

Definition at line 376 of file nsXBLDocumentInfo.cpp.

{
  NS_NOTREACHED("waaah!");
  return NS_ERROR_UNEXPECTED;
}
nsresult nsXBLDocGlobalObject::SetNewDocument ( nsIDOMDocument aDocument,
nsISupports *  aState,
PRBool  aRemoveEventListeners,
PRBool  aClearScope 
) [virtual]

Implements nsIScriptGlobalObject.

Definition at line 287 of file nsXBLDocumentInfo.cpp.

{
  NS_NOTREACHED("waaah!");
  return NS_ERROR_UNEXPECTED;
}

Implements nsIScriptGlobalObject.

Definition at line 313 of file nsXBLDocumentInfo.cpp.

{
  NS_NOTREACHED("waaah!");
}
void nsXBLDocGlobalObject::SetScriptsEnabled ( PRBool  aEnabled,
PRBool  aFireTimeouts 
) [virtual]

Called to enable/disable scripts.

Implements nsIScriptGlobalObject.

Definition at line 370 of file nsXBLDocumentInfo.cpp.

{
    // We don't care...
}

Member Data Documentation

Definition at line 103 of file nsXBLDocumentInfo.cpp.

Definition at line 101 of file nsXBLDocumentInfo.cpp.

Definition at line 100 of file nsXBLDocumentInfo.cpp.


The documentation for this class was generated from the following file: