Back to index

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

List of all members.

Public Member Functions

 nsHTMLFragmentContentSink (PRBool aAllContent=PR_FALSE)
virtual ~nsHTMLFragmentContentSink ()
NS_DECL_ISUPPORTS 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 BeginContext (PRInt32 aID)
 This gets called when handling illegal contents, especially in dealing with tables.
NS_IMETHOD EndContext (PRInt32 aID)
 This method terminates any new context that got created by BeginContext and switches back to the main context.
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 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 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 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 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 leaf 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 leaf 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.
NS_IMETHOD GetFragment (nsIDOMDocumentFragment **aFragment)
 This method is used to obtain the fragment created by a fragment content sink.
NS_IMETHOD SetTargetDocument (nsIDocument *aDocument)
 This method is used to set the target document for this fragment sink.
NS_IMETHOD WillBuildContent ()
 This method is used to indicate to the sink that we're done building the context and should start paying attention to the incoming content.
NS_IMETHOD DidBuildContent ()
 This method is used to indicate to the sink that we're done building The real content.
NS_IMETHOD IgnoreFirstContainer ()
 This method is a total hack to help with parsing fragments.
nsIContentGetCurrentContent ()
PRInt32 PushContent (nsIContent *aContent)
nsIContentPopContent ()
virtual nsresult AddAttributes (const nsIParserNode &aNode, nsIContent *aContent)
nsresult AddText (const nsAString &aString)
nsresult AddTextToContent (nsIContent *aContent, const nsAString &aText)
nsresult FlushText ()
void ProcessBaseTag (nsIContent *aContent)
void AddBaseTagInfo (nsIContent *aContent)
nsresult Init ()
nsresult SetDocumentTitle (const nsAString &aString, const nsIParserNode *aNode)

Public Attributes

PRPackedBool mAllContent
PRPackedBool mProcessing
PRPackedBool mSeenBody
PRPackedBool mIgnoreContainer
nsCOMPtr< nsIContentmRoot
nsCOMPtr< nsIParsermParser
nsVoidArraymContentStack
PRUnicharmText
PRInt32 mTextLength
PRInt32 mTextSize
nsString mBaseHREF
nsString mBaseTarget
nsCOMPtr< nsIDocumentmTargetDocument
nsRefPtr< nsNodeInfoManagermNodeInfoManager

Detailed Description

Definition at line 75 of file nsHTMLFragmentContentSink.cpp.


Constructor & Destructor Documentation

Definition at line 203 of file nsHTMLFragmentContentSink.cpp.

  : mAllContent(aAllContent),
    mProcessing(aAllContent),
    mSeenBody(!aAllContent),
    mIgnoreContainer(PR_FALSE),
    mContentStack(nsnull),
    mText(nsnull),
    mTextLength(0),
    mTextSize(0)
{
}

Definition at line 215 of file nsHTMLFragmentContentSink.cpp.

{
  // Should probably flush the text buffer here, just to make sure:
  //FlushText();

  if (nsnull != mContentStack) {
    // there shouldn't be anything here except in an error condition
    PRInt32 indx = mContentStack->Count();
    while (0 < indx--) {
      nsIContent* content = (nsIContent*)mContentStack->ElementAt(indx);
      NS_RELEASE(content);
    }
    delete mContentStack;
  }

  PR_FREEIF(mText);
}

Member Function Documentation

Reimplemented in nsHTMLParanoidFragmentSink.

Definition at line 876 of file nsHTMLFragmentContentSink.cpp.

