Back to index

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

List of all members.

Public Member Functions

 HTMLContentSink ()
virtual ~HTMLContentSink ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nsresult 
Init (nsIDocument *aDoc, nsIURI *aURI, nsISupports *aContainer, nsIChannel *aChannel)
NS_DECL_ISUPPORTS_INHERITED
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 OpenContainer (const nsIParserNode &aNode)
 This method is used to open a generic container in the sink.
NS_IMETHOD CloseContainer (const nsHTMLTag aTag)
 This method gets called by the parser when a close container tag has been consumed and needs to be closed.
NS_IMETHOD AddHeadContent (const nsIParserNode &aNode)
 This gets called by the parser to contents to the head container.
NS_IMETHOD AddLeaf (const nsIParserNode &aNode)
 This gets called by the parser when you want to add a leaf node to the current container in the content model.
NS_IMETHOD AddComment (const nsIParserNode &aNode)
 This gets called by the parser when you want to add a leaf node to the current container in the content model.
NS_IMETHOD AddProcessingInstruction (const nsIParserNode &aNode)
 This gets called by the parser when you want to add a leaf node to the current container in the content model.
NS_IMETHOD AddDocTypeDecl (const nsIParserNode &aNode)
 This method is called by the parser when it encounters a document type declaration.
NS_IMETHOD WillProcessTokens (void)
 This method is called when parser is about to begin synchronously processing a chunk of tokens.
NS_IMETHOD DidProcessTokens (void)
 This method is called when parser has completed processing a chunk of tokens.
NS_IMETHOD WillProcessAToken (void)
 This method is called when parser is about to process a single token.
NS_IMETHOD DidProcessAToken (void)
 This method is called when parser has completed the processing for a single token.
NS_IMETHOD NotifyTagObservers (nsIParserNode *aNode)
 This gets called by the parser to notify observers of the tag.
NS_IMETHOD BeginContext (PRInt32 aID)
 This gets called when handling illegal contents, especially in dealing with tables.
NS_IMETHOD EndContext (PRInt32 aID)
 This method terminates any new context that got created by BeginContext and switches back to the main context.
NS_IMETHOD SetTitle (const nsString &aValue)
 This method gets called by the parser when it encounters a title tag and wants to set the document title in the sink.
NS_IMETHOD OpenHTML (const nsIParserNode &aNode)
 This method is used to open the outer HTML container.
NS_IMETHOD CloseHTML ()
 This method is used to close the outer HTML container.
NS_IMETHOD OpenHead (const nsIParserNode &aNode)
 This method is used to open the only HEAD container.
NS_IMETHOD CloseHead ()
 This method is used to close the only HEAD container.
NS_IMETHOD OpenBody (const nsIParserNode &aNode)
 This method is used to open the main BODY container.
NS_IMETHOD CloseBody ()
 This method is used to close the main BODY container.
NS_IMETHOD OpenForm (const nsIParserNode &aNode)
 This method is used to open a new FORM container.
NS_IMETHOD CloseForm ()
 This method is used to close the outer FORM container.
NS_IMETHOD OpenFrameset (const nsIParserNode &aNode)
 This method is used to open the FRAMESET container.
NS_IMETHOD CloseFrameset ()
 This method is used to close the FRAMESET container.
NS_IMETHOD OpenMap (const nsIParserNode &aNode)
 This method is used to open a new MAP container.
NS_IMETHOD CloseMap ()
 This method is used to close the MAP container.
NS_IMETHOD IsEnabled (PRInt32 aTag, PRBool *aReturn)
 01/09/2003 harishd
 NS_IMETHOD_ (PRBool) IsFormOnStack()
 Call this method to determnine if a FORM is on the sink's stack.
virtual
NS_DECL_NSITIMERCALLBACK void 
BeginUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)
 Notify that a content model update is beginning.
virtual void EndUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)
 Notify that a content model update is finished.
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 notify (in nsITimer timer)
virtual void BeginLoad (nsIDocument *aDocument)=0
 Notify the observer that a document load is beginning.
