Back to index

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

#include <nsXBLContentSink.h>

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

List of all members.

Public Member Functions

 nsXBLContentSink ()
 ~nsXBLContentSink ()
nsresult Init (nsIDocument *aDoc, nsIURI *aURL, nsISupports *aContainer)
NS_IMETHOD HandleStartElement (const PRUnichar *aName, const PRUnichar **aAtts, PRUint32 aAttsCount, PRInt32 aIndex, PRUint32 aLineNumber)
NS_IMETHOD HandleEndElement (const PRUnichar *aName)
NS_IMETHOD HandleCDataSection (const PRUnichar *aData, PRUint32 aLength)
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

PRBool OnOpenContainer (const PRUnichar **aAtts, PRUint32 aAttsCount, PRInt32 aNameSpaceID, nsIAtom *aTagName, PRUint32 aLineNumber)
nsresult CreateElement (const PRUnichar **aAtts, PRUint32 aAttsCount, nsINodeInfo *aNodeInfo, PRUint32 aLineNumber, nsIContent **aResult, PRBool *aAppendContent)
nsresult AddAttributes (const PRUnichar **aAtts, nsIContent *aContent)
nsresult ConstructBinding ()
void ConstructHandler (const PRUnichar **aAtts, PRUint32 aLineNumber)
void ConstructResource (const PRUnichar **aAtts, nsIAtom *aResourceType)
void ConstructImplementation (const PRUnichar **aAtts)
void ConstructProperty (const PRUnichar **aAtts)
void ConstructMethod (const PRUnichar **aAtts)
void ConstructParameter (const PRUnichar **aAtts)
void ConstructField (const PRUnichar **aAtts, PRUint32 aLineNumber)
nsresult FlushText (PRBool aCreateTextNode=PR_TRUE, PRBool *aDidFlush=nsnull)
NS_IMETHOD ReportError (const PRUnichar *aErrorText, const PRUnichar *aSourceText)
nsresult ReportUnexpectedElement (nsIAtom *aElementName, PRUint32 aLineNumber)
void AddMember (nsXBLProtoImplMember *aMember)
void StartLayout ()
void StartLayout (PRBool aIsFrameset)
nsresult AddText (const PRUnichar *aString, PRInt32 aLength)
nsresult ProcessEndSCRIPTTag (nsIContent *aContent, nsIContent *aParent)
virtual PRBool SetDocElement (PRInt32 aNameSpaceID, nsIAtom *aTagName, nsIContent *aContent)
virtual nsresult CloseElement (nsIContent *aContent, nsIContent *aParent, PRBool *aAppendContent)
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)
virtual void PreEvaluateScript ()
virtual void PostEvaluateScript ()

Protected Attributes

XBLPrimaryState mState
XBLSecondaryState mSecondaryState
nsIXBLDocumentInfomDocInfo
PRBool mIsChromeOrResource
nsXBLPrototypeBindingmBinding
nsXBLPrototypeHandlermHandler
nsXBLProtoImplmImplementation
nsXBLProtoImplMembermImplMember
nsXBLProtoImplPropertymProperty
nsXBLProtoImplMethodmMethod
nsXBLProtoImplFieldmField
nsIContentmDocElement
PRUnicharmText
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 90 of file nsXBLContentSink.h.


Constructor & Destructor Documentation

Definition at line 101 of file nsXBLContentSink.cpp.

{
}

Member Function Documentation

nsresult nsXBLContentSink::AddAttributes ( const PRUnichar **  aAtts,
nsIContent aContent 
) [protected, virtual]

Reimplemented from nsXMLContentSink.

Definition at line 887 of file nsXBLContentSink.cpp.

{
  if (aContent->IsContentOfType(nsIContent::eXUL))
    return NS_OK; // Nothing to do, since the proto already has the attrs.

  return nsXMLContentSink::AddAttributes(aAtts, aContent);
}

Here is the call graph for this function:

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:

Definition at line 261 of file nsXBLContentSink.cpp.