{
  // Add tag attributes to the content attributes

  PRInt32 ac = aNode.GetAttributeCount();

  if (ac == 0) {
    // No attributes, nothing to do. Do an early return to avoid
    // constructing the nsAutoString object for nothing.

    return NS_OK;
  }

  nsCAutoString k;
  nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());

  // The attributes are on the parser node in the order they came in in the
  // source.  What we want to happen if a single attribute is set multiple
  // times on an element is that the first time should "win".  That is, <input
  // value="foo" value="bar"> should show "foo".  So we loop over the
  // attributes backwards; this ensures that the first attribute in the set
  // wins.  This does mean that we do some extra work in the case when the same
  // attribute is set multiple times, but we save a HasAttr call in the much
  // more common case of reasonable HTML.

  for (PRInt32 i = ac - 1; i >= 0; i--) {
    // Get lower-cased key
    const nsAString& key = aNode.GetKeyAt(i);
    // Copy up-front to avoid shared-buffer overhead (and convert to UTF-8
    // at the same time since that's what the atom table uses).
    CopyUTF16toUTF8(key, k);
    ToLowerCase(k);

    nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);

    // Get value and remove mandatory quotes
    static const char* kWhitespace = "\n\r\t\b";
    const nsAString& v =
      nsContentUtils::TrimCharsInSet(kWhitespace, aNode.GetValueAt(i));

    if (nodeType == eHTMLTag_a && keyAtom == nsHTMLAtoms::name) {
      NS_ConvertUCS2toUTF8 cname(v);
      NS_ConvertUTF8toUCS2 uv(nsUnescape(cname.BeginWriting()));

      // Add attribute to content
      aContent->SetAttr(kNameSpaceID_None, keyAtom, uv, PR_FALSE);
    } else {
      // Add attribute to content
      aContent->SetAttr(kNameSpaceID_None, keyAtom, v, PR_FALSE);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 405 of file nsHTMLFragmentContentSink.cpp.

{
  if (aContent) {
    if (!mBaseHREF.IsEmpty()) {
      aContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::_baseHref, mBaseHREF, PR_FALSE);
    }
    if (!mBaseTarget.IsEmpty()) {
      aContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::_baseTarget, mBaseTarget, PR_FALSE);
    }
  }
}

Here is the call graph for this function:

Here is the caller 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.

Reimplemented in nsHTMLParanoidFragmentSink.

Definition at line 648 of file nsHTMLFragmentContentSink.cpp.

{
  nsIContent *comment;
  nsIDOMComment *domComment;
  nsresult result = NS_OK;

  FlushText();

  result = NS_NewCommentNode(&comment, mNodeInfoManager);
  if (NS_SUCCEEDED(result)) {
    result = CallQueryInterface(comment, &domComment);
    if (NS_SUCCEEDED(result)) {
      domComment->AppendData(aNode.GetText());
      NS_RELEASE(domComment);

      nsIContent *parent = GetCurrentContent();

      if (nsnull == parent) {
        parent = mRoot;
      }

      parent->AppendChildTo(comment, PR_FALSE);
    }
    NS_RELEASE(comment);
  }

  return NS_OK;
}

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 689 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

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

Implements nsIHTMLContentSink.

Definition at line 528 of file nsHTMLFragmentContentSink.cpp.

{
  return AddLeaf(aNode);
}

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.

Reimplemented in nsHTMLParanoidFragmentSink.

Definition at line 534 of file nsHTMLFragmentContentSink.cpp.

