Back to index

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

List of all members.

Public Member Functions

 nsXHTMLParanoidFragmentSink ()
NS_DECL_ISUPPORTS_INHERITED
nsresult 
AddAttributes (const PRUnichar **aNode, nsIContent *aContent)
NS_IMETHOD HandleStartElement (const PRUnichar *aName, const PRUnichar **aAtts, PRUint32 aAttsCount, PRInt32 aIndex, PRUint32 aLineNumber)
NS_IMETHOD HandleEndElement (const PRUnichar *aName)
NS_IMETHOD HandleComment (const PRUnichar *aName)
NS_IMETHOD HandleProcessingInstruction (const PRUnichar *aTarget, const PRUnichar *aData)
NS_IMETHOD HandleCDataSection (const PRUnichar *aData, PRUint32 aLength)
NS_IMETHOD HandleCharacterData (const PRUnichar *aData, PRUint32 aLength)
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
HandleDoctypeDecl (const nsAString &aSubset, const nsAString &aName, const nsAString &aSystemId, const nsAString &aPublicId, nsISupports *aCatalogData)
void HandleDoctypeDecl (in AString aSubset, in AString aName, in AString aSystemId, in AString aPublicId, in nsISupports aCatalogData)
 Called to handle the doctype declaration.
void HandleProcessingInstruction (in wstring aTarget, in wstring aData)
 Called to handle a processing instruction.
NS_IMETHOD HandleXMLDeclaration (const PRUnichar *aVersion, const PRUnichar *aEncoding, PRInt32 aStandalone)
void HandleXMLDeclaration (in wstring aVersion, in wstring aEncoding, in long aStandalone)
 Handle the XML Declaration.
NS_IMETHOD ReportError (const PRUnichar *aErrorText, const PRUnichar *aSourceText)
void ReportError (in wstring aErrorText, in wstring aSourceText)
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 ()
 This method gets called when the parser concludes the process of building the content model via the content 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 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.
nsresult Init (nsIDocument *aDoc, nsIURI *aURL, nsISupports *aContainer, nsIChannel *aChannel)
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 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 HandleCharacterData ([size_is(aLength)] in wstring aData, in unsigned long aLength)
 Called to handle character data.

Static Public Member Functions

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

Protected Member Functions

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 ProcessStyleLink (nsIContent *aElement, const nsSubstring &aHref, PRBool aAlternate, const nsSubstring &aTitle, const nsSubstring &aType, const nsSubstring &aMedia)
nsresult LoadXSLStyleSheet (nsIURI *aUrl)
void StartLayout ()
void StartLayout (PRBool aIsFrameset)
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 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)
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)
virtual void PreEvaluateScript ()
virtual void PostEvaluateScript ()

Protected Attributes

PRUint32 mSkipLevel
nsCOMPtr< nsIDocumentmTargetDocument
nsCOMPtr< nsIContentmRoot
PRPackedBool mParseError
PRPackedBool mAllContent
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

Static Protected Attributes

static nsTHashtable
< nsISupportsHashKey > * 
sAllowedTags
static nsTHashtable
< nsISupportsHashKey > * 
sAllowedAttributes

Detailed Description

Definition at line 450 of file nsXMLFragmentContentSink.cpp.


Constructor & Destructor Documentation


Member Function Documentation

Reimplemented from nsXMLContentSink.

nsresult nsXMLContentSink::AddContentAsLeaf ( nsIContent aContent) [protected, inherited]

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, inherited]

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:

Definition at line 537 of file nsXMLFragmentContentSink.cpp.

Here is the caller graph for this function:

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

Reimplemented from nsXMLContentSink.

Definition at line 258 of file nsXMLFragmentContentSink.cpp.