{
  // Add this member to our chain.
  if (mImplMember)
    mImplMember->SetNext(aMember); // Already have a chain. Just append to the end.
  else
    mImplementation->SetMemberList(aMember); // We're the first member in the chain.

  mImplMember = aMember; // Adjust our pointer to point to the new last member in the chain.
}

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:

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

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:

Definition at line 548 of file nsXBLContentSink.cpp.

{
  nsCOMPtr<nsIContent> binding = GetCurrentContent();
  nsAutoString id;
  binding->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id, id);
  NS_ConvertUTF16toUTF8 cid(id);

  nsresult rv = NS_OK;
  
  if (!cid.IsEmpty()) {
    mBinding = new nsXBLPrototypeBinding();
    if (!mBinding)
      return NS_ERROR_OUT_OF_MEMORY;
      
    rv = mBinding->Init(cid, mDocInfo, binding);
    if (NS_SUCCEEDED(rv)) {
      mDocInfo->SetPrototypeBinding(cid, mBinding);
      binding->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::id, PR_FALSE);
    } else {
      delete mBinding;
      mBinding = nsnull;
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXBLContentSink::ConstructField ( const PRUnichar **  aAtts,
PRUint32  aLineNumber 
) [protected]

Definition at line 748 of file nsXBLContentSink.cpp.

{
  const PRUnichar* name     = nsnull;
  const PRUnichar* readonly = nsnull;

  nsCOMPtr<nsIAtom> prefix, localName;
  for (; *aAtts; aAtts += 2) {
    PRInt32 nameSpaceID;
    nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);

    if (nameSpaceID != kNameSpaceID_None) {
      continue;
    }

    // Is this attribute one of the ones we care about?
    if (localName == nsXBLAtoms::name) {
      name = aAtts[1];
    }
    else if (localName == nsXBLAtoms::readonly) {
      readonly = aAtts[1];
    }
  }

  // All of our pointers are now filled in. Construct our field with all of
  // these parameters.
  mField = new nsXBLProtoImplField(name, readonly);
  if (mField) {
    mField->SetLineNumber(aLineNumber);
    AddMember(mField);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXBLContentSink::ConstructHandler ( const PRUnichar **  aAtts,
PRUint32  aLineNumber 
) [protected]

Definition at line 596 of file nsXBLContentSink.cpp.

{
  const PRUnichar* event          = nsnull;
  const PRUnichar* modifiers      = nsnull;
  const PRUnichar* button         = nsnull;
  const PRUnichar* clickcount     = nsnull;
  const PRUnichar* keycode        = nsnull;
  const PRUnichar* charcode       = nsnull;
  const PRUnichar* phase          = nsnull;
  const PRUnichar* command        = nsnull;
  const PRUnichar* action         = nsnull;
  const PRUnichar* group          = nsnull;
  const PRUnichar* preventdefault = nsnull;
  const PRUnichar* allowuntrusted = nsnull;

  nsCOMPtr<nsIAtom> prefix, localName;
  for (; *aAtts; aAtts += 2) {
    PRInt32 nameSpaceID;
    nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);

    if (nameSpaceID != kNameSpaceID_None) {
      continue;
    }

    // Is this attribute one of the ones we care about?
    if (localName == nsXBLAtoms::event)
      event = aAtts[1];
    else if (localName == nsXBLAtoms::modifiers)
      modifiers = aAtts[1];
    else if (localName == nsXBLAtoms::button)
      button = aAtts[1];
    else if (localName == nsXBLAtoms::clickcount)
      clickcount = aAtts[1];
    else if (localName == nsXBLAtoms::keycode)
      keycode = aAtts[1];
    else if (localName == nsXBLAtoms::key || localName == nsXBLAtoms::charcode)
      charcode = aAtts[1];
    else if (localName == nsXBLAtoms::phase)
      phase = aAtts[1];
    else if (localName == nsXBLAtoms::command)
      command = aAtts[1];
    else if (localName == nsXBLAtoms::action)
      action = aAtts[1];
    else if (localName == nsXBLAtoms::group)
      group = aAtts[1];
    else if (localName == nsXBLAtoms::preventdefault)
      preventdefault = aAtts[1];
    else if (localName == nsXBLAtoms::allowuntrusted)
      allowuntrusted = aAtts[1];
  }

  if (command && !mIsChromeOrResource) {
    // Make sure the XBL doc is chrome or resource if we have a command
    // shorthand syntax.
    mState = eXBL_Error;
    return; // Don't even make this handler.
  }

  // All of our pointers are now filled in. Construct our handler with all of
  // these parameters.
  nsXBLPrototypeHandler* newHandler;
  newHandler = new nsXBLPrototypeHandler(event, phase, action, command,
                                         keycode, charcode, modifiers, button,
                                         clickcount, group, preventdefault,
                                         allowuntrusted, mBinding);

  if (newHandler) {
    newHandler->SetLineNumber(aLineNumber);
    
    // Add this handler to our chain of handlers.
    if (mHandler) {
      // Already have a chain. Just append to the end.
      mHandler->SetNextHandler(newHandler);
    }
    else {
      // We're the first handler in the chain.
      mBinding->SetPrototypeHandlers(newHandler);
    }
    // Adjust our mHandler pointer to point to the new last handler in the
    // chain.
    mHandler = newHandler;
  } else {
    mState = eXBL_Error;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 697 of file nsXBLContentSink.cpp.

{
  mImplementation = nsnull;
  mImplMember = nsnull;
      
  if (!mBinding)
    return;

  const PRUnichar* name = nsnull;

  nsCOMPtr<nsIAtom> prefix, localName;
  for (; *aAtts; aAtts += 2) {
    PRInt32 nameSpaceID;
    nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);

    if (nameSpaceID != kNameSpaceID_None) {
      continue;
    }

    // Is this attribute one of the ones we care about?
    if (localName == nsXBLAtoms::name) {
      name = aAtts[1];
    }
    else if (localName == nsXBLAtoms::implements) {
      // Only allow implementation of interfaces via XBL if the principal of
      // our XBL document has UniversalXPConnect privileges.  No principal
      // means no privs!
      
      nsIPrincipal* principal = mDocument->GetPrincipal();
      if (principal) {
        // XXX this api is so badly tied to JS it's not even funny.  We don't
        // have a concept of enabling capabilities on a per-principal basis,
        // but only on a per-principal-and-JS-stackframe basis!  So for now
        // this is basically equivalent to testing that we have the system
        // principal, since there is no JS stackframe in sight here...
        PRBool hasUniversalXPConnect;
        nsresult rv = principal->IsCapabilityEnabled("UniversalXPConnect",
                                                     nsnull,
                                                     &hasUniversalXPConnect);
        if (NS_SUCCEEDED(rv) && hasUniversalXPConnect) {
          mBinding->ConstructInterfaceTable(nsDependentString(aAtts[1]));
        }
      }
    }
  }

  NS_NewXBLProtoImpl(mBinding, name, &mImplementation);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 825 of file nsXBLContentSink.cpp.

{
  mMethod = nsnull;

  const PRUnichar* name = nsnull;
  if (FindValue(aAtts, nsXBLAtoms::name, &name)) {
    mMethod = new nsXBLProtoImplMethod(name);
  }

  if (mMethod) {
    AddMember(mMethod);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 840 of file nsXBLContentSink.cpp.

{
  if (!mMethod)
    return;

  const PRUnichar* name = nsnull;
  if (FindValue(aAtts, nsXBLAtoms::name, &name)) {
    mMethod->AddParameter(nsDependentString(name));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 782 of file nsXBLContentSink.cpp.

{
  const PRUnichar* name     = nsnull;
  const PRUnichar* readonly = nsnull;
  const PRUnichar* onget    = nsnull;
  const PRUnichar* onset    = nsnull;

  nsCOMPtr<nsIAtom> prefix, localName;
  for (; *aAtts; aAtts += 2) {
    PRInt32 nameSpaceID;
    nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);

    if (nameSpaceID != kNameSpaceID_None) {
      continue;
    }

    // Is this attribute one of the ones we care about?
    if (localName == nsXBLAtoms::name) {
      name = aAtts[1];
    }
    else if (localName == nsXBLAtoms::readonly) {
      readonly = aAtts[1];
    }
    else if (localName == nsXBLAtoms::onget) {
      onget = aAtts[1];
    }
    else if (localName == nsXBLAtoms::onset) {
      onset = aAtts[1];
    }
  }

  if (name) {
    // All of our pointers are now filled in. Construct our property with all of
    // these parameters.
    mProperty = new nsXBLProtoImplProperty(name, onget, onset, readonly);
    if (mProperty) {
      AddMember(mProperty);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXBLContentSink::ConstructResource ( const PRUnichar **  aAtts,
nsIAtom aResourceType 
) [protected]

Definition at line 684 of file nsXBLContentSink.cpp.

{
  if (!mBinding)
    return;

  const PRUnichar* src = nsnull;
  if (FindValue(aAtts, nsHTMLAtoms::src, &src)) {
    mBinding->AddResource(aResourceType, nsDependentString(src));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from nsXMLContentSink.

Definition at line 852 of file nsXBLContentSink.cpp.

{
#ifdef MOZ_XUL
  if (!aNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) {
#endif
    return nsXMLContentSink::CreateElement(aAtts, aAttsCount, aNodeInfo,
                                           aLineNumber, aResult,
                                           aAppendContent);
#ifdef MOZ_XUL
  }

  *aAppendContent = PR_TRUE;
  nsXULPrototypeElement* prototype = new nsXULPrototypeElement();
  if (!prototype)
    return NS_ERROR_OUT_OF_MEMORY;

  prototype->mNodeInfo = aNodeInfo;

  AddAttributesToXULPrototype(aAtts, aAttsCount, prototype);

  nsresult rv = nsXULElement::Create(prototype, mDocument, PR_FALSE, aResult);

  // XUL prototype elements start with a refcnt of 1 to represent
  // ownership by the XUL prototype document.  In our case we have no
  // prototype document, so release that reference.  The Create call
  // above took a reference.
  prototype->Release();

  return rv;
#endif
}

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, 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 nsXBLContentSink::FlushText ( PRBool  aCreateTextNode = PR_TRUE,
PRBool aDidFlush = nsnull 
) [protected, virtual]

Reimplemented from nsXMLContentSink.

Definition at line 116 of file nsXBLContentSink.cpp.

{
  if (mTextLength == 0) {
    if (aDidFlush)
      *aDidFlush = PR_FALSE;
    return NS_OK;
  }

  const nsASingleFragmentString& text = Substring(mText, mText+mTextLength);
  if (mState == eXBL_InHandlers) {
    NS_ASSERTION(mBinding, "Must have binding here");
    // Get the text and add it to the event handler.
    if (mSecondaryState == eXBL_InHandler)
      mHandler->AppendHandlerText(text);
    mTextLength = 0;
    if (aDidFlush)
      *aDidFlush = PR_TRUE;
    return NS_OK;
  }
  else if (mState == eXBL_InImplementation) {
    NS_ASSERTION(mBinding, "Must have binding here");
    if (mSecondaryState == eXBL_InConstructor ||
        mSecondaryState == eXBL_InDestructor) {
      // Construct a method for the constructor/destructor.
      nsXBLProtoImplMethod* method;
      if (mSecondaryState == eXBL_InConstructor)
        method = mBinding->GetConstructor();
      else
        method = mBinding->GetDestructor();

      // Get the text and add it to the constructor/destructor.
      method->AppendBodyText(text);
    }
    else if (mSecondaryState == eXBL_InGetter ||
             mSecondaryState == eXBL_InSetter) {
      // Get the text and add it to the getter/setter
      if (mSecondaryState == eXBL_InGetter)
        mProperty->AppendGetterText(text);
      else
        mProperty->AppendSetterText(text);
    }
    else if (mSecondaryState == eXBL_InBody) {
      // Get the text and add it to the method
      if (mMethod)
        mMethod->AppendBodyText(text);
    }
    else if (mSecondaryState == eXBL_InField) {
      // Get the text and add it to the method
      mField->AppendFieldText(text);
    }
    mTextLength = 0;
    if (aDidFlush)
      *aDidFlush = PR_TRUE;
    return NS_OK;
  }

  nsIContent* content = GetCurrentContent();
  if (content && (content->GetNodeInfo()->NamespaceEquals(kNameSpaceID_XBL) || (
      content->GetNodeInfo()->NamespaceEquals(kNameSpaceID_XUL) &&
      content->Tag() != nsXULAtoms::label &&
      content->Tag() != nsXULAtoms::description))) {

    PRBool isWS = PR_TRUE;
    if (mTextLength > 0) {
      const PRUnichar* cp = mText;
      const PRUnichar* end = mText + mTextLength;
      while (cp < end) {
        PRUnichar ch = *cp++;
        if (!XP_IS_SPACE(ch)) {
          isWS = PR_FALSE;
          break;
        }
      }
    }

    if (isWS && mTextLength > 0) {
      mTextLength = 0;
      if (aDidFlush)
        *aDidFlush = PR_TRUE;
      return NS_OK;
    }
  }

  return nsXMLContentSink::FlushText(aCreateTextNode, aDidFlush);
}

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:

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

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

Definition at line 382 of file nsXBLContentSink.cpp.

Here is the call graph for this function:

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

Definition at line 296 of file nsXBLContentSink.cpp.

{
  FlushText();

  if (mState != eXBL_InDocument) {
    PRInt32 nameSpaceID;
    nsCOMPtr<nsIAtom> prefix, localName;
    nsContentUtils::SplitExpatName(aName, getter_AddRefs(prefix),
                                   getter_AddRefs(localName), &nameSpaceID);

    if (nameSpaceID == kNameSpaceID_XBL) {
      if (mState == eXBL_Error) {
        // Check whether we've opened this tag before; we may not have if
        // it was a real XBL tag before the error occured.
        if (!GetCurrentContent()->GetNodeInfo()->Equals(localName,
                                                        nameSpaceID)) {
          // OK, this tag was never opened as far as the XML sink is
          // concerned.  Just drop the HandleEndElement
          return NS_OK;
        }
      }
      else if (mState == eXBL_InHandlers) {
        if (localName == nsXBLAtoms::handlers) {
          mState = eXBL_InBinding;
          mHandler = nsnull;
        }
        else if (localName == nsXBLAtoms::handler)
          mSecondaryState = eXBL_None;
        return NS_OK;
      }
      else if (mState == eXBL_InResources) {
        if (localName == nsXBLAtoms::resources)
          mState = eXBL_InBinding;
        return NS_OK;
      }
      else if (mState == eXBL_InImplementation) {
        if (localName == nsXBLAtoms::implementation)
          mState = eXBL_InBinding;
        else if (localName == nsXBLAtoms::property) {
          mSecondaryState = eXBL_None;
          mProperty = nsnull;
        }
        else if (localName == nsXBLAtoms::method) {
          mSecondaryState = eXBL_None;
          mMethod = nsnull;
        }
        else if (localName == nsXBLAtoms::field) {
          mSecondaryState = eXBL_None;
          mField = nsnull;
        }
        else if (localName == nsXBLAtoms::constructor ||
                 localName == nsXBLAtoms::destructor)
          mSecondaryState = eXBL_None;
        else if (localName == nsXBLAtoms::getter ||
                 localName == nsXBLAtoms::setter)
          mSecondaryState = eXBL_InProperty;
        else if (localName == nsXBLAtoms::parameter ||
                 localName == nsXBLAtoms::body)
          mSecondaryState = eXBL_InMethod;
        return NS_OK;
      }
      else if (mState == eXBL_InBindings &&
               localName == nsXBLAtoms::bindings) {
        mState = eXBL_InDocument;
      }
      
      nsresult rv = nsXMLContentSink::HandleEndElement(aName);
      if (NS_FAILED(rv))
        return rv;

      if (mState == eXBL_InBinding && localName == nsXBLAtoms::binding) {
        mState = eXBL_InBindings;
        if (mBinding) {  // See comment in HandleStartElement()
          mBinding->Initialize();
          mBinding = nsnull; // Clear our current binding ref.
        }
      }

      return NS_OK;
    }
  }

  return nsXMLContentSink::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
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 nsXBLContentSink::HandleStartElement ( const PRUnichar aName,
const PRUnichar **  aAtts,
PRUint32  aAttsCount,
PRInt32  aIndex,
PRUint32  aLineNumber 
)

Definition at line 273 of file nsXBLContentSink.cpp.

{
  nsresult rv = nsXMLContentSink::HandleStartElement(aName,aAtts,aAttsCount,aIndex,aLineNumber);
  if (NS_FAILED(rv))
    return rv;

  if (mState == eXBL_InBinding && !mBinding) {
    rv = ConstructBinding();
    if (NS_FAILED(rv))
      return rv;
    
    // mBinding may still be null, if the binding had no id.  If so,
    // we'll deal with that later in the sink.
  }

  return rv;
}

Here is the call graph for this function:

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 
) [inherited]

Reimplemented from nsContentSink.

Definition at line 169 of file nsXMLContentSink.cpp.

Here is the caller graph for this function:

nsresult nsXBLContentSink::Init ( nsIDocument aDoc,
nsIURI aURL,
nsISupports *  aContainer 
)

Definition at line 106 of file nsXBLContentSink.cpp.

{
  nsresult rv;
  rv = nsXMLContentSink::Init(aDoc, aURI, aContainer, nsnull);
  return rv;
}

Here is the caller graph for this function:

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

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:

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:

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

Reimplemented from nsXMLContentSink.

Definition at line 396 of file nsXBLContentSink.cpp.

{
  if (mState == eXBL_Error) {
    return PR_TRUE;
  }
  
  if (aNameSpaceID != kNameSpaceID_XBL) {
    // Construct non-XBL nodes
    return PR_TRUE;
  }

  PRBool ret = PR_TRUE;
  if (aTagName == nsXBLAtoms::bindings) {
    ENSURE_XBL_STATE(mState == eXBL_InDocument);
      
    NS_NewXBLDocumentInfo(mDocument, &mDocInfo);
    if (!mDocInfo) {
      mState = eXBL_Error;
      return PR_TRUE;
    }

    mDocument->BindingManager()->PutXBLDocumentInfo(mDocInfo);

    nsIURI *uri = mDocument->GetDocumentURI();
      
    PRBool isChrome = PR_FALSE;
    PRBool isRes = PR_FALSE;

    uri->SchemeIs("chrome", &isChrome);
    uri->SchemeIs("resource", &isRes);
    mIsChromeOrResource = isChrome || isRes;
      
    nsIXBLDocumentInfo* info = mDocInfo;
    NS_RELEASE(info); // We keep a weak ref. We've created a cycle between doc/binding manager/doc info.
    mState = eXBL_InBindings;
  }
  else if (aTagName == nsXBLAtoms::binding) {
    ENSURE_XBL_STATE(mState == eXBL_InBindings);
    mState = eXBL_InBinding;
  }
  else if (aTagName == nsXBLAtoms::handlers) {
    ENSURE_XBL_STATE(mState == eXBL_InBinding && mBinding);
    mState = eXBL_InHandlers;
    ret = PR_FALSE;
  }
  else if (aTagName == nsXBLAtoms::handler) {
    ENSURE_XBL_STATE(mState == eXBL_InHandlers);
    mSecondaryState = eXBL_InHandler;
    ConstructHandler(aAtts, aLineNumber);
    ret = PR_FALSE;
  }
  else if (aTagName == nsXBLAtoms::resources) {
    ENSURE_XBL_STATE(mState == eXBL_InBinding && mBinding);
    mState = eXBL_InResources;
    // Note that this mState will cause us to return false, so no need
    // to set ret to false.
  }
  else if (aTagName == nsXBLAtoms::stylesheet || aTagName == nsXBLAtoms::image) {
    ENSURE_XBL_STATE(mState == eXBL_InResources);
    NS_ASSERTION(mBinding, "Must have binding here");
    ConstructResource(aAtts, aTagName);
  }
  else if (aTagName == nsXBLAtoms::implementation) {
    ENSURE_XBL_STATE(mState == eXBL_InBinding && mBinding);
    mState = eXBL_InImplementation;
    ConstructImplementation(aAtts);
    // Note that this mState will cause us to return false, so no need
    // to set ret to false.
  }
  else if (aTagName == nsXBLAtoms::constructor) {
    ENSURE_XBL_STATE(mState == eXBL_InImplementation &&
                     mSecondaryState == eXBL_None);
    NS_ASSERTION(mBinding, "Must have binding here");
      
    mSecondaryState = eXBL_InConstructor;
    nsXBLProtoImplAnonymousMethod* newMethod =
      new nsXBLProtoImplAnonymousMethod();
    if (newMethod) {
      newMethod->SetLineNumber(aLineNumber);
      mBinding->SetConstructor(newMethod);
      AddMember(newMethod);
    }
  }
  else if (aTagName == nsXBLAtoms::destructor) {
    ENSURE_XBL_STATE(mState == eXBL_InImplementation &&
                     mSecondaryState == eXBL_None);
    NS_ASSERTION(mBinding, "Must have binding here");
    mSecondaryState = eXBL_InDestructor;
    nsXBLProtoImplAnonymousMethod* newMethod =
      new nsXBLProtoImplAnonymousMethod();
    if (newMethod) {
      newMethod->SetLineNumber(aLineNumber);
      mBinding->SetDestructor(newMethod);
      AddMember(newMethod);
    }
  }
  else if (aTagName == nsXBLAtoms::field) {
    ENSURE_XBL_STATE(mState == eXBL_InImplementation &&
                     mSecondaryState == eXBL_None);
    NS_ASSERTION(mBinding, "Must have binding here");
    mSecondaryState = eXBL_InField;
    ConstructField(aAtts, aLineNumber);
  }
  else if (aTagName == nsXBLAtoms::property) {
    ENSURE_XBL_STATE(mState == eXBL_InImplementation &&
                     mSecondaryState == eXBL_None);
    NS_ASSERTION(mBinding, "Must have binding here");
    mSecondaryState = eXBL_InProperty;
    ConstructProperty(aAtts);
  }
  else if (aTagName == nsXBLAtoms::getter) {
    ENSURE_XBL_STATE(mSecondaryState == eXBL_InProperty && mProperty);
    NS_ASSERTION(mState == eXBL_InImplementation, "Unexpected state");
    mProperty->SetGetterLineNumber(aLineNumber);
    mSecondaryState = eXBL_InGetter;
  }
  else if (aTagName == nsXBLAtoms::setter) {
    ENSURE_XBL_STATE(mSecondaryState == eXBL_InProperty && mProperty);
    NS_ASSERTION(mState == eXBL_InImplementation, "Unexpected state");
    mProperty->SetSetterLineNumber(aLineNumber);
    mSecondaryState = eXBL_InSetter;
  }
  else if (aTagName == nsXBLAtoms::method) {
    ENSURE_XBL_STATE(mState == eXBL_InImplementation &&
                     mSecondaryState == eXBL_None);
    NS_ASSERTION(mBinding, "Must have binding here");
    mSecondaryState = eXBL_InMethod;
    ConstructMethod(aAtts);
  }
  else if (aTagName == nsXBLAtoms::parameter) {
    ENSURE_XBL_STATE(mSecondaryState == eXBL_InMethod && mMethod);
    NS_ASSERTION(mState == eXBL_InImplementation, "Unexpected state");
    ConstructParameter(aAtts);
  }
  else if (aTagName == nsXBLAtoms::body) {
    ENSURE_XBL_STATE(mSecondaryState == eXBL_InMethod && mMethod);
    NS_ASSERTION(mState == eXBL_InImplementation, "Unexpected state");
    // stash away the line number
    mMethod->SetLineNumber(aLineNumber);
    mSecondaryState = eXBL_InBody;
  }

  return ret && mState != eXBL_InResources && mState != eXBL_InImplementation;
}

Here is the call graph for this function:

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

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

void nsIExpatSink::ReportError ( in wstring  aErrorText,
in wstring  aSourceText 
) [inherited]
NS_IMETHODIMP nsXBLContentSink::ReportError ( const PRUnichar aErrorText,
const PRUnichar aSourceText 
) [protected]

Definition at line 204 of file nsXBLContentSink.cpp.

{
  // XXX We should make sure the binding has no effect, but that it also
  // gets destroyed properly without leaking.  Perhaps we should even
  // ensure that the content that was bound is displayed with no
  // binding.

  // Report the error to the error console.
  nsCOMPtr<nsIConsoleService> consoleService =
    do_GetService(NS_CONSOLESERVICE_CONTRACTID);
  if (consoleService) {
    // XXX It would be nice if the parser didn't pre-format it for us,
    // because then we could create a instance of nsIScriptError and the
    // error console would format this much more nicely for us.
    // However, that would require duplicating even more code between
    // the XML content sink and the XUL content sink.

    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

  // Most of what this does won't be too useful, but whatever...
  return nsXMLContentSink::ReportError(aErrorText, aSourceText);
}

Here is the call graph for this function:

nsresult nsXBLContentSink::ReportUnexpectedElement ( nsIAtom aElementName,
PRUint32  aLineNumber 
) [protected]

Definition at line 238 of file nsXBLContentSink.cpp.

{
  // XXX we should really somehow stop the parse and drop the binding
  // instead of just letting the XML sink build the content model like
  // we do...
  mState = eXBL_Error;
  nsAutoString elementName;
  aElementName->ToString(elementName);

  const PRUnichar* params[] = { elementName.get() };

  return nsContentUtils::ReportToConsole(nsContentUtils::eXBL_PROPERTIES,
                                         "UnexpectedElement",
                                         params, NS_ARRAY_LENGTH(params),
                                         mDocumentURI,
                                         EmptyString() /* source line */,
                                         aLineNumber, 0 /* column number */,
                                         nsIScriptError::errorFlag,
                                         "XBL Content Sink");
}

Here is the call graph for this function:

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

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

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;
}
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;
}
void nsXMLContentSink::StartLayout ( ) [protected, inherited]

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:

NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIEXPATSINK NS_IMETHOD nsXMLContentSink::WillBuildModel ( void  ) [virtual, inherited]

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;
}
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 167 of file nsXMLContentSink.h.

Definition at line 161 of file nsXBLContentSink.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 158 of file nsXBLContentSink.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 167 of file nsXBLContentSink.h.

Definition at line 162 of file nsXBLContentSink.h.

Definition at line 166 of file nsXMLContentSink.h.

Definition at line 163 of file nsXBLContentSink.h.

Definition at line 164 of file nsXBLContentSink.h.

PRUint8 nsXMLContentSink::mInTitle [protected, inherited]

Definition at line 162 of file nsXMLContentSink.h.

Definition at line 159 of file nsXBLContentSink.h.

Definition at line 166 of file nsXBLContentSink.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.

Definition at line 165 of file nsXBLContentSink.h.

nsCString nsContentSink::mRef [protected, inherited]

Definition at line 121 of file nsContentSink.h.

Definition at line 119 of file nsContentSink.h.

PRUint32 nsXMLContentSink::mScriptLineNo [protected, inherited]

Definition at line 159 of file nsXMLContentSink.h.

Definition at line 157 of file nsXBLContentSink.h.

Reimplemented from nsXMLContentSink.

Definition at line 156 of file nsXBLContentSink.h.

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.

PRUint8 nsXMLContentSink::unused [protected, inherited]

Definition at line 168 of file nsXMLContentSink.h.


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