Back to index

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

#include <nsLoggingSink.h>

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

List of all members.

Public Member Functions

 nsLoggingSink ()
virtual ~nsLoggingSink ()
void SetProxySink (nsIHTMLContentSink *aSink)
void ReleaseProxySink ()
NS_DECL_ISUPPORTS NS_IMETHOD WillBuildModel ()
 This method gets called when the parser begins the process of building the content model via the content sink.
NS_IMETHOD DidBuildModel ()
 This method gets called when the parser concludes the process of building the content model via the content sink.
NS_IMETHOD WillInterrupt ()
 This method gets called when the parser gets i/o blocked, and wants to notify the sink that it may be a while before more data is available.
NS_IMETHOD WillResume ()
 This method gets called when the parser i/o gets unblocked, and we're about to start dumping content again to the sink.
NS_IMETHOD SetParser (nsIParser *aParser)
 This method gets called by the parser so that the content sink can retain a reference to the parser.
NS_IMETHOD OpenContainer (const nsIParserNode &aNode)
 This method is used to open a generic container in the sink.
NS_IMETHOD CloseContainer (const nsHTMLTag aTag)
 This method gets called by the parser when a close container tag has been consumed and needs to be closed.
NS_IMETHOD AddHeadContent (const nsIParserNode &aNode)
 This gets called by the parser to contents to the head container.
NS_IMETHOD AddLeaf (const nsIParserNode &aNode)
 This gets called by the parser when you want to add a leaf node to the current container in the content model.
NS_IMETHOD AddComment (const nsIParserNode &aNode)
 This gets called by the parser when you want to add a comment node to the current container in the content model.
NS_IMETHOD AddProcessingInstruction (const nsIParserNode &aNode)
 This gets called by the parser when you want to add a PI node to the current container in the content model.
NS_IMETHOD AddDocTypeDecl (const nsIParserNode &aNode)
 This gets called by the parser when it encounters a DOCTYPE declaration in the HTML document.
virtual void FlushPendingNotifications (mozFlushType aType)
 Flush content so that the content model is in sync with the state of the sink.
NS_IMETHOD SetDocumentCharset (nsACString &aCharset)
 Set the document character set.
virtual nsISupports * GetTarget ()
 Returns the target object (often a document object) into which the content built by this content sink is being added, if any (IOW, may return null).
NS_IMETHOD SetTitle (const nsString &aValue)
 This method gets called by the parser when it encounters a title tag and wants to set the document title in the sink.
NS_IMETHOD OpenHTML (const nsIParserNode &aNode)
 This method is used to open the outer HTML container.
NS_IMETHOD CloseHTML ()
 This method is used to close the outer HTML container.
NS_IMETHOD OpenHead (const nsIParserNode &aNode)
 This method is used to open the only HEAD container.
NS_IMETHOD CloseHead ()
 This method is used to close the only HEAD container.
NS_IMETHOD OpenBody (const nsIParserNode &aNode)
 This method is used to open the main BODY container.
NS_IMETHOD CloseBody ()
 This method is used to close the main BODY container.
NS_IMETHOD OpenForm (const nsIParserNode &aNode)
 This method is used to open a new FORM container.
NS_IMETHOD CloseForm ()
 This method is used to close the outer FORM container.
NS_IMETHOD OpenMap (const nsIParserNode &aNode)
 This method is used to open a new MAP container.
NS_IMETHOD CloseMap ()
 This method is used to close the MAP container.
NS_IMETHOD OpenFrameset (const nsIParserNode &aNode)
 This method is used to open the FRAMESET container.
NS_IMETHOD CloseFrameset ()
 This method is used to close the FRAMESET container.
NS_IMETHOD IsEnabled (PRInt32 aTag, PRBool *aReturn)
 01/09/2003 harishd
NS_IMETHOD NotifyTagObservers (nsIParserNode *aNode)
 This gets called by the parser to notify observers of the tag.
 NS_IMETHOD_ (PRBool) IsFormOnStack()
 Call this method to determnine if a FORM is on the sink's stack.
NS_IMETHOD BeginContext (PRInt32 aPosition)
 This gets called when handling illegal contents, especially in dealing with tables.
NS_IMETHOD EndContext (PRInt32 aPosition)
 This method terminates any new context that got created by BeginContext and switches back to the main context.
