Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsLocation.cpp File Reference
#include "nsGlobalWindow.h"
#include "nsIScriptSecurityManager.h"
#include "nsIScriptContext.h"
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIWebNavigation.h"
#include "nsCDefaultURIFixup.h"
#include "nsIURIFixup.h"
#include "nsIURL.h"
#include "nsIJARURI.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "nsNetUtil.h"
#include "plstr.h"
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsEscape.h"
#include "nsJSUtils.h"
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIJSContextStack.h"
#include "nsXPIDLString.h"
#include "nsDOMError.h"
#include "nsDOMClassInfo.h"
#include "nsCRT.h"
#include "nsIProtocolHandler.h"
#include "nsReadableUtils.h"
#include "nsITextToSubURI.h"
#include "nsContentUtils.h"

Go to the source code of this file.

Functions

static nsresult GetContextFromStack (nsIJSContextStack *aStack, JSContext **aContext)
static nsresult GetDocumentCharacterSetForURI (const nsAString &aHref, nsACString &aCharset)

Function Documentation

static nsresult GetContextFromStack ( nsIJSContextStack aStack,
JSContext **  aContext 
) [static]

Definition at line 77 of file nsLocation.cpp.

{
  nsCOMPtr<nsIJSContextStackIterator>
    iterator(do_CreateInstance("@mozilla.org/js/xpc/ContextStackIterator;1"));
  NS_ENSURE_TRUE(iterator, NS_ERROR_FAILURE);

  nsresult rv = iterator->Reset(aStack);
  NS_ENSURE_SUCCESS(rv, rv);
  
  PRBool done;
  while (NS_SUCCEEDED(iterator->Done(&done)) && !done) {
    rv = iterator->Prev(aContext);
    NS_ASSERTION(NS_SUCCEEDED(rv), "Broken iterator implementation");

    if (nsJSUtils::GetDynamicScriptContext(*aContext)) {
      return NS_OK;
    }
  }

  *aContext = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetDocumentCharacterSetForURI ( const nsAString &  aHref,
nsACString &  aCharset 
) [static]

Definition at line 102 of file nsLocation.cpp.

{
  aCharset.Truncate();

  nsresult rv;

  nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  JSContext *cx;

  rv = GetContextFromStack(stack, &cx);
  NS_ENSURE_SUCCESS(rv, rv);

  if (cx) {
    nsCOMPtr<nsIDOMWindow> window =
      do_QueryInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
    NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);

    nsCOMPtr<nsIDOMDocument> domDoc;
    rv = window->GetDocument(getter_AddRefs(domDoc));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));

    if (doc) {
      aCharset = doc->GetDocumentCharacterSet();
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: