From 471d34af108d11e1f928340bbaef58e14b72076b Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Wed, 8 Dec 1999 22:54:08 +0000 Subject: [PATCH] fixed bug 21146; r=buster; a=chofmann. --- .../html/document/src/nsHTMLContentSink.cpp | 28 +++++++++++++++---- layout/html/document/src/html.css | 1 + .../html/document/src/nsHTMLContentSink.cpp | 28 +++++++++++++++---- layout/style/html.css | 1 + 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 4a17375622fd..bce85c134fe1 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -1179,7 +1179,9 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) rv = mSink->AddAttributes(aNode, content); if (mPreAppend) { - NS_ASSERTION(mStackPos > 0, "container w/o parent"); + if (mStackPos <= 0) { + return NS_ERROR_FAILURE; + } nsIHTMLContent* parent = mStack[mStackPos-1].mContent; if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, @@ -1252,7 +1254,9 @@ SinkContext::CloseContainer(const nsIParserNode& aNode) // Add container to its parent if we haven't already done it if (0 == (mStack[mStackPos].mFlags & APPENDED)) { - NS_ASSERTION(mStackPos > 0, "container w/o parent"); + if (mStackPos <= 0) { + return NS_ERROR_FAILURE; + } nsIHTMLContent* parent = mStack[mStackPos-1].mContent; // If the parent has an insertion point, insert rather than // append. @@ -1563,7 +1567,11 @@ SinkContext::AddLeaf(const nsIParserNode& aNode) nsresult SinkContext::AddLeaf(nsIHTMLContent* aContent) { - NS_ASSERTION(mStackPos > 0, "leaf w/o container"); + + if (mStackPos <= 0) { + return NS_ERROR_FAILURE; + } + nsIHTMLContent* parent = mStack[mStackPos-1].mContent; // If the parent has an insertion point, insert rather than // append. @@ -1865,7 +1873,10 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast) NS_RELEASE(text); // Add text to its parent - NS_ASSERTION(mStackPos > 0, "leaf w/o container"); + if (mStackPos<= 0) { + return NS_ERROR_FAILURE; + } + nsIHTMLContent* parent = mStack[mStackPos - 1].mContent; if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, @@ -2299,7 +2310,9 @@ HTMLContentSink::BeginContext(PRInt32 aPosition) return NS_ERROR_OUT_OF_MEMORY; } - NS_ASSERTION(mCurrentContext != nsnull," Non-existing context"); + if (mCurrentContext == 0) { + return NS_ERROR_FAILURE; + } // Flush everything in the current context so that we don't have // to worry about insertions resulting in inconsistent frame creation. @@ -3915,7 +3928,10 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) } // Create content object - NS_ASSERTION(mCurrentContext->mStackPos > 0, "leaf w/o container"); + if (mCurrentContext->mStackPos <= 0) { + return NS_ERROR_FAILURE; + } + nsIHTMLContent* parent = mCurrentContext->mStack[mCurrentContext->mStackPos-1].mContent; nsAutoString tag("SCRIPT"); nsIHTMLContent* element = nsnull; diff --git a/layout/html/document/src/html.css b/layout/html/document/src/html.css index ca8e1d42cd4a..9cccf09aaa8f 100644 --- a/layout/html/document/src/html.css +++ b/layout/html/document/src/html.css @@ -1522,6 +1522,7 @@ viewsource|val {color: blue; font-weight:normal;} viewsource|val:before {content: "="; color: black;} viewsource|entity {color: maroon; font-weight:normal;} +viewsource|entity:before {content: "&"; color: maroon;} viewsource|comment {color: green; font-style:italic; } viewsource|cdata {color: #CC0066;} diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp index 4a17375622fd..bce85c134fe1 100644 --- a/layout/html/document/src/nsHTMLContentSink.cpp +++ b/layout/html/document/src/nsHTMLContentSink.cpp @@ -1179,7 +1179,9 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) rv = mSink->AddAttributes(aNode, content); if (mPreAppend) { - NS_ASSERTION(mStackPos > 0, "container w/o parent"); + if (mStackPos <= 0) { + return NS_ERROR_FAILURE; + } nsIHTMLContent* parent = mStack[mStackPos-1].mContent; if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, @@ -1252,7 +1254,9 @@ SinkContext::CloseContainer(const nsIParserNode& aNode) // Add container to its parent if we haven't already done it if (0 == (mStack[mStackPos].mFlags & APPENDED)) { - NS_ASSERTION(mStackPos > 0, "container w/o parent"); + if (mStackPos <= 0) { + return NS_ERROR_FAILURE; + } nsIHTMLContent* parent = mStack[mStackPos-1].mContent; // If the parent has an insertion point, insert rather than // append. @@ -1563,7 +1567,11 @@ SinkContext::AddLeaf(const nsIParserNode& aNode) nsresult SinkContext::AddLeaf(nsIHTMLContent* aContent) { - NS_ASSERTION(mStackPos > 0, "leaf w/o container"); + + if (mStackPos <= 0) { + return NS_ERROR_FAILURE; + } + nsIHTMLContent* parent = mStack[mStackPos-1].mContent; // If the parent has an insertion point, insert rather than // append. @@ -1865,7 +1873,10 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast) NS_RELEASE(text); // Add text to its parent - NS_ASSERTION(mStackPos > 0, "leaf w/o container"); + if (mStackPos<= 0) { + return NS_ERROR_FAILURE; + } + nsIHTMLContent* parent = mStack[mStackPos - 1].mContent; if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, @@ -2299,7 +2310,9 @@ HTMLContentSink::BeginContext(PRInt32 aPosition) return NS_ERROR_OUT_OF_MEMORY; } - NS_ASSERTION(mCurrentContext != nsnull," Non-existing context"); + if (mCurrentContext == 0) { + return NS_ERROR_FAILURE; + } // Flush everything in the current context so that we don't have // to worry about insertions resulting in inconsistent frame creation. @@ -3915,7 +3928,10 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) } // Create content object - NS_ASSERTION(mCurrentContext->mStackPos > 0, "leaf w/o container"); + if (mCurrentContext->mStackPos <= 0) { + return NS_ERROR_FAILURE; + } + nsIHTMLContent* parent = mCurrentContext->mStack[mCurrentContext->mStackPos-1].mContent; nsAutoString tag("SCRIPT"); nsIHTMLContent* element = nsnull; diff --git a/layout/style/html.css b/layout/style/html.css index ca8e1d42cd4a..9cccf09aaa8f 100644 --- a/layout/style/html.css +++ b/layout/style/html.css @@ -1522,6 +1522,7 @@ viewsource|val {color: blue; font-weight:normal;} viewsource|val:before {content: "="; color: black;} viewsource|entity {color: maroon; font-weight:normal;} +viewsource|entity:before {content: "&"; color: maroon;} viewsource|comment {color: green; font-style:italic; } viewsource|cdata {color: #CC0066;}