virtual void EndLoad (nsIDocument *aDocument)=0
 Notify the observer that a document load has finished.
virtual void BeginReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is being reflowed in the given presentation shell.
virtual void EndReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is done being reflowed in the given presentation shell.
virtual void CharacterDataChanged (nsIDocument *aDocument, nsIContent *aContent, PRBool aAppend)=0
 Notification that the content model has changed.
virtual void ContentStatesChanged (nsIDocument *aDocument, nsIContent *aContent1, nsIContent *aContent2, PRInt32 aStateMask)=0
 Notification that the state of a content node has changed.
virtual void AttributeChanged (nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType)=0
 Notification that the content model has changed.
virtual void ContentAppended (nsIDocument *aDocument, nsIContent *aContainer, PRInt32 aNewIndexInContainer)=0
 Notifcation that the content model has had data appended to the given content object.
virtual void ContentInserted (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)=0
 Notification that content has been inserted.
virtual void ContentRemoved (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)=0
 Content has just been removed.
virtual void StyleSheetAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)=0
 A StyleSheet has just been added to the document.
virtual void StyleSheetRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)=0
 A StyleSheet has just been removed from the document.
virtual void StyleSheetApplicableStateChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aApplicable)=0
 A StyleSheet has just changed its applicable state.
virtual void StyleRuleChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aOldStyleRule, nsIStyleRule *aNewStyleRule)=0
 A StyleRule has just been modified within a style sheet.
virtual void StyleRuleAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)=0
 A StyleRule has just been added to a style sheet.
virtual void StyleRuleRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)=0
 A StyleRule has just been removed from a style sheet.
virtual void DocumentWillBeDestroyed (nsIDocument *aDocument)=0
 The document is in the process of being destroyed.

Protected Member Functions

PRBool IsTimeToNotify ()
nsresult SetDocumentTitle (const nsAString &aTitle, const nsIParserNode *aNode)
nsresult AddAttributes (const nsIParserNode &aNode, nsIContent *aContent, PRBool aNotify=PR_FALSE, PRBool aCheckIfPresent=PR_FALSE)
already_AddRefed
< nsGenericHTMLElement
CreateContentObject (const nsIParserNode &aNode, nsHTMLTag aNodeType, nsGenericHTMLElement *aForm, nsIDocShell *aDocShell)
 Factory subroutine to create all of the html content objects.
PRInt32 GetNotificationInterval ()
PRInt32 GetMaxTokenProcessingTime ()
void StartLayout ()
void TryToScrollToRef ()
void AddBaseTagInfo (nsIContent *aContent)
 AddBaseTagInfo adds the "current" base URI and target to the content node in the form of bogo-attributes.
void ProcessBaseHref (const nsAString &aBaseHref)
void ProcessBaseTarget (const nsAString &aBaseTarget)
nsresult ProcessAREATag (const nsIParserNode &aNode)
nsresult ProcessBASETag (const nsIParserNode &aNode)
nsresult ProcessLINKTag (const nsIParserNode &aNode)
nsresult ProcessMAPTag (nsIContent *aContent)
nsresult ProcessMETATag (const nsIParserNode &aNode)
nsresult ProcessSCRIPTTag (const nsIParserNode &aNode)
nsresult ProcessSTYLETag (const nsIParserNode &aNode)
nsresult OpenHeadContext ()
nsresult CloseHeadContext ()
virtual void PreEvaluateScript ()
virtual void PostEvaluateScript ()
void UpdateAllContexts ()
void NotifyAppend (nsIContent *aContent, PRUint32 aStartIndex)
void NotifyInsert (nsIContent *aContent, nsIContent *aChildContent, PRInt32 aIndexInContainer)
PRBool IsMonolithicContainer (nsHTMLTag aTag)
nsresult AddDummyParserRequest (void)
nsresult RemoveDummyParserRequest (void)
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)
virtual nsresult ProcessStyleLink (nsIContent *aElement, const nsSubstring &aHref, PRBool aAlternate, const nsSubstring &aTitle, const nsSubstring &aType, const nsSubstring &aMedia)
nsresult ProcessMETATag (nsIContent *aContent)
void PrefetchHref (const nsAString &aHref, PRBool aExplicit)
PRBool ScrollToRef (PRBool aReallyScroll)
nsresult RefreshIfEnabled (nsIViewManager *vm)
void StartLayout (PRBool aIsFrameset)

