Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsGlobalWindow.cpp File Reference
#include "nsGlobalWindow.h"
#include "nsScreen.h"
#include "nsHistory.h"
#include "nsBarProps.h"
#include "nsDOMStorage.h"
#include "nsXPIDLString.h"
#include "nsJSUtils.h"
#include "prmem.h"
#include "jsdbgapi.h"
#include "nsReadableUtils.h"
#include "nsDOMClassInfo.h"
#include "nsBuildID.h"
#include "nsIEventListenerManager.h"
#include "nsEscape.h"
#include "nsStyleCoord.h"
#include "nsMimeTypeArray.h"
#include "nsNetUtil.h"
#include "nsPluginArray.h"
#include "nsIPluginHost.h"
#include "nsContentCID.h"
#include "nsLayoutStatics.h"
#include "nsIWidget.h"
#include "nsIBaseWindow.h"
#include "nsICharsetConverterManager.h"
#include "nsIContent.h"
#include "nsIWebBrowserPrint.h"
#include "nsIContentViewerEdit.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocCharset.h"
#include "nsIDocument.h"
#include "nsIHTMLDocument.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMCrypto.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMDocumentView.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocumentEvent.h"
#include "nsIDOMEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMPkcs11.h"
#include "nsDOMString.h"
#include "nsIEmbeddingSiteWindow2.h"
#include "nsIEventQueueService.h"
#include "nsIEventStateManager.h"
#include "nsIHttpProtocolHandler.h"
#include "nsIJSContextStack.h"
#include "nsIJSRuntimeService.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIPrefBranch.h"
#include "nsIPresShell.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIProgrammingLanguage.h"
#include "nsIAuthPrompt.h"
#include "nsIServiceManager.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIScriptSecurityManager.h"
#include "nsIScrollableView.h"
#include "nsISelectionController.h"
#include "nsISelection.h"
#include "nsIFrameSelection.h"
#include "nsIPrompt.h"
#include "nsIWebNavigation.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebBrowserFind.h"
#include "nsIWindowMediator.h"
#include "nsIWebContentHandlerRegistrar.h"
#include "nsIComputedDOMStyle.h"
#include "nsIEntropyCollector.h"
#include "nsDOMCID.h"
#include "nsDOMError.h"
#include "nsDOMWindowUtils.h"
#include "nsIWindowWatcher.h"
#include "nsPIWindowWatcher.h"
#include "nsIContentViewer.h"
#include "nsISupportsPrimitives.h"
#include "nsIJSNativeInitializer.h"
#include "nsIFullScreen.h"
#include "nsIStringBundle.h"
#include "nsIScriptEventManager.h"
#include "nsIConsoleService.h"
#include "nsIControllerContext.h"
#include "nsGlobalWindowCommands.h"
#include "nsAutoPtr.h"
#include "nsContentUtils.h"
#include "nsCSSProps.h"
#include "nsIURIFixup.h"
#include "nsCDefaultURIFixup.h"
#include "nsIScriptError.h"
#include "plbase64.h"
#include "nsIObserverService.h"
#include "nsIDragService.h"
#include "nsIPrintSettings.h"
#include "nsIPrintSettingsService.h"
#include "nsWindowRoot.h"
#include "nsNetCID.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIBindingManager.h"
#include "nsIXBLService.h"
#include "nsIPopupWindowManager.h"
#include "prlog.h"

Go to the source code of this file.

Classes

class  WindowStateHolder
struct  nsCloseEvent

Defines

#define DOM_MIN_TIMEOUT_VALUE   10
#define DOM_MAX_TIMEOUT_VALUE   PR_BIT(8 * sizeof(PRIntervalTime) - 1)
#define FORWARD_TO_OUTER(method, args, err_rval)
#define FORWARD_TO_OUTER_VOID(method, args)
#define FORWARD_TO_OUTER_CHROME(method, args, err_rval)
#define FORWARD_TO_INNER(method, args, err_rval)
#define FORWARD_TO_INNER_VOID(method, args)
#define FORWARD_TO_INNER_CREATE(method, args)
#define WINDOWSTATEHOLDER_IID   {0x0b917c3e, 0xbd50, 0x4683, {0xaf, 0xc9, 0xc7, 0x81, 0x07, 0xae, 0x33, 0x26}}
#define COOKIE_BEHAVIOR_REJECT   2

