Back to index

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

#include <nsXMLContentSink.h>

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

List of all members.

Public Member Functions

 nsXMLContentSink ()
virtual ~nsXMLContentSink ()
nsresult Init (nsIDocument *aDoc, nsIURI *aURL, nsISupports *aContainer, nsIChannel *aChannel)
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIEXPATSINK
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 OnDocumentCreated (nsIDOMDocument *aResultDocument)
NS_IMETHOD OnTransformDone (nsresult aResult, nsIDOMDocument *aResultDocument)
void scriptAvailable (in nsresult aResult, in nsIScriptElement aElement, in boolean aIsInline, in boolean aWasPending, in nsIURI aURI, in PRInt32 aLineNo, in AString aScript)
 The script is available for evaluation.
void scriptEvaluated (in nsresult aResult, in nsIScriptElement aElement, in boolean aIsInline, in boolean aWasPending)
 The script has been evaluated.
void HandleStartElement (in wstring aName,[array, size_is(aAttsCount)] in wstring aAtts, in unsigned long aAttsCount, in long aIndex, in unsigned long aLineNumber)
 Called to handle the opening tag of an element.
void HandleEndElement (in wstring aName)
 Called to handle the closing tag of an element.
void HandleComment (in wstring aCommentText)
 Called to handle a comment.
void HandleCDataSection ([size_is(aLength)] in wstring aData, in unsigned long aLength)
 Called to handle a CDATA section.
void HandleDoctypeDecl (in AString aSubset, in AString aName, in AString aSystemId, in AString aPublicId, in nsISupports aCatalogData)
 Called to handle the doctype declaration.
void HandleCharacterData ([size_is(aLength)] in wstring aData, in unsigned long aLength)
 Called to handle character data.
void HandleProcessingInstruction (in wstring aTarget, in wstring aData)
 Called to handle a processing instruction.
void HandleXMLDeclaration (in wstring aVersion, in wstring aEncoding, in long aStandalone)
 Handle the XML Declaration.
void ReportError (in wstring aErrorText, in wstring aSourceText)

Static Public Member Functions

static void ParsePIData (const nsString &aData, nsString &aHref, nsString &aTitle, nsString &aMedia, PRBool &aIsAlternate)

Protected Member Functions

void StartLayout ()
virtual nsresult AddAttributes (const PRUnichar **aNode, nsIContent *aContent)
nsresult AddText (const PRUnichar *aString, PRInt32 aLength)
nsresult ProcessEndSCRIPTTag (nsIContent *aContent, nsIContent *aParent)
virtual PRBool OnOpenContainer (const PRUnichar **aAtts, PRUint32 aAttsCount, PRInt32 aNameSpaceID, nsIAtom *aTagName, PRUint32 aLineNumber)
virtual PRBool SetDocElement (PRInt32 aNameSpaceID, nsIAtom *aTagName, nsIContent *aContent)
virtual nsresult CreateElement (const PRUnichar **aAtts, PRUint32 aAttsCount, nsINodeInfo *aNodeInfo, PRUint32 aLineNumber, nsIContent **aResult, PRBool *aAppendContent)
virtual nsresult CloseElement (nsIContent *aContent, nsIContent *aParent, PRBool *aAppendContent)
virtual nsresult FlushText (PRBool aCreateTextNode=PR_TRUE, PRBool *aDidFlush=nsnull)
nsresult AddContentAsLeaf (nsIContent *aContent)
nsIContentGetCurrentContent ()
PRInt32 PushContent (nsIContent *aContent)
already_AddRefed< nsIContentPopContent ()
nsresult ProcessBASETag (nsIContent *aContent)
virtual nsresult ProcessStyleLink (nsIContent *aElement, const nsSubstring &aHref, PRBool aAlternate, const nsSubstring &aTitle, const nsSubstring &aType, const nsSubstring &aMedia)
nsresult LoadXSLStyleSheet (nsIURI *aUrl)
nsresult MaybePrettyPrint ()
nsresult ProcessHTTPHeaders (nsIChannel *aChannel)
nsresult ProcessHeaderData (nsIAtom *aHeader, const nsAString &aValue, nsIContent *aContent=nsnull)
nsresult ProcessLinkHeader (nsIContent *aElement, const nsAString &aLinkData)
nsresult ProcessLink (nsIContent *aElement, const nsSubstring &aHref, const nsSubstring &aRel, const nsSubstring &aTitle, const nsSubstring &aType, const nsSubstring &aMedia)
nsresult ProcessMETATag (nsIContent *aContent)
void PrefetchHref (const nsAString &aHref, PRBool aExplicit)
PRBool ScrollToRef (PRBool aReallyScroll)
nsresult RefreshIfEnabled (nsIViewManager *vm)
void StartLayout (PRBool aIsFrameset)
virtual void PreEvaluateScript ()
virtual void PostEvaluateScript ()

Protected Attributes

nsIContentmDocElement
PRUnicharmText
XMLContentSinkState mState
nsString mTitleText
PRInt32 mTextLength
PRInt32 mTextSize
PRUint32 mScriptLineNo
PRUint8 mConstrainSize: 1
PRUint8 mInTitle: 1
PRUint8 mPrettyPrintXML: 1
PRUint8 mPrettyPrintHasSpecialRoot: 1
PRUint8 mPrettyPrintHasFactoredElements: 1
PRUint8 mHasProcessedBase: 1
PRUint8 mAllowAutoXLinks: 1
PRUint8 unused: 1
nsCOMArray< nsIContentmContentStack
nsCOMPtr< nsIDocumentTransformermXSLTProcessor
nsCOMPtr< nsIDocumentmDocument
nsCOMPtr< nsIParsermParser
nsCOMPtr< nsIURImDocumentURI
nsCOMPtr< nsIURImDocumentBaseURI
nsCOMPtr< nsIDocShellmDocShell
nsCOMPtr< nsICSSLoadermCSSLoader
nsRefPtr< nsNodeInfoManagermNodeInfoManager
nsCOMArray< nsIScriptElementmScriptElements
nsCString mRef
PRBool mNeedToBlockParser

Detailed Description

Definition at line 62 of file nsXMLContentSink.h.


Constructor & Destructor Documentation

Definition at line 160 of file nsXMLContentSink.cpp.

{
  NS_IF_RELEASE(mDocElement);
  if (mText) {
    PR_Free(mText);  //  Doesn't null out, unlike PR_FREEIF
  }
}

Member Function Documentation

nsresult nsXMLContentSink::AddAttributes ( const PRUnichar **  aNode,
nsIContent aContent 
) [protected, virtual]

Reimplemented in nsXHTMLParanoidFragmentSink, and nsXBLContentSink.

Definition at line 1373 of file nsXMLContentSink.cpp.

{
  // Add tag attributes to the content attributes
  nsCOMPtr<nsIAtom> prefix, localName;
  while (*aAtts) {
    PRInt32 nameSpaceID;
    nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);

    // Add attribute to content
    aContent->SetAttr(nameSpaceID, localName, prefix,
                      nsDependentString(aAtts[1]), PR_FALSE);
    aAtts += 2;
  }

  // Give autoloading links a chance to fire
  if (mDocShell && mAllowAutoXLinks) {
    nsCOMPtr<nsIXMLContent> xmlcontent(do_QueryInterface(aContent));
    if (xmlcontent) {
      nsresult rv = xmlcontent->MaybeTriggerAutoLink(mDocShell);
      if (rv == NS_XML_AUTOLINK_REPLACE ||
          rv == NS_XML_AUTOLINK_UNDEFINED) {
        // If we do not terminate the parse, we just keep generating link trigger
        // events. We want to parse only up to the first replace link, and stop.
        mParser->Terminate();
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 624 of file nsXMLContentSink.cpp.

{
  nsresult result = NS_OK;

  if ((eXMLContentSinkState_InProlog == mState) ||
      (eXMLContentSinkState_InEpilog == mState)) {
    nsCOMPtr<nsIDOMDocument> domDoc( do_QueryInterface(mDocument) );
    nsCOMPtr<nsIDOMNode> trash;
    nsCOMPtr<nsIDOMNode> child( do_QueryInterface(aContent) );
    NS_ASSERTION(child, "not a dom node");
    domDoc->AppendChild(child, getter_AddRefs(trash));
  }
  else {
    nsCOMPtr<nsIContent> parent = GetCurrentContent();

    if (parent) {
      result = parent->AppendChildTo(aContent, PR_FALSE);
    }
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXMLContentSink::AddText ( const PRUnichar aString,
PRInt32  aLength 
) [protected]

Definition at line 1409 of file nsXMLContentSink.cpp.

{

  if (mInTitle) {
    mTitleText.Append(aText,aLength);
  }

  // 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;
  }

  const nsAString& str = Substring(aText, aText+aLength);

  // Copy data from string into our buffer; flush buffer when it fills up
  PRInt32 offset = 0;
  PRBool  isLastCharCR = PR_FALSE;
  while (0 != aLength) {
    PRInt32 amount = mTextSize - mTextLength;
    if (amount > aLength) {
      amount = aLength;
    }
    if (0 == amount) {
      // XSLT wants adjacent textnodes merged.
      if (mConstrainSize && !mXSLTProcessor) {
        nsresult rv = FlushText();
        if (NS_OK != rv) {
          return rv;
        }
      }
      else {
        mTextSize += aLength;
        mText = (PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * mTextSize);
        if (nsnull == mText) {
          return NS_ERROR_OUT_OF_MEMORY;
        }
      }
    }
    mTextLength +=
      nsContentUtils::CopyNewlineNormalizedUnicodeTo(str, 
                                                     offset, 
                                                     &mText[mTextLength], 
                                                     amount,
                                                     isLastCharCR);
    offset  += amount;
    aLength -= amount;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXMLContentSink::CloseElement ( nsIContent aContent,
nsIContent aParent,
PRBool aAppendContent 
) [protected, virtual]

Reimplemented in nsXMLFragmentContentSink.

Definition at line 543 of file nsXMLContentSink.cpp.

{
  NS_ASSERTION(aContent, "missing element to close");

  *aAppendContent = PR_FALSE;

  nsINodeInfo* nodeInfo = aContent->GetNodeInfo();

  // Some HTML nodes need DoneAddingChildren() called to initialize
  // properly (eg form state restoration).
  if ((nodeInfo->NamespaceID() == kNameSpaceID_XHTML &&
       (nodeInfo->NameAtom() == nsHTMLAtoms::select ||
        nodeInfo->NameAtom() == nsHTMLAtoms::textarea ||
        nodeInfo->NameAtom() == nsHTMLAtoms::object ||
        nodeInfo->NameAtom() == nsHTMLAtoms::applet))
#ifdef MOZ_XTF
      || nodeInfo->NamespaceID() > kNameSpaceID_LastBuiltin
#endif
      ) {
    aContent->DoneAddingChildren();
  }
  
  if (!nodeInfo->NamespaceEquals(kNameSpaceID_XHTML) &&
      !nodeInfo->NamespaceEquals(kNameSpaceID_SVG)) {
    return NS_OK;
  }

  nsresult rv = NS_OK;

  if (nodeInfo->Equals(nsHTMLAtoms::script, kNameSpaceID_XHTML)
#ifdef MOZ_SVG
      || nodeInfo->Equals(nsSVGAtoms::script, kNameSpaceID_SVG)
#endif
    ) {
    rv = ProcessEndSCRIPTTag(aContent, aParent);
    *aAppendContent = PR_TRUE;
    return rv;
  }
  
  if ((nodeInfo->Equals(nsHTMLAtoms::title, kNameSpaceID_XHTML)
#ifdef MOZ_SVG
       || nodeInfo->Equals(nsSVGAtoms::title, kNameSpaceID_SVG)
#endif // MOZ_SVG
      ) && mInTitle) {
    NS_ASSERTION(mDocument, "How did mInTitle get to be true if mDocument is null?");
    // The first title wins
    nsCOMPtr<nsIDOMNSDocument> dom_doc(do_QueryInterface(mDocument));
    mTitleText.CompressWhitespace();
    dom_doc->SetTitle(mTitleText);
    mInTitle = PR_FALSE;
  }
  else if (nodeInfo->Equals(nsHTMLAtoms::base, kNameSpaceID_XHTML) &&
           !mHasProcessedBase) {
    // The first base wins
    rv = ProcessBASETag(aContent);
    mHasProcessedBase = PR_TRUE;
  }
  else if (nodeInfo->Equals(nsHTMLAtoms::meta, kNameSpaceID_XHTML) &&
           // Need to check here to make sure this meta tag does not set
           // mPrettyPrintXML to false when we have a special root!
           (!mPrettyPrintXML || !mPrettyPrintHasSpecialRoot)) {
    rv = ProcessMETATag(aContent);
  }
  else if (nodeInfo->Equals(nsHTMLAtoms::link, kNameSpaceID_XHTML) ||
           nodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_XHTML) ||
           nodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_SVG)) {
    nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aContent));
    if (ssle) {
      ssle->SetEnableUpdates(PR_TRUE);
      rv = ssle->UpdateStyleSheet(nsnull, nsnull);
      if (rv == NS_ERROR_HTMLPARSER_BLOCK && mParser) {
        mParser->BlockParser();
      }
    }
  }

  return rv;
}  

Here is the call graph for this function:

nsresult nsXMLContentSink::CreateElement ( const PRUnichar **  aAtts,
PRUint32  aAttsCount,
nsINodeInfo aNodeInfo,
PRUint32  aLineNumber,
nsIContent **  aResult,
PRBool aAppendContent 
) [protected, virtual]

Reimplemented in nsXBLContentSink, and nsXMLFragmentContentSink.

Definition at line 461 of file nsXMLContentSink.cpp.

{
  NS_ASSERTION(aNodeInfo, "can't create element without nodeinfo");

  *aResult = nsnull;
  *aAppendContent = PR_TRUE;
  nsresult rv = NS_OK;

  nsCOMPtr<nsIContent> content;
  rv = NS_NewElement(getter_AddRefs(content), aNodeInfo->NamespaceID(),
                     aNodeInfo);
  NS_ENSURE_SUCCESS(rv, rv);

  if (aNodeInfo->Equals(nsHTMLAtoms::script, kNameSpaceID_XHTML)
#ifdef MOZ_SVG
      || aNodeInfo->Equals(nsSVGAtoms::script, kNameSpaceID_SVG)
#endif
    ) {
    // Don't append the content to the tree until we're all
    // done collecting its contents
    mConstrainSize = PR_FALSE;
    mScriptLineNo = aLineNumber;
    *aAppendContent = PR_FALSE;
  }

  // XHTML needs some special attention
  if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
    mPrettyPrintHasFactoredElements = PR_TRUE;
  }
  else {
    // If we care, find out if we just used a special factory.
    if (!mPrettyPrintHasFactoredElements && !mPrettyPrintHasSpecialRoot &&
        mPrettyPrintXML) {
      mPrettyPrintHasFactoredElements =
        nsContentUtils::GetNSManagerWeakRef()->
          HasElementCreator(aNodeInfo->NamespaceID());
    }

    if (!aNodeInfo->NamespaceEquals(kNameSpaceID_SVG)) {
      content.swap(*aResult);

      return NS_OK;
    }
  }

  if (aNodeInfo->Equals(nsHTMLAtoms::title, kNameSpaceID_XHTML)) {
    if (mDocument && mDocument->GetDocumentTitle().IsVoid()) {
      mInTitle = PR_TRUE; // The first title wins
    }
  }
#ifdef MOZ_SVG
  else if (aNodeInfo->Equals(nsSVGAtoms::title, kNameSpaceID_SVG)) {
    nsIContent* parent = GetCurrentContent();
    if (mDocument && mDocument->GetDocumentTitle().IsVoid() &&
        parent && parent == mDocElement &&
        parent->GetNodeInfo()->Equals(nsSVGAtoms::svg, kNameSpaceID_SVG)) {
      mInTitle = PR_TRUE; // The first title wins
    }
  }
#endif // MOZ_SVG
  else if (aNodeInfo->Equals(nsHTMLAtoms::link, kNameSpaceID_XHTML) ||
           aNodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_XHTML) ||
           aNodeInfo->Equals(nsHTMLAtoms::style, kNameSpaceID_SVG)) {
    nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(content));
    if (ssle) {
      ssle->InitStyleLinkElement(mParser, PR_FALSE);
      ssle->SetEnableUpdates(PR_FALSE);
      if (!aNodeInfo->Equals(nsHTMLAtoms::link, kNameSpaceID_XHTML)) {
        ssle->SetLineNumber(aLineNumber);
      }
    }
  } 

  content.swap(*aResult);

  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.

