Back to index

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

#include <nsDTDUtils.h>

Inheritance diagram for nsObserverEntry:
Inheritance graph
Collaboration diagram for nsObserverEntry:
Collaboration graph

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsObserverEntry (const nsAString &aString)
virtual ~nsObserverEntry ()
NS_IMETHOD Notify (nsIParserNode *aNode, nsIParser *aParser, nsISupports *aWebShell, const PRUint32 aFlags)
nsresult AddObserver (nsIElementObserver *aObserver, eHTMLTags aTag)
void RemoveObserver (nsIElementObserver *aObserver)
PRBool Matches (const nsAString &aTopic)

Protected Attributes

nsAutoString mTopic
nsVoidArraymObservers [NS_HTML_TAG_MAX+1]


class nsMatchesTopic

Detailed Description

Definition at line 441 of file nsDTDUtils.h.

Constructor & Destructor Documentation

nsObserverEntry::nsObserverEntry ( const nsAString &  aString)

Definition at line 1012 of file nsDTDUtils.cpp.

                                                        : mTopic(aTopic) 
  memset(mObservers, 0, sizeof(mObservers));

Here is the call graph for this function:

Definition at line 1017 of file nsDTDUtils.cpp.

  for (PRInt32 i = 0; i <= NS_HTML_TAG_MAX; ++i){
    if (mObservers[i]) {
      PRInt32 count = mObservers[i]->Count();
      for (PRInt32 j = 0; j < count; ++j) {
        nsISupports* obs = (nsISupports*)mObservers[i]->ElementAt(j);
      delete mObservers[i];

Member Function Documentation

Definition at line 1111 of file nsDTDUtils.cpp.

  if (aObserver) {
    if (!mObservers[aTag]) {
      mObservers[aTag] = new nsAutoVoidArray();
      if (!mObservers[aTag]) {
        return NS_ERROR_OUT_OF_MEMORY;
  return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsObserverEntry::Matches ( const nsAString &  aTopic)

Definition at line 1105 of file nsDTDUtils.cpp.

  PRBool result = aString.Equals(mTopic);
  return result;

Here is the caller graph for this function:

NS_IMETHODIMP nsObserverEntry::Notify ( nsIParserNode aNode,
nsIParser aParser,
nsISupports *  aWebShell,
const PRUint32  aFlags 
) [virtual]

Implements nsIObserverEntry.

Definition at line 1031 of file nsDTDUtils.cpp.


  nsresult result = NS_OK;
  eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
  if (theTag <= NS_HTML_TAG_MAX) {
    nsVoidArray*  theObservers = mObservers[theTag];
    if (theObservers) {
      PRInt32   theCharsetSource;
      nsCAutoString      charset;
      NS_ConvertASCIItoUCS2 theCharsetValue(charset);

      PRInt32 theAttrCount = aNode->GetAttributeCount(); 
      PRInt32 theObserversCount = theObservers->Count(); 
      if (0 < theObserversCount){
        nsStringArray keys(theAttrCount+4), values(theAttrCount+4);

        // XXX this and the following code may be a performance issue.
        // Every key and value is copied and added to an voidarray (causing at
        // least 2 allocations for mImpl, usually more, plus at least 1 per
        // string (total = 2*(keys+3) + 2(or more) array allocations )).
        PRInt32 index;
        for (index = 0; index < theAttrCount; ++index) {

        nsAutoString intValue;



        nsCOMPtr<nsIChannel> channel;

        for (index=0;index<theObserversCount;++index) {
          nsIElementObserver* observer = NS_STATIC_CAST(nsIElementObserver*,theObservers->ElementAt(index));
          if (observer) {
            result = observer->Notify(aWebShell, channel,
                                      &keys, &values, aFlags);
            if (NS_FAILED(result)) {

            if (result == NS_HTMLPARSER_VALID_META_CHARSET) {
              // Inform the parser that this meta tag contained a valid
              // charset. See bug 272815
              aParser->SetDocumentCharset(charset, kCharsetFromMetaTag);
              result = NS_OK;
  return result;

Here is the call graph for this function:

Definition at line 1128 of file nsDTDUtils.cpp.

  for (PRInt32 i=0; i <= NS_HTML_TAG_MAX; ++i){
    if (mObservers[i]) {
      nsISupports* obs = aObserver;
      PRBool removed = mObservers[i]->RemoveElement(obs);
      if (removed) {

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class nsMatchesTopic [friend]

Definition at line 459 of file nsDTDUtils.h.

Member Data Documentation

Definition at line 458 of file nsDTDUtils.h.

Definition at line 457 of file nsDTDUtils.h.

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