Functions

static NS_DEFINE_CID (kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID)
static NS_DEFINE_CID (kHTTPHandlerCID, NS_HTTPPROTOCOLHANDLER_CID)
static NS_DEFINE_CID (kXULControllersCID, NS_XULCONTROLLERS_CID)
static NS_DEFINE_CID (kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID)
static NS_DEFINE_CID (kWindowMediatorCID, NS_WINDOWMEDIATOR_CID)
static NS_DEFINE_CID (kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID)
static PRBool IsAboutBlank (nsIURI *aURI)
PopupControlState PushPopupControlState (PopupControlState aState, PRBool aForce)
void PopPopupControlState (PopupControlState aState)
void MaybeSuppressDrag ()
static already_AddRefed
< nsIDocShellTreeItem
GetCallerDocShellTreeItem ()
static void ReportUseOfDeprecatedMethod (nsGlobalWindow *aWindow, const char *aWarning)
static PRBool IsPopupBlocked (nsIDOMDocument *aDoc)
static void FirePopupBlockedEvent (nsIDOMDocument *aDoc, nsIDOMWindow *aRequestingWindow, nsIURI *aPopupURI, const nsAString &aPopupWindowFeatures)
void FirePopupWindowEvent (nsIDOMDocument *aDoc)
static void PR_CALLBACK HandleCloseEvent (nsCloseEvent *aEvent)
static void PR_CALLBACK DestroyCloseEvent (nsCloseEvent *aEvent)
static PRBool Is8bit (const nsAString &aString)
static void AppendToReachableList (nsISupports *aObject, nsCOMArray< nsIDOMGCParticipant > &aArray)
 FirePendingStorageEvents (const nsAString &aKey, PRBool aData, void *userArg)
static void TitleConsoleWarning ()
nsresult NS_NewScriptGlobalObject (PRBool aIsChrome, nsIScriptGlobalObject **aResult)

Variables

static nsIEntropyCollectorgEntropyCollector = nsnull
static PRInt32 gRefCnt = 0
static PRInt32 gOpenPopupSpamCount = 0
static PopupControlState gPopupControlState = openAbused
static PRInt32 gRunningTimeoutDepth = 0
static PRBool gMouseDown = PR_FALSE
static PRBool gDragServiceDisabled = PR_FALSE
static const char sJSStackContractID [] = "@mozilla.org/js/xpc/ContextStack;1"
static const char kDOMBundleURL [] = "chrome://global/locale/commonDialogs.properties"
static const char kDOMSecurityWarningsBundleURL [] = "chrome://global/locale/dom/dom.properties"
static const char kCryptoContractID [] = NS_CRYPTO_CONTRACTID
static const char kPkcs11ContractID [] = NS_PKCS11_CONTRACTID
static const char kSetIntervalStr [] = "setInterval"
static const char kSetTimeoutStr [] = "setTimeout"

Define Documentation

Definition at line 8238 of file nsGlobalWindow.cpp.

Definition at line 206 of file nsGlobalWindow.cpp.

Definition at line 201 of file nsGlobalWindow.cpp.

#define FORWARD_TO_INNER (   method,
  args,
  err_rval 
)
Value:
PR_BEGIN_MACRO                                                              \
  if (IsOuterWindow()) {                                                      \
    if (!mInnerWindow) {                                                      \
      NS_WARNING("No inner window available!");                               \
      return err_rval;                                                        \
    }                                                                         \
    return GetCurrentInnerWindowInternal()->method args;                      \
  }                                                                           \
  PR_END_MACRO

Definition at line 245 of file nsGlobalWindow.cpp.

Value:
PR_BEGIN_MACRO                                                              \
  if (IsOuterWindow()) {                                                      \
    if (!mInnerWindow) {                                                      \
      if (mIsClosed) {                                                        \
        return NS_ERROR_NOT_AVAILABLE;                                        \
      }                                                                       \
      nsCOMPtr<nsIDOMDocument> doc;                                           \
      nsresult fwdic_nr = GetDocument(getter_AddRefs(doc));                   \
      NS_ENSURE_SUCCESS(fwdic_nr, fwdic_nr);                                  \
      if (!mInnerWindow) {                                                    \
        return NS_ERROR_NOT_AVAILABLE;                                        \
      }                                                                       \
    }                                                                         \
    return GetCurrentInnerWindowInternal()->method args;                      \
  }                                                                           \
  PR_END_MACRO