Protected Attributes

nsIHTMLDocumentmHTMLDocument
PRInt32 mBackoffCount
PRInt32 mNotificationInterval
PRTime mLastNotificationTime
nsCOMPtr< nsITimermNotificationTimer
PRInt32 mMaxTextRun
nsGenericHTMLElementmRoot
nsGenericHTMLElementmBody
nsGenericHTMLElementmFrameset
nsGenericHTMLElementmHead
nsString mSkippedContent
PRPackedBool mNotifyOnTimer
PRPackedBool mLayoutStarted
PRPackedBool mScrolledToRefAlready
PRInt32 mInNotification
nsRefPtr< nsGenericHTMLElementmCurrentForm
nsCOMPtr< nsIContentmCurrentMap
nsAutoVoidArray mContextStack
SinkContextmCurrentContext
SinkContextmHeadContext
PRInt32 mNumOpenIFRAMES
nsCOMPtr< nsIRequestmDummyParserRequest
nsString mBaseHREF
nsString mBaseTarget
PRInt32 mInsideNoXXXTag
PRInt32 mInMonolithicContainer
PRUint32 mFlags
PRUint32 mDelayTimerStart
PRInt32 mMaxTokenProcessingTime
PRInt32 mDynamicIntervalSwitchThreshold
PRInt32 mBeginLoadTime
PRUint32 mLastSampledUserEventTime
PRUint8 mDeflectedCount
nsCOMPtr< nsIObserverEntrymObservers
nsCOMPtr< nsIDocumentmDocument
nsCOMPtr< nsIParsermParser
nsCOMPtr< nsIURImDocumentURI
nsCOMPtr< nsIURImDocumentBaseURI
nsCOMPtr< nsIDocShellmDocShell
nsCOMPtr< nsICSSLoadermCSSLoader
nsRefPtr< nsNodeInfoManagermNodeInfoManager
nsCOMArray< nsIScriptElementmScriptElements
nsCString mRef
PRBool mNeedToBlockParser

Friends

class SinkContext
class DummyParserRequest

Detailed Description

Definition at line 202 of file nsHTMLContentSink.cpp.


Constructor & Destructor Documentation

Definition at line 1831 of file nsHTMLContentSink.cpp.

{
  // Note: operator new zeros our memory


#ifdef NS_DEBUG
  if (!gSinkLogModuleInfo) {
    gSinkLogModuleInfo = PR_NewLogModule("htmlcontentsink");
  }
#endif
}

Definition at line 1843 of file nsHTMLContentSink.cpp.

{
  NS_IF_RELEASE(mHead);
  NS_IF_RELEASE(mBody);
  NS_IF_RELEASE(mFrameset);
  NS_IF_RELEASE(mRoot);

  if (mDocument) {
    mDocument->RemoveObserver(this);
  }
  NS_IF_RELEASE(mHTMLDocument);

  if (mNotificationTimer) {
    mNotificationTimer->Cancel();
  }

  PRInt32 numContexts = mContextStack.Count();

  if (mCurrentContext == mHeadContext && numContexts > 0) {
    // Pop off the second html context if it's not done earlier
    mContextStack.RemoveElementAt(--numContexts);
  }

  for (PRInt32 i = 0; i < numContexts; i++) {
    SinkContext* sc = (SinkContext*)mContextStack.ElementAt(i);
    if (sc) {
      sc->End();
      if (sc == mCurrentContext) {
        mCurrentContext = nsnull;
      }

      delete sc;
    }
  }

  if (mCurrentContext == mHeadContext) {
    mCurrentContext = nsnull;
  }

  delete mCurrentContext;

  delete mHeadContext;
}

Here is the call graph for this function:


Member Function Documentation

