Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsParserService Class Reference

#include <nsParserService.h>

Inheritance diagram for nsParserService:
Inheritance graph
[legend]
Collaboration diagram for nsParserService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsParserService ()
virtual ~nsParserService ()
NS_DECL_ISUPPORTS PRInt32 HTMLAtomTagToId (nsIAtom *aAtom) const
 Looks up the nsHTMLTag enum value corresponding to the tag in aAtom.
PRInt32 HTMLCaseSensitiveAtomTagToId (nsIAtom *aAtom) const
 Looks up the nsHTMLTag enum value corresponding to the tag in aAtom.
PRInt32 HTMLStringTagToId (const nsAString &aTag) const
 Looks up the nsHTMLTag enum value corresponding to the tag in aTag.
const PRUnicharHTMLIdToStringTag (PRInt32 aId) const
 Gets the tag corresponding to the nsHTMLTag enum value in aId.
nsIAtomHTMLIdToAtomTag (PRInt32 aId) const
 Gets the tag corresponding to the nsHTMLTag enum value in aId.
NS_IMETHOD HTMLConvertEntityToUnicode (const nsAString &aEntity, PRInt32 *aUnicode) const
NS_IMETHOD HTMLConvertUnicodeToEntity (PRInt32 aUnicode, nsCString &aEntity) const
NS_IMETHOD IsContainer (PRInt32 aId, PRBool &aIsContainer) const
NS_IMETHOD IsBlock (PRInt32 aId, PRBool &aIsBlock) const
NS_IMETHOD RegisterObserver (nsIElementObserver *aObserver, const nsAString &aTopic, const eHTMLTags *aTags=nsnull)
NS_IMETHOD UnregisterObserver (nsIElementObserver *aObserver, const nsAString &aTopic)
NS_IMETHOD GetTopicObservers (const nsAString &aTopic, nsIObserverEntry **aEntry)
nsresult CheckQName (const nsASingleFragmentString &aQName, PRBool aNamespaceAware, const PRUnichar **aColon)
PRBool IsXMLLetter (PRUnichar aChar)
PRBool IsXMLNCNameChar (PRUnichar aChar)
PRUint32 DecodeEntity (const PRUnichar *aStart, const PRUnichar *aEnd, const PRUnichar **aNext, PRUnichar *aResult)
 Decodes an entity into a UTF-16 character.

Protected Member Functions

nsObserverEntryGetEntry (const nsAString &aTopic)
nsresult CreateEntry (const nsAString &aTopic, nsObserverEntry **aEntry)

Protected Attributes

nsDeque mEntries
PRBool mHaveNotifiedCategoryObservers

Detailed Description

Definition at line 50 of file nsParserService.h.


Constructor & Destructor Documentation

Definition at line 50 of file nsParserService.cpp.

Definition at line 55 of file nsParserService.cpp.

{
  nsObserverEntry *entry = nsnull;
  while( (entry = NS_STATIC_CAST(nsObserverEntry*,mEntries.Pop())) ) {
    NS_RELEASE(entry);
  }
}

Member Function Documentation

nsresult nsParserService::CheckQName ( const nsASingleFragmentString aQName,
PRBool  aNamespaceAware,
const PRUnichar **  aColon 
) [virtual]

Implements nsIParserService.

Definition at line 203 of file nsParserService.cpp.

{
  const char* colon;
  const PRUnichar *begin, *end;
  aQName.BeginReading(begin);
  aQName.EndReading(end);
  int result = MOZ_XMLCheckQName(NS_REINTERPRET_CAST(const char*, begin),
                                 NS_REINTERPRET_CAST(const char*, end),
                                 aNamespaceAware, &colon);
  *aColon = NS_REINTERPRET_CAST(const PRUnichar*, colon);

  if (result == 0) {
    return NS_OK;
  }

  // MOZ_EXPAT_EMPTY_QNAME || MOZ_EXPAT_INVALID_CHARACTER
  if (result & (1 << 0) || result & (1 << 1)) {
    return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
  }

  return NS_ERROR_DOM_NAMESPACE_ERR;
}

Here is the call graph for this function:

nsresult nsParserService::CreateEntry ( const nsAString &  aTopic,
nsObserverEntry **  aEntry 
) [protected]

Definition at line 258 of file nsParserService.cpp.