Definition at line 270 of file nsGlobalWindow.cpp.

Value:
PR_BEGIN_MACRO                                                              \
  if (IsOuterWindow()) {                                                      \
    if (!mInnerWindow) {                                                      \
      NS_WARNING("No inner window available!");                               \
      return;                                                                 \
    }                                                                         \
    GetCurrentInnerWindowInternal()->method args;                             \
    return;                                                                   \
  }                                                                           \
  PR_END_MACRO

Definition at line 256 of file nsGlobalWindow.cpp.

#define FORWARD_TO_OUTER (   method,
  args,
  err_rval 
)
Value:
PR_BEGIN_MACRO                                                              \
  if (IsInnerWindow()) {                                                      \
    nsGlobalWindow *outer = GetOuterWindowInternal();                         \
    if (!outer) {                                                             \
      NS_WARNING("No outer window available!");                               \
      return err_rval;                                                        \
    }                                                                         \
    return outer->method args;                                                \
  }                                                                           \
  PR_END_MACRO

Definition at line 208 of file nsGlobalWindow.cpp.

#define FORWARD_TO_OUTER_CHROME (   method,
  args,
  err_rval 
)
Value:
PR_BEGIN_MACRO                                                              \
  if (IsInnerWindow()) {                                                      \
    nsGlobalWindow *outer = GetOuterWindowInternal();                         \
    if (!outer) {                                                             \
      NS_WARNING("No outer window available!");                               \
      return err_rval;                                                        \
    }                                                                         \
    return ((nsGlobalChromeWindow *)outer)->method args;                      \
  }                                                                           \
  PR_END_MACRO

Definition at line 233 of file nsGlobalWindow.cpp.

Value:
PR_BEGIN_MACRO                                                              \
  if (IsInnerWindow()) {                                                      \
    nsGlobalWindow *outer = GetOuterWindowInternal();                         \
    if (!outer) {                                                             \
      NS_WARNING("No outer window available!");                               \
      return;                                                                 \
    }                                                                         \
    outer->method args;                                                       \
    return;                                                                   \
  }                                                                           \
  PR_END_MACRO

Definition at line 220 of file nsGlobalWindow.cpp.

#define WINDOWSTATEHOLDER_IID   {0x0b917c3e, 0xbd50, 0x4683, {0xaf, 0xc9, 0xc7, 0x81, 0x07, 0xae, 0x33, 0x26}}

Definition at line 793 of file nsGlobalWindow.cpp.


Function Documentation

static void AppendToReachableList ( nsISupports *  aObject,
nsCOMArray< nsIDOMGCParticipant > &  aArray 
) [static]

Definition at line 5514 of file nsGlobalWindow.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void PR_CALLBACK DestroyCloseEvent ( nsCloseEvent aEvent) [static]

Definition at line 4624 of file nsGlobalWindow.cpp.

{
  delete aEvent;
}

Here is the caller graph for this function:

FirePendingStorageEvents ( const nsAString &  aKey,
PRBool  aData,
void userArg 
)

Definition at line 6089 of file nsGlobalWindow.cpp.

{
  nsGlobalWindow *win = NS_STATIC_CAST(nsGlobalWindow *, userArg);

  nsCOMPtr<nsIDOMStorage> storage;
  win->GetSessionStorage(getter_AddRefs(storage));

  if (storage) {
    win->Observe(storage, "dom-storage-changed",
                 aKey.IsEmpty() ? nsnull : PromiseFlatString(aKey).get());
  }

  return PL_DHASH_NEXT;
}

Here is the call graph for this function:

static void FirePopupBlockedEvent ( nsIDOMDocument aDoc,
nsIDOMWindow aRequestingWindow,
nsIURI aPopupURI,
const nsAString &  aPopupWindowFeatures 
) [static]

