Added start/stop calls for the stopwatch in the nsIContentSink and nsIHTMLContentSink method implementations. Added printing of content creation time in DidBuildModel().

This commit is contained in:
nisheeth%netscape.com 1999-09-14 19:24:42 +00:00
Родитель 62311a91e1
Коммит cd8a6da86e
2 изменённых файлов: 124 добавлений и 14 удалений

Просмотреть файл

@ -1661,6 +1661,17 @@ HTMLContentSink::Init(nsIDocument* aDoc,
nsIWebShell* aContainer)
{
// NRA Dump document and stopwatch start info here
#ifdef DEBUG_nisheeth
{
char* url;
nsresult rv = NS_OK;
rv = aURL->GetSpec(&url);
if (NS_SUCCEEDED(rv)) {
printf("Starting stopwatch for '%s'", url);
delete [] url;
}
}
#endif
NS_RESET_AND_START_STOPWATCH()
NS_PRECONDITION(nsnull != aDoc, "null ptr");
@ -1747,6 +1758,9 @@ NS_IMETHODIMP
HTMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
{
// NRA Dump stopwatch stop info here
#ifdef RAPTOR_PERF_METRICS
mWatch.Print();
#endif
if (nsnull == mTitle) {
mHTMLDocument->SetTitle("");
@ -1818,11 +1832,13 @@ HTMLContentSink::SetParser(nsIParser* aParser)
NS_IMETHODIMP
HTMLContentSink::BeginContext(PRInt32 aPosition)
{
NS_START_STOPWATCH()
NS_PRECONDITION(aPosition > -1, "out of bounds");
// Create new context
SinkContext* sc = new SinkContext(this);
if (nsnull == sc) {
NS_STOP_STOPWATCH()
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1835,12 +1851,14 @@ HTMLContentSink::BeginContext(PRInt32 aPosition)
mContextStack.AppendElement(mCurrentContext);
mCurrentContext = sc;
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::EndContext(PRInt32 aPosition)
{
NS_START_STOPWATCH()
NS_PRECONDITION(mCurrentContext != nsnull && aPosition > -1, "non-existing context");
PRInt32 n = mContextStack.Count() - 1;
@ -1865,7 +1883,7 @@ HTMLContentSink::EndContext(PRInt32 aPosition)
mCurrentContext = sc;
mContextStack.RemoveElementAt(n);
NS_STOP_STOPWATCH()
return NS_OK;
}
@ -1873,6 +1891,7 @@ HTMLContentSink::EndContext(PRInt32 aPosition)
NS_IMETHODIMP
HTMLContentSink::SetTitle(const nsString& aValue)
{
NS_START_STOPWATCH()
NS_ASSERTION(mCurrentContext == mHeadContext, "SetTitle not in head");
if (nsnull == mTitle) {
@ -1882,6 +1901,7 @@ HTMLContentSink::SetTitle(const nsString& aValue)
// If the title was already set then don't try to overwrite it
// when a new title is encountered - For backwards compatiblity
//*mTitle = aValue;
NS_STOP_STOPWATCH()
return NS_OK;
}
ReduceEntities(*mTitle);
@ -1909,20 +1929,25 @@ HTMLContentSink::SetTitle(const nsString& aValue)
NS_RELEASE(it);
}
NS_RELEASE(atom);
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenHTML(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHTML", aNode);
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::CloseHTML(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHTML", aNode);
if (nsnull != mHeadContext) {
@ -1930,23 +1955,27 @@ HTMLContentSink::CloseHTML(const nsIParserNode& aNode)
delete mHeadContext;
mHeadContext = nsnull;
}
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenHead(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHead", aNode);
nsresult rv = NS_OK;
if (nsnull == mHeadContext) {
mHeadContext = new SinkContext(this);
if (nsnull == mHeadContext) {
NS_STOP_STOPWATCH()
return NS_ERROR_OUT_OF_MEMORY;
}
mHeadContext->SetPreAppend(PR_TRUE);
rv = mHeadContext->Begin(eHTMLTag_head, mHead);
if (NS_OK != rv) {
NS_STOP_STOPWATCH()
return rv;
}
}
@ -1959,23 +1988,27 @@ HTMLContentSink::OpenHead(const nsIParserNode& aNode)
NS_IF_RELEASE(sco);
}
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseHead(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHead", aNode);
PRInt32 n = mContextStack.Count() - 1;
mCurrentContext = (SinkContext*) mContextStack.ElementAt(n);
mContextStack.RemoveElementAt(n);
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenBody(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
//NS_PRECONDITION(nsnull == mBody, "parser called OpenBody twice");
SINK_TRACE_NODE(SINK_TRACE_CALLS,
@ -1984,7 +2017,8 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
if(mBody != nsnull){
nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner();
AddAttributes(aNode,mBody,sco,PR_TRUE);
NS_IF_RELEASE(sco);
NS_IF_RELEASE(sco);
NS_STOP_STOPWATCH()
return NS_OK;
}
@ -1994,12 +2028,14 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
nsresult rv = mCurrentContext->OpenContainer(aNode);
mCurrentContext->SetPreAppend(PR_FALSE);
if (NS_OK != rv) {
NS_STOP_STOPWATCH()
return rv;
}
mBody = mCurrentContext->mStack[mCurrentContext->mStackPos - 1].mContent;
mBodyChildCount = 0;
NS_ADDREF(mBody);
NS_STOP_STOPWATCH()
StartLayout();
return NS_OK;
}
@ -2007,12 +2043,14 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::CloseBody(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseBody", aNode);
PRBool didFlush;
nsresult rv = mCurrentContext->FlushText(&didFlush);
if (NS_OK != rv) {
NS_STOP_STOPWATCH()
return rv;
}
mCurrentContext->CloseContainer(aNode);
@ -2022,12 +2060,14 @@ HTMLContentSink::CloseBody(const nsIParserNode& aNode)
NotifyBody();
}
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenForm(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult result = NS_OK;
nsIHTMLContent* content = nsnull;
@ -2080,6 +2120,7 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
mHTMLDocument->AddForm(mCurrentForm);
}
NS_STOP_STOPWATCH()
return result;
}
@ -2088,6 +2129,7 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::CloseForm(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult result = NS_OK;
mCurrentContext->FlushText();
@ -2112,12 +2154,14 @@ HTMLContentSink::CloseForm(const nsIParserNode& aNode)
NS_RELEASE(mCurrentForm);
}
NS_STOP_STOPWATCH()
return result;
}
NS_IMETHODIMP
HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenFrameset", aNode);
@ -2127,12 +2171,14 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
NS_ADDREF(mFrameset);
}
mInMonolithicContainer++;
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseFrameset", aNode);
@ -2140,6 +2186,7 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
nsIHTMLContent* fs = sc->mStack[sc->mStackPos-1].mContent;
PRBool done = fs == mFrameset;
nsresult rv = sc->CloseContainer(aNode);
NS_STOP_STOPWATCH()
if (done) {
StartLayout();
}
@ -2149,24 +2196,32 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::OpenMap(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenMap", aNode);
// We used to treat MAP elements specially (i.e. they were
// only parent elements for AREAs), but we don't anymore.
// HTML 4.0 says that MAP elements can have block content
// as children.
return mCurrentContext->OpenContainer(aNode);
rv = mCurrentContext->OpenContainer(aNode);
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseMap(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseMap", aNode);
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
return mCurrentContext->CloseContainer(aNode);
rv = mCurrentContext->CloseContainer(aNode);
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
@ -2255,7 +2310,7 @@ nsresult HTMLContentSink::AddComment(const nsIParserNode& aNode) {
NS_START_STOPWATCH()
nsresult rv = NS_OK;
rv = mCurrentContext->AddComment(aNode);
NS_STOP_STOPWATCH();
NS_STOP_STOPWATCH()
return rv;
}
@ -2270,7 +2325,7 @@ nsresult HTMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) {
NS_START_STOPWATCH()
// Implementation of AddProcessingInstruction() should start here
NS_STOP_STOPWATCH();
NS_STOP_STOPWATCH()
return result;
}
@ -2286,7 +2341,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
NS_START_STOPWATCH()
// Implementation of AddDocTypeDecl() should start here
NS_STOP_STOPWATCH();
NS_STOP_STOPWATCH()
return rv;
}

Просмотреть файл

@ -1661,6 +1661,17 @@ HTMLContentSink::Init(nsIDocument* aDoc,
nsIWebShell* aContainer)
{
// NRA Dump document and stopwatch start info here
#ifdef DEBUG_nisheeth
{
char* url;
nsresult rv = NS_OK;
rv = aURL->GetSpec(&url);
if (NS_SUCCEEDED(rv)) {
printf("Starting stopwatch for '%s'", url);
delete [] url;
}
}
#endif
NS_RESET_AND_START_STOPWATCH()
NS_PRECONDITION(nsnull != aDoc, "null ptr");
@ -1747,6 +1758,9 @@ NS_IMETHODIMP
HTMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
{
// NRA Dump stopwatch stop info here
#ifdef RAPTOR_PERF_METRICS
mWatch.Print();
#endif
if (nsnull == mTitle) {
mHTMLDocument->SetTitle("");
@ -1818,11 +1832,13 @@ HTMLContentSink::SetParser(nsIParser* aParser)
NS_IMETHODIMP
HTMLContentSink::BeginContext(PRInt32 aPosition)
{
NS_START_STOPWATCH()
NS_PRECONDITION(aPosition > -1, "out of bounds");
// Create new context
SinkContext* sc = new SinkContext(this);
if (nsnull == sc) {
NS_STOP_STOPWATCH()
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1835,12 +1851,14 @@ HTMLContentSink::BeginContext(PRInt32 aPosition)
mContextStack.AppendElement(mCurrentContext);
mCurrentContext = sc;
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::EndContext(PRInt32 aPosition)
{
NS_START_STOPWATCH()
NS_PRECONDITION(mCurrentContext != nsnull && aPosition > -1, "non-existing context");
PRInt32 n = mContextStack.Count() - 1;
@ -1865,7 +1883,7 @@ HTMLContentSink::EndContext(PRInt32 aPosition)
mCurrentContext = sc;
mContextStack.RemoveElementAt(n);
NS_STOP_STOPWATCH()
return NS_OK;
}
@ -1873,6 +1891,7 @@ HTMLContentSink::EndContext(PRInt32 aPosition)
NS_IMETHODIMP
HTMLContentSink::SetTitle(const nsString& aValue)
{
NS_START_STOPWATCH()
NS_ASSERTION(mCurrentContext == mHeadContext, "SetTitle not in head");
if (nsnull == mTitle) {
@ -1882,6 +1901,7 @@ HTMLContentSink::SetTitle(const nsString& aValue)
// If the title was already set then don't try to overwrite it
// when a new title is encountered - For backwards compatiblity
//*mTitle = aValue;
NS_STOP_STOPWATCH()
return NS_OK;
}
ReduceEntities(*mTitle);
@ -1909,20 +1929,25 @@ HTMLContentSink::SetTitle(const nsString& aValue)
NS_RELEASE(it);
}
NS_RELEASE(atom);
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenHTML(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHTML", aNode);
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::CloseHTML(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHTML", aNode);
if (nsnull != mHeadContext) {
@ -1930,23 +1955,27 @@ HTMLContentSink::CloseHTML(const nsIParserNode& aNode)
delete mHeadContext;
mHeadContext = nsnull;
}
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenHead(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHead", aNode);
nsresult rv = NS_OK;
if (nsnull == mHeadContext) {
mHeadContext = new SinkContext(this);
if (nsnull == mHeadContext) {
NS_STOP_STOPWATCH()
return NS_ERROR_OUT_OF_MEMORY;
}
mHeadContext->SetPreAppend(PR_TRUE);
rv = mHeadContext->Begin(eHTMLTag_head, mHead);
if (NS_OK != rv) {
NS_STOP_STOPWATCH()
return rv;
}
}
@ -1959,23 +1988,27 @@ HTMLContentSink::OpenHead(const nsIParserNode& aNode)
NS_IF_RELEASE(sco);
}
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseHead(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHead", aNode);
PRInt32 n = mContextStack.Count() - 1;
mCurrentContext = (SinkContext*) mContextStack.ElementAt(n);
mContextStack.RemoveElementAt(n);
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenBody(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
//NS_PRECONDITION(nsnull == mBody, "parser called OpenBody twice");
SINK_TRACE_NODE(SINK_TRACE_CALLS,
@ -1984,7 +2017,8 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
if(mBody != nsnull){
nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner();
AddAttributes(aNode,mBody,sco,PR_TRUE);
NS_IF_RELEASE(sco);
NS_IF_RELEASE(sco);
NS_STOP_STOPWATCH()
return NS_OK;
}
@ -1994,12 +2028,14 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
nsresult rv = mCurrentContext->OpenContainer(aNode);
mCurrentContext->SetPreAppend(PR_FALSE);
if (NS_OK != rv) {
NS_STOP_STOPWATCH()
return rv;
}
mBody = mCurrentContext->mStack[mCurrentContext->mStackPos - 1].mContent;
mBodyChildCount = 0;
NS_ADDREF(mBody);
NS_STOP_STOPWATCH()
StartLayout();
return NS_OK;
}
@ -2007,12 +2043,14 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::CloseBody(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseBody", aNode);
PRBool didFlush;
nsresult rv = mCurrentContext->FlushText(&didFlush);
if (NS_OK != rv) {
NS_STOP_STOPWATCH()
return rv;
}
mCurrentContext->CloseContainer(aNode);
@ -2022,12 +2060,14 @@ HTMLContentSink::CloseBody(const nsIParserNode& aNode)
NotifyBody();
}
NS_STOP_STOPWATCH()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenForm(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult result = NS_OK;
nsIHTMLContent* content = nsnull;
@ -2080,6 +2120,7 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
mHTMLDocument->AddForm(mCurrentForm);
}
NS_STOP_STOPWATCH()
return result;
}
@ -2088,6 +2129,7 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::CloseForm(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult result = NS_OK;
mCurrentContext->FlushText();
@ -2112,12 +2154,14 @@ HTMLContentSink::CloseForm(const nsIParserNode& aNode)
NS_RELEASE(mCurrentForm);
}
NS_STOP_STOPWATCH()
return result;
}
NS_IMETHODIMP
HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenFrameset", aNode);
@ -2127,12 +2171,14 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
NS_ADDREF(mFrameset);
}
mInMonolithicContainer++;
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseFrameset", aNode);
@ -2140,6 +2186,7 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
nsIHTMLContent* fs = sc->mStack[sc->mStackPos-1].mContent;
PRBool done = fs == mFrameset;
nsresult rv = sc->CloseContainer(aNode);
NS_STOP_STOPWATCH()
if (done) {
StartLayout();
}
@ -2149,24 +2196,32 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::OpenMap(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenMap", aNode);
// We used to treat MAP elements specially (i.e. they were
// only parent elements for AREAs), but we don't anymore.
// HTML 4.0 says that MAP elements can have block content
// as children.
return mCurrentContext->OpenContainer(aNode);
rv = mCurrentContext->OpenContainer(aNode);
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseMap(const nsIParserNode& aNode)
{
NS_START_STOPWATCH()
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseMap", aNode);
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
return mCurrentContext->CloseContainer(aNode);
rv = mCurrentContext->CloseContainer(aNode);
NS_STOP_STOPWATCH()
return rv;
}
NS_IMETHODIMP
@ -2255,7 +2310,7 @@ nsresult HTMLContentSink::AddComment(const nsIParserNode& aNode) {
NS_START_STOPWATCH()
nsresult rv = NS_OK;
rv = mCurrentContext->AddComment(aNode);
NS_STOP_STOPWATCH();
NS_STOP_STOPWATCH()
return rv;
}
@ -2270,7 +2325,7 @@ nsresult HTMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) {
NS_START_STOPWATCH()
// Implementation of AddProcessingInstruction() should start here
NS_STOP_STOPWATCH();
NS_STOP_STOPWATCH()
return result;
}
@ -2286,7 +2341,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
NS_START_STOPWATCH()
// Implementation of AddDocTypeDecl() should start here
NS_STOP_STOPWATCH();
NS_STOP_STOPWATCH()
return rv;
}