Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsCxPusher Class Reference

#include <nsContentUtils.h>

Collaboration diagram for nsCxPusher:
Collaboration graph

List of all members.

Public Member Functions

 nsCxPusher ()
 ~nsCxPusher ()
PRBool Push (nsISupports *aCurrentTarget)
void Pop ()

Private Attributes

nsCOMPtr< nsIJSContextStackmStack
nsCOMPtr< nsIScriptContextmScx
PRBool mScriptIsRunning

Detailed Description

Definition at line 702 of file nsContentUtils.h.

Constructor & Destructor Documentation

nsCxPusher::nsCxPusher ( ) [inline]

Definition at line 705 of file nsContentUtils.h.

Definition at line 706 of file nsContentUtils.h.

{ Pop(); }

Here is the call graph for this function:

Member Function Documentation

Definition at line 2398 of file nsContentUtils.cpp.

  if (!mScx || !mStack) {
    mScx = nsnull;

    NS_ASSERTION(!mScriptIsRunning, "Huh, this can't be happening, "
                 "mScriptIsRunning can't be set here!");


  JSContext *unused;

  if (!mScriptIsRunning) {
    // No JS is running, but executing the event handler might have
    // caused some JS to run. Tell the script context that it's done.


  mScx = nsnull;
  mScriptIsRunning = PR_FALSE;

Here is the caller graph for this function:

PRBool nsCxPusher::Push ( nsISupports *  aCurrentTarget)

Definition at line 2320 of file nsContentUtils.cpp.

  if (mScx) {
    NS_ERROR("Whaaa! No double pushing with nsCxPusher::Push()!");

    return PR_FALSE;

  nsCOMPtr<nsIScriptGlobalObject> sgo;
  nsCOMPtr<nsIContent> content(do_QueryInterface(aCurrentTarget));
  nsCOMPtr<nsIDocument> document;

  if (content) {
    document = content->GetOwnerDoc();

  if (!document) {
    document = do_QueryInterface(aCurrentTarget);

  if (document) {
    nsCOMPtr<nsIDocument_MOZILLA_1_8_BRANCH3> branch3doc =
                 "Document must implement nsIDocument_MOZILLA_1_8_BRANCH3!!!");
    PRBool hasHadScriptObject = PR_TRUE;
    sgo = branch3doc->GetScriptHandlingObject(hasHadScriptObject);
    // It is bad if the document doesn't have event handling context,
    // but it used to have one.
    NS_ENSURE_TRUE(sgo || !hasHadScriptObject, PR_FALSE);

  if (!document && !sgo) {
    sgo = do_QueryInterface(aCurrentTarget);

  JSContext *cx = nsnull;

  if (sgo) {
    mScx = sgo->GetContext();

    if (mScx) {
      cx = (JSContext *)mScx->GetNativeContext();
      // Bad, no JSContext from script global object!

  if (cx) {
    if (!mStack) {
      mStack = do_GetService(kJSStackContractID);

    if (mStack) {
      JSContext *current = nsnull;

      if (current) {
        // If there's a context on the stack, that means that a script
        // is running at the moment.

        mScriptIsRunning = PR_TRUE;

  } else {
    // If there's no native context in the script context it must be
    // in the process or being torn down. We don't want to notify the
    // script context about scripts having been evaluated in such a
    // case, so null out mScx.

    mScx = nsnull;
  return PR_TRUE;

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Definition at line 714 of file nsContentUtils.h.

Definition at line 713 of file nsContentUtils.h.

Definition at line 712 of file nsContentUtils.h.

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