Definition at line 4263 of file nsGlobalWindow.cpp.

{
  if (aDoc) {
    // Fire a "DOMPopupBlocked" event so that the UI can hear about
    // blocked popups.
    nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(aDoc));
    nsCOMPtr<nsIDOMEvent> event;
    docEvent->CreateEvent(NS_LITERAL_STRING("PopupBlockedEvents"),
                          getter_AddRefs(event));
    nsCOMPtr<nsIDOMPopupBlockedEvent_MOZILLA_1_8_BRANCH> pbev = 
      do_QueryInterface(event);
    if (pbev) {
      pbev->InitPopupBlockedEvent(NS_LITERAL_STRING("DOMPopupBlocked"),
                                  PR_TRUE, PR_TRUE, aRequestingWindow,
                                  aPopupURI, aPopupWindowFeatures);
      nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
      privateEvent->SetTrusted(PR_TRUE);

      nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(aDoc));
      PRBool defaultActionEnabled;
      targ->DispatchEvent(event, &defaultActionEnabled);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4290 of file nsGlobalWindow.cpp.

{
  if (aDoc) {
    // Fire a "PopupWindow" event
    nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(aDoc));
    nsCOMPtr<nsIDOMEvent> event;
    docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
    if (event) {
      event->InitEvent(NS_LITERAL_STRING("PopupWindow"), PR_TRUE, PR_TRUE);

      nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
      privateEvent->SetTrusted(PR_TRUE);

      PRBool defaultActionEnabled;
      nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(aDoc));
      targ->DispatchEvent(event, &defaultActionEnabled);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3138 of file nsGlobalWindow.cpp.

{
  nsCOMPtr<nsIJSContextStack> stack =
    do_GetService(sJSStackContractID);

  JSContext *cx = nsnull;

  if (stack) {
    stack->Peek(&cx);
  }

  nsIDocShellTreeItem *callerItem = nsnull;

  if (cx) {
    nsCOMPtr<nsIWebNavigation> callerWebNav =
      do_GetInterface(nsJSUtils::GetDynamicScriptGlobal(cx));

    if (callerWebNav) {
      CallQueryInterface(callerWebNav, &callerItem);
    }
  }

  return callerItem;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void PR_CALLBACK HandleCloseEvent ( nsCloseEvent aEvent) [static]

Definition at line 4620 of file nsGlobalWindow.cpp.

{
  aEvent->HandleEvent();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool Is8bit ( const nsAString &  aString) [static]

Definition at line 5211 of file nsGlobalWindow.cpp.

{
  static const PRUnichar EIGHT_BIT = PRUnichar(~0x00FF);

  nsAString::const_iterator done_reading;
  aString.EndReading(done_reading);

  // for each chunk of |aString|...
  PRUint32 fragmentLength = 0;
  nsAString::const_iterator iter;
  for (aString.BeginReading(iter); iter != done_reading;
       iter.advance(PRInt32(fragmentLength))) {
    fragmentLength = PRUint32(iter.size_forward());
    const PRUnichar* c = iter.get();
    const PRUnichar* fragmentEnd = c + fragmentLength;

    // for each character in this chunk...
    while (c < fragmentEnd)
      if (*c++ & EIGHT_BIT)
        return PR_FALSE;
  }

  return PR_TRUE;
}
static PRBool IsAboutBlank ( nsIURI aURI) [static]

Definition at line 309 of file nsGlobalWindow.cpp.

{
  NS_PRECONDITION(aURI, "Must have URI");
    
  // GetSpec can be expensive for some URIs, so check the scheme first.
  PRBool isAbout = PR_FALSE;
  if (NS_FAILED(aURI->SchemeIs("about", &isAbout)) || !isAbout) {
    return PR_FALSE;
  }
    
  nsCAutoString str;
  aURI->GetSpec(str);
  return str.EqualsLiteral("about:blank");  
}
static PRBool IsPopupBlocked ( nsIDOMDocument aDoc) [static]

Definition at line 4242 of file nsGlobalWindow.cpp.

{
  nsCOMPtr<nsIPopupWindowManager> pm =
    do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID);

  if (!pm) {
    return PR_FALSE;
  }

  PRBool blocked = PR_TRUE;
  nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDoc));

  if (doc) {
    PRUint32 permission = nsIPopupWindowManager::ALLOW_POPUP;
    pm->TestPermission(doc->GetDocumentURI(), &permission);
    blocked = (permission == nsIPopupWindowManager::DENY_POPUP);
  }
  return blocked;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2552 of file nsGlobalWindow.cpp.

                    {
  if (gMouseDown && !gDragServiceDisabled) {
    nsCOMPtr<nsIDragService_1_8_BRANCH> ds18 =
      do_GetService("@mozilla.org/widget/dragservice;1");
    NS_WARN_IF_FALSE(ds18, "No drag service?");
    if (ds18) {
      gDragServiceDisabled = PR_TRUE;
      ds18->Suppress();
    }
  }
}

Here is the call graph for this function:

static NS_DEFINE_CID ( kHTTPHandlerCID  ,
NS_HTTPPROTOCOLHANDLER_CID   
) [static]
static NS_DEFINE_CID ( kXULControllersCID  ,
NS_XULCONTROLLERS_CID   
) [static]
static NS_DEFINE_CID ( kCharsetConverterManagerCID  ,
NS_ICHARSETCONVERTERMANAGER_CID   
) [static]
static NS_DEFINE_CID ( kWindowMediatorCID  ,
NS_WINDOWMEDIATOR_CID   
) [static]
static NS_DEFINE_CID ( kCStringBundleServiceCID  ,
NS_STRINGBUNDLESERVICE_CID   
) [static]

Definition at line 7893 of file nsGlobalWindow.cpp.

{
  *aResult = nsnull;

  nsGlobalWindow *global;

  if (aIsChrome) {
    global = new nsGlobalChromeWindow(nsnull);
  } else {
    global = new nsGlobalWindow(nsnull);
  }

  NS_ENSURE_TRUE(global, NS_ERROR_OUT_OF_MEMORY);

  return CallQueryInterface(NS_STATIC_CAST(nsIScriptGlobalObject *, global),
                            aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 769 of file nsGlobalWindow.cpp.

{
  gPopupControlState = aState;
}

Definition at line 757 of file nsGlobalWindow.cpp.

{
  PopupControlState oldState = gPopupControlState;

  if (aState < gPopupControlState || aForce) {
    gPopupControlState = aState;
  }

  return oldState;
}
static void ReportUseOfDeprecatedMethod ( nsGlobalWindow aWindow,
const char *  aWarning 
) [static]

Definition at line 4180 of file nsGlobalWindow.cpp.

Here is the call graph for this function:

static void TitleConsoleWarning ( ) [static]

Definition at line 7674 of file nsGlobalWindow.cpp.

{
  nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
  if (console)
    console->LogStringMessage(NS_LITERAL_STRING("Deprecated property window.title used.  Please use document.title instead.").get());
}

Here is the call graph for this function:


Variable Documentation

Definition at line 190 of file nsGlobalWindow.cpp.

Definition at line 184 of file nsGlobalWindow.cpp.

Definition at line 189 of file nsGlobalWindow.cpp.

Definition at line 186 of file nsGlobalWindow.cpp.

Definition at line 187 of file nsGlobalWindow.cpp.

PRInt32 gRefCnt = 0 [static]

Definition at line 185 of file nsGlobalWindow.cpp.

Definition at line 188 of file nsGlobalWindow.cpp.

Definition at line 305 of file nsGlobalWindow.cpp.

const char kDOMBundleURL[] = "chrome://global/locale/commonDialogs.properties" [static]

Definition at line 302 of file nsGlobalWindow.cpp.

const char kDOMSecurityWarningsBundleURL[] = "chrome://global/locale/dom/dom.properties" [static]

Definition at line 303 of file nsGlobalWindow.cpp.

Definition at line 306 of file nsGlobalWindow.cpp.

const char kSetIntervalStr[] = "setInterval" [static]

Definition at line 6422 of file nsGlobalWindow.cpp.

const char kSetTimeoutStr[] = "setTimeout" [static]

Definition at line 6423 of file nsGlobalWindow.cpp.

const char sJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1" [static]

Definition at line 300 of file nsGlobalWindow.cpp.