{
  *aEntry = new nsObserverEntry(aTopic);

  if (!aEntry) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(*aEntry);
  mEntries.Push(*aEntry);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsParserService::DecodeEntity ( const PRUnichar aStart,
const PRUnichar aEnd,
const PRUnichar **  aNext,
PRUnichar aResult 
) [inline, virtual]

Decodes an entity into a UTF-16 character.

If a ; is found between aStart and aEnd it will try to decode the entity and set aNext to point to the character after the ;. The resulting UTF-16 character will be written in aResult, so if the entity is a valid numeric entity there needs to be space for at least two PRUnichars.

Parameters:
aStartpointer to the character after the ampersand.
aEndpointer to the position after the last character of the string.
aNext[out] will be set to the character after the ; or null if the decoding was unsuccessful.
aResultthe buffer to write the resulting UTF-16 character in.
Returns:
the number of PRUnichars written to aResult.

Implements nsIParserService_MOZILLA_1_8_BRANCH.

Definition at line 95 of file nsParserService.h.

  {
    *aNext = nsnull;
    return MOZ_XMLTranslateEntity(NS_REINTERPRET_CAST(const char*, aStart),
                                  NS_REINTERPRET_CAST(const char*, aEnd),
                                  NS_REINTERPRET_CAST(const char**, aNext),
                                  aResult);
  }

Here is the call graph for this function:

nsObserverEntry * nsParserService::GetEntry ( const nsAString &  aTopic) [protected]

Definition at line 243 of file nsParserService.cpp.

{
  if (!mHaveNotifiedCategoryObservers) {
    mHaveNotifiedCategoryObservers = PR_TRUE;
    NS_CreateServicesFromCategory("parser-service-category",
                                  NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)),
                                  "parser-service-start"); 
  }

  nsMatchesTopic matchesTopic(aTopic);
  mEntries.FirstThat(*&matchesTopic);
  return matchesTopic.matched?matchesTopic.entry:nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsParserService::GetTopicObservers ( const nsAString &  aTopic,
nsIObserverEntry **  aEntry 
) [virtual]

Implements nsIParserService.

Definition at line 188 of file nsParserService.cpp.

                                                              {
  nsresult result = NS_OK;
  nsObserverEntry* entry = GetEntry(aTopic);

  if (!entry) {
    return NS_ERROR_NULL_POINTER;
  }

  NS_ADDREF(*aEntry = entry);

  return result;
}

Here is the call graph for this function:

Looks up the nsHTMLTag enum value corresponding to the tag in aAtom.

The lookup happens case insensitively.

Parameters:
aAtomThe tag to look up.
Returns:
PRInt32 The nsHTMLTag enum value corresponding to the tag in aAtom or eHTMLTag_userdefined if the tag does not correspond to any of the tag nsHTMLTag enum values.

Implements nsIParserService.

Looks up the nsHTMLTag enum value corresponding to the tag in aAtom.

Parameters:
aAtomThe tag to look up.
Returns:
PRInt32 The nsHTMLTag enum value corresponding to the tag in aAtom or eHTMLTag_userdefined if the tag does not correspond to any of the tag nsHTMLTag enum values.

Implements nsIParserService.

Definition at line 76 of file nsParserService.cpp.

{
  nsAutoString tagName;
  aAtom->ToString(tagName);

  return nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
}

Here is the call graph for this function:

NS_IMETHODIMP nsParserService::HTMLConvertEntityToUnicode ( const nsAString &  aEntity,
PRInt32 aUnicode 
) const [virtual]

Implements nsIParserService.

Definition at line 103 of file nsParserService.cpp.