nsresult HTMLContentSink::AddAttributes ( const nsIParserNode aNode,
nsIContent aContent,
PRBool  aNotify = PR_FALSE,
PRBool  aCheckIfPresent = PR_FALSE 
) [protected]

Definition at line 777 of file nsHTMLContentSink.cpp.

{
  // Add tag attributes to the content attributes

  PRInt32 ac = aNode.GetAttributeCount();

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

    return NS_OK;
  }

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

  // The attributes are on the parser node in the order they came in in the
  // source.  What we want to happen if a single attribute is set multiple
  // times on an element is that the first time should "win".  That is, <input
  // value="foo" value="bar"> should show "foo".  So we loop over the
  // attributes backwards; this ensures that the first attribute in the set
  // wins.  This does mean that we do some extra work in the case when the same
  // attribute is set multiple times, but we save a HasAttr call in the much
  // more common case of reasonable HTML.
  
  for (PRInt32 i = ac - 1; i >= 0; i--) {
    // Get lower-cased key
    const nsAString& key = aNode.GetKeyAt(i);
    // Copy up-front to avoid shared-buffer overhead (and convert to UTF-8
    // at the same time since that's what the atom table uses).
    CopyUTF16toUTF8(key, k);
    ToLowerCase(k);

    nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);

    if (aCheckIfPresent && aContent->HasAttr(kNameSpaceID_None, keyAtom)) {
      continue;
    }

    // Get value and remove mandatory quotes
    static const char* kWhitespace = "\n\r\t\b";

    // Bug 114997: Don't trim whitespace on <input value="...">:
    // Using ?: outside the function call would be more efficient, but
    // we don't trust ?: with references.
    const nsAString& v =
      nsContentUtils::TrimCharsInSet(
        (nodeType == eHTMLTag_input &&
          keyAtom == nsHTMLAtoms::value) ?
        "" : kWhitespace, aNode.GetValueAt(i));

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

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

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void HTMLContentSink::AddBaseTagInfo ( nsIContent aContent) [protected]

AddBaseTagInfo adds the "current" base URI and target to the content node in the form of bogo-attributes.

This MUST be called before attributes are added to the content node, since the way URI attributes are treated may depend on the value of the base URI

Here is the caller graph for this function:

This gets called by the parser when you want to add a leaf node to the current container in the content model.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is called by the parser when it encounters a document type declaration.

XXX Should the parser also part the internal subset?

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

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

Implements nsIHTMLContentSink.

This gets called by the parser when you want to add a leaf node to the current container in the content model.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This gets called by the parser when you want to add a leaf node to the current container in the content model.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

virtual void nsIDocumentObserver::AttributeChanged ( nsIDocument aDocument,
nsIContent aContent,
PRInt32  aNameSpaceID,
nsIAtom aAttribute,
PRInt32  aModType 
) [pure virtual, inherited]

Notification that the content model has changed.

This method is called automatically by content objects when an attribute's value has changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers document observers.

Parameters:
aDocumentThe document being observed
aContentthe piece of content whose attribute changed
aAttributethe atom name of the attribute
aModTypeWhether or not the attribute was added, changed, or removed. The constants are defined in nsIDOMMutationEvent.h.

Implemented in PresShell, nsContentList, nsXULContentBuilder, nsXULTemplateBuilder, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

This gets called when handling illegal contents, especially in dealing with tables.

This method creates a new context.

04/04/99 harishd

Parameters:
aPosition- The position from where the new context begins.

Implements nsIHTMLContentSink.

virtual void nsIDocumentObserver::BeginLoad ( nsIDocument aDocument) [pure virtual, inherited]

Notify the observer that a document load is beginning.

Implemented in PresShell.

virtual void nsIDocumentObserver::BeginReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is being reflowed in the given presentation shell.

virtual NS_DECL_NSITIMERCALLBACK void HTMLContentSink::BeginUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [virtual]

Notify that a content model update is beginning.

This call can be nested.

Implements nsIDocumentObserver.

virtual void nsIDocumentObserver::CharacterDataChanged ( nsIDocument aDocument,
nsIContent aContent,
PRBool  aAppend 
) [pure virtual, inherited]

