Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
nsHTMLTags Class Reference

#include <nsHTMLTags.h>

List of all members.

Static Public Member Functions

static nsresult AddRefTable (void)
static void ReleaseTable (void)
static nsHTMLTag LookupTag (const nsAString &aTagName)
static nsHTMLTag CaseSensitiveLookupTag (const PRUnichar *aTagName)
static const PRUnicharGetStringValue (nsHTMLTag aEnum)
static nsIAtomGetAtom (nsHTMLTag aEnum)

Detailed Description

Definition at line 69 of file nsHTMLTags.h.


Member Function Documentation

Definition at line 313 of file nsHTMLTags.cpp.

{
  if (gTableRefCount++ == 0) {
    NS_ASSERTION(!gTagTable, "pre existing hash!");

    gTagTable = PL_NewHashTable(64, HTMLTagsHashCodeUCPtr,
                                HTMLTagsKeyCompareUCPtr, PL_CompareValues,
                                nsnull, nsnull);
    NS_ENSURE_TRUE(gTagTable, NS_ERROR_OUT_OF_MEMORY);

    // Fill in gTagTable with the above static PRUnichar strings as
    // keys and the value of the corresponding enum as the value in
    // the table.

    PRInt32 i;
    for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
      PRUint32 len = nsCRT::strlen(kTagUnicodeTable[i]);

      PL_HashTableAdd(gTagTable, kTagUnicodeTable[i],
                      NS_INT32_TO_PTR(i + 1));

      if (len > sMaxTagNameLength) {
        sMaxTagNameLength = len;
      }
    }

    NS_ASSERTION(sMaxTagNameLength == NS_HTMLTAG_NAME_MAX_LENGTH,
                 "NS_HTMLTAG_NAME_MAX_LENGTH not set correctly!");

    // Fill in our static atom pointers
    NS_RegisterStaticAtoms(kTagAtoms_info, NS_ARRAY_LENGTH(kTagAtoms_info));

#ifdef DEBUG
    {
      // let's verify that all names in the the table are lowercase...
      for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
        nsCAutoString temp1(kTagAtoms_info[i].mString);
        nsCAutoString temp2(kTagAtoms_info[i].mString);
        ToLowerCase(temp1);
        NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
      }

      // let's verify that all names in the unicode strings above are
      // correct.
      for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
        nsAutoString temp1(kTagUnicodeTable[i]);
        nsAutoString temp2; temp2.AssignWithConversion(kTagAtoms_info[i].mString);
        NS_ASSERTION(temp1.Equals(temp2), "Bad unicode tag name!");
      }
    }
#endif
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 386 of file nsHTMLTags.cpp.

{
  NS_ASSERTION(gTagTable, "no lookup table, needs addref");
  NS_ASSERTION(aTagName, "null tagname!");

  PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));

  return tag == eHTMLTag_unknown ? eHTMLTag_userdefined : (nsHTMLTag)tag;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIAtom * nsHTMLTags::GetAtom ( nsHTMLTag  aEnum) [static]

Definition at line 448 of file nsHTMLTags.cpp.

{
  if (aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX) {
    return nsnull;
  }

  return kTagAtomTable[aEnum - 1];
}

Definition at line 437 of file nsHTMLTags.cpp.

{
  if (aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX) {
    return nsnull;
  }

  return kTagUnicodeTable[aEnum - 1];
}

Here is the caller graph for this function:

nsHTMLTag nsHTMLTags::LookupTag ( const nsAString &  aTagName) [static]

Definition at line 398 of file nsHTMLTags.cpp.

{
  PRUint32 length = aTagName.Length();

  if (length > sMaxTagNameLength) {
    return eHTMLTag_userdefined;
  }

  static PRUnichar buf[NS_HTMLTAG_NAME_MAX_LENGTH + 1];

  nsAString::const_iterator iter;
  PRUint32 i = 0;
  PRUnichar c;

  aTagName.BeginReading(iter);

  // Fast lowercasing-while-copying of ASCII characters into a
  // PRUnichar buffer

  while (i < length) {
    c = *iter;

    if (c <= 'Z' && c >= 'A') {
      c |= 0x20; // Lowercase the ASCII character.
    }

    buf[i] = c; // Copy ASCII character.

    ++i;
    ++iter;
  }

  buf[i] = 0;

  return CaseSensitiveLookupTag(buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 371 of file nsHTMLTags.cpp.

{
  if (0 == --gTableRefCount) {
    if (gTagTable) {
      // Nothing to delete/free in this table, just destroy the table.

      PL_HashTableDestroy(gTagTable);

      gTagTable = nsnull;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


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