{
  *aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsParserService::HTMLConvertUnicodeToEntity ( PRInt32  aUnicode,
nsCString aEntity 
) const [virtual]

Implements nsIParserService.

Definition at line 112 of file nsParserService.cpp.

{
  const char* str = nsHTMLEntities::UnicodeToEntity(aUnicode);
  if (str) {
    aEntity.Assign(str);
  }

  return NS_OK;
}

Here is the call graph for this function:

nsIAtom * nsParserService::HTMLIdToAtomTag ( PRInt32  aId) const [virtual]

Gets the tag corresponding to the nsHTMLTag enum value in aId.

The returned tag will be in lowercase.

Parameters:
aIdThe nsHTMLTag enum value to get the tag for.
Returns:
nsIAtom* The tag corresponding to the nsHTMLTag enum value, or nsnull if the enum value doesn't correspond to a tag (eHTMLTag_unknown, eHTMLTag_userdefined, eHTMLTag_text, ...).

Implements nsIParserService.

Definition at line 97 of file nsParserService.cpp.

{
  return nsHTMLTags::GetAtom((nsHTMLTag)aId);
}

Here is the call graph for this function:

Gets the tag corresponding to the nsHTMLTag enum value in aId.

The returned tag will be in lowercase.

Parameters:
aIdThe nsHTMLTag enum value to get the tag for.
Returns:
const PRUnichar* The tag corresponding to the nsHTMLTag enum value, or nsnull if the enum value doesn't correspond to a tag (eHTMLTag_unknown, eHTMLTag_userdefined, eHTMLTag_text, ...).

Implements nsIParserService.

Definition at line 91 of file nsParserService.cpp.

Here is the call graph for this function:

PRInt32 nsParserService::HTMLStringTagToId ( const nsAString &  aTag) const [virtual]

Looks up the nsHTMLTag enum value corresponding to the tag in aTag.

The lookup happens case insensitively.

Parameters:
aTagThe tag to look up.
Returns:
PRInt32 The nsHTMLTag enum value corresponding to the tag in aTag or eHTMLTag_userdefined if the tag does not correspond to any of the tag nsHTMLTag enum values.

Implements nsIParserService.

Definition at line 85 of file nsParserService.cpp.

{
  return nsHTMLTags::LookupTag(aTag);
}

Here is the call graph for this function:

NS_IMETHODIMP nsParserService::IsBlock ( PRInt32  aId,
PRBool aIsBlock 
) const [virtual]

Implements nsIParserService.

Definition at line 132 of file nsParserService.cpp.

{
  if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) {
    aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock))       ||
              (gHTMLElements[aId].IsMemberOf(kBlockEntity)) ||
              (gHTMLElements[aId].IsMemberOf(kHeading))     ||
              (gHTMLElements[aId].IsMemberOf(kPreformatted))||
              (gHTMLElements[aId].IsMemberOf(kList)));
  }
  else {
    aIsBlock = PR_FALSE;
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsParserService::IsContainer ( PRInt32  aId,
PRBool aIsContainer 
) const [virtual]

Implements nsIParserService.

Definition at line 124 of file nsParserService.cpp.

{
  aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId);

  return NS_OK;
}
PRBool nsParserService::IsXMLLetter ( PRUnichar  aChar) [inline, virtual]

Implements nsIParserService.

Definition at line 87 of file nsParserService.h.

  {
    return MOZ_XMLIsLetter(NS_REINTERPRET_CAST(const char*, &aChar));
  }

Here is the call graph for this function:

PRBool nsParserService::IsXMLNCNameChar ( PRUnichar  aChar) [inline, virtual]

Implements nsIParserService.

Definition at line 91 of file nsParserService.h.

  {
    return MOZ_XMLIsNCNameChar(NS_REINTERPRET_CAST(const char*, &aChar));
  }

Here is the call graph for this function:

NS_IMETHODIMP nsParserService::RegisterObserver ( nsIElementObserver aObserver,
const nsAString &  aTopic,
const eHTMLTags aTags = nsnull 
) [virtual]

Implements nsIParserService.

Definition at line 149 of file nsParserService.cpp.

{
  nsresult result = NS_OK;
  nsObserverEntry* entry = GetEntry(aTopic);

  if(!entry) {
    result = CreateEntry(aTopic,&entry);
    NS_ENSURE_SUCCESS(result,result);
  }

  while (*aTags) {
    if (*aTags <= NS_HTML_TAG_MAX) {
      entry->AddObserver(aObserver,*aTags);
    }
    ++aTags;
  }

  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsParserService::UnregisterObserver ( nsIElementObserver aObserver,
const nsAString &  aTopic 
) [virtual]

Implements nsIParserService.

Definition at line 172 of file nsParserService.cpp.

{
  PRInt32 count = mEntries.GetSize();

  for (PRInt32 i=0; i < count; ++i) {
    nsObserverEntry* entry = NS_STATIC_CAST(nsObserverEntry*,mEntries.ObjectAt(i));
    if (entry && entry->Matches(aTopic)) {
      entry->RemoveObserver(aObserver);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

nsDeque nsParserService::mEntries [protected]

Definition at line 110 of file nsParserService.h.

Definition at line 111 of file nsParserService.h.


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