Back to index

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

List of all members.

Public Member Functions

 nsXULPDGlobalObject ()
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 ()

Protected Member Functions

virtual ~nsXULPDGlobalObject ()

Protected Attributes

nsCOMPtr< nsIScriptContextmScriptContext
JSObjectmJSObject
nsIScriptGlobalObjectOwnermGlobalObjectOwner

Static Protected Attributes

static JSClass gSharedGlobalClass

Detailed Description

Definition at line 79 of file nsXULPrototypeDocument.cpp.


Constructor & Destructor Documentation

Definition at line 783 of file nsXULPrototypeDocument.cpp.

{
}

Member Function Documentation

Implements nsIScriptGlobalObject.

Definition at line 809 of file nsXULPrototypeDocument.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();

        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 860 of file nsXULPrototypeDocument.cpp.

{
    NS_WARNING("waaah!");

    return nsnull;
}

Implements nsIScriptGlobalObject.

Definition at line 901 of file nsXULPrototypeDocument.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 883 of file nsXULPrototypeDocument.cpp.

{
    return mGlobalObjectOwner;
}

Implements nsIScriptObjectPrincipal.

Definition at line 944 of file nsXULPrototypeDocument.cpp.

{
    if (!mGlobalObjectOwner) {
        // See nsXULPrototypeDocument::NewXULPDGlobalObject, the comment
        // about gSystemGlobal implying gSystemPrincipal.
        if (this == nsXULPrototypeDocument::gSystemGlobal) {
            return nsXULPrototypeDocument::gSystemPrincipal;
        }
        return nsnull;
    }
    nsCOMPtr<nsIXULPrototypeDocument> protoDoc
      = do_QueryInterface(mGlobalObjectOwner);

    return protoDoc->GetDocumentPrincipal();
}

Here is the call graph for this function:

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

Implements nsIScriptGlobalObject.

Definition at line 890 of file nsXULPrototypeDocument.cpp.

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

Called when the global JSObject is finalized.

Implements nsIScriptGlobalObject.

Definition at line 918 of file nsXULPrototypeDocument.cpp.

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

    mJSObject = nsnull;
}

Implements nsIScriptGlobalObject.

Definition at line 802 of file nsXULPrototypeDocument.cpp.

Implements nsIScriptGlobalObject.

Definition at line 853 of file nsXULPrototypeDocument.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 876 of file nsXULPrototypeDocument.cpp.

{
    mGlobalObjectOwner = aOwner; // weak reference
}
nsresult nsXULPDGlobalObject::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 932 of file nsXULPrototypeDocument.cpp.

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

Implements nsIScriptGlobalObject.

Definition at line 842 of file nsXULPrototypeDocument.cpp.

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

Implements nsIScriptGlobalObject.

Definition at line 869 of file nsXULPrototypeDocument.cpp.

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

Called to enable/disable scripts.

Implements nsIScriptGlobalObject.

Definition at line 926 of file nsXULPrototypeDocument.cpp.

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

Member Data Documentation

Definition at line 119 of file nsXULPrototypeDocument.cpp.

Definition at line 117 of file nsXULPrototypeDocument.cpp.

Definition at line 116 of file nsXULPrototypeDocument.cpp.


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