Notification that the content model has changed.

This method is called automatically by content objects when their state is changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers. The notification is passed on to all of the document observers.

This notification is not sent when a piece of content is added/removed from the document (the other notifications are used for that).

Parameters:
aDocumentThe document being observed
aContentthe piece of content that changed
aAppendWhether the change was an append

Implemented in PresShell.

This method is used to close the main BODY container.

Implements nsIHTMLContentSink.

This method gets called by the parser when a close container tag has been consumed and needs to be closed.

Parameters:
aTag- The tag to be closed.

Implements nsIHTMLContentSink.

This method is used to close the outer FORM container.

Implements nsIHTMLContentSink.

This method is used to close the FRAMESET container.

Implements nsIHTMLContentSink.

This method is used to close the only HEAD container.

Implements nsIHTMLContentSink.

This method is used to close the outer HTML container.

Implements nsIHTMLContentSink.

This method is used to close the MAP container.

Implements nsIHTMLContentSink.

virtual void nsIDocumentObserver::ContentAppended ( nsIDocument aDocument,
nsIContent aContainer,
PRInt32  aNewIndexInContainer 
) [pure virtual, inherited]

Notifcation that the content model has had data appended to the given content object.

This method is called automatically by the content container objects when a new content object is appended to the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a new child appended
aNewIndexInContainerthe index in the container of the first new child

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentInserted ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [pure virtual, inherited]

Notification that content has been inserted.

This method is called automatically by the content container objects when a new content object is inserted in the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that now contains aChild
aChildthe child that was inserted
aIndexInContainerthe index of the child in the container

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentRemoved ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [pure virtual, inherited]

Content has just been removed.

This method is called automatically by content container objects when a content object has just been removed from the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a child removed
aChildthe child that was just removed
aIndexInContainerthe index of the child in the container before it was removed

Implemented in PresShell, nsContentList, nsBindingManager, nsImageMap, nsTreeContentView, and nsXMLPrettyPrinter.

virtual void nsIDocumentObserver::ContentStatesChanged ( nsIDocument aDocument,
nsIContent aContent1,
nsIContent aContent2,
PRInt32  aStateMask 
) [pure virtual, inherited]

Notification that the state of a content node has changed.

(ie: gained or lost focus, became active or hovered over) This method is called automatically by content objects when their state is changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers. The notification is passed on to all of the document observers.

This notification is not sent when a piece of content is added/removed from the document or the content itself changed (the other notifications are used for that).

The optional second content node is to allow optimization of the case where state moves from one node to another (as is likely for :focus and :hover)

Either content node may be nsnull, but not both

Parameters:
aDocumentThe document being observed
aContent1the piece of content that changed
aContent2optional second piece of content that changed

Implemented in PresShell, and nsTreeContentView.

Factory subroutine to create all of the html content objects.

Definition at line 865 of file nsHTMLContentSink.cpp.

{
  // Find/create atom for the tag name

  nsCOMPtr<nsINodeInfo> nodeInfo;

  if (aNodeType == eHTMLTag_userdefined) {
    NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
    ToLowerCase(tmp);

    nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
    mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
                                  getter_AddRefs(nodeInfo));
  } else {
    nsIParserService *parserService =
      nsContentUtils::GetParserServiceWeakRef();
    if (!parserService)
      return nsnull;

    nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType);
    NS_ASSERTION(name, "What? Reverse mapping of id to string broken!!!");

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

  NS_ENSURE_TRUE(nodeInfo, nsnull);

  // Make the content object
  nsGenericHTMLElement* result = MakeContentObject(aNodeType, nodeInfo, aForm,
                                             !!mInsideNoXXXTag, PR_TRUE).get();
  if (!result) {
    return nsnull;
  }

  result->SetContentID(mDocument->GetAndIncrementContentID());

  return result;
}

Here is the call graph for this function:

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

This method is called when parser has completed the processing for a single token.

Returns:
NS_OK if processing should not be interrupted NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted

Implements nsIHTMLContentSink.