{
  // don't do fancy stuff in nsXMLContentSink
  *aAppendContent = PR_FALSE;

  return NS_OK;
}
nsresult nsXMLFragmentContentSink::CreateElement ( const PRUnichar **  aAtts,
PRUint32  aAttsCount,
nsINodeInfo aNodeInfo,
PRUint32  aLineNumber,
nsIContent **  aResult,
PRBool aAppendContent 
) [protected, virtual, inherited]

Reimplemented from nsXMLContentSink.

Definition at line 236 of file nsXMLFragmentContentSink.cpp.

{
  nsresult rv = nsXMLContentSink::CreateElement(aAtts, aAttsCount,
                                aNodeInfo, aLineNumber,
                                aResult, aAppendContent);

  // Make sure that scripts are added immediately, not on close.
  *aAppendContent = PR_TRUE;

  // However, when we aren't grabbing all of the content we, never open a doc
  // element, we run into trouble on the first element, so we don't append,
  // and simply push this onto the content stack.
  if (!mAllContent && mContentStack.Count() == 0) {
    *aAppendContent = PR_FALSE;
  }

  return rv;
}

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 421 of file nsXMLFragmentContentSink.cpp.

{
  // If we're taking all of the content, then this is handled in DidBuildModel
  if (!mAllContent) {
    // Note: we need to FlushText() here because if we don't, we might not get
    // an end element to do it for us, so make sure.
    if (!mParseError) {
      FlushText();
    }
    // Need the nsCOMPtr to properly release
    nsCOMPtr<nsIContent> root = PopContent();
  }

  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

Reimplemented from nsXMLContentSink.

Definition at line 195 of file nsXMLFragmentContentSink.cpp.

{
  if (mAllContent) {
    // Need the nsCOMPtr to properly release
    nsCOMPtr<nsIContent> root = PopContent();  // remove mRoot pushed above
  }

  nsCOMPtr<nsIParser> kungFuDeathGrip(mParser);

  // 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, inherited]

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, inherited]

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:

nsIContent * nsXMLContentSink::GetCurrentContent ( ) [protected, inherited]

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:

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 384 of file nsXMLFragmentContentSink.cpp.

{
  *aFragment = nsnull;
  if (mParseError) {
    //XXX PARSE_ERR from DOM3 Load and Save would be more appropriate
    return NS_ERROR_DOM_SYNTAX_ERR;
  } else if (mRoot) {
    return CallQueryInterface(mRoot, aFragment);
  } else {
    return NS_OK;
  }
}

Here is the call graph for this function:

nsISupports * nsXMLFragmentContentSink::GetTarget ( ) [virtual, inherited]

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).

Reimplemented from nsXMLContentSink.

Definition at line 219 of file nsXMLFragmentContentSink.cpp.

{
  return mTargetDocument;
}
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

Definition at line 738 of file nsXMLFragmentContentSink.cpp.

{
  if (mSkipLevel != 0) {
    return NS_OK;
  }

  return nsXMLFragmentContentSink::HandleCDataSection(aData, aLength);
}
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

Definition at line 749 of file nsXMLFragmentContentSink.cpp.

{
  if (mSkipLevel != 0) {
    return NS_OK;
  }

  return nsXMLFragmentContentSink::HandleCharacterData(aData, aLength);
}
void nsIExpatSink::HandleComment ( in wstring  aCommentText) [inherited]

Called to handle a comment.

Parameters:
aCommentTextthe text of the comment (not including the "<!--" and "-->")

Definition at line 730 of file nsXMLFragmentContentSink.cpp.

{
  // We don't do comments
  return NS_OK;
}
NS_IMETHODIMP nsXMLFragmentContentSink::HandleDoctypeDecl ( const nsAString &  aSubset,
const nsAString &  aName,
const nsAString &  aSystemId,
const nsAString &  aPublicId,
nsISupports *  aCatalogData 
) [inherited]

Definition at line 271 of file nsXMLFragmentContentSink.cpp.

{
  NS_NOTREACHED("fragments shouldn't have doctype declarations");

  return NS_OK;
}
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