{
  if (eHTMLTag_title == aNode.GetNodeType()) {
    nsCOMPtr<nsIDTD> dtd;
    mParser->GetDTD(getter_AddRefs(dtd));
    NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);

    nsAutoString skippedContent;
    PRInt32 lineNo = 0;

    dtd->CollectSkippedContent(eHTMLTag_title, skippedContent, lineNo);

    return SetDocumentTitle(skippedContent, &aNode);
  }

  NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED);

  nsresult result = NS_OK;

  switch (aNode.GetTokenType()) {
    case eToken_start:
      {
        FlushText();

        // Create new leaf content object
        nsCOMPtr<nsIContent> content;
        nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());

        nsIParserService* parserService =
          nsContentUtils::GetParserServiceWeakRef();
        if (!parserService)
          return NS_ERROR_OUT_OF_MEMORY;

        nsCOMPtr<nsINodeInfo> nodeInfo;

        if (nodeType == eHTMLTag_userdefined) {
          result =
            mNodeInfoManager->GetNodeInfo(aNode.GetText(), nsnull,
                                          kNameSpaceID_None,
                                          getter_AddRefs(nodeInfo));
        } else {
          nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
          NS_ASSERTION(name, "This should not happen!");

          result = mNodeInfoManager->GetNodeInfo(name, nsnull,
                                                 kNameSpaceID_None,
                                                 getter_AddRefs(nodeInfo));
        }

        NS_ENSURE_SUCCESS(result, result);

        if(NS_SUCCEEDED(result)) {
          result = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo);

          if (NS_OK == result) {
            result = AddAttributes(aNode, content);
            if (NS_OK == result) {
              nsIContent *parent = GetCurrentContent();

              if (nsnull == parent) {
                parent = mRoot;
              }

              parent->AppendChildTo(content, PR_FALSE);
            }
          }

          if(nodeType == eHTMLTag_script    ||
             nodeType == eHTMLTag_style     ||
             nodeType == eHTMLTag_server) {

            // Create a text node holding the content
            nsCOMPtr<nsIDTD> dtd;
            mParser->GetDTD(getter_AddRefs(dtd));
            NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);

            nsAutoString skippedContent;
            PRInt32 lineNo = 0;

            dtd->CollectSkippedContent(nodeType, skippedContent, lineNo);
            result=AddTextToContent(content, skippedContent);
          }
          else if (nodeType == eHTMLTag_img || nodeType == eHTMLTag_frame
              || nodeType == eHTMLTag_input)    // elements with 'SRC='
              AddBaseTagInfo(content);
          else if (nodeType == eHTMLTag_base)
              ProcessBaseTag(content);
        }
      }
      break;
    case eToken_text:
    case eToken_whitespace:
    case eToken_newline:
      result = AddText(aNode.GetText());
      break;

    case eToken_entity:
      {
        nsAutoString tmp;
        PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp);
        if (unicode < 0) {
          result = AddText(aNode.GetText());
        }
        else {
          result = AddText(tmp);
        }
      }
      break;
  }

  return result;
}

Here is the call graph for this function:

Here is the caller 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.

Reimplemented in nsHTMLParanoidFragmentSink.

Definition at line 678 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

Definition at line 783 of file nsHTMLFragmentContentSink.cpp.

{
  PRInt32 addLen = aString.Length();
  if (0 == addLen) {
    return NS_OK;
  }

  // Create buffer when we first need it
  if (0 == mTextSize) {
    mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * NS_ACCUMULATION_BUFFER_SIZE);
    if (nsnull == mText) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
    mTextSize = NS_ACCUMULATION_BUFFER_SIZE;
  }

  // Copy data from string into our buffer; flush buffer when it fills up
  PRInt32 offset = 0;
  PRBool  isLastCharCR = PR_FALSE;
  while (0 != addLen) {
    PRInt32 amount = mTextSize - mTextLength;
    if (amount > addLen) {
      amount = addLen;
    }
    if (0 == amount) {
      nsresult rv = FlushText();
      if (NS_OK != rv) {
        return rv;
      }
    }
    mTextLength +=
      nsContentUtils::CopyNewlineNormalizedUnicodeTo(aString,
                                                     offset,
                                                     &mText[mTextLength],
                                                     amount,
                                                     isLastCharCR);
    offset += amount;
    addLen -= amount;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHTMLFragmentContentSink::AddTextToContent ( nsIContent aContent,
const nsAString &  aText 
)

Definition at line 827 of file nsHTMLFragmentContentSink.cpp.

                                                                                        {
  NS_ASSERTION(aContent !=nsnull, "can't add text w/o a content");

  nsresult result=NS_OK;

  if(aContent) {
    if (!aText.IsEmpty()) {
      nsCOMPtr<nsITextContent> text;
      result = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager);
      if (NS_SUCCEEDED(result)) {
        text->SetText(aText, PR_TRUE);

        result = aContent->AppendChildTo(text, PR_FALSE);
      }
    }
  }
  return result;
}

Here is the call graph for this function:

Here is the caller 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 295 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

