Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsHTMLDocument.cpp File Reference
#include "nsICharsetAlias.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsPrintfCString.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsHTMLDocument.h"
#include "nsIParserFilter.h"
#include "nsIHTMLContentSink.h"
#include "nsIXMLContentSink.h"
#include "nsHTMLParts.h"
#include "nsHTMLStyleSheet.h"
#include "nsHTMLAtoms.h"
#include "nsLayoutAtoms.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMElement.h"
#include "nsIDOMText.h"
#include "nsIDOMComment.h"
#include "nsIDOMDOMImplementation.h"
#include "nsIDOMDocumentType.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsDOMString.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
#include "nsIIOService.h"
#include "nsNetUtil.h"
#include "nsIContentViewerContainer.h"
#include "nsIContentViewer.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebNavigation.h"
#include "nsIBaseWindow.h"
#include "nsIWebShellServices.h"
#include "nsIDocumentLoader.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIXPConnect.h"
#include "nsContentList.h"
#include "nsDOMError.h"
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsIScrollableView.h"
#include "nsNetCID.h"
#include "nsICookieService.h"
#include "nsIServiceManager.h"
#include "nsIConsoleService.h"
#include "nsIComponentManager.h"
#include "nsParserCIID.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsINameSpaceManager.h"
#include "nsGenericHTMLElement.h"
#include "nsGenericDOMNodeList.h"
#include "nsICSSLoader.h"
#include "nsIHttpChannel.h"
#include "nsIFile.h"
#include "nsIEventListenerManager.h"
#include "nsISelectElement.h"
#include "nsIFrameSelection.h"
#include "nsISelectionPrivate.h"
#include "nsICharsetDetector.h"
#include "nsICharsetDetectionAdaptor.h"
#include "nsCharsetDetectionAdaptorCID.h"
#include "nsContentUtils.h"
#include "nsJSUtils.h"
#include "nsIDocumentCharsetInfo.h"
#include "nsIDocumentEncoder.h"
#include "nsICharsetResolver.h"
#include "nsICachingChannel.h"
#include "nsICacheEntryDescriptor.h"
#include "nsIJSContextStack.h"
#include "nsIDocumentViewer.h"
#include "nsIWyciwygChannel.h"
#include "nsIScriptError.h"
#include "nsArray.h"
#include "nsIPrompt.h"
#include "nsBidiUtils.h"
#include "nsIEditingSession.h"
#include "nsIEditor.h"
#include "nsNodeInfoManager.h"
#include "prmem.h"
#include "prtime.h"

Go to the source code of this file.

Classes

class  IdAndNameMapEntry
struct  MidasCommand
struct  MidasParam

Defines

#define NS_MAX_DOCUMENT_WRITE_DEPTH   20
#define DETECTOR_CONTRACTID_MAX   127
#define ID_NOT_IN_DOCUMENT   ((nsIContent *)1)
#define NAME_NOT_VALID   ((nsBaseContentList*)1)
#define MidasCommandCount   ((sizeof(gMidasCommandTable) / sizeof(struct MidasCommand)) - 1)
#define MidasParamCount   ((sizeof(gMidasParamTable) / sizeof(struct MidasParam)) - 1)

Functions