Definition at line 689 of file nsXMLFragmentContentSink.cpp.

{
  nsresult rv;
  PRInt32 nameSpaceID;
  nsCOMPtr<nsIAtom> prefix, localName;
  nsContentUtils::SplitExpatName(aName, getter_AddRefs(prefix),
                                 getter_AddRefs(localName), &nameSpaceID);
  
  // If the element is not in the XHTML namespace, bounce it
  if (nameSpaceID != kNameSpaceID_XHTML) {
    return NS_OK;
  }
  
  nsCOMPtr<nsINodeInfo> nodeInfo;
  rv = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                     getter_AddRefs(nodeInfo));
  NS_ENSURE_SUCCESS(rv, rv);
  
  nsCOMPtr<nsIAtom> name = nodeInfo->NameAtom();
  if (mSkipLevel != 0) {
    --mSkipLevel;
    return NS_OK;
  }

  if (!sAllowedTags || !sAllowedTags->GetEntry(name)) {
    return NS_OK;
  }

  return nsXMLFragmentContentSink::HandleEndElement(aName);
}

Here is the call graph for this function:

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

Reimplemented from nsXMLFragmentContentSink.

Definition at line 722 of file nsXMLFragmentContentSink.cpp.

{
  // We don't do PIs
  return NS_OK;
}
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.
NS_IMETHODIMP nsXHTMLParanoidFragmentSink::HandleStartElement ( const PRUnichar aName,
const PRUnichar **  aAtts,
PRUint32  aAttsCount,
PRInt32  aIndex,
PRUint32  aLineNumber 
)

Definition at line 627 of file nsXMLFragmentContentSink.cpp.

{
  nsresult rv;
  PRInt32 nameSpaceID;
  nsCOMPtr<nsIAtom> prefix, localName;
  nsContentUtils::SplitExpatName(aName, getter_AddRefs(prefix),
                                 getter_AddRefs(localName), &nameSpaceID);
  
  // If the element is not in the XHTML namespace, bounce it
  if (nameSpaceID != kNameSpaceID_XHTML)
    return NS_OK;
  
  nsCOMPtr<nsINodeInfo> nodeInfo;
  rv = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                     getter_AddRefs(nodeInfo));
  NS_ENSURE_SUCCESS(rv, rv);
  
  // bounce it if it's not on the whitelist or we're inside
  // <script> or <style>
  nsCOMPtr<nsIAtom> name = nodeInfo->NameAtom();
  if (mSkipLevel != 0 ||
      name == nsHTMLAtoms::script ||
      name == nsHTMLAtoms::style) {
    ++mSkipLevel; // track this so we don't spew script text
    return NS_OK;
  }  
  
  if (!sAllowedTags || !sAllowedTags->GetEntry(name))
    return NS_OK;
  
  // It's an allowed element, so let's scrub the attributes
  nsTArray<const PRUnichar *> allowedAttrs;
  for (PRUint32 i = 0; i < aAttsCount; i += 2) {
    nsContentUtils::SplitExpatName(aAtts[i], getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);
    rv = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                       getter_AddRefs(nodeInfo));
    NS_ENSURE_SUCCESS(rv, rv);
    
    name = nodeInfo->NameAtom();
    // Add if it's xmlns, xml:, or on the HTML whitelist
    if (nameSpaceID == kNameSpaceID_XMLNS ||
        nameSpaceID == kNameSpaceID_XML ||
        sAllowedAttributes && sAllowedAttributes->GetEntry(name)) {
      allowedAttrs.AppendElement(aAtts[i]);
      allowedAttrs.AppendElement(aAtts[i + 1]);
    }
  }
  allowedAttrs.AppendElement((const PRUnichar*) nsnull);
  return
    nsXMLFragmentContentSink::HandleStartElement(aName,
                                                 allowedAttrs.Elements(),
                                                 allowedAttrs.Length() - 1,
                                                 aIndex,
                                                 aLineNumber);
}

Here is the call graph for this function:

NS_IMETHODIMP nsXMLFragmentContentSink::HandleXMLDeclaration ( const PRUnichar aVersion,
const PRUnichar aEncoding,
PRInt32  aStandalone 
) [inherited]

Definition at line 304 of file nsXMLFragmentContentSink.cpp.

{
  NS_NOTREACHED("fragments shouldn't have XML declarations");
  return NS_OK;
}
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.

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 438 of file nsXMLFragmentContentSink.cpp.

{
  NS_NOTREACHED("XML isn't as broken as HTML");
  return NS_ERROR_FAILURE;
}
nsresult nsXMLContentSink::Init ( nsIDocument aDoc,
nsIURI aURL,
nsISupports *  aContainer,
nsIChannel aChannel 
) [inherited]

Reimplemented from nsContentSink.

Definition at line 169 of file nsXMLContentSink.cpp.

Here is the caller graph for this function:

Definition at line 498 of file nsXMLFragmentContentSink.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXMLFragmentContentSink::LoadXSLStyleSheet ( nsIURI aUrl) [protected, inherited]

Reimplemented from nsXMLContentSink.

Definition at line 369 of file nsXMLFragmentContentSink.cpp.

{
  NS_NOTREACHED("fragments shouldn't have XSL style sheets");
  return NS_ERROR_UNEXPECTED;
}
nsresult nsXMLContentSink::MaybePrettyPrint ( ) [protected, inherited]

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:

NS_IMETHODIMP nsXMLContentSink::OnDocumentCreated ( nsIDOMDocument aResultDocument) [virtual, inherited]

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, inherited]

Reimplemented in nsXBLContentSink.

Definition at line 106 of file nsXMLContentSink.h.

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

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, inherited]

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:

nsresult nsXMLContentSink::ProcessBASETag ( nsIContent aContent) [protected, inherited]

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, inherited]

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 nsXMLFragmentContentSink::ProcessStyleLink ( nsIContent aElement,
const nsSubstring aHref,
PRBool  aAlternate,
const nsSubstring aTitle,
const nsSubstring aType,
const nsSubstring aMedia 
) [protected, virtual, inherited]

Reimplemented from nsXMLContentSink.

Definition at line 357 of file nsXMLFragmentContentSink.cpp.

{
  // don't process until moved to document
  return NS_OK;
}
PRInt32 nsXMLContentSink::PushContent ( nsIContent aContent) [protected, inherited]

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:

NS_IMETHODIMP nsXMLFragmentContentSink::ReportError ( const PRUnichar aErrorText,
const PRUnichar aSourceText 
) [inherited]

Definition at line 313 of file nsXMLFragmentContentSink.cpp.

{
  mParseError = PR_TRUE;
  // The following error reporting is copied from nsXBLContentSink::ReportError()

  nsCOMPtr<nsIConsoleService> consoleService =
    do_GetService(NS_CONSOLESERVICE_CONTRACTID);
  if (consoleService) {
    consoleService->LogStringMessage(aErrorText);
  }

#ifdef DEBUG
  // Report the error to stderr.
  fprintf(stderr,
          "\n%s\n%s\n\n",
          NS_LossyConvertUCS2toASCII(aErrorText).get(),
          NS_LossyConvertUCS2toASCII(aSourceText).get());
#endif

  // The following code is similar to the cleanup in nsXMLContentSink::ReportError()
  mState = eXMLContentSinkState_InProlog;

  // Clear the current content
  nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mRoot));
  if (node) {
    for (;;) {
      nsCOMPtr<nsIDOMNode> child, dummy;
      node->GetLastChild(getter_AddRefs(child));
      if (!child)
        break;
      node->RemoveChild(child, getter_AddRefs(dummy));
    }
  }

  // Clear any buffered-up text we have.  It's enough to set the length to 0.
  // The buffer itself is allocated when we're created and deleted in our
  // destructor, so don't mess with it.
  mTextLength = 0;

  return NS_OK; 
}