Reimplemented in nsXMLFragmentContentSink.

Definition at line 281 of file nsXMLContentSink.cpp.

{
  if (mDocument && mDocument->GetDocumentTitle().IsVoid()) {
    nsCOMPtr<nsIDOMNSDocument> dom_doc(do_QueryInterface(mDocument));
    dom_doc->SetTitle(EmptyString());
  }

  if (mXSLTProcessor) {

    // Check for xslt-param and xslt-param-namespace PIs
    PRUint32 i;
    nsIContent* child;
    for (i = 0; (child = mDocument->GetChildAt(i)); ++i) {
      if (child->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION)) {
        nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(child);
        CheckXSLTParamPI(pi, mXSLTProcessor, mDocument);
      }
      else if (child->IsContentOfType(nsIContent::eELEMENT)) {
        // Only honor PIs in the prolog
        break;
      }
    }

    nsCOMPtr<nsIDOMDocument> currentDOMDoc(do_QueryInterface(mDocument));
    mXSLTProcessor->SetSourceContentModel(currentDOMDoc);
    // Since the processor now holds a reference to us we drop our reference
    // to it to avoid owning cycles
    mXSLTProcessor = nsnull;
  }
  else {
    // Kick off layout for non-XSLT transformed documents.
    nsIScriptLoader *loader = mDocument->GetScriptLoader();
    if (loader) {
      loader->RemoveObserver(this);
    }

    if (mDocElement) {
      // Notify document observers that all the content has been stuck
      // into the document.
      // XXX do we need to notify for things like PIs?  Or just the
      // documentElement?
      NS_ASSERTION(mDocument->IndexOf(mDocElement) != -1,
                   "mDocElement not in doc?");

      mozAutoDocUpdate docUpdate(mDocument, UPDATE_CONTENT_MODEL, PR_TRUE);
      mDocument->ContentInserted(nsnull, mDocElement,
                                 // XXXbz is this last arg relevant if
                                 // the container is null?
                                 mDocument->IndexOf(mDocElement));
    }

    // Check if we want to prettyprint
    MaybePrettyPrint();

    StartLayout();

#if 0 /* Disable until this works for XML */
    //  Scroll to Anchor only if the document was *not* loaded through history means. 
    if (mDocShell) {
      PRUint32 documentLoadType = 0;
      mDocShell->GetLoadType(&documentLoadType);
      ScrollToRef(!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY));
    }
#else
    ScrollToRef(PR_TRUE);
#endif

    mDocument->EndLoad();
  }

  // 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:

virtual void nsXMLContentSink::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 87 of file nsXMLContentSink.h.

{ }
nsresult nsXMLContentSink::FlushText ( PRBool  aCreateTextNode = PR_TRUE,
PRBool aDidFlush = nsnull 
) [protected, virtual]

Reimplemented in nsXBLContentSink.

Definition at line 795 of file nsXMLContentSink.cpp.