NS_IMETHOD WillProcessTokens (void)
 This method is called when parser is about to begin synchronously processing a chunk of tokens.
NS_IMETHOD DidProcessTokens (void)
 This method is called when parser has completed processing a chunk of tokens.
NS_IMETHOD WillProcessAToken (void)
 This method is called when parser is about to process a single token.
NS_IMETHOD DidProcessAToken (void)
 This method is called when parser has completed the processing for a single token.
NS_IMETHOD SetOutputStream (PRFileDesc *aStream, PRBool autoDelete=PR_FALSE)
nsresult OpenNode (const char *aKind, const nsIParserNode &aNode)
nsresult CloseNode (const char *aKind)
nsresult LeafNode (const nsIParserNode &aNode)
nsresult WriteAttributes (const nsIParserNode &aNode)
nsresult QuoteText (const nsAString &aValue, nsString &aResult)
nsresult GetNewCString (const nsAString &aValue, char **aResult)
 Use this method to convert nsString to char*.
PRBool WillWriteAttributes (const nsIParserNode &aNode)

Protected Attributes

PRFileDescmOutput
int mLevel
nsIHTMLContentSinkmSink
PRBool mAutoDeleteOutput
nsIParsermParser

Detailed Description

Definition at line 44 of file nsLoggingSink.h.


Constructor & Destructor Documentation

Definition at line 74 of file nsLoggingSink.cpp.

                             {
  mOutput = 0;
       mLevel=-1;
  mSink=0;
  mParser=0;
}

Definition at line 81 of file nsLoggingSink.cpp.

                              { 
  mSink=0;
  if(mOutput && mAutoDeleteOutput) {
    delete mOutput;
  }
  mOutput=0;
}

Member Function Documentation

This gets called by the parser when you want to add a comment node to the current container in the content model.

gess 3/25/98

Parameters:
@return

Implements nsIHTMLContentSink.

Definition at line 351 of file nsLoggingSink.cpp.

                                                   {

#ifdef VERBOSE_DEBUG
  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
#endif

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->AddComment(aNode);
  }
  
  return theResult;

}

Here is the call graph for this function:

This gets called by the parser when it encounters a DOCTYPE declaration in the HTML document.

Implements nsIHTMLContentSink.

Definition at line 324 of file nsLoggingSink.cpp.

                                                        {

#ifdef VERBOSE_DEBUG
  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
#endif

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->AddDocTypeDecl(aNode);
  }
  
  return theResult;

}

Here is the call graph for this function:

This gets called by the parser to contents to the head container.

Implements nsIHTMLContentSink.

Definition at line 248 of file nsLoggingSink.cpp.

                                                        {
  eHTMLTags type = (eHTMLTags)aNode.GetNodeType();

  if (type == eHTMLTag_title) {
    nsCOMPtr<nsIDTD> dtd;
    mParser->GetDTD(getter_AddRefs(dtd));
    NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);
    
    nsString theString;
    PRInt32 lineNo = 0;

    dtd->CollectSkippedContent(type, theString, lineNo);
    SetTitle(theString);
  }
  else {
    LeafNode(aNode);
  }

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->AddHeadContent(aNode);
  }
  
  return theResult;

}

Here is the call graph for this function:

This gets called by the parser when you want to add a leaf node to the current container in the content model.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 278 of file nsLoggingSink.cpp.

                                                 {
  LeafNode(aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->AddLeaf(aNode);
  }
  
  return theResult;

} 

Here is the call graph for this function:

This gets called by the parser when you want to add a PI node to the current container in the content model.

gess 3/25/98

Parameters:
@return

Implements nsIHTMLContentSink.

Definition at line 302 of file nsLoggingSink.cpp.

                                                                 {

#ifdef VERBOSE_DEBUG
  DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
#endif

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->AddProcessingInstruction(aNode);
  }
  
  return theResult;
}

Here is the call graph for this function:

This gets called when handling illegal contents, especially in dealing with tables.

This method creates a new context.

04/04/99 harishd

Parameters:
aPosition- The position from where the new context begins.

Implements nsIHTMLContentSink.

Definition at line 807 of file nsLoggingSink.cpp.

{
  return NS_OK;
}

This method is used to close the main BODY container.

Implements nsIHTMLContentSink.

Definition at line 466 of file nsLoggingSink.cpp.

                         {
  CloseNode("body");

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseBody();
  }
  
  return theResult;
}

Here is the call graph for this function:

This method gets called by the parser when a close container tag has been consumed and needs to be closed.

Parameters:
aTag- The tag to be closed.

Implements nsIHTMLContentSink.

Definition at line 226 of file nsLoggingSink.cpp.

                                                  {

  nsresult theResult=NS_OK;

  nsHTMLTag nodeType = nsHTMLTag(aTag);
  if ((nodeType >= eHTMLTag_unknown) &&
      (nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
    const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
    theResult = CloseNode(NS_ConvertUCS2toUTF8(tag).get());
  }
  else theResult= CloseNode("???");

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseContainer(aTag);
  }
  
  return theResult;

}

Here is the call graph for this function:

This method is used to close the outer FORM container.

Implements nsIHTMLContentSink.

Definition at line 494 of file nsLoggingSink.cpp.

                         {
  CloseNode("form");

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseForm();
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to close the FRAMESET container.

Implements nsIHTMLContentSink.

Definition at line 550 of file nsLoggingSink.cpp.

                             {
  CloseNode("frameset");

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseFrameset();
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to close the only HEAD container.

Implements nsIHTMLContentSink.

Definition at line 438 of file nsLoggingSink.cpp.

                         {
  CloseNode("head");

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseHead();
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to close the outer HTML container.

Implements nsIHTMLContentSink.

Definition at line 409 of file nsLoggingSink.cpp.

                         {
  CloseNode("html");

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseHTML();
  }
  
  return theResult;

}

Here is the call graph for this function:

This method is used to close the MAP container.

Implements nsIHTMLContentSink.

Definition at line 522 of file nsLoggingSink.cpp.

                        {
  CloseNode("map");

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->CloseMap();
  }
  
  return theResult;
}

Here is the call graph for this function:

Definition at line 598 of file nsLoggingSink.cpp.

                                          {
       WriteTabs(mOutput,mLevel--);
  PR_fprintf(mOutput, "<close container=\"%s\">\n", aKind);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method gets called when the parser concludes the process of building the content model via the content sink.

5/7/98 gess

Implements nsIContentSink.

Definition at line 153 of file nsLoggingSink.cpp.

                             {
  
  WriteTabs(mOutput,--mLevel);
  PR_fprintf(mOutput, "</begin>\n");

  //proxy the call to the real sink if you have one.
  nsresult theResult=NS_OK;
  if(mSink) {
    theResult=mSink->DidBuildModel();
  }

  return theResult;
}

Here is the call graph for this function:

This method is called when parser has completed the processing for a single token.

Returns:
NS_OK if processing should not be interrupted NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted

Implements nsIHTMLContentSink.

Definition at line 104 of file nsLoggingSink.h.

{ return NS_OK; }

This method is called when parser has completed processing a chunk of tokens.

The processing of the tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from DidProcessAToken.

Implements nsIHTMLContentSink.

Definition at line 102 of file nsLoggingSink.h.

{ return NS_OK; }

This method terminates any new context that got created by BeginContext and switches back to the main context.

04/04/99 harishd

Parameters:
aPosition- Validates the end of a context.

Implements nsIHTMLContentSink.

Definition at line 820 of file nsLoggingSink.cpp.

{
  return NS_OK;
}
virtual void nsLoggingSink::FlushPendingNotifications ( mozFlushType  aType) [inline, virtual]

Flush content so that the content model is in sync with the state of the sink.

Parameters:
aTypethe type of flush to perform

Implements nsIContentSink.

Definition at line 75 of file nsLoggingSink.h.

{ }
nsresult nsLoggingSink::GetNewCString ( const nsAString &  aValue,
char **  aResult 
)

Use this method to convert nsString to char*.

REMEMBER: Match this call with nsMemory::Free(aResult);

04/04/99 harishd

Parameters:
aValue- The string value
aResult- String coverted to char*.

Definition at line 788 of file nsLoggingSink.cpp.

{
  nsresult result=NS_OK;
  nsAutoString temp;
  result=QuoteText(aValue,temp);
  if(NS_SUCCEEDED(result)) {
    *aResult = temp.IsEmpty() ? nsnull : ToNewCString(temp);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual nsISupports* nsLoggingSink::GetTarget ( ) [inline, virtual]

Returns the target object (often a document object) into which the content built by this content sink is being added, if any (IOW, may return null).

Implements nsIContentSink.

Definition at line 77 of file nsLoggingSink.h.

{ return nsnull; }
NS_IMETHOD nsLoggingSink::IsEnabled ( PRInt32  aTag,
PRBool aReturn 
) [inline, virtual]

01/09/2003 harishd

Parameters:
aTag- Check if this tag is enabled or not.

Implements nsIHTMLContentSink.

Definition at line 93 of file nsLoggingSink.h.

  { NS_ENSURE_ARG_POINTER(aReturn); *aReturn = PR_TRUE; return NS_OK; }

Definition at line 693 of file nsLoggingSink.cpp.

{
       WriteTabs(mOutput,1+mLevel);
       nsHTMLTag                          nodeType  = nsHTMLTag(aNode.GetNodeType());

  if ((nodeType >= eHTMLTag_unknown) &&
      (nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
    const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);

              if(tag)
      PR_fprintf(mOutput, "<leaf tag=\"%s\"", NS_ConvertUCS2toUTF8(tag).get());
    else PR_fprintf(mOutput, "<leaf tag=\"???\"");

    if (WillWriteAttributes(aNode)) {
                     PR_fprintf(mOutput, ">\n");
      WriteAttributes(aNode);
                     PR_fprintf(mOutput, "</leaf>\n");
    }
    else {
                     PR_fprintf(mOutput, "/>\n");
    }
  }
  else {
    PRInt32 pos;
    nsAutoString tmp;
    char* str = nsnull;
    switch (nodeType) {
                     case eHTMLTag_whitespace:
                     case eHTMLTag_text:
        GetNewCString(aNode.GetText(), &str);
        if(str) {
          PR_fprintf(mOutput, "<text value=\"%s\"/>\n", str);
          nsMemory::Free(str);
        }
                            break;

                     case eHTMLTag_newline:
                            PR_fprintf(mOutput, "<newline/>\n");
                            break;

                     case eHTMLTag_entity:
                            tmp.Append(aNode.GetText());
                            tmp.Cut(0, 1);
                            pos = tmp.Length() - 1;
                            if (pos >= 0) {
                                   tmp.Cut(pos, 1);
                            }
                            PR_fprintf(mOutput, "<entity value=\"%s\"/>\n", NS_LossyConvertUCS2toASCII(tmp).get());
                            break;

                     default:
                            NS_NOTREACHED("unsupported leaf node type");
              }//switch
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This gets called by the parser to notify observers of the tag.

Parameters:
aErrorResultthe error code

Implements nsIHTMLContentSink.

Definition at line 96 of file nsLoggingSink.h.

{ return NS_OK; }
nsLoggingSink::NS_IMETHOD_ ( PRBool  ) [inline, virtual]

Call this method to determnine if a FORM is on the sink's stack.

Returns:
PR_TRUE if found else PR_FALSE

Implements nsIHTMLContentSink.

Definition at line 97 of file nsLoggingSink.h.

{ return PR_FALSE; }

This method is used to open the main BODY container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 452 of file nsLoggingSink.cpp.

                                                  {
  OpenNode("body", aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenBody(aNode);
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to open a generic container in the sink.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 210 of file nsLoggingSink.cpp.

                                                       {

  OpenNode("container", aNode); //do the real logging work...

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenContainer(aNode);
  }
  
  return theResult;

}

Here is the call graph for this function:

This method is used to open a new FORM container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 480 of file nsLoggingSink.cpp.

                                                  {
  OpenNode("form", aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenForm(aNode);
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to open the FRAMESET container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 536 of file nsLoggingSink.cpp.

                                                      {
  OpenNode("frameset", aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenFrameset(aNode);
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to open the only HEAD container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 424 of file nsLoggingSink.cpp.

                                                  {
  OpenNode("head", aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenHead(aNode);
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is used to open the outer HTML container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 394 of file nsLoggingSink.cpp.

                                                  {
  OpenNode("html", aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenHTML(aNode);
  }
  
  return theResult;

}

Here is the call graph for this function:

This method is used to open a new MAP container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 508 of file nsLoggingSink.cpp.

                                                 {
  OpenNode("map", aNode);

  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->OpenMap(aNode);
  }
  
  return theResult;
}

Here is the call graph for this function:

nsresult nsLoggingSink::OpenNode ( const char *  aKind,
const nsIParserNode aNode 
)

Definition at line 565 of file nsLoggingSink.cpp.

                                                                     {
       WriteTabs(mOutput,++mLevel);

  PR_fprintf(mOutput,"<open container=");

  nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
  if ((nodeType >= eHTMLTag_unknown) &&
      (nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
    const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
    PR_fprintf(mOutput, "\"%s\"", NS_ConvertUCS2toUTF8(tag).get());
  }
  else {
    char* text = nsnull;
    GetNewCString(aNode.GetText(), &text);
    if(text) {
      PR_fprintf(mOutput, "\"%s\"", text);
      nsMemory::Free(text);
    }
  }

  if (WillWriteAttributes(aNode)) {
    PR_fprintf(mOutput, ">\n");
    WriteAttributes(aNode);
    PR_fprintf(mOutput, "</open>\n");
  }
  else {
    PR_fprintf(mOutput, ">\n");
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsLoggingSink::QuoteText ( const nsAString &  aValue,
nsString aResult 
)

Definition at line 751 of file nsLoggingSink.cpp.

                                                                   {
  aResult.Truncate();
    /*
      if you're stepping through the string anyway, why not use iterators instead of forcing the string to copy?
     */
  const nsPromiseFlatString& flat = PromiseFlatString(aValue);
  const PRUnichar* cp = flat.get();
  const PRUnichar* end = cp + aValue.Length();
  while (cp < end) {
    PRUnichar ch = *cp++;
    if (ch == '"') {
      aResult.AppendLiteral("&quot;");
    }
    else if (ch == '&') {
      aResult.AppendLiteral("&amp;");
    }
    else if ((ch < 32) || (ch >= 127)) {
      aResult.AppendLiteral("&#");
      aResult.AppendInt(PRInt32(ch), 10);
      aResult.Append(PRUnichar(';'));
    }
    else {
      aResult.Append(ch);
    }
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 53 of file nsLoggingSink.h.

Here is the caller graph for this function:

NS_IMETHOD nsLoggingSink::SetDocumentCharset ( nsACString &  aCharset) [inline, virtual]

Set the document character set.

This should be passed on to the document itself.

Implements nsIContentSink.

Definition at line 76 of file nsLoggingSink.h.

{ return NS_OK; }
NS_IMETHODIMP nsLoggingSink::SetOutputStream ( PRFileDesc aStream,
PRBool  autoDelete = PR_FALSE 
) [virtual]

Implements nsILoggingSink.

Definition at line 124 of file nsLoggingSink.cpp.

                                                                          {
  mOutput = aStream;
  mAutoDeleteOutput=autoDeleteOutput;
  return NS_OK;
}

This method gets called by the parser so that the content sink can retain a reference to the parser.

The expectation is that the content sink will drop the reference when it gets the DidBuildModel notification i.e. when parsing is done.

Implements nsIContentSink.

Definition at line 192 of file nsLoggingSink.cpp.

                                            {
  nsresult theResult=NS_OK;

  //proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->SetParser(aParser);
  }
  
  NS_IF_RELEASE(mParser);
  
  mParser = aParser;
  
  NS_IF_ADDREF(mParser);

  return theResult;
}

Here is the call graph for this function:

Definition at line 49 of file nsLoggingSink.h.

                                               {
    mSink=aSink;    
  }

This method gets called by the parser when it encounters a title tag and wants to set the document title in the sink.

4/1/98 gess

Parameters:
nsStringreference to new title value

Implements nsIHTMLContentSink.

Definition at line 370 of file nsLoggingSink.cpp.

                                              {
   
  char* tmp = nsnull;
  GetNewCString(aValue, &tmp);
       WriteTabs(mOutput,++mLevel);
  if(tmp) {
    PR_fprintf(mOutput, "<title value=\"%s\"/>\n", tmp);
    nsMemory::Free(tmp);
  }
  --mLevel;
  
  nsresult theResult=NS_OK;

  //then proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->SetTitle(aValue);
  }
  
  return theResult;

}

Here is the call graph for this function:

Here is the caller graph for this function:

This method gets called when the parser begins the process of building the content model via the content sink.

5/7/98 gess

Implements nsIContentSink.

Definition at line 139 of file nsLoggingSink.cpp.

                              {
  
  WriteTabs(mOutput,++mLevel);
  PR_fprintf(mOutput, "<begin>\n");
  
  //proxy the call to the real sink if you have one.
  if(mSink) {
    mSink->WillBuildModel();
  }

  return NS_OK;
}

Here is the call graph for this function:

This method gets called when the parser gets i/o blocked, and wants to notify the sink that it may be a while before more data is available.

5/7/98 gess

Implements nsIContentSink.

Definition at line 168 of file nsLoggingSink.cpp.

                             {
  nsresult theResult=NS_OK;

  //proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->WillInterrupt();
  }
  
  return theResult;
}

Here is the call graph for this function:

This method is called when parser is about to process a single token.

Implements nsIHTMLContentSink.

Definition at line 103 of file nsLoggingSink.h.

{ return NS_OK; }

This method is called when parser is about to begin synchronously processing a chunk of tokens.

Implements nsIHTMLContentSink.

Definition at line 101 of file nsLoggingSink.h.

{ return NS_OK; }

This method gets called when the parser i/o gets unblocked, and we're about to start dumping content again to the sink.

5/7/98 gess

Implements nsIContentSink.

Definition at line 180 of file nsLoggingSink.cpp.

                          {
  nsresult theResult=NS_OK;

  //proxy the call to the real sink if you have one.
  if(mSink) {
    theResult=mSink->WillResume();
  }
  
  return theResult;
}

Here is the call graph for this function:

Definition at line 670 of file nsLoggingSink.cpp.

{
  PRInt32 ac = aNode.GetAttributeCount();
  if (0 != ac) {
    return PR_TRUE;
  }
  if (0 != strchr(gSkippedContentTags, aNode.GetNodeType())) {
    nsCOMPtr<nsIDTD> dtd;
    mParser->GetDTD(getter_AddRefs(dtd));
    NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);
    
    nsString content;
    PRInt32 lineNo = 0;

    dtd->CollectSkippedContent(aNode.GetNodeType(), content, lineNo);
    if (!content.IsEmpty()) {
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 606 of file nsLoggingSink.cpp.

                                                         {

  WriteTabs(mOutput,1+mLevel);
  nsAutoString tmp;
  PRInt32 ac = aNode.GetAttributeCount();
  for (PRInt32 i = 0; i < ac; ++i) {
    char* key=nsnull;
    char* value=nsnull;
    const nsAString& k = aNode.GetKeyAt(i);
    const nsAString& v = aNode.GetValueAt(i);

    GetNewCString(k, &key);
    if(key) {
      PR_fprintf(mOutput, " <attr key=\"%s\" value=\"", key);
      nsMemory::Free(key);
    }
 
    tmp.Truncate();
    tmp.Append(v);
    if(!tmp.IsEmpty()) {
      PRUnichar first = tmp.First();
      if ((first == '"') || (first == '\'')) {
        if (tmp.Last() == first) {
          tmp.Cut(0, 1);
          PRInt32 pos = tmp.Length() - 1;
          if (pos >= 0) {
            tmp.Cut(pos, 1);
          }
        } else {
          // Mismatched quotes - leave them in
        }
      }
      GetNewCString(tmp, &value);

      if(value) {
        PR_fprintf(mOutput, "%s\"/>\n", value);
        WriteTabs(mOutput,1+mLevel);
        nsMemory::Free(value);
      }
    }
  }

  if (0 != strchr(gSkippedContentTags, aNode.GetNodeType())) {
    nsCOMPtr<nsIDTD> dtd;
    mParser->GetDTD(getter_AddRefs(dtd));
    NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);
    
    nsString theString;
    PRInt32 lineNo = 0;

    dtd->CollectSkippedContent(aNode.GetNodeType(), theString, lineNo);
    char* content = nsnull;
    GetNewCString(theString, &content);
    if(content) {
      PR_fprintf(mOutput, " <content value=\"");
      PR_fprintf(mOutput, "%s\"/>\n", content) ;
      nsMemory::Free(content);
    }
  }
  WriteTabs(mOutput,1+mLevel);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 121 of file nsLoggingSink.h.

Definition at line 119 of file nsLoggingSink.h.

Definition at line 118 of file nsLoggingSink.h.

Definition at line 122 of file nsLoggingSink.h.

Definition at line 120 of file nsLoggingSink.h.


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