Here is the call 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 nsXMLFragmentContentSink::SetDocElement ( PRInt32  aNameSpaceID,
nsIAtom aTagName,
nsIContent aContent 
) [protected, virtual, inherited]

Reimplemented from nsXMLContentSink.

Definition at line 227 of file nsXMLFragmentContentSink.cpp.

{
  // this is a fragment, not a document
  return PR_FALSE;
}
NS_IMETHODIMP nsXMLFragmentContentSink::SetDocumentCharset ( nsACString &  aCharset) [virtual, inherited]

Set the document character set.

This should be passed on to the document itself.

Reimplemented from nsXMLContentSink.

Definition at line 212 of file nsXMLFragmentContentSink.cpp.

{
  NS_NOTREACHED("fragments shouldn't set charset");
  return NS_OK;
}
NS_IMETHODIMP nsXMLContentSink::SetParser ( nsIParser aParser) [virtual, inherited]

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

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 398 of file nsXMLFragmentContentSink.cpp.

{
  NS_ENSURE_ARG_POINTER(aTargetDocument);

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

  return NS_OK;
}

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

void nsXMLFragmentContentSink::StartLayout ( ) [protected, inherited]

Reimplemented from nsXMLContentSink.

Definition at line 376 of file nsXMLFragmentContentSink.cpp.

{
  NS_NOTREACHED("fragments shouldn't layout");
}

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 409 of file nsXMLFragmentContentSink.cpp.

{
  // If we're taking all of the content, then we've already pushed mRoot
  // onto the content stack, otherwise, start here.
  if (!mAllContent) {
    PushContent(mRoot);
  }

  return NS_OK;
}

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

Reimplemented from nsXMLContentSink.

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;
}
NS_IMETHODIMP nsXMLContentSink::WillResume ( void  ) [virtual, inherited]

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 128 of file nsXMLFragmentContentSink.cpp.

Definition at line 167 of file nsXMLContentSink.h.

PRUint8 nsXMLContentSink::mConstrainSize [protected, inherited]

Definition at line 161 of file nsXMLContentSink.h.

Definition at line 170 of file nsXMLContentSink.h.

Definition at line 116 of file nsContentSink.h.

nsIContent* nsXMLContentSink::mDocElement [protected, inherited]

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.

PRUint8 nsXMLContentSink::mInTitle [protected, inherited]

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.

Definition at line 125 of file nsXMLFragmentContentSink.cpp.

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 124 of file nsXMLFragmentContentSink.cpp.

Definition at line 119 of file nsContentSink.h.

PRUint32 nsXMLContentSink::mScriptLineNo [protected, inherited]

Definition at line 159 of file nsXMLContentSink.h.

Definition at line 483 of file nsXMLFragmentContentSink.cpp.

Reimplemented in nsXBLContentSink.

Definition at line 153 of file nsXMLContentSink.h.

Definition at line 122 of file nsXMLFragmentContentSink.cpp.

PRUnichar* nsXMLContentSink::mText [protected, inherited]

Definition at line 151 of file nsXMLContentSink.h.

PRInt32 nsXMLContentSink::mTextLength [protected, inherited]

Definition at line 157 of file nsXMLContentSink.h.

PRInt32 nsXMLContentSink::mTextSize [protected, inherited]

Definition at line 158 of file nsXMLContentSink.h.

nsString nsXMLContentSink::mTitleText [protected, inherited]

Definition at line 155 of file nsXMLContentSink.h.

Definition at line 171 of file nsXMLContentSink.h.

Definition at line 486 of file nsXMLFragmentContentSink.cpp.

Definition at line 485 of file nsXMLFragmentContentSink.cpp.

PRUint8 nsXMLContentSink::unused [protected, inherited]

Definition at line 168 of file nsXMLContentSink.h.


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