{
  nsresult rv = NS_OK;
  PRBool didFlush = PR_FALSE;
  if (0 != mTextLength) {
    if (aCreateTextNode) {
      nsCOMPtr<nsITextContent> textContent;
      rv = NS_NewTextNode(getter_AddRefs(textContent), mNodeInfoManager);
      NS_ENSURE_SUCCESS(rv, rv);

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

      // Add text to its parent
      AddContentAsLeaf(textContent);
    }
    mTextLength = 0;
    didFlush = PR_TRUE;
  }

  if (nsnull != aDidFlush) {
    *aDidFlush = didFlush;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 822 of file nsXMLContentSink.cpp.

{
  PRInt32 count = mContentStack.Count();

  if (count == 0) {
    return nsnull;
  }

  NS_ASSERTION(count > 0, "Bogus Count()");

  return mContentStack[count-1];
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsISupports * nsXMLContentSink::GetTarget ( ) [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.

Reimplemented in nsXMLFragmentContentSink.

Definition at line 789 of file nsXMLContentSink.cpp.

{
  return mDocument;
}
void nsIExpatSink::HandleCDataSection ( [size_is(aLength)] in wstring  aData,
in unsigned long  aLength 
) [inherited]

Called to handle a CDATA section.

Parameters:
aDatathe text in the CDATA section. This is null-terminated.
aLengththe length of the aData string
void nsIExpatSink::HandleCharacterData ( [size_is(aLength)] in wstring  aData,
in unsigned long  aLength 
) [inherited]

Called to handle character data.

Note that this does NOT get called for the contents of CDATA sections.

Parameters:
aDatathe data to handle. aData is NOT NULL-TERMINATED.
aLengththe length of the aData string
void nsIExpatSink::HandleComment ( in wstring  aCommentText) [inherited]

Called to handle a comment.

Parameters:
aCommentTextthe text of the comment (not including the "<!--" and "-->")
void nsIExpatSink::HandleDoctypeDecl ( in AString  aSubset,
in AString  aName,
in AString  aSystemId,
in AString  aPublicId,
in nsISupports  aCatalogData 
) [inherited]

Called to handle the doctype declaration.

void nsIExpatSink::HandleEndElement ( in wstring  aName) [inherited]

Called to handle the closing tag of an element.

Parameters:
aNamethe fully qualified tagname of the element
void nsIExpatSink::HandleProcessingInstruction ( in wstring  aTarget,
in wstring  aData 
) [inherited]

Called to handle a processing instruction.

Parameters:
aTargetthe PI target (e.g. xml-stylesheet)
aDataall the rest of the data in the PI
void nsIExpatSink::HandleStartElement ( in wstring  aName,
[array, size_is(aAttsCount)] in wstring  aAtts,
in unsigned long  aAttsCount,
in long  aIndex,
in unsigned long  aLineNumber 
) [inherited]

Called to handle the opening tag of an element.

Parameters:
aNamethe fully qualified tagname of the element
aAttsthe array of attribute names and values. There are aAttsCount/2 names and aAttsCount/2 values, so the total number of elements in the array is aAttsCount. The names and values alternate. Thus, if we number attributes starting with 0, aAtts[2*k] is the name of the k-th attribute and aAtts[2*k+1] is the value of that attribute Both explicitly specified attributes and attributes that are defined to have default values in a DTD are present in aAtts.
aAttsCountthe number of elements in aAtts.
aIndexIf the element has an attribute of type ID, then aAtts[aIndex] is the name of that attribute. Otherwise, aIndex is -1
aLineNumberthe line number of the start tag in the data stream.
void nsIExpatSink::HandleXMLDeclaration ( in wstring  aVersion,
in wstring  aEncoding,
in long  aStandalone 
) [inherited]

Handle the XML Declaration.

Parameters:
aVersionThe version string, can be null if not specified.
aEncodingThe encoding string, can be null if not specified.
aStandalone-1, 0, or 1 indicating respectively that there was no standalone parameter in the declaration, that it was given as no, or that it was given as yes.
nsresult nsXMLContentSink::Init ( nsIDocument aDoc,
nsIURI aURL,
nsISupports *  aContainer,
nsIChannel aChannel 
)

Reimplemented from nsContentSink.

Definition at line 169 of file nsXMLContentSink.cpp.

Here is the caller graph for this function:

Reimplemented in nsXMLFragmentContentSink.

Definition at line 650 of file nsXMLContentSink.cpp.

{
  mXSLTProcessor =
    do_CreateInstance("@mozilla.org/document-transformer;1?type=xslt");
  if (!mXSLTProcessor) {
    // No XSLT processor available, continue normal document loading
    return NS_OK;
  }

  mXSLTProcessor->SetTransformObserver(this);

  nsCOMPtr<nsILoadGroup> loadGroup = mDocument->GetDocumentLoadGroup();
  if (!loadGroup) {
    mXSLTProcessor = nsnull;
    return NS_ERROR_FAILURE;
  }

  return mXSLTProcessor->LoadStyleSheet(aUrl, loadGroup, mDocument->GetPrincipal());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 213 of file nsXMLContentSink.cpp.

{
  if (!mPrettyPrintXML || (mPrettyPrintHasFactoredElements &&
                           !mPrettyPrintHasSpecialRoot)) {
    mPrettyPrintXML = PR_FALSE;

    return NS_OK;
  }

  // Reenable the CSSLoader so that the prettyprinting stylesheets can load
  if (mCSSLoader) {
    mCSSLoader->SetEnabled(PR_TRUE);
  }
  
  nsCOMPtr<nsXMLPrettyPrinter> printer;
  nsresult rv = NS_NewXMLPrettyPrinter(getter_AddRefs(printer));
  NS_ENSURE_SUCCESS(rv, rv);

  return printer->PrettyPrint(mDocument);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsITransformObserver.

Definition at line 359 of file nsXMLContentSink.cpp.

{
  NS_ENSURE_ARG(aResultDocument);

  nsCOMPtr<nsIContentViewer> contentViewer;
  mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
  if (contentViewer) {
    contentViewer->SetDOMDocument(aResultDocument);
  }
  return NS_OK;
}

Here is the call graph for this function:

virtual PRBool nsXMLContentSink::OnOpenContainer ( const PRUnichar **  aAtts,
PRUint32  aAttsCount,
PRInt32  aNameSpaceID,
nsIAtom aTagName,
PRUint32  aLineNumber 
) [inline, protected, virtual]

Reimplemented in nsXBLContentSink.

Definition at line 106 of file nsXMLContentSink.h.

                                                       { return PR_TRUE; }
NS_IMETHODIMP nsXMLContentSink::OnTransformDone ( nsresult  aResult,
nsIDOMDocument aResultDocument 
) [virtual]

Implements nsITransformObserver.

Definition at line 372 of file nsXMLContentSink.cpp.

{
  NS_ASSERTION(NS_FAILED(aResult) || aResultDocument,
               "Don't notify about transform success without a document.");

  nsCOMPtr<nsIContentViewer> contentViewer;
  mDocShell->GetContentViewer(getter_AddRefs(contentViewer));

  if (NS_FAILED(aResult) && contentViewer) {
    // Transform failed.
    if (aResultDocument) {
      // We have an error document.
      contentViewer->SetDOMDocument(aResultDocument);
    }
    else {
      // We don't have an error document, display the
      // untransformed source document.
      nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(mDocument);
      contentViewer->SetDOMDocument(document);
    }
  }

  nsCOMPtr<nsIDocument> originalDocument = mDocument;
  if (NS_SUCCEEDED(aResult) || aResultDocument) {
    // Transform succeeded or it failed and we have an error
    // document to display.
    mDocument = do_QueryInterface(aResultDocument);
  }

  nsIScriptLoader *loader = originalDocument->GetScriptLoader();
  if (loader) {
    loader->RemoveObserver(this);
  }

  // Notify document observers that all the content has been stuck
  // into the document.  
  // XXX do we need to notify for things like PIs?  Or just the
  // documentElement?
  nsIContent *rootContent = mDocument->GetRootContent();
  if (rootContent) {
    NS_ASSERTION(mDocument->IndexOf(rootContent) != -1,
                 "rootContent not in doc?");
    mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
    mDocument->ContentInserted(nsnull, rootContent,
                               // XXXbz is this last arg relevant if
                               // the container is null?
                               mDocument->IndexOf(rootContent));
    mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
  }
  
  // Start the layout process
  StartLayout();

#if 0 /* Disable until this works for XML */
  //  Scroll to Anchor only if the document was *not* loaded through history means. 
  PRUint32 documentLoadType = 0;
  docShell->GetLoadType(&documentLoadType);
  ScrollToRef(!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY));
#else
  ScrollToRef(PR_TRUE);
#endif

  originalDocument->EndLoad();

  return NS_OK;
}

Here is the call graph for this function:

void nsXMLContentSink::ParsePIData ( const nsString aData,
nsString aHref,
nsString aTitle,
nsString aMedia,
PRBool aIsAlternate 
) [static]

Definition at line 1271 of file nsXMLContentSink.cpp.

{
  nsParserUtils::GetQuotedAttributeValue(aData, nsHTMLAtoms::href, aHref);

  // If there was no href, we can't do anything with this PI
  if (aHref.IsEmpty()) {
    return;
  }

  nsParserUtils::GetQuotedAttributeValue(aData, nsHTMLAtoms::title, aTitle);

  nsParserUtils::GetQuotedAttributeValue(aData, nsHTMLAtoms::media, aMedia);

  nsAutoString alternate;
  nsParserUtils::GetQuotedAttributeValue(aData, nsHTMLAtoms::alternate,
                                         alternate);

  aIsAlternate = alternate.EqualsLiteral("yes");
}

Here is the call graph for this function:

Definition at line 844 of file nsXMLContentSink.cpp.

{  
  PRInt32 count = mContentStack.Count();

  if (count == 0) {
    NS_WARNING("Popping empty stack");
    return nsnull;
  }

  NS_ASSERTION(count > 0, "Bogus Count()");

  nsIContent* content = mContentStack[count - 1];
  NS_IF_ADDREF(content);
  mContentStack.RemoveObjectAt(count - 1);
  
  return content;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void nsContentSink::PostEvaluateScript ( ) [inline, protected, virtual, inherited]

Reimplemented in HTMLContentSink.

Definition at line 109 of file nsContentSink.h.

{return;}
virtual void nsContentSink::PreEvaluateScript ( ) [inline, protected, virtual, inherited]

Reimplemented in HTMLContentSink.

Definition at line 108 of file nsContentSink.h.

{return;}
void nsContentSink::PrefetchHref ( const nsAString &  aHref,
PRBool  aExplicit 
) [protected, inherited]

Definition at line 717 of file nsContentSink.cpp.

{
  //
  // SECURITY CHECK: disable prefetching from mailnews!
  //
  // walk up the docshell tree to see if any containing
  // docshell are of type MAIL.
  //
  if (!mDocShell)
    return;

  nsCOMPtr<nsIDocShell> docshell = mDocShell;

  nsCOMPtr<nsIDocShellTreeItem> treeItem, parentItem;
  do {
    PRUint32 appType = 0;
    nsresult rv = docshell->GetAppType(&appType);
    if (NS_FAILED(rv) || appType == nsIDocShell::APP_TYPE_MAIL)
      return; // do not prefetch from mailnews
    if (treeItem = do_QueryInterface(docshell)) {
      treeItem->GetParent(getter_AddRefs(parentItem));
      if (parentItem) {
        treeItem = parentItem;
        docshell = do_QueryInterface(treeItem);
        if (!docshell) {
          NS_ERROR("cannot get a docshell from a treeItem!");
          return;
        }
      }
    }
  } while (parentItem);
  
  // OK, we passed the security check...
  
  nsCOMPtr<nsIPrefetchService> prefetchService(do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
  if (prefetchService) {
    // construct URI using document charset
    const nsACString &charset = mDocument->GetDocumentCharacterSet();
    nsCOMPtr<nsIURI> uri;
    NS_NewURI(getter_AddRefs(uri), aHref,
              charset.IsEmpty() ? nsnull : PromiseFlatCString(charset).get(),
              mDocumentBaseURI);
    if (uri) {
      prefetchService->PrefetchURI(uri, mDocumentURI, aExplicit);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 747 of file nsXMLContentSink.cpp.

{
  NS_ASSERTION(aContent, "missing base-element");

  nsresult rv = NS_OK;

  if (mDocument) {
    nsAutoString value;
  
    if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, value) ==
        NS_CONTENT_ATTR_HAS_VALUE) {
      mDocument->SetBaseTarget(value);
    }

    if (aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::href, value) ==
        NS_CONTENT_ATTR_HAS_VALUE) {
      nsCOMPtr<nsIURI> baseURI;
      rv = NS_NewURI(getter_AddRefs(baseURI), value);
      if (NS_SUCCEEDED(rv)) {
        rv = mDocument->SetBaseURI(baseURI); // The document checks if it is legal to set this base
        if (NS_SUCCEEDED(rv)) {
          mDocumentBaseURI = mDocument->GetBaseURI();
        }
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXMLContentSink::ProcessEndSCRIPTTag ( nsIContent aContent,
nsIContent aParent 
) [protected]

Definition at line 1466 of file nsXMLContentSink.cpp.

{
  nsresult result = NS_OK;

  mConstrainSize = PR_TRUE; 
  nsCOMPtr<nsIScriptElement> scriptElement(do_QueryInterface(aContent));
  NS_ASSERTION(scriptElement, "null script element in XML content sink");

  scriptElement->SetScriptLineNumber(mScriptLineNo);

  if (!aParent || aParent->GetCurrentDoc() == mDocument) {
    // Assume that we're going to block the parser with a script load.
    // If it's an inline script, we'll be told otherwise in the call
    // to our ScriptAvailable method.
    mScriptElements.AppendObject(scriptElement);
    mNeedToBlockParser = PR_TRUE;
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSink::ProcessHeaderData ( nsIAtom aHeader,
const nsAString &  aValue,
nsIContent aContent = nsnull 
) [protected, inherited]

Definition at line 307 of file nsContentSink.cpp.

{
  nsresult rv = NS_OK;
  // necko doesn't process headers coming in from the parser

  mDocument->SetHeaderData(aHeader, aValue);

  if (aHeader == nsHTMLAtoms::setcookie) {
    // Note: Necko already handles cookies set via the channel.  We can't just
    // call SetCookie on the channel because we want to do some security checks
    // here and want to use the prompt associated to our current window, not
    // the window where the channel was dispatched.
    nsCOMPtr<nsICookieService> cookieServ =
      do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
    if (NS_FAILED(rv)) {
      return rv;
    }

    // Get a URI from the document principal

    // We use the original codebase in case the codebase was changed
    // by SetDomain

    nsIPrincipal *docPrincipal = mDocument->GetPrincipal();
    if (!docPrincipal) {
      return NS_ERROR_FAILURE;
    }

    nsCOMPtr<nsIPrincipal> systemPrincipal;
    nsContentUtils::GetSecurityManager()->
      GetSystemPrincipal(getter_AddRefs(systemPrincipal));
    NS_ASSERTION(systemPrincipal, "No system principal");
    
    if (docPrincipal == systemPrincipal) {
      // Document's principal is not a codebase, so we can't set cookies
      return NS_OK;
    }

    nsCOMPtr<nsIURI> codebaseURI;
    rv = docPrincipal->GetURI(getter_AddRefs(codebaseURI));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIPrompt> prompt;
    nsCOMPtr<nsIDOMWindowInternal> window (do_QueryInterface(mDocument->GetScriptGlobalObject()));
    if (window) {
      window->GetPrompter(getter_AddRefs(prompt));
    }

    nsCOMPtr<nsIChannel> channel;
    if (mParser) {
      mParser->GetChannel(getter_AddRefs(channel));
    }

    rv = cookieServ->SetCookieString(codebaseURI,
                                     prompt,
                                     NS_ConvertUCS2toUTF8(aValue).get(),
                                     channel);
    if (NS_FAILED(rv)) {
      return rv;
    }
  }
  else if (aHeader == nsHTMLAtoms::link) {
    rv = ProcessLinkHeader(aContent, aValue);
  }
  else if (aHeader == nsHTMLAtoms::msthemecompatible) {
    // Disable theming for the presshell if the value is no.
    // XXXbz don't we want to support this as an HTTP header too?
    nsAutoString value(aValue);
    if (value.LowerCaseEqualsLiteral("no")) {
      nsIPresShell* shell = mDocument->GetShellAt(0);
      if (shell) {
        shell->DisableThemeSupport();
      }
    }
  }
  // Don't report "refresh" headers back to necko, since our document handles
  // them
  else if (aHeader != nsHTMLAtoms::refresh && mParser) {
    // we also need to report back HTTP-EQUIV headers to the channel
    // so that it can process things like pragma: no-cache or other
    // cache-control headers. Ideally this should also be the way for
    // cookies to be set! But we'll worry about that in the next
    // iteration
    nsCOMPtr<nsIChannel> channel;
    if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
      nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
      if (httpChannel) {
        const char* header;
        (void)aHeader->GetUTF8String(&header);
        (void)httpChannel->SetResponseHeader(nsDependentCString(header),
                                             NS_ConvertUCS2toUTF8(aValue),
                                             PR_TRUE);
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSink::ProcessHTTPHeaders ( nsIChannel aChannel) [protected, inherited]

Definition at line 283 of file nsContentSink.cpp.

{
  nsCOMPtr<nsIHttpChannel> httpchannel(do_QueryInterface(aChannel));
  
  if (!httpchannel) {
    return NS_OK;
  }

  // Note that the only header we care about is the "link" header, since we
  // have all the infrastructure for kicking off stylesheet loads.
  
  nsCAutoString linkHeader;
  
  nsresult rv = httpchannel->GetResponseHeader(NS_LITERAL_CSTRING("link"),
                                               linkHeader);
  if (NS_SUCCEEDED(rv) && !linkHeader.IsEmpty()) {
    ProcessHeaderData(nsHTMLAtoms::link,
                      NS_ConvertASCIItoUTF16(linkHeader));
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSink::ProcessLink ( nsIContent aElement,
const nsSubstring aHref,
const nsSubstring aRel,
const nsSubstring aTitle,
const nsSubstring aType,
const nsSubstring aMedia 
) [protected, inherited]

Definition at line 593 of file nsContentSink.cpp.

{
  // XXX seems overkill to generate this string array
  nsStringArray linkTypes;
  nsStyleLinkElement::ParseLinkTypes(aRel, linkTypes);

  PRBool hasPrefetch = (linkTypes.IndexOf(NS_LITERAL_STRING("prefetch")) != -1);
  // prefetch href if relation is "next" or "prefetch"
  if (hasPrefetch || linkTypes.IndexOf(NS_LITERAL_STRING("next")) != -1) {
    PrefetchHref(aHref, hasPrefetch);
  }

  // is it a stylesheet link?
  if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) == -1) {
    return NS_OK;
  }

  PRBool isAlternate = linkTypes.IndexOf(NS_LITERAL_STRING("alternate")) != -1;
  return ProcessStyleLink(aElement, aHref, isAlternate, aTitle, aType,
                          aMedia);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSink::ProcessLinkHeader ( nsIContent aElement,
const nsAString &  aLinkData 
) [protected, inherited]

Definition at line 415 of file nsContentSink.cpp.

{
  nsresult rv = NS_OK;

  // parse link content and call process style link
  nsAutoString href;
  nsAutoString rel;
  nsAutoString title;
  nsAutoString type;
  nsAutoString media;
  PRBool didBlock = PR_FALSE;

  // copy to work buffer
  nsAutoString stringList(aLinkData);

  // put an extra null at the end
  stringList.Append(kNullCh);

  PRUnichar* start = stringList.BeginWriting();
  PRUnichar* end   = start;
  PRUnichar* last  = start;
  PRUnichar  endCh;

  while (*start != kNullCh) {
    // skip leading space
    while ((*start != kNullCh) && nsCRT::IsAsciiSpace(*start)) {
      ++start;
    }

    end = start;
    last = end - 1;

    // look for semicolon or comma
    while (*end != kNullCh && *end != kSemiCh && *end != kCommaCh) {
      PRUnichar ch = *end;

      if (ch == kApostrophe || ch == kQuote || ch == kLessThanCh) {
        // quoted string

        PRUnichar quote = *end;
        if (quote == kLessThanCh) {
          quote = kGreaterThanCh;
        }

        PRUnichar* closeQuote = (end + 1);

        // seek closing quote
        while (*closeQuote != kNullCh && quote != *closeQuote) {
          ++closeQuote;
        }

        if (quote == *closeQuote) {
          // found closer

          // skip to close quote
          end = closeQuote;

          last = end - 1;

          ch = *(end + 1);

          if (ch != kNullCh && ch != kSemiCh && ch != kCommaCh) {
            // end string here
            *(++end) = kNullCh;

            ch = *(end + 1);

            // keep going until semi or comma
            while (ch != kNullCh && ch != kSemiCh && ch != kCommaCh) {
              ++end;

              ch = *end;
            }
          }
        }
      }

      ++end;
      ++last;
    }

    endCh = *end;

    // end string here
    *end = kNullCh;

    if (start < end) {
      if ((*start == kLessThanCh) && (*last == kGreaterThanCh)) {
        *last = kNullCh;

        if (href.IsEmpty()) { // first one wins
          href = (start + 1);
          href.StripWhitespace();
        }
      } else {
        PRUnichar* equals = start;

        while ((*equals != kNullCh) && (*equals != kEqualsCh)) {
          equals++;
        }

        if (*equals != kNullCh) {
          *equals = kNullCh;
          nsAutoString  attr(start);
          attr.StripWhitespace();

          PRUnichar* value = ++equals;
          while (nsCRT::IsAsciiSpace(*value)) {
            value++;
          }

          if (((*value == kApostrophe) || (*value == kQuote)) &&
              (*value == *last)) {
            *last = kNullCh;
            value++;
          }

          if (attr.LowerCaseEqualsLiteral("rel")) {
            if (rel.IsEmpty()) {
              rel = value;
              rel.CompressWhitespace();
            }
          } else if (attr.LowerCaseEqualsLiteral("title")) {
            if (title.IsEmpty()) {
              title = value;
              title.CompressWhitespace();
            }
          } else if (attr.LowerCaseEqualsLiteral("type")) {
            if (type.IsEmpty()) {
              type = value;
              type.StripWhitespace();
            }
          } else if (attr.LowerCaseEqualsLiteral("media")) {
            if (media.IsEmpty()) {
              media = value;

              // HTML4.0 spec is inconsistent, make it case INSENSITIVE
              ToLowerCase(media);
            }
          }
        }
      }
    }

    if (endCh == kCommaCh) {
      // hit a comma, process what we've got so far

      if (!href.IsEmpty() && !rel.IsEmpty()) {
        rv = ProcessLink(aElement, href, rel, title, type, media);
        if (rv == NS_ERROR_HTMLPARSER_BLOCK) {
          didBlock = PR_TRUE;
        }
      }

      href.Truncate();
      rel.Truncate();
      title.Truncate();
      type.Truncate();
      media.Truncate();
    }

    start = ++end;
  }

  if (!href.IsEmpty() && !rel.IsEmpty()) {
    rv = ProcessLink(aElement, href, rel, title, type, media);

    if (NS_SUCCEEDED(rv) && didBlock) {
      rv = NS_ERROR_HTMLPARSER_BLOCK;
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSink::ProcessMETATag ( nsIContent aContent) [protected, inherited]

Definition at line 693 of file nsContentSink.cpp.

{
  NS_ASSERTION(aContent, "missing base-element");

  nsresult rv = NS_OK;

  // set any HTTP-EQUIV data into document's header data as well as url
  nsAutoString header;
  aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::httpEquiv, header);
  if (!header.IsEmpty()) {
    nsAutoString result;
    aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::content, result);
    if (!result.IsEmpty()) {
      ToLowerCase(header);
      nsCOMPtr<nsIAtom> fieldAtom(do_GetAtom(header));
      rv = ProcessHeaderData(fieldAtom, result, aContent); 
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXMLContentSink::ProcessStyleLink ( nsIContent aElement,
const nsSubstring aHref,
PRBool  aAlternate,
const nsSubstring aTitle,
const nsSubstring aType,
const nsSubstring aMedia 
) [protected, virtual]

Reimplemented from nsContentSink.

Reimplemented in nsXMLFragmentContentSink.

Definition at line 671 of file nsXMLContentSink.cpp.

{
  nsresult rv = NS_OK;
  mPrettyPrintXML = PR_FALSE;

  nsCAutoString cmd;
  if (mParser)
    mParser->GetCommand(cmd);
  if (cmd.EqualsASCII(kLoadAsData))
    return NS_OK; // Do not load stylesheets when loading as data

  NS_ConvertUTF16toUTF8 type(aType);
  if (type.EqualsIgnoreCase(kXSLType) ||
      type.EqualsIgnoreCase(kXMLTextContentType) ||
      type.EqualsIgnoreCase(kXMLApplicationContentType)) {
    if (aAlternate) {
      // don't load alternate XSLT
      return NS_OK;
    }
    // LoadXSLStyleSheet needs a mDocShell.
    if (!mDocShell)
      return NS_OK;

    nsCOMPtr<nsIURI> url;
    rv = NS_NewURI(getter_AddRefs(url), aHref, nsnull, mDocumentBaseURI);
    NS_ENSURE_SUCCESS(rv, rv);

    // Do security check
    nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
    rv = secMan->
      CheckLoadURIWithPrincipal(mDocument->GetPrincipal(), url,
                                nsIScriptSecurityManager::ALLOW_CHROME);
    NS_ENSURE_SUCCESS(rv, NS_OK);

    rv = secMan->CheckSameOriginURI(mDocumentURI, url);
    NS_ENSURE_SUCCESS(rv, NS_OK);

    // Do content policy check
    PRInt16 decision = nsIContentPolicy::ACCEPT;
    rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
                                   url,
                                   mDocument->GetDocumentURI(),
                                   aElement,
                                   type,
                                   nsnull,
                                   &decision);

    NS_ENSURE_SUCCESS(rv, rv);

    if (NS_CP_REJECTED(decision)) {
      return NS_OK;
    }

    return LoadXSLStyleSheet(url);
  }

  // Let nsContentSink deal with css.
  rv = nsContentSink::ProcessStyleLink(aElement, aHref, aAlternate,
                                       aTitle, aType, aMedia);

  if (rv == NS_ERROR_HTMLPARSER_BLOCK) {
    if (mParser) {
      mParser->BlockParser();
    }
    return NS_OK;
  }

  return rv;
}

Here is the call graph for this function:

PRInt32 nsXMLContentSink::PushContent ( nsIContent aContent) [protected]

Definition at line 836 of file nsXMLContentSink.cpp.

{
  NS_PRECONDITION(aContent, "Null content being pushed!");
  mContentStack.AppendObject(aContent);
  return mContentStack.Count();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSink::RefreshIfEnabled ( nsIViewManager vm) [protected, inherited]

Definition at line 870 of file nsContentSink.cpp.

{
  if (!vm) {
    return NS_OK;
  }

  NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);

  nsCOMPtr<nsIContentViewer> contentViewer;
  mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
  if (contentViewer) {
    PRBool enabled;
    contentViewer->GetEnableRendering(&enabled);
    if (enabled) {
      vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIExpatSink::ReportError ( in wstring  aErrorText,
in wstring  aSourceText 
) [inherited]
void nsIScriptLoaderObserver::scriptAvailable ( in nsresult  aResult,
in nsIScriptElement  aElement,
in boolean  aIsInline,
in boolean  aWasPending,
in nsIURI  aURI,
in PRInt32  aLineNo,
in AString  aScript 
) [inherited]

The script is available for evaluation.

For inline scripts, this method will be called synchronously. For externally loaded scripts, this method will be called when the load completes.

Parameters:
aResultA result code representing the result of loading a script. If this is a failure code, script evaluation will not occur.
aElementThe element being processed.
aIsInlineIs this an inline script or externally loaded?
aWasPendingDid script processing have to be delayed, either for loading of an external script or because processing of an earlier scheduled script was delayed?
aURIWhat is the URI of the script (the document URI if it is inline).
aLineNoAt what line does the script appear (generally 1 if it is a loaded script).
aScriptString representation of the string to be evaluated.
void nsIScriptLoaderObserver::scriptEvaluated ( in nsresult  aResult,
in nsIScriptElement  aElement,
in boolean  aIsInline,
in boolean  aWasPending 
) [inherited]

The script has been evaluated.

Parameters:
aResultA result code representing the success or failure of the script evaluation.
aElementThe element being processed.
aIsInlineIs this an inline script or externally loaded?
aWasPendingDid script processing have to be delayed, either for loading of an external script or because processing of an earlier scheduled script was delayed?
PRBool nsContentSink::ScrollToRef ( PRBool  aReallyScroll) [protected, inherited]

Definition at line 814 of file nsContentSink.cpp.

{
  if (mRef.IsEmpty()) {
    return PR_FALSE;
  }

  PRBool didScroll = PR_FALSE;

  char* tmpstr = ToNewCString(mRef);
  if (!tmpstr) {
    return PR_FALSE;
  }

  nsUnescape(tmpstr);
  nsCAutoString unescapedRef;
  unescapedRef.Assign(tmpstr);
  nsMemory::Free(tmpstr);

  nsresult rv = NS_ERROR_FAILURE;
  // We assume that the bytes are in UTF-8, as it says in the spec:
  // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
  NS_ConvertUTF8toUCS2 ref(unescapedRef);

  PRInt32 i, ns = mDocument->GetNumberOfShells();
  for (i = 0; i < ns; i++) {
    nsIPresShell* shell = mDocument->GetShellAt(i);
    if (shell) {
      // Check an empty string which might be caused by the UTF-8 conversion
      if (!ref.IsEmpty()) {
        // Note that GoToAnchor will handle flushing layout as needed.
        rv = shell->GoToAnchor(ref, aReallyScroll);
      } else {
        rv = NS_ERROR_FAILURE;
      }

      // If UTF-8 URI failed then try to assume the string as a
      // document's charset.

      if (NS_FAILED(rv)) {
        const nsACString &docCharset = mDocument->GetDocumentCharacterSet();

        rv = CharsetConvRef(docCharset, unescapedRef, ref);

        if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
          rv = shell->GoToAnchor(ref, aReallyScroll);
      }
      if (NS_SUCCEEDED(rv)) {
        didScroll = PR_TRUE;
      }
    }
  }

  return didScroll;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsXMLContentSink::SetDocElement ( PRInt32  aNameSpaceID,
nsIAtom aTagName,
nsIContent aContent 
) [protected, virtual]

Reimplemented in nsXMLFragmentContentSink.

Definition at line 904 of file nsXMLContentSink.cpp.

{
  if (mDocElement)
    return PR_FALSE;

  // check for root elements that needs special handling for
  // prettyprinting
  if ((aNameSpaceID == kNameSpaceID_XBL &&
       aTagName == nsXBLAtoms::bindings) ||
      (aNameSpaceID == kNameSpaceID_XSLT &&
       (aTagName == nsLayoutAtoms::stylesheet ||
        aTagName == nsLayoutAtoms::transform))) {
    mPrettyPrintHasSpecialRoot = PR_TRUE;
    if (mPrettyPrintXML) {
      // In this case, disable script execution, stylesheet
      // loading, and auto XLinks since we plan to prettyprint.
      mAllowAutoXLinks = PR_FALSE;
      nsIScriptLoader* scriptLoader = mDocument->GetScriptLoader();
      if (scriptLoader) {
        scriptLoader->SetEnabled(PR_FALSE);
      }
      if (mCSSLoader) {
        mCSSLoader->SetEnabled(PR_FALSE);
      }
    }        
  }

  mDocElement = aContent;
  NS_ADDREF(mDocElement);

  nsresult rv = mDocument->SetRootContent(mDocElement);
  if (NS_FAILED(rv)) {
    // If we return PR_FALSE here, the caller will bail out because it won't
    // find a parent content node to append to, which is fine.
    return PR_FALSE;
  }
  return PR_TRUE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsXMLContentSink::SetDocumentCharset ( nsACString &  aCharset) [virtual]

Set the document character set.

This should be passed on to the document itself.

Implements nsIContentSink.

Reimplemented in nsXMLFragmentContentSink.

Definition at line 779 of file nsXMLContentSink.cpp.

{
  if (mDocument) {
    mDocument->SetDocumentCharacterSet(aCharset);
  }
  
  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 454 of file nsXMLContentSink.cpp.

{
  mParser = aParser;
  return NS_OK;
}

Reimplemented in nsXMLFragmentContentSink.

Definition at line 863 of file nsXMLContentSink.cpp.

{
  PRBool topLevelFrameset = PR_FALSE;
  nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
  if (docShellAsItem) {
    nsCOMPtr<nsIDocShellTreeItem> root;
    docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
    if(docShellAsItem == root) {
      topLevelFrameset = PR_TRUE;
    }
  }
  
  nsContentSink::StartLayout(topLevelFrameset);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsContentSink::StartLayout ( PRBool  aIsFrameset) [protected, inherited]

Definition at line 892 of file nsContentSink.cpp.

{
  PRUint32 i, ns = mDocument->GetNumberOfShells();
  for (i = 0; i < ns; i++) {
    nsIPresShell *shell = mDocument->GetShellAt(i);

    if (shell) {
      // Make sure we don't call InitialReflow() for a shell that has
      // already called it. This can happen when the layout frame for
      // an iframe is constructed *between* the Embed() call for the
      // docshell in the iframe, and the content sink's call to OpenBody().
      // (Bug 153815)

      PRBool didInitialReflow = PR_FALSE;
      shell->GetDidInitialReflow(&didInitialReflow);
      if (didInitialReflow) {
        // XXX: The assumption here is that if something already
        // called InitialReflow() on this shell, it also did some of
        // the setup below, so we do nothing and just move on to the
        // next shell in the list.

        continue;
      }

      // Make shell an observer for next time
      shell->BeginObservingDocument();

      // Resize-reflow this time
      nsRect r = shell->GetPresContext()->GetVisibleArea();
      shell->InitialReflow(r.width, r.height);

      // Now trigger a refresh
      RefreshIfEnabled(shell->GetViewManager());
    }
  }

  // If the document we are loading has a reference or it is a
  // frameset document, disable the scroll bars on the views.

  if (mDocumentURI) {
    nsCAutoString ref;

    // Since all URI's that pass through here aren't URL's we can't
    // rely on the nsIURI implementation for providing a way for
    // finding the 'ref' part of the URI, we'll haveto revert to
    // string routines for finding the data past '#'

    mDocumentURI->GetSpec(ref);

    nsReadingIterator<char> start, end;

    ref.BeginReading(start);
    ref.EndReading(end);

    if (FindCharInReadable('#', start, end)) {
      ++start; // Skip over the '#'

      mRef = Substring(start, end);
    }
  }
}

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

Reimplemented in nsXMLFragmentContentSink.

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 442 of file nsXMLContentSink.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 448 of file nsXMLContentSink.cpp.

{
  return NS_OK;
}

Member Data Documentation

Definition at line 167 of file nsXMLContentSink.h.

Definition at line 161 of file nsXMLContentSink.h.

Definition at line 170 of file nsXMLContentSink.h.

Definition at line 116 of file nsContentSink.h.

Definition at line 150 of file nsXMLContentSink.h.

Definition at line 115 of file nsContentSink.h.

Definition at line 111 of file nsContentSink.h.

Definition at line 114 of file nsContentSink.h.

nsCOMPtr<nsIURI> nsContentSink::mDocumentURI [protected, inherited]

Definition at line 113 of file nsContentSink.h.

Definition at line 166 of file nsXMLContentSink.h.

Definition at line 162 of file nsXMLContentSink.h.

PRBool nsContentSink::mNeedToBlockParser [protected, inherited]

Definition at line 122 of file nsContentSink.h.

Definition at line 117 of file nsContentSink.h.

nsCOMPtr<nsIParser> nsContentSink::mParser [protected, inherited]

Definition at line 112 of file nsContentSink.h.

Definition at line 165 of file nsXMLContentSink.h.

Definition at line 164 of file nsXMLContentSink.h.

Definition at line 163 of file nsXMLContentSink.h.

nsCString nsContentSink::mRef [protected, inherited]

Definition at line 121 of file nsContentSink.h.

Definition at line 119 of file nsContentSink.h.

Definition at line 159 of file nsXMLContentSink.h.

Reimplemented in nsXBLContentSink.

Definition at line 153 of file nsXMLContentSink.h.

Definition at line 151 of file nsXMLContentSink.h.

Definition at line 157 of file nsXMLContentSink.h.

Definition at line 158 of file nsXMLContentSink.h.

Definition at line 155 of file nsXMLContentSink.h.

Definition at line 171 of file nsXMLContentSink.h.

Definition at line 168 of file nsXMLContentSink.h.


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