This method is used to close the main BODY container.

Implements nsIHTMLContentSink.

Definition at line 351 of file nsHTMLFragmentContentSink.cpp.

{
  return CloseContainer(eHTMLTag_body);
}

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.

Reimplemented in nsHTMLParanoidFragmentSink.

Definition at line 516 of file nsHTMLFragmentContentSink.cpp.

{
  if (mProcessing && (nsnull != GetCurrentContent())) {
    nsIContent* content;
    FlushText();
    content = PopContent();
    NS_RELEASE(content);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method is used to close the outer FORM container.

Implements nsIHTMLContentSink.

Definition at line 363 of file nsHTMLFragmentContentSink.cpp.

{
  return CloseContainer(eHTMLTag_form);
}

Here is the call graph for this function:

This method is used to close the FRAMESET container.

Implements nsIHTMLContentSink.

Definition at line 375 of file nsHTMLFragmentContentSink.cpp.

{
  return CloseContainer(eHTMLTag_frameset);
}

Here is the call graph for this function:

This method is used to close the only HEAD container.

Implements nsIHTMLContentSink.

Definition at line 331 of file nsHTMLFragmentContentSink.cpp.

{
  return CloseContainer(eHTMLTag_head);
}

Here is the call graph for this function:

This method is used to close the outer HTML container.

Implements nsIHTMLContentSink.

Definition at line 319 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

This method is used to close the MAP container.

Implements nsIHTMLContentSink.

Definition at line 387 of file nsHTMLFragmentContentSink.cpp.

{
  return CloseContainer(eHTMLTag_map);
}

Here is the call graph for this function:

This method is used to indicate to the sink that we're done building The real content.

This is useful if you want to parse additional context (such as an end context).

Implements nsIFragmentContentSink.

Definition at line 726 of file nsHTMLFragmentContentSink.cpp.

{
  if (!mAllContent) {
    FlushText();
    DidBuildModel(); // Release our ref to the parser now.
    mProcessing = PR_FALSE;
  }

  return NS_OK;
}

Here is the call 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 263 of file nsHTMLFragmentContentSink.cpp.

{
  FlushText();

  // Drop our reference to the parser to get rid of a circular
  // reference.
  mParser = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller 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 118 of file nsHTMLFragmentContentSink.cpp.

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

{ 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 301 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

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 90 of file nsHTMLFragmentContentSink.cpp.

{ }

Definition at line 847 of file nsHTMLFragmentContentSink.cpp.

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

  nsCOMPtr<nsITextContent> content;
  nsresult rv = NS_NewTextNode(getter_AddRefs(content), mNodeInfoManager);
  NS_ENSURE_SUCCESS(rv, rv);

  // Set the text in the text node
  content->SetText(mText, mTextLength, PR_FALSE);

  // Add text to its parent
  nsIContent *parent = GetCurrentContent();

  if (!parent) {
    parent = mRoot;
  }

  rv = parent->AppendChildTo(content, PR_FALSE);

  mTextLength = 0;

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 745 of file nsHTMLFragmentContentSink.cpp.

{
  if (nsnull != mContentStack) {
    PRInt32 indx = mContentStack->Count() - 1;
    if (indx >= 0)
      return (nsIContent *)mContentStack->ElementAt(indx);
  }
  return nsnull;
}

Here is the caller graph for this function:

This method is used to obtain the fragment created by a fragment content sink.

The value returned will be null if the content sink hasn't yet received parser notifications.

Implements nsIFragmentContentSink.

Definition at line 695 of file nsHTMLFragmentContentSink.cpp.

{
  if (mRoot) {
    return CallQueryInterface(mRoot, aFragment);
  }

  *aFragment = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

virtual nsISupports* nsHTMLFragmentContentSink::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 92 of file nsHTMLFragmentContentSink.cpp.

{ return mTargetDocument; }

This method is a total hack to help with parsing fragments.

It is called to tell the fragment sink that a container from the context will be delivered after the call to WillBuildContent(). This is only relevent for HTML fragments that use nsHTMLTokenizer/CNavDTD.

Implements nsIFragmentContentSink.

Definition at line 738 of file nsHTMLFragmentContentSink.cpp.

Reimplemented in nsHTMLParanoidFragmentSink.

NS_IMETHOD nsHTMLFragmentContentSink::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 108 of file nsHTMLFragmentContentSink.cpp.

                                                      {
    *aReturn = PR_TRUE;
    return NS_OK;
  }

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

Parameters:
aErrorResultthe error code

Implements nsIHTMLContentSink.

Definition at line 119 of file nsHTMLFragmentContentSink.cpp.

{ return NS_OK; }

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 112 of file nsHTMLFragmentContentSink.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 337 of file nsHTMLFragmentContentSink.cpp.

{
  // Ignore repeated BODY elements. The DTD is just sending them
  // to us for compatibility reasons that don't apply here.
  if (!mSeenBody) {
    mSeenBody = PR_TRUE;
    return OpenContainer(aNode);
  }
  else {
    return NS_OK;
  }
}

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.

Reimplemented in nsHTMLParanoidFragmentSink.

Definition at line 448 of file nsHTMLFragmentContentSink.cpp.

{
  NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED);

  nsresult result = NS_OK;

  if (mProcessing && !mIgnoreContainer) {
    FlushText();

    nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
    nsIContent *content = nsnull;

    nsCOMPtr<nsINodeInfo> nodeInfo;

    if (nodeType == eHTMLTag_userdefined) {
      result =
        mNodeInfoManager->GetNodeInfo(aNode.GetText(), nsnull,
                                      kNameSpaceID_None,
                                      getter_AddRefs(nodeInfo));
    } else {
      nsIParserService* parserService =
        nsContentUtils::GetParserServiceWeakRef();
      if (!parserService)
        return NS_ERROR_OUT_OF_MEMORY;

      nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
      NS_ASSERTION(name, "This should not happen!");

      result = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
                                             getter_AddRefs(nodeInfo));
    }

    NS_ENSURE_SUCCESS(result, result);

    result = NS_NewHTMLElement(&content, nodeInfo);

    if (NS_OK == result) {
      result = AddAttributes(aNode, content);
      if (NS_OK == result) {
        nsIContent *parent = GetCurrentContent();

        if (nsnull == parent) {
          parent = mRoot;
        }

        parent->AppendChildTo(content, PR_FALSE);
        PushContent(content);
      }
    }

    if (nodeType == eHTMLTag_table
        || nodeType == eHTMLTag_thead
        || nodeType == eHTMLTag_tbody
        || nodeType == eHTMLTag_tfoot
        || nodeType == eHTMLTag_tr
        || nodeType == eHTMLTag_td
        || nodeType == eHTMLTag_th)
      // XXX if navigator_quirks_mode (only body in html supports background)
      AddBaseTagInfo(content); 
  }
  else if (mProcessing && mIgnoreContainer) {
    mIgnoreContainer = PR_FALSE;
  }

  return result;
}

Here is the call graph for this function:

Here is the caller 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 357 of file nsHTMLFragmentContentSink.cpp.

{
  return OpenContainer(aNode);
}

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 369 of file nsHTMLFragmentContentSink.cpp.

{
  return OpenContainer(aNode);
}

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 325 of file nsHTMLFragmentContentSink.cpp.

{
  return OpenContainer(aNode);
}

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 313 of file nsHTMLFragmentContentSink.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 381 of file nsHTMLFragmentContentSink.cpp.

{
  return OpenContainer(aNode);
}

Here is the call graph for this function:

Definition at line 767 of file nsHTMLFragmentContentSink.cpp.

{
  nsIContent* content = nsnull;
  if (nsnull != mContentStack) {
    PRInt32 indx = mContentStack->Count() - 1;
    if (indx >= 0) {
      content = (nsIContent *)mContentStack->ElementAt(indx);
      mContentStack->RemoveElementAt(indx);
    }
  }
  return content;
}

Here is the caller graph for this function:

Definition at line 393 of file nsHTMLFragmentContentSink.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 756 of file nsHTMLFragmentContentSink.cpp.

{
  if (nsnull == mContentStack) {
    mContentStack = new nsVoidArray();
  }

  mContentStack->AppendElement((void *)aContent);
  return mContentStack->Count();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Set the document character set.

This should be passed on to the document itself.

Implements nsIContentSink.

Definition at line 91 of file nsHTMLFragmentContentSink.cpp.

{ return NS_OK; }

Definition at line 418 of file nsHTMLFragmentContentSink.cpp.

{
  NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED);

  nsCOMPtr<nsINodeInfo> nodeInfo;
  nsresult rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::title, nsnull,
                                              kNameSpaceID_None,
                                              getter_AddRefs(nodeInfo));
  NS_ENSURE_SUCCESS(rv, rv);

  nsRefPtr<nsGenericHTMLElement> content = NS_NewHTMLTitleElement(nodeInfo);
  NS_ENSURE_TRUE(content, NS_ERROR_OUT_OF_MEMORY);

  nsIContent *parent = GetCurrentContent();

  if (!parent) {
    parent = mRoot;
  }

  if (aNode) {
    AddAttributes(*aNode, content);
  }

  rv = parent->AppendChildTo(content, PR_FALSE);
  NS_ENSURE_SUCCESS(rv, rv);

  return AddTextToContent(content, aString);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 287 of file nsHTMLFragmentContentSink.cpp.

{
  mParser = aParser;

  return NS_OK;
}

This method is used to set the target document for this fragment sink.

This document's nodeinfo manager will be used to create the content objects. This MUST be called before the sink is used.

Parameters:
aDocumentthe document the new nodes will belong to (should not be null)

Implements nsIFragmentContentSink.

Definition at line 707 of file nsHTMLFragmentContentSink.cpp.

{
  NS_ENSURE_ARG_POINTER(aTargetDocument);

  mTargetDocument = aTargetDocument;
  mNodeInfoManager = aTargetDocument->NodeInfoManager();

  return NS_OK;
}

Here is the call graph for this function:

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 307 of file nsHTMLFragmentContentSink.cpp.

{
  return SetDocumentTitle(aValue, nsnull);
}

Here is the call graph for this function:

This method is used to indicate to the sink that we're done building the context and should start paying attention to the incoming content.

Implements nsIFragmentContentSink.

Definition at line 718 of file nsHTMLFragmentContentSink.cpp.

{
  mProcessing = PR_TRUE;

  return NS_OK;
}

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

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 275 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

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

Implements nsIHTMLContentSink.

Definition at line 117 of file nsHTMLFragmentContentSink.cpp.

{ return NS_OK; }

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

Implements nsIHTMLContentSink.

Definition at line 115 of file nsHTMLFragmentContentSink.cpp.

{ 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 281 of file nsHTMLFragmentContentSink.cpp.

{
  return NS_OK;
}

Member Data Documentation

Definition at line 152 of file nsHTMLFragmentContentSink.cpp.

Definition at line 166 of file nsHTMLFragmentContentSink.cpp.

Definition at line 167 of file nsHTMLFragmentContentSink.cpp.

Definition at line 160 of file nsHTMLFragmentContentSink.cpp.

Definition at line 155 of file nsHTMLFragmentContentSink.cpp.

Definition at line 170 of file nsHTMLFragmentContentSink.cpp.

Definition at line 158 of file nsHTMLFragmentContentSink.cpp.

Definition at line 153 of file nsHTMLFragmentContentSink.cpp.

Definition at line 157 of file nsHTMLFragmentContentSink.cpp.

Definition at line 154 of file nsHTMLFragmentContentSink.cpp.

Definition at line 169 of file nsHTMLFragmentContentSink.cpp.

Definition at line 162 of file nsHTMLFragmentContentSink.cpp.

Definition at line 163 of file nsHTMLFragmentContentSink.cpp.

Definition at line 164 of file nsHTMLFragmentContentSink.cpp.


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