HI, all:
I have added some code in nsDocShell::EndPageLoad:
nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
nsIChannel * aChannel, nsresult aStatus)
{
//
// one of many safeguards that prevent death and destruction if
// someone is so very very rude as to bring this window down
// during this load handler.
//
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
//
// Notify the ContentViewer that the Document has finished loading...
//
// This will cause any OnLoad(...) handlers to fire, if it is a HTML
// document...
if (!mEODForCurrentDocument && mContentViewer) {
mIsExecutingOnLoadHandler = PR_TRUE;
mContentViewer->LoadComplete(aStatus);
mIsExecutingOnLoadHandler = PR_FALSE;
mEODForCurrentDocument = PR_TRUE;
//Added By Xu Jianbin Oct 18 2007 for handling time out
nsCOMPtr<nsIDocumentViewer> DocViwer(do_QueryInterface(mContentViewer));
DocViwer->GetDocument(getter_AddRefs(HtmlDoc));
nsAutoString ContentType;
HtmlDoc->GetContentType(ContentType);
if(ContentType.EqualsLiteral("text/html"))
{
nsCOMPtr<nsIHTMLDocument> tmpHtmlDoc =do_QueryInterface(HtmlDoc);
nsIContent *tmpRoot = HtmlDoc->GetRootContent();
// search for body element
nsIContent *tmpBody =FindTagInHtml( tmpRoot, nsHTMLAtoms::body);
}
.........
}
nsIContent *FindTagInHtml(nsIContent *aContent, nsIAtom *aTag)
{
nsINodeInfo * ni2 =aContent->GetNodeInfo();
// It's possible that some of leaves is special node.
if(ni2&&(ni2->Equals(aTag)))
return aContent;
PRUint32 idx =0, Count = aContent->GetChildCount();
for( ; idx <Count; idx++)
{
nsIContent *tmp = aContent->GetChildAt(idx);
nsIContent *tmp2 =FindTagInHtml(tmp, aTag);
if(tmp2)
return tmp2;
}
return nsnull;
}
//end Xu Jianbin
when loaded www.buy.com , can't found body element. But can see it using
firebug.
Why?
Xu Jianbin
2007-11-02
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout