Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
RobotSink Class Reference
Inheritance diagram for RobotSink:
Inheritance graph
[legend]
Collaboration diagram for RobotSink:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RobotSink ()
virtual ~RobotSink ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS 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_ (PRBool) IsFormOnStack()
 Call this method to determnine if a FORM is on the sink's stack.
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 CloseTopmostContainer ()
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 parsing system when we find a comment gess11/9/98.
NS_IMETHOD AddProcessingInstruction (const nsIParserNode &aNode)
 This gets called by the parsing system when we find a PI gess11/9/98.
NS_IMETHOD AddDocTypeDecl (const nsIParserNode &aNode)
 This gets called by the parser when it encounters a DOCTYPE declaration in the HTML document.
NS_IMETHOD WillBuildModel (void)
 This method gets called when the parser begins the process of building the content model via the content sink.
NS_IMETHOD DidBuildModel (void)
 This method gets called when the parser concludes the process of building the content model via the content sink.
NS_IMETHOD WillInterrupt (void)
 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 (void)
 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.
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 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 NotifyTagObservers (nsIParserNode *aNode)
 This gets called by the parser to notify observers of the tag.
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 Init (nsIURI *aDocumentURL)
NS_IMETHOD AddObserver (nsIRobotSinkObserver *aObserver)
NS_IMETHOD RemoveObserver (nsIRobotSinkObserver *aObserver)
void ProcessLink (const nsString &aLink)

Protected Attributes

nsIURImDocumentURL
nsVoidArray mObservers

Detailed Description

Definition at line 67 of file nsRobotSink.cpp.


Constructor & Destructor Documentation

Definition at line 139 of file nsRobotSink.cpp.

{
}
RobotSink::~RobotSink ( ) [virtual]

Definition at line 143 of file nsRobotSink.cpp.

{
  NS_IF_RELEASE(mDocumentURL);
  PRInt32 i, n = mObservers.Count();
  for (i = 0; i < n; ++i) {
    nsIRobotSinkObserver* cop = (nsIRobotSinkObserver*)mObservers.ElementAt(i);
    NS_RELEASE(cop);
  }
}  

Member Function Documentation

This gets called by the parsing system when we find a comment gess11/9/98.

Parameters:
aNodecontains a comment token
Returns:
error code

Implements nsIHTMLContentSink.

Definition at line 306 of file nsRobotSink.cpp.

                                                              {
  nsresult result= NS_OK;
  return result;
}

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

Implements nsIHTMLContentSink.

Definition at line 328 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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

Implements nsIHTMLContentSink.

Definition at line 290 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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 295 of file nsRobotSink.cpp.

{
  return NS_OK;
}

Implements nsIRobotSink.

Definition at line 341 of file nsRobotSink.cpp.

{
  if (mObservers.AppendElement(aObserver)) {
    NS_ADDREF(aObserver);
    return NS_OK;
  }
  return NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

This gets called by the parsing system when we find a PI gess11/9/98.

Parameters:
aNodecontains a comment token
Returns:
error code

Implements nsIHTMLContentSink.

Definition at line 317 of file nsRobotSink.cpp.

                                                                            {
  nsresult result= NS_OK;
  return result;
}
NS_IMETHOD RobotSink::BeginContext ( PRInt32  aPosition) [inline, virtual]

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 116 of file nsRobotSink.cpp.

{ return NS_OK; }

This method is used to close the main BODY container.

Implements nsIHTMLContentSink.

Definition at line 210 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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 280 of file nsRobotSink.cpp.

{
  return NS_OK;
}

This method is used to close the outer FORM container.

Implements nsIHTMLContentSink.

Definition at line 220 of file nsRobotSink.cpp.

{
  return NS_OK;
}

This method is used to close the FRAMESET container.

Implements nsIHTMLContentSink.

Definition at line 240 of file nsRobotSink.cpp.

{
  return NS_OK;
}

This method is used to close the only HEAD container.

Implements nsIHTMLContentSink.

Definition at line 200 of file nsRobotSink.cpp.

{
  return NS_OK;
}

This method is used to close the outer HTML container.

Implements nsIHTMLContentSink.

Definition at line 190 of file nsRobotSink.cpp.

{
  return NS_OK;
}

This method is used to close the MAP container.

Implements nsIHTMLContentSink.

Definition at line 230 of file nsRobotSink.cpp.

{
  return NS_OK;
}

Definition at line 285 of file nsRobotSink.cpp.

{
  return NS_OK;
}
NS_IMETHOD RobotSink::DidBuildModel ( void  ) [inline, virtual]

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 103 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::DidProcessAToken ( void  ) [inline, virtual]

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 113 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::DidProcessTokens ( void  ) [inline, virtual]

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 111 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::EndContext ( PRInt32  aPosition) [inline, virtual]

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 117 of file nsRobotSink.cpp.

{ return NS_OK; }
virtual void RobotSink::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 107 of file nsRobotSink.cpp.

{ }
virtual nsISupports* RobotSink::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 109 of file nsRobotSink.cpp.

{ return nsnull; }
NS_IMETHODIMP RobotSink::Init ( nsIURI aDocumentURL) [virtual]

Implements nsIRobotSink.

Definition at line 333 of file nsRobotSink.cpp.

{
  NS_IF_RELEASE(mDocumentURL);
  mDocumentURL = aDocumentURL;
  NS_IF_ADDREF(aDocumentURL);
  return NS_OK;
}
NS_IMETHOD RobotSink::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 91 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::NotifyTagObservers ( nsIParserNode aNode) [inline, virtual]

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

Parameters:
aErrorResultthe error code

Implements nsIHTMLContentSink.

Definition at line 114 of file nsRobotSink.cpp.

{ return NS_OK; }
RobotSink::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 92 of file nsRobotSink.cpp.

{ 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 205 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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 245 of file nsRobotSink.cpp.

{
  nsAutoString tmp; tmp.Assign(aNode.GetText());
  ToLowerCase(tmp);
  if (tmp.EqualsLiteral("a")) {
    nsAutoString k, v;
    PRInt32 ac = aNode.GetAttributeCount();
    for (PRInt32 i = 0; i < ac; ++i) {
      // Get upper-cased key
      const nsAString& key = aNode.GetKeyAt(i);
      k.Assign(key);
      ToLowerCase(k);
      if (k.EqualsLiteral("href")) {
        // Get value and remove mandatory quotes
        v.Truncate();
        v.Append(aNode.GetValueAt(i));
        PRUnichar first = v.First();
        if ((first == '"') || (first == '\'')) {
          if (v.Last() == first) {
            v.Cut(0, 1);
            PRInt32 pos = v.Length() - 1;
            if (pos >= 0) {
              v.Cut(pos, 1);
            }
          } else {
            // Mismatched quotes - leave them in
          }
        }
        ProcessLink(v);
      }
    }
  }
  return NS_OK;
}

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 215 of file nsRobotSink.cpp.

{
  return NS_OK;
}

This method is used to open the FRAMESET container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

Definition at line 235 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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 195 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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 185 of file nsRobotSink.cpp.

{
  return NS_OK;
}

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 225 of file nsRobotSink.cpp.

{
  return NS_OK;
}

Definition at line 360 of file nsRobotSink.cpp.

{
  nsAutoString absURLSpec; absURLSpec.Assign(aLink);

  // Make link absolute
  // XXX base tag handling
  nsIURI* docURL = mDocumentURL;
  if (nsnull != docURL) {
    nsIURI* absurl;
    nsresult rv;
    nsCOMPtr<nsIIOService> service(do_GetService(kIOServiceCID, &rv));
    if (NS_FAILED(rv)) return;

    nsIURI *uri = nsnull, *baseUri = nsnull;

    rv = mDocumentURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
    if (NS_FAILED(rv)) return;

    NS_ConvertUCS2toUTF8 uriStr(aLink);
    rv = service->NewURI(uriStr, nsnull, baseUri, &uri);
    NS_RELEASE(baseUri);
    if (NS_FAILED(rv)) return;

    rv = uri->QueryInterface(NS_GET_IID(nsIURI), (void**)&absurl);
    NS_RELEASE(uri);

    if (NS_OK == rv) {
      absURLSpec.Truncate();
      nsCAutoString str;
      absurl->GetSpec(str);
      absURLSpec = NS_ConvertUTF8toUCS2(str);
    }
  }

  // Now give link to robot observers
  PRInt32 i, n = mObservers.Count();
  for (i = 0; i < n; ++i) {
    nsIRobotSinkObserver* cop = (nsIRobotSinkObserver*)mObservers.ElementAt(i);
    cop->ProcessLink(absURLSpec);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIRobotSink.

Definition at line 350 of file nsRobotSink.cpp.

{
  if (mObservers.RemoveElement(aObserver)) {
    NS_RELEASE(aObserver);
    return NS_OK;
  }
  //XXX return NS_ERROR_NOT_FOUND;
  return NS_OK;
}
NS_IMETHOD RobotSink::SetDocumentCharset ( nsACString &  aCharset) [inline, virtual]

Set the document character set.

This should be passed on to the document itself.

Implements nsIContentSink.

Definition at line 108 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::SetParser ( nsIParser aParser) [inline, virtual]

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 106 of file nsRobotSink.cpp.

{ return NS_OK; }

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 180 of file nsRobotSink.cpp.

{
  return NS_OK;
}
NS_IMETHOD RobotSink::WillBuildModel ( void  ) [inline, virtual]

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 102 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::WillInterrupt ( void  ) [inline, virtual]

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 104 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::WillProcessAToken ( void  ) [inline, virtual]

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

Implements nsIHTMLContentSink.

Definition at line 112 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::WillProcessTokens ( void  ) [inline, virtual]

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

Implements nsIHTMLContentSink.

Definition at line 110 of file nsRobotSink.cpp.

{ return NS_OK; }
NS_IMETHOD RobotSink::WillResume ( void  ) [inline, virtual]

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 105 of file nsRobotSink.cpp.

{ return NS_OK; }

Member Data Documentation

Definition at line 127 of file nsRobotSink.cpp.

Definition at line 128 of file nsRobotSink.cpp.


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