This method is called when parser has completed processing a chunk of tokens.

The processing of the tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from DidProcessAToken.

Implements nsIHTMLContentSink.

virtual void nsIDocumentObserver::DocumentWillBeDestroyed ( nsIDocument aDocument) [pure virtual, inherited]

The document is in the process of being destroyed.

This method is called automatically during document destruction.

Parameters:
aDocumentThe document being observed

Implemented in nsFragmentObserver, nsDOMStyleSheetList, nsContentList, nsBindingManager, nsXULContentBuilder, nsXULTreeBuilder, nsXULTemplateBuilder, nsTreeContentView, and nsXMLPrettyPrinter.

This method terminates any new context that got created by BeginContext and switches back to the main context.

04/04/99 harishd

Parameters:
aPosition- Validates the end of a context.

Implements nsIHTMLContentSink.

virtual void nsIDocumentObserver::EndLoad ( nsIDocument aDocument) [pure virtual, inherited]

Notify the observer that a document load has finished.

Note that the associated reflow of the document will be done before EndLoad is invoked, not after.

Implemented in PresShell.

virtual void nsIDocumentObserver::EndReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is done being reflowed in the given presentation shell.

virtual void HTMLContentSink::EndUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [virtual]

Notify that a content model update is finished.

This call can be nested.

Implements nsIDocumentObserver.

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

Definition at line 292 of file nsHTMLContentSink.cpp.

  {
    if (mFlags & NS_SINK_FLAG_DYNAMIC_LOWER_VALUE) {
      return 1000;
    }

    return mNotificationInterval;
  }
virtual nsISupports* HTMLContentSink::GetTarget ( ) [virtual]

Returns the target object (often a document object) into which the content built by this content sink is being added, if any (IOW, may return null).

Implements nsIContentSink.

NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW nsresult HTMLContentSink::Init ( nsIDocument aDoc,
nsIURI aURI,
nsISupports *  aContainer,
nsIChannel aChannel 
)

Reimplemented from nsContentSink.

NS_IMETHOD HTMLContentSink::IsEnabled ( PRInt32  aTag,
PRBool aReturn 
) [virtual]

01/09/2003 harishd

Parameters:
aTag- Check if this tag is enabled or not.

Implements nsIHTMLContentSink.

Here is the caller graph for this function:

Here is the caller graph for this function:

void nsITimerCallback::notify ( in nsITimer  timer) [inherited]
Parameters:
aTimerthe timer which has expired
void HTMLContentSink::NotifyAppend ( nsIContent aContent,
PRUint32  aStartIndex 
) [protected]

Here is the caller graph for this function:

void HTMLContentSink::NotifyInsert ( nsIContent aContent,
nsIContent aChildContent,
PRInt32  aIndexInContainer 
) [protected]

Here is the caller graph for this function:

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

Parameters:
aErrorResultthe error code

Implements nsIHTMLContentSink.

Call this method to determnine if a FORM is on the sink's stack.

Returns:
PR_TRUE if found else PR_FALSE

Implements nsIHTMLContentSink.

This method is used to open the main BODY container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is used to open a generic container in the sink.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is used to open a new FORM container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is used to open the FRAMESET container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is used to open the only HEAD container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is used to open the outer HTML container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

This method is used to open a new MAP container.

4/1/98 gess

Parameters:
nsIParserNodereference to parser node interface

Implements nsIHTMLContentSink.

virtual void HTMLContentSink::PostEvaluateScript ( ) [protected, virtual]

Reimplemented from nsContentSink.

virtual void HTMLContentSink::PreEvaluateScript ( ) [protected, virtual]

Reimplemented from nsContentSink.

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:

void HTMLContentSink::ProcessBaseHref ( const nsAString &  aBaseHref) [protected]
void HTMLContentSink::ProcessBaseTarget ( const nsAString &  aBaseTarget) [protected]
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 HTMLContentSink::ProcessMAPTag ( nsIContent aContent) [protected]

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

Reimplemented in nsXMLContentSink, and nsXMLFragmentContentSink.

Definition at line 619 of file nsContentSink.cpp.