static NS_DEFINE_CID (kCookieServiceCID, NS_COOKIESERVICE_CID)
static NS_DEFINE_CID (kRDFServiceCID, NS_RDFSERVICE_CID)
static NS_DEFINE_CID (kCharsetAliasCID, NS_CHARSETALIAS_CID)
static PRBool IsNamedItem (nsIContent *aContent, nsIAtom *aTag, nsAString &aName)
nsIContentMatchElementId (nsIContent *aContent, const nsACString &aUTF8Id, const nsAString &aId)
static NS_DEFINE_CID (kCParserCID, NS_PARSER_CID)
static int PR_CALLBACK MyPrefChangedCallback (const char *aPrefName, void *instance_data)
nsresult NS_NewHTMLDocument (nsIDocument **aInstancePtrResult)
 IdAndNameHashGetKey (PLDHashTable *table, PLDHashEntryHdr *entry)
 IdAndNameHashHashKey (PLDHashTable *table, const void *key)
 IdAndNameHashMatchEntry (PLDHashTable *table, const PLDHashEntryHdr *entry, const void *key)
 IdAndNameHashClearEntry (PLDHashTable *table, PLDHashEntryHdr *entry)
 IdAndNameHashInitEntry (PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
static PRBool CheckSameOrigin (nsIDocument *aDoc1, nsIDocument *aDoc2)
static void ReportUseOfDeprecatedMethod (nsHTMLDocument *aDoc, const char *aWarning)
 IdAndNameMapEntryRemoveCallback (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)
static nsresult ReserveNameInHash (const nsAString &aName, PLDHashTable *aHash)
static void FindNamedItems (const nsAString &aName, nsIContent *aContent, IdAndNameMapEntry &aEntry, PRBool aIsXHTML)

Variables

static char g_detector_contractid [DETECTOR_CONTRACTID_MAX+1]
static PRBool gInitDetector = PR_FALSE
static PRBool gPlugDetector = PR_FALSE
const PRInt32 kForward = 0
const PRInt32 kBackward = 1
static struct MidasCommand []
static struct MidasParam []

Class Documentation

struct MidasCommand

Definition at line 3805 of file nsHTMLDocument.cpp.

Class Members
PRPackedBool convertToBoolean
const char * incomingCommandString
const char * internalCommandString
const char * internalParamString
PRPackedBool useNewParam
struct MidasParam

Definition at line 3870 of file nsHTMLDocument.cpp.

Class Members
const char * incomingParamString
const char * internalParamString

Define Documentation

Definition at line 137 of file nsHTMLDocument.cpp.

Definition at line 152 of file nsHTMLDocument.cpp.

#define MidasCommandCount   ((sizeof(gMidasCommandTable) / sizeof(struct MidasCommand)) - 1)

Definition at line 3868 of file nsHTMLDocument.cpp.

#define MidasParamCount   ((sizeof(gMidasParamTable) / sizeof(struct MidasParam)) - 1)

Definition at line 3888 of file nsHTMLDocument.cpp.

Definition at line 153 of file nsHTMLDocument.cpp.

Definition at line 135 of file nsHTMLDocument.cpp.


Function Documentation

static PRBool CheckSameOrigin ( nsIDocument aDoc1,
nsIDocument aDoc2 
) [static]

Definition at line 557 of file nsHTMLDocument.cpp.

{
  NS_PRECONDITION(aDoc1, "Null doc?");
  NS_PRECONDITION(aDoc2, "Null doc?");

  nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
  if (!secMan) {
    return PR_FALSE;
  }

  nsIPrincipal* principal1 = aDoc1->GetPrincipal();
  nsIPrincipal* principal2 = aDoc2->GetPrincipal();

  if (!principal1 || !principal2) {
    return PR_FALSE;
  }

  return
    NS_SUCCEEDED(secMan->CheckSameOriginPrincipal(principal1, principal2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void FindNamedItems ( const nsAString &  aName,
nsIContent aContent,
IdAndNameMapEntry aEntry,
PRBool  aIsXHTML 
) [static]

Definition at line 3334 of file nsHTMLDocument.cpp.

{
  NS_ASSERTION(aEntry.mContentList,
               "Entry w/o content list passed to FindNamedItems()!");
  NS_ASSERTION(aEntry.mContentList != NAME_NOT_VALID,
               "Entry that should never have a list passed to FindNamedItems()!");

  if (aContent->IsContentOfType(nsIContent::eTEXT)) {
    // Text nodes are not named items nor can they have children.
    return;
  }

  nsAutoString value;

  if (!aIsXHTML && IsNamedItem(aContent, aContent->Tag(), value) &&
      value.Equals(aName)) {
    aEntry.mContentList->AppendElement(aContent);
  }

  if (!aEntry.mIdContent) {
    nsIAtom* idAttr = aContent->GetIDAttributeName();
    if (idAttr) {
      aContent->GetAttr(kNameSpaceID_None, idAttr, value);

      if (value.Equals(aName)) {
        aEntry.mIdContent = aContent;
      }
    }
  }

  PRUint32 i, count = aContent->GetChildCount();

  for (i = 0; i < count; ++i) {
    FindNamedItems(aName, aContent->GetChildAt(i), aEntry, aIsXHTML);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 262 of file nsHTMLDocument.cpp.

{
  IdAndNameMapEntry *e = NS_STATIC_CAST(IdAndNameMapEntry *, entry);

  // An entry is being cleared, let the entry do its own cleanup.
  e->~IdAndNameMapEntry();
}

Here is the call graph for this function:

Here is the caller graph for this function:

IdAndNameHashGetKey ( PLDHashTable table,
PLDHashEntryHdr entry 
)

Definition at line 235 of file nsHTMLDocument.cpp.

{
  IdAndNameMapEntry *e = NS_STATIC_CAST(IdAndNameMapEntry *, entry);

  return NS_STATIC_CAST(const nsAString *, &e->mKey);
}

Here is the caller graph for this function:

IdAndNameHashHashKey ( PLDHashTable table,
const void key 
)

Definition at line 243 of file nsHTMLDocument.cpp.

{
  const nsAString *str = NS_STATIC_CAST(const nsAString *, key);

  return HashString(*str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

IdAndNameHashInitEntry ( PLDHashTable table,
PLDHashEntryHdr entry,
const void key 
)

Definition at line 271 of file nsHTMLDocument.cpp.

{
  const nsAString *keyStr = NS_STATIC_CAST(const nsAString *, key);

  // Inititlize the entry with placement new
  new (entry) IdAndNameMapEntry(*keyStr);
  return PR_TRUE;
}

Here is the caller graph for this function:

IdAndNameHashMatchEntry ( PLDHashTable table,
const PLDHashEntryHdr entry,
const void key 
)

Definition at line 251 of file nsHTMLDocument.cpp.

{
  const IdAndNameMapEntry *e =
    NS_STATIC_CAST(const IdAndNameMapEntry *, entry);
  const nsAString *str = NS_STATIC_CAST(const nsAString *, key);

  return str->Equals(e->mKey);
}

Here is the caller graph for this function:

IdAndNameMapEntryRemoveCallback ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void arg 
)

Definition at line 3046 of file nsHTMLDocument.cpp.

{
  return PL_DHASH_REMOVE;
}

Here is the caller graph for this function:

static PRBool IsNamedItem ( nsIContent aContent,
nsIAtom aTag,
nsAString &  aName 
) [static]

Definition at line 3119 of file nsHTMLDocument.cpp.

{
  // Only the content types reflected in Level 0 with a NAME
  // attribute are registered. Images, layers and forms always get
  // reflected up to the document. Applets and embeds only go
  // to the closest container (which could be a form).
  if (aTag == nsHTMLAtoms::img    ||
      aTag == nsHTMLAtoms::form   ||
      aTag == nsHTMLAtoms::applet ||
      aTag == nsHTMLAtoms::embed  ||
      aTag == nsHTMLAtoms::object) {
    aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, aName);

    if (!aName.IsEmpty()) {
      return PR_TRUE;
    }
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIContent* MatchElementId ( nsIContent aContent,
const nsACString &  aUTF8Id,
const nsAString &  aId 
)

Definition at line 739 of file nsXMLDocument.cpp.

{
  if (aContent->IsContentOfType(nsIContent::eHTML)) {
    if (aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::id)) {
      nsAutoString value;
      aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id, value);

      if (aId.Equals(value)) {
        return aContent;
      }
    }
  }
  else if (aContent->IsContentOfType(nsIContent::eELEMENT)) {
    nsCOMPtr<nsIXMLContent> xmlContent = do_QueryInterface(aContent);    

    if (xmlContent) {
      nsIAtom* value = xmlContent->GetID();
      if (value && value->EqualsUTF8(aUTF8Id)) {
        return aContent;
      }
    }
  }
  
  nsIContent *result = nsnull;
  PRUint32 i, count = aContent->GetChildCount();

  for (i = 0; i < count && result == nsnull; i++) {
    result = MatchElementId(aContent->GetChildAt(i), aUTF8Id, aId);
  }  

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int PR_CALLBACK MyPrefChangedCallback ( const char *  aPrefName,
void instance_data 
) [static]

Definition at line 172 of file nsHTMLDocument.cpp.

{
  const nsAdoptingString& detector_name =
    nsContentUtils::GetLocalizedStringPref("intl.charset.detector");

  if (detector_name.Length() > 0) {
    PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,
               DETECTOR_CONTRACTID_MAX);
    PL_strncat(g_detector_contractid,
               NS_ConvertUCS2toUTF8(detector_name).get(),
               DETECTOR_CONTRACTID_MAX);
    gPlugDetector = PR_TRUE;
  } else {
    g_detector_contractid[0]=0;
    gPlugDetector = PR_FALSE;
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kCookieServiceCID  ,
NS_COOKIESERVICE_CID   
) [static]
static NS_DEFINE_CID ( kRDFServiceCID  ,
NS_RDFSERVICE_CID   
) [static]
static NS_DEFINE_CID ( kCharsetAliasCID  ,
NS_CHARSETALIAS_CID   
) [static]
static NS_DEFINE_CID ( kCParserCID  ,
NS_PARSER_CID   
) [static]
nsresult NS_NewHTMLDocument ( nsIDocument **  aInstancePtrResult)

Definition at line 196 of file nsHTMLDocument.cpp.

{
  nsHTMLDocument* doc = new nsHTMLDocument();
  NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);

  NS_ADDREF(doc);
  nsresult rv = doc->Init();

  if (NS_FAILED(rv)) {
    NS_RELEASE(doc);
  }

  *aInstancePtrResult = doc;

  return rv;
}

Here is the call graph for this function:

static void ReportUseOfDeprecatedMethod ( nsHTMLDocument aDoc,
const char *  aWarning 
) [static]

Definition at line 2964 of file nsHTMLDocument.cpp.

Here is the call graph for this function:

static nsresult ReserveNameInHash ( const nsAString &  aName,
PLDHashTable aHash 
) [static]

Definition at line 3061 of file nsHTMLDocument.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 138 of file nsHTMLDocument.cpp.

Definition at line 139 of file nsHTMLDocument.cpp.

Definition at line 140 of file nsHTMLDocument.cpp.

Definition at line 147 of file nsHTMLDocument.cpp.

Definition at line 146 of file nsHTMLDocument.cpp.

struct MidasCommand[] [static]

Definition at line 3813 of file nsHTMLDocument.cpp.

struct MidasParam[] [static]
Initial value:
 {
  { "<P>",                "P" },
  { "<H1>",               "H1" },
  { "<H2>",               "H2" },
  { "<H3>",               "H3" },
  { "<H4>",               "H4" },
  { "<H5>",               "H5" },
  { "<H6>",               "H6" },
  { "<PRE>",              "PRE" },
  { "<ADDRESS>",          "ADDRESS" },
  { NULL, NULL }
}

Definition at line 3875 of file nsHTMLDocument.cpp.