{
  if (aAlternate && aTitle.IsEmpty()) {
    // alternates must have title return without error, for now
    return NS_OK;
  }

  nsAutoString  mimeType;
  nsAutoString  params;
  nsParserUtils::SplitMimeType(aType, mimeType, params);

  // see bug 18817
  if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
    // Unknown stylesheet language
    return NS_OK;
  }

  nsCOMPtr<nsIURI> url;
  nsresult rv = NS_NewURI(getter_AddRefs(url), aHref, nsnull, mDocumentBaseURI);
  
  if (NS_FAILED(rv)) {
    // The URI is bad, move along, don't propagate the error (for now)
    return NS_OK;
  }

  if (!aAlternate) {
    // possibly preferred sheet

    if (!aTitle.IsEmpty()) {
      nsAutoString preferredStyle;
      mDocument->GetHeaderData(nsHTMLAtoms::headerDefaultStyle,
                               preferredStyle);
      if (preferredStyle.IsEmpty()) {
        mDocument->SetHeaderData(nsHTMLAtoms::headerDefaultStyle, aTitle);
      }
    }
  }

  PRBool blockParser = kBlockByDefault;
  if (aAlternate) {
    blockParser = PR_FALSE;
  }

  // NOTE: no longer honoring the important keyword to indicate
  // blocking as it is proprietary and unnecessary since all
  // non-alternate will block the parser now -mja
#if 0
  if (linkTypes.IndexOf("important") != -1) {
    blockParser = PR_TRUE;
  }
#endif

  PRBool doneLoading;
  nsIParser* parser = nsnull;
  if (blockParser) {
    parser = mParser;
  }
  rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia,
                                 parser, doneLoading, this);

  if (NS_SUCCEEDED(rv) && blockParser && !doneLoading) {
    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::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 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:

NS_IMETHOD HTMLContentSink::SetDocumentCharset ( nsACString &  aCharset) [virtual]

Set the document character set.

This should be passed on to the document itself.

Implements nsIContentSink.

nsresult HTMLContentSink::SetDocumentTitle ( const nsAString &  aTitle,
const nsIParserNode aNode 
) [protected]

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.

This method gets called by the parser when it encounters a title tag and wants to set the document title in the sink.

4/1/98 gess

Parameters:
nsStringreference to new title value

Implements nsIHTMLContentSink.

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:

virtual void nsIDocumentObserver::StyleRuleAdded ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aStyleRule 
) [pure virtual, inherited]

A StyleRule has just been added to a style sheet.

This method is called automatically when the rule gets added to the sheet. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been modified
aStyleRulethe rule that was added

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleRuleChanged ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aOldStyleRule,
nsIStyleRule aNewStyleRule 
) [pure virtual, inherited]

A StyleRule has just been modified within a style sheet.

This method is called automatically when the rule gets modified. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Since nsIStyleRule objects are immutable, there is a new object replacing the old one. However, the use of this method (rather than StyleRuleAdded and StyleRuleRemoved) implies that the new rule matches the same elements and has the same priority (weight, origin, specificity) as the old one. (However, if it is a CSS style rule, there may be a change in whether it has an important rule.)

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that contians the rule
aOldStyleRuleThe rule being removed. This rule may not be fully valid anymore -- however, it can still be used for pointer comparison and |QueryInterface|.
aNewStyleRuleThe rule being added.

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleRuleRemoved ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
nsIStyleRule aStyleRule 
) [pure virtual, inherited]

A StyleRule has just been removed from a style sheet.

This method is called automatically when the rule gets removed from the sheet. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been modified
aStyleRulethe rule that was removed

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleSheetAdded ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aDocumentSheet 
) [pure virtual, inherited]

A StyleSheet has just been added to the document.

This method is called automatically when a StyleSheet gets added to the document, even if the stylesheet is not applicable. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been added
aDocumentSheetTrue if sheet is in document's style sheet list, false if sheet is not (i.e., UA or user sheet)

Implemented in PresShell, and nsDOMStyleSheetList.

virtual void nsIDocumentObserver::StyleSheetApplicableStateChanged ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aApplicable 
) [pure virtual, inherited]

A StyleSheet has just changed its applicable state.

This method is called automatically when the applicable state of a StyleSheet gets changed. The style sheet passes this notification to the document. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has changed state
aApplicablePR_TRUE if the sheet is applicable, PR_FALSE if it is not applicable

Implemented in PresShell.

virtual void nsIDocumentObserver::StyleSheetRemoved ( nsIDocument aDocument,
nsIStyleSheet aStyleSheet,
PRBool  aDocumentSheet 
) [pure virtual, inherited]

A StyleSheet has just been removed from the document.

This method is called automatically when a StyleSheet gets removed from the document, even if the stylesheet is not applicable. The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aStyleSheetthe StyleSheet that has been removed
aDocumentSheetTrue if sheet is in document's style sheet list, false if sheet is not (i.e., UA or user sheet)

Implemented in PresShell, and nsDOMStyleSheetList.

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.

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.

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

Implements nsIHTMLContentSink.

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

Implements nsIHTMLContentSink.

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.


Friends And Related Function Documentation

friend class DummyParserRequest [friend]

Definition at line 212 of file nsHTMLContentSink.cpp.

friend class SinkContext [friend]

Definition at line 211 of file nsHTMLContentSink.cpp.


Member Data Documentation

Definition at line 321 of file nsHTMLContentSink.cpp.

Definition at line 358 of file nsHTMLContentSink.cpp.

Definition at line 359 of file nsHTMLContentSink.cpp.

Definition at line 375 of file nsHTMLContentSink.cpp.

Definition at line 336 of file nsHTMLContentSink.cpp.

nsAutoVoidArray HTMLContentSink::mContextStack [protected]

Definition at line 352 of file nsHTMLContentSink.cpp.

Definition at line 116 of file nsContentSink.h.

Definition at line 353 of file nsHTMLContentSink.cpp.

Definition at line 349 of file nsHTMLContentSink.cpp.

Definition at line 350 of file nsHTMLContentSink.cpp.

Definition at line 385 of file nsHTMLContentSink.cpp.

Definition at line 367 of file nsHTMLContentSink.cpp.

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 356 of file nsHTMLContentSink.cpp.

Definition at line 373 of file nsHTMLContentSink.cpp.

Definition at line 364 of file nsHTMLContentSink.cpp.

Definition at line 337 of file nsHTMLContentSink.cpp.

Definition at line 338 of file nsHTMLContentSink.cpp.

Definition at line 354 of file nsHTMLContentSink.cpp.

Definition at line 318 of file nsHTMLContentSink.cpp.

Definition at line 363 of file nsHTMLContentSink.cpp.

Definition at line 348 of file nsHTMLContentSink.cpp.

Definition at line 362 of file nsHTMLContentSink.cpp.

Definition at line 327 of file nsHTMLContentSink.cpp.

Definition at line 379 of file nsHTMLContentSink.cpp.

Definition at line 345 of file nsHTMLContentSink.cpp.

Definition at line 333 of file nsHTMLContentSink.cpp.

Definition at line 370 of file nsHTMLContentSink.cpp.

PRBool nsContentSink::mNeedToBlockParser [protected, inherited]

Definition at line 122 of file nsContentSink.h.

Definition at line 117 of file nsContentSink.h.

Definition at line 324 of file nsHTMLContentSink.cpp.

Definition at line 330 of file nsHTMLContentSink.cpp.

Definition at line 343 of file nsHTMLContentSink.cpp.

Definition at line 355 of file nsHTMLContentSink.cpp.

Definition at line 387 of file nsHTMLContentSink.cpp.

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

Definition at line 112 of file nsContentSink.h.

nsCString nsContentSink::mRef [protected, inherited]

Definition at line 121 of file nsContentSink.h.

Definition at line 335 of file nsHTMLContentSink.cpp.

Definition at line 119 of file nsContentSink.h.

Definition at line 346 of file nsHTMLContentSink.cpp.

Definition at line 340 of file nsHTMLContentSink.cpp.


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