Do not hold parser nodes, that do not contain residual style information, longer than necessary. By recycling the nodes earlier the number of malloc calls and the peak memory usage can be reduced. b=177994, r=heikki, sr=jst

This commit is contained in:
harishd%netscape.com 2002-11-19 18:29:35 +00:00
Родитель c306e75366
Коммит 858dd7ab53
40 изменённых файлов: 1490 добавлений и 1326 удалений

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

@ -327,8 +327,6 @@ mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement,
return rv;
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenContainer(const nsIParserNode& aNode)
{
@ -339,14 +337,11 @@ mozSanitizingHTMLSerializer::OpenContainer(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseContainer(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseContainer(const nsHTMLTag aTag)
{
PRInt32 type = aNode.GetNodeType();
const nsAString& namestr = aNode.GetText();
nsCOMPtr<nsIAtom> name = dont_AddRef(NS_NewAtom(namestr));
mParserNode = NS_CONST_CAST(nsIParserNode*, &aNode);
return DoCloseContainer(type);
// XXX Why do we need this?
// mParserNode = NS_CONST_CAST(nsIParserNode*, &aNode);
return DoCloseContainer(aTag);
}
NS_IMETHODIMP
@ -366,9 +361,9 @@ mozSanitizingHTMLSerializer::OpenHTML(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseHTML(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseHTML()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_html);
}
NS_IMETHODIMP
@ -407,9 +402,9 @@ mozSanitizingHTMLSerializer::OpenHead(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseHead(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseHead()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_head);
}
NS_IMETHODIMP
@ -419,9 +414,9 @@ mozSanitizingHTMLSerializer::OpenBody(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseBody(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseBody()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_body);
}
NS_IMETHODIMP
@ -431,9 +426,9 @@ mozSanitizingHTMLSerializer::OpenForm(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseForm(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseForm()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_form);
}
NS_IMETHODIMP
@ -443,9 +438,9 @@ mozSanitizingHTMLSerializer::OpenMap(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseMap(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseMap()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_map);
}
NS_IMETHODIMP
@ -455,9 +450,9 @@ mozSanitizingHTMLSerializer::OpenFrameset(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseFrameset(const nsIParserNode& aNode)
mozSanitizingHTMLSerializer::CloseFrameset()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_frameset);
}
NS_IMETHODIMP

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

@ -99,7 +99,7 @@ public:
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode)
@ -111,18 +111,18 @@ public:
// nsIHTMLContentSink
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref);
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD DoFragment(PRBool aFlag);

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

@ -418,14 +418,11 @@ nsPlainTextSerializer::OpenContainer(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseContainer(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseContainer(const nsHTMLTag aTag)
{
PRInt32 type = aNode.GetNodeType();
const nsAString& namestr = aNode.GetText();
nsCOMPtr<nsIAtom> name = dont_AddRef(NS_NewAtom(namestr));
mParserNode = NS_CONST_CAST(nsIParserNode *, &aNode);
return DoCloseContainer(type);
// XXX What do we need this?
// mParserNode = NS_CONST_CAST(nsIParserNode*, &aNode);
return DoCloseContainer(aTag);
}
NS_IMETHODIMP
@ -463,9 +460,9 @@ nsPlainTextSerializer::OpenHTML(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseHTML(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseHTML()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_html);
}
NS_IMETHODIMP
@ -476,7 +473,7 @@ nsPlainTextSerializer::OpenHead(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseHead(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseHead()
{
mInHead = PR_FALSE;
return NS_OK;
@ -489,9 +486,9 @@ nsPlainTextSerializer::OpenBody(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseBody(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseBody()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_body);
}
NS_IMETHODIMP
@ -501,9 +498,9 @@ nsPlainTextSerializer::OpenForm(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseForm(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseForm()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_form);
}
NS_IMETHODIMP
@ -513,9 +510,9 @@ nsPlainTextSerializer::OpenMap(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseMap(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseMap()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_map);
}
NS_IMETHODIMP
@ -525,9 +522,9 @@ nsPlainTextSerializer::OpenFrameset(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseFrameset(const nsIParserNode& aNode)
nsPlainTextSerializer::CloseFrameset()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_frameset);
}
NS_IMETHODIMP

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

@ -96,7 +96,7 @@ public:
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) { return NS_OK; }
@ -108,17 +108,17 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue) { return NS_OK; }
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref);
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }

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

@ -186,12 +186,12 @@ static PRLogModuleInfo* gSinkLogModuleInfo;
} \
PR_END_MACRO
#define SINK_TRACE_NODE(_bit, _msg, _node, _sp, _obj) \
_obj->SinkTraceNode(_bit, _msg, _node, _sp, this)
#define SINK_TRACE_NODE(_bit, _msg, _tag, _sp, _obj) \
_obj->SinkTraceNode(_bit, _msg, _tag, _sp, this)
#else
#define SINK_TRACE(_bit, _args)
#define SINK_TRACE_NODE(_bit, _msg, _node, _sp, _obj)
#define SINK_TRACE_NODE(_bit, _msg, _tag, _sp, _obj)
#endif
#undef SINK_NO_INCREMENTAL
@ -254,7 +254,7 @@ public:
// nsIHTMLContentSink
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
@ -268,17 +268,17 @@ public:
NS_IMETHOD EndContext(PRInt32 aID);
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD GetPref(PRInt32 aTag, PRBool& aPref);
NS_IMETHOD_(PRBool) IsFormOnStack();
@ -430,7 +430,7 @@ public:
#ifdef NS_DEBUG
void SinkTraceNode(PRUint32 aBit,
const char* aMsg,
const nsIParserNode& aNode,
const nsHTMLTag aTag,
PRInt32 aStackPos,
void* aThis);
#endif
@ -855,7 +855,7 @@ public:
nsresult Begin(nsHTMLTag aNodeType, nsIHTMLContent* aRoot,
PRInt32 aNumFlushed, PRInt32 aInsertionPoint);
nsresult OpenContainer(const nsIParserNode& aNode);
nsresult CloseContainer(const nsIParserNode& aNode);
nsresult CloseContainer(const nsHTMLTag aTag);
nsresult AddLeaf(const nsIParserNode& aNode);
nsresult AddLeaf(nsIHTMLContent* aContent);
nsresult AddComment(const nsIParserNode& aNode);
@ -911,26 +911,21 @@ public:
void
HTMLContentSink::SinkTraceNode(PRUint32 aBit,
const char* aMsg,
const nsIParserNode& aNode,
const nsHTMLTag aTag,
PRInt32 aStackPos,
void* aThis)
{
if (SINK_LOG_TEST(gSinkLogModuleInfo, aBit)) {
const char* cp;
PRInt32 nt = aNode.GetNodeType();
NS_ConvertUCS2toUTF8 flat(aNode.GetText());
if ((nt > PRInt32(eHTMLTag_unknown)) &&
(nt < PRInt32(eHTMLTag_text)) && mParser) {
nsCOMPtr<nsIDTD> dtd;
nsCOMPtr<nsIDTD> dtd;
if (mParser) {
mParser->GetDTD(getter_AddRefs(dtd));
nsHTMLTag tag = nsHTMLTag(aNode.GetNodeType());
flat.AssignWithConversion(dtd->IntTagToStringTag(tag));
if (!dtd)
return;
}
cp = flat.get();
PR_LogPrint("%s: this=%p node='%s' stackPos=%d", aMsg, aThis, cp,
aStackPos);
const char* cp =
NS_ConvertUCS2toUTF8(dtd->IntTagToStringTag(aTag)).get();
PR_LogPrint("%s: this=%p node='%s' stackPos=%d",
aMsg, aThis, cp, aStackPos);
}
}
#endif
@ -1648,7 +1643,10 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
FlushTextAndRelease();
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"SinkContext::OpenContainer", aNode, mStackPos, mSink);
"SinkContext::OpenContainer",
nsHTMLTag(aNode.GetNodeType()),
mStackPos,
mSink);
nsresult rv;
if (mStackPos + 1 > mStackSize) {
@ -1742,7 +1740,7 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
}
nsresult
SinkContext::CloseContainer(const nsIParserNode& aNode)
SinkContext::CloseContainer(const nsHTMLTag aTag)
{
nsresult result = NS_OK;
@ -1751,7 +1749,8 @@ SinkContext::CloseContainer(const nsIParserNode& aNode)
FlushTextAndRelease();
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"SinkContext::CloseContainer", aNode, mStackPos - 1, mSink);
"SinkContext::CloseContainer",
aTag, mStackPos - 1, mSink);
NS_WARN_IF_FALSE(mStackPos > 0,
"stack out of bounds. wrong context probably!");
@ -1839,15 +1838,13 @@ SinkContext::CloseContainer(const nsIParserNode& aNode)
case eHTMLTag_form:
{
mSink->mFlags &= ~NS_SINK_FLAG_FORM_ON_STACK;
nsHTMLTag parserNodeType = nsHTMLTag(aNode.GetNodeType());
// If there's a FORM on the stack, but this close tag doesn't
// close the form, then close out the form *and* close out the
// next container up. This is since the parser doesn't do fix up
// of invalid form nesting. When the end FORM tag comes through,
// we'll ignore it.
if (parserNodeType != nodeType) {
result = CloseContainer(aNode);
if (aTag != nodeType) {
result = CloseContainer(aTag);
}
}
@ -1886,7 +1883,9 @@ nsresult
SinkContext::AddLeaf(const nsIParserNode& aNode)
{
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"SinkContext::AddLeaf", aNode, mStackPos, mSink);
"SinkContext::AddLeaf",
nsHTMLTag(aNode.GetNodeType()),
mStackPos, mSink);
nsresult rv = NS_OK;
@ -2013,7 +2012,9 @@ nsresult
SinkContext::AddComment(const nsIParserNode& aNode)
{
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"SinkContext::AddLeaf", aNode, mStackPos, mSink);
"SinkContext::AddLeaf",
nsHTMLTag(aNode.GetNodeType()),
mStackPos, mSink);
FlushTextAndRelease();
@ -3178,7 +3179,8 @@ HTMLContentSink::OpenHTML(const nsIParserNode& aNode)
{
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHTML", aNode, 0, this);
"HTMLContentSink::OpenHTML",
eHTMLTag_html, 0, this);
if (mRoot) {
// Add attributes to the node...if found.
@ -3195,12 +3197,13 @@ HTMLContentSink::OpenHTML(const nsIParserNode& aNode)
}
NS_IMETHODIMP
HTMLContentSink::CloseHTML(const nsIParserNode& aNode)
HTMLContentSink::CloseHTML()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseHTML()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHTML", aNode, 0, this);
"HTMLContentSink::CloseHTML",
eHTMLTag_html, 0, this);
if (mHeadContext) {
if (mCurrentContext == mHeadContext) {
@ -3229,7 +3232,8 @@ HTMLContentSink::OpenHead(const nsIParserNode& aNode)
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenHead()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHead", aNode, 0, this);
"HTMLContentSink::OpenHead",
eHTMLTag_head, 0, this);
nsresult rv = NS_OK;
@ -3279,13 +3283,13 @@ HTMLContentSink::OpenHead(const nsIParserNode& aNode)
}
NS_IMETHODIMP
HTMLContentSink::CloseHead(const nsIParserNode& aNode)
HTMLContentSink::CloseHead()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseHead()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHead", aNode,
0, this);
"HTMLContentSink::CloseHead",
eHTMLTag_head, 0, this);
PRInt32 n = mContextStack.Count() - 1;
@ -3305,8 +3309,10 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenBody", aNode,
mCurrentContext->mStackPos, this);
"HTMLContentSink::OpenBody",
eHTMLTag_body,
mCurrentContext->mStackPos,
this);
// Add attributes, if any, to the current BODY node
if (mBody) {
@ -3388,13 +3394,15 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
}
NS_IMETHODIMP
HTMLContentSink::CloseBody(const nsIParserNode& aNode)
HTMLContentSink::CloseBody()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseBody()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseBody", aNode,
mCurrentContext->mStackPos - 1, this);
"HTMLContentSink::CloseBody",
eHTMLTag_body,
mCurrentContext->mStackPos - 1,
this);
PRBool didFlush;
nsresult rv = mCurrentContext->FlushTextAndRelease(&didFlush);
@ -3410,7 +3418,7 @@ HTMLContentSink::CloseBody(const nsIParserNode& aNode)
("HTMLContentSink::CloseBody: layout final body content"));
mCurrentContext->FlushTags(PR_TRUE);
mCurrentContext->CloseContainer(aNode);
mCurrentContext->CloseContainer(eHTMLTag_body);
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseBody()\n"));
MOZ_TIMER_STOP(mWatch);
@ -3429,8 +3437,10 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
mCurrentContext->FlushTextAndRelease();
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenForm", aNode,
mCurrentContext->mStackPos, this);
"HTMLContentSink::OpenForm",
eHTMLTag_form,
mCurrentContext->mStackPos,
this);
// Close out previous form if it's there. If there is one
// around, it's probably because the last one wasn't well-formed.
@ -3479,7 +3489,7 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
// XXX MAYBE add code to place close form tag into the content model
// for navigator layout compatability.
NS_IMETHODIMP
HTMLContentSink::CloseForm(const nsIParserNode& aNode)
HTMLContentSink::CloseForm()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseForm()\n"));
MOZ_TIMER_START(mWatch);
@ -3487,14 +3497,16 @@ HTMLContentSink::CloseForm(const nsIParserNode& aNode)
nsresult result = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseForm", aNode,
mCurrentContext->mStackPos - 1, this);
"HTMLContentSink::CloseForm",
eHTMLTag_form,
mCurrentContext->mStackPos - 1,
this);
if (mCurrentForm) {
// if this is a well-formed form, close it too
if (mCurrentContext->IsCurrentContainer(eHTMLTag_form)) {
mCurrentContext->FlushTextAndRelease();
result = mCurrentContext->CloseContainer(aNode);
result = mCurrentContext->CloseContainer(eHTMLTag_form);
mFlags &= ~NS_SINK_FLAG_FORM_ON_STACK;
}
@ -3513,8 +3525,10 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenFrameset()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenFrameset", aNode,
mCurrentContext->mStackPos, this);
"HTMLContentSink::OpenFrameset",
eHTMLTag_frameset,
mCurrentContext->mStackPos,
this);
nsresult rv = mCurrentContext->OpenContainer(aNode);
@ -3532,18 +3546,20 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
}
NS_IMETHODIMP
HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
HTMLContentSink::CloseFrameset()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseFrameset()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseFrameset", aNode,
mCurrentContext->mStackPos - 1, this);
"HTMLContentSink::CloseFrameset",
eHTMLTag_frameset,
mCurrentContext->mStackPos - 1,
this);
SinkContext* sc = mCurrentContext;
nsIHTMLContent* fs = sc->mStack[sc->mStackPos - 1].mContent;
PRBool done = fs == mFrameset;
nsresult rv = sc->CloseContainer(aNode);
nsresult rv = sc->CloseContainer(eHTMLTag_frameset);
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseFrameset()\n"));
MOZ_TIMER_STOP(mWatch);
@ -3564,8 +3580,10 @@ HTMLContentSink::OpenMap(const nsIParserNode& aNode)
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenMap", aNode,
mCurrentContext->mStackPos, this);
"HTMLContentSink::OpenMap",
eHTMLTag_map,
mCurrentContext->mStackPos,
this);
// We used to treat MAP elements specially (i.e. they were
// only parent elements for AREAs), but we don't anymore.
@ -3580,7 +3598,7 @@ HTMLContentSink::OpenMap(const nsIParserNode& aNode)
}
NS_IMETHODIMP
HTMLContentSink::CloseMap(const nsIParserNode& aNode)
HTMLContentSink::CloseMap()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseMap()\n"));
MOZ_TIMER_START(mWatch);
@ -3588,12 +3606,14 @@ HTMLContentSink::CloseMap(const nsIParserNode& aNode)
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseMap", aNode,
mCurrentContext->mStackPos - 1, this);
"HTMLContentSink::CloseMap",
eHTMLTag_map,
mCurrentContext->mStackPos - 1,
this);
mCurrentMap = nsnull;
rv = mCurrentContext->CloseContainer(aNode);
rv = mCurrentContext->CloseContainer(eHTMLTag_map);
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseMap()\n"));
MOZ_TIMER_STOP(mWatch);
@ -3639,7 +3659,7 @@ HTMLContentSink::OpenContainer(const nsIParserNode& aNode)
}
NS_IMETHODIMP
HTMLContentSink::CloseContainer(const nsIParserNode& aNode)
HTMLContentSink::CloseContainer(const eHTMLTags aTag)
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseContainer()\n"));
MOZ_TIMER_START(mWatch);
@ -3647,13 +3667,13 @@ HTMLContentSink::CloseContainer(const nsIParserNode& aNode)
nsresult rv = NS_OK;
// XXX work around parser bug
if (eHTMLTag_frameset == aNode.GetNodeType()) {
if (eHTMLTag_frameset == aTag) {
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseContainer()\n"));
MOZ_TIMER_STOP(mWatch);
return CloseFrameset(aNode);
return CloseFrameset();
}
rv = mCurrentContext->CloseContainer(aNode);
rv = mCurrentContext->CloseContainer(aTag);
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseContainer()\n"));
MOZ_TIMER_STOP(mWatch);

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

@ -85,7 +85,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
@ -96,22 +96,22 @@ public:
NS_IMETHOD EndContext(PRInt32 aID);
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD OpenNoscript(const nsIParserNode& aNode);
NS_IMETHOD CloseNoscript(const nsIParserNode& aNode);
NS_IMETHOD CloseNoscript();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
@ -378,7 +378,7 @@ nsHTMLFragmentContentSink::OpenHTML(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseHTML(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseHTML()
{
return NS_OK;
}
@ -391,7 +391,7 @@ nsHTMLFragmentContentSink::OpenHead(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseHead(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseHead()
{
return NS_OK;
}
@ -411,9 +411,9 @@ nsHTMLFragmentContentSink::OpenBody(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseBody(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseBody()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_body);
}
NS_IMETHODIMP
@ -423,9 +423,9 @@ nsHTMLFragmentContentSink::OpenForm(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseForm(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseForm()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_form);
}
NS_IMETHODIMP
@ -435,9 +435,9 @@ nsHTMLFragmentContentSink::OpenFrameset(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseFrameset(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseFrameset()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_frameset);
}
NS_IMETHODIMP
@ -447,9 +447,9 @@ nsHTMLFragmentContentSink::OpenMap(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseMap(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseMap()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_map);
}
NS_IMETHODIMP
@ -459,9 +459,9 @@ nsHTMLFragmentContentSink::OpenNoscript(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseNoscript(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseNoscript()
{
return CloseContainer(aNode);
return CloseContainer(eHTMLTag_noscript);
}
void
@ -563,7 +563,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseContainer(const nsIParserNode& aNode)
nsHTMLFragmentContentSink::CloseContainer(const nsHTMLTag aTag)
{
if (mHitSentinel && (nsnull != GetCurrentContent())) {
nsIContent* content;

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

@ -84,6 +84,7 @@
*/
#include "nsIParserNode.h"
#include "nsIContentSink.h"
#include "nsHTMLTags.h"
#define NS_IHTML_CONTENT_SINK_IID \
{ 0xa6cf9051, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
@ -95,8 +96,8 @@
#define MAX_REFLOW_DEPTH 200 //windows and linux (etc) can do much deeper structures.
#endif
class nsIHTMLContentSink : public nsIContentSink {
class nsIHTMLContentSink : public nsIContentSink
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
@ -108,7 +109,7 @@ public:
* @update 4/1/98 gess
* @param nsString reference to new title value
*/
NS_IMETHOD SetTitle(const nsString& aValue)=0;
NS_IMETHOD SetTitle(const nsString& aValue) = 0;
/**
* This method is used to open the outer HTML container.
@ -116,15 +117,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHTML(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenHTML(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHTML(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseHTML() = 0;
/**
* This method is used to open the only HEAD container.
@ -132,15 +131,12 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHead(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenHead(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHead(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseHead() = 0;
/**
* This method is used to open the main BODY container.
@ -148,15 +144,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenBody(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenBody(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseBody(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseBody() = 0;
/**
* This method is used to open a new FORM container.
@ -164,15 +158,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenForm(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenForm(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the outer FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseForm(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseForm() = 0;
/**
* This method is used to open a new MAP container.
@ -180,15 +172,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenMap(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenMap(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseMap(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseMap() = 0;
/**
* This method is used to open the FRAMESET container.
@ -196,15 +186,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseFrameset() = 0;
/**
* This method tells the sink whether or not it is
@ -215,7 +203,7 @@ public:
* @param aFlag set to true if only encoding a fragment
*/
NS_IMETHOD DoFragment(PRBool aFlag)=0;
NS_IMETHOD DoFragment(PRBool aFlag) = 0;
/**
* This gets called when handling illegal contents, especially
@ -224,7 +212,7 @@ public:
* @update 04/04/99 harishd
* @param aPosition - The position from where the new context begins.
*/
NS_IMETHOD BeginContext(PRInt32 aPosition)=0;
NS_IMETHOD BeginContext(PRInt32 aPosition) = 0;
/**
* This method terminates any new context that got created by
@ -233,7 +221,7 @@ public:
* @update 04/04/99 harishd
* @param aPosition - Validates the end of a context.
*/
NS_IMETHOD EndContext(PRInt32 aPosition)=0;
NS_IMETHOD EndContext(PRInt32 aPosition) = 0;
/**
* Use this method to retrieve pref. for the tag.
@ -241,13 +229,13 @@ public:
* @update 04/11/01 harishd
* @param aTag - Check pref. for this tag.
*/
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref)=0;
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) = 0;
/**
* This method is called when parser is about to begin
* synchronously processing a chunk of tokens.
*/
NS_IMETHOD WillProcessTokens(void)=0;
NS_IMETHOD WillProcessTokens(void) = 0;
/**
* This method is called when parser has
@ -255,13 +243,13 @@ public:
* tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
* DidProcessAToken.
*/
NS_IMETHOD DidProcessTokens()=0;
NS_IMETHOD DidProcessTokens() = 0;
/**
* This method is called when parser is about to
* process a single token
*/
NS_IMETHOD WillProcessAToken(void)=0;
NS_IMETHOD WillProcessAToken(void) = 0;
/**
* This method is called when parser has completed
@ -269,7 +257,7 @@ public:
* @return NS_OK if processing should not be interrupted
* NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
*/
NS_IMETHOD DidProcessAToken(void)=0;
NS_IMETHOD DidProcessAToken(void) = 0;
/**
* This method is used to open a generic container in the sink.
@ -283,10 +271,9 @@ public:
* This method gets called by the parser when a close
* container tag has been consumed and needs to be closed.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
* @param aTag - The tag to be closed.
*/
NS_IMETHOD CloseContainer(const nsIParserNode& aNode) = 0;
NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
/**
* This gets called by the parser when you want to add
@ -326,7 +313,7 @@ public:
*
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode)=0;
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser to notify observers of
@ -334,7 +321,7 @@ public:
*
* @param aErrorResult the error code
*/
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode)=0;
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) = 0;
/**
* Call this method to determnine if a FORM is on the sink's stack
@ -346,9 +333,7 @@ public:
};
#ifdef NS_DEBUG
extern nsresult NS_NewHTMLNullSink(nsIContentSink** aInstancePtrResult);
#endif
#endif /* nsIHTMLContentSink_h___ */

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

@ -90,14 +90,14 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsString& GetName() const =0; //to get name of tag
virtual const nsAString& GetTagName() const = 0; //to get name of tag
/**
* Retrieve the text from the given node
* @update gess5/11/98
* @return string containing node text
*/
virtual const nsAString& GetText() const =0; //get plain text if available
virtual const nsAString& GetText() const = 0; //get plain text if available
/**
* Retrieve the type of the parser node.
@ -126,7 +126,7 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const =0;
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const = 0;
/**
* Retrieve the value (of key/value pair) at given index
@ -134,7 +134,7 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsAString& GetValueAt(PRUint32 anIndex) const =0;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const = 0;
/**
* NOTE: When the node is an entity, this will translate the entity
@ -175,15 +175,6 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @return void
*/
virtual nsresult ReleaseAll()=0;
/*
* Get and set the ID attribute atom for this node.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult) const = 0;
virtual nsresult SetIDAttributeAtom(nsIAtom* aID) = 0;
};
#endif

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

@ -78,22 +78,22 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD CloseTopmostContainer();
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
@ -187,7 +187,7 @@ NS_IMETHODIMP RobotSink::OpenHTML(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseHTML(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseHTML()
{
return NS_OK;
}
@ -197,7 +197,7 @@ NS_IMETHODIMP RobotSink::OpenHead(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseHead(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseHead()
{
return NS_OK;
}
@ -207,7 +207,7 @@ NS_IMETHODIMP RobotSink::OpenBody(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseBody(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseBody()
{
return NS_OK;
}
@ -217,7 +217,7 @@ NS_IMETHODIMP RobotSink::OpenForm(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseForm(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseForm()
{
return NS_OK;
}
@ -227,7 +227,7 @@ NS_IMETHODIMP RobotSink::OpenMap(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseMap(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseMap()
{
return NS_OK;
}
@ -237,7 +237,7 @@ NS_IMETHODIMP RobotSink::OpenFrameset(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseFrameset(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseFrameset()
{
return NS_OK;
}
@ -277,7 +277,7 @@ NS_IMETHODIMP RobotSink::OpenContainer(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseContainer(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseContainer(const nsHTMLTag aTag)
{
return NS_OK;
}

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

@ -612,12 +612,9 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
//If you're here, then an error occured, but we still have nodes on the stack.
//At a minimum, we should grab the nodes and recycle them.
//Just to be correct, we'll also recycle the nodes.
while(mBodyContext->GetCount() > 0) {
nsEntryStack *theChildStyles=0;
nsCParserNode* theNode=mBodyContext->Pop(theChildStyles);
nsEntryStack* theChildStyles = 0;
nsCParserNode* theNode = mBodyContext->Pop(theChildStyles);
IF_DELETE(theChildStyles,&mNodeAllocator);
IF_FREE(theNode, &mNodeAllocator);
}
@ -1245,14 +1242,13 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
eProcessRule theRule=eNormalOp;
if((!theParentContains) &&
(IsBlockElement(aChildTag,theParentTag) &&
IsInlineElement(theParentTag,theParentTag))) { //broaden this to fix <inline><block></block></inline>
if(eHTMLTag_li!=aChildTag) { //remove test for table to fix 57554
nsCParserNode* theParentNode= NS_STATIC_CAST(nsCParserNode*, mBodyContext->PeekNode());
if(theParentNode->mToken->IsWellFormed()) {
theRule=eLetInlineContainBlock;
if (!theParentContains &&
(IsBlockElement(aChildTag,theParentTag) &&
IsInlineElement(theParentTag,theParentTag))) { //broaden this to fix <inline><block></block></inline>
if (eHTMLTag_li != aChildTag) { //remove test for table to fix 57554
nsCParserNode* theParentNode = NS_STATIC_CAST(nsCParserNode*, mBodyContext->PeekNode());
if (theParentNode && theParentNode->mToken->IsWellFormed()) {
theRule = eLetInlineContainBlock;
}
}
}
@ -1459,19 +1455,15 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
}
//this code is here to make sure the head is closed before we deal
//with any tags that don't belong in the head.
//this code is here to make sure the head is closed before we deal
//with any tags that don't belong in the head.
if(NS_OK==result) {
if(mOpenHeadCount>0){
static eHTMLTags skip2[]={eHTMLTag_newline,eHTMLTag_whitespace};
if(!FindTagInSet(aTag,skip2,sizeof(skip2)/sizeof(eHTMLTag_unknown))){
PRBool theExclusive=PR_FALSE;
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive)){
//because this code calls CloseHead() directly, stack-based token/nodes are ok.
CEndToken theToken(eHTMLTag_head);
nsCParserNode theNode(&theToken, 0 /*stack token*/);
result=CloseHead(&theNode);
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive)){
result = CloseHead();
}
}
}
@ -1943,16 +1935,13 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
break;
case eHTMLTag_head:
StripWSFollowingTag(theChildTag,mTokenizer,mTokenAllocator,mLineNumber);
StripWSFollowingTag(theChildTag,mTokenizer, mTokenAllocator, mLineNumber);
mFlags &= ~NS_DTD_FLAG_REQUESTED_HEAD;
//ok to fall through...
result = CloseContainer(eHTMLTag_head, theChildTag, PR_FALSE);
break;
case eHTMLTag_form:
{
//this is safe because we call close container directly. This node/token is not cached.
nsCParserNode theNode((CHTMLToken*)aToken, mTokenAllocator);
result=CloseContainer(&theNode,theChildTag,PR_FALSE);
}
result = CloseContainer(eHTMLTag_form, theChildTag, PR_FALSE);
break;
case eHTMLTag_br:
@ -2082,14 +2071,7 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
START_TIMER()
// The body context should contain contents only upto the marked position.
PRInt32 i=0;
nsEntryStack* theChildStyleStack=0;
for(i=0; i<(theTagCount - theTopIndex); ++i) {
nsCParserNode* node=mBodyContext->Pop(theChildStyleStack);
mTempContext->Push(node);
IF_FREE(node, &mNodeAllocator); //release the popped node since push will addref for us.
}
mBodyContext->MoveEntries(*mTempContext, theTagCount - theTopIndex);
// Now flush out all the bad contents.
while(theBadTokenCount-- > 0){
@ -2128,11 +2110,7 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
// Bad-contents were successfully processed. Now, itz time to get
// back to the original body context state.
for(PRInt32 k=0; k<(theTagCount - theTopIndex); ++k) {
nsCParserNode* node=mTempContext->Pop(theChildStyleStack);
mBodyContext->Push(node);
IF_FREE(node, &mNodeAllocator);
}
mTempContext->MoveEntries(*mBodyContext, theTagCount - theTopIndex);
STOP_TIMER()
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleSavedTokensAbove(), this=%p\n", this));
@ -2994,27 +2972,7 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aChildTag){
* @return 0 (for now)
*/
nsresult CNavDTD::CloseTransientStyles(eHTMLTags aChildTag){
nsresult result=NS_OK;
if(mFlags & NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE) {
#ifdef ENABLE_RESIDUALSTYLE
#if 0
int theTagPos=0;
//now iterate style set, and close the containers...
nsEntryStack* theStack=mBodyContext->GetStylesAt();
for(theTagPos=mBodyContext->mOpenStyles;theTagPos>0;theTagPos--){
eHTMLTags theTag=GetTopNode();
CStartToken token(theTag);
nsCParserNode theNode(&token, 0 /*stack token*/);
token.SetTypeID(theTag);
result=CloseContainer(theNode,theTag,PR_FALSE);
}
#endif
#endif
} //if
return result;
return NS_OK;
}
/**
@ -3054,14 +3012,14 @@ nsresult CNavDTD::OpenHTML(const nsCParserNode *aNode){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
nsresult result=(mSink) ? mSink->OpenHTML(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->OpenHTML(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
START_TIMER();
// Don't push more than one HTML tag into the stack...
if(mBodyContext->GetCount()==0)
mBodyContext->Push(aNode);
if (mBodyContext->GetCount() == 0)
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
return result;
}
@ -3075,12 +3033,12 @@ nsresult CNavDTD::OpenHTML(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseHTML(const nsIParserNode *aNode){
nsresult CNavDTD::CloseHTML(){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseHTML(), this=%p\n", this));
nsresult result=(mSink) ? mSink->CloseHTML(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->CloseHTML() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseHTML(), this=%p\n", this));
START_TIMER();
@ -3104,7 +3062,7 @@ nsresult CNavDTD::OpenHead(const nsIParserNode *aNode){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenHead(), this=%p\n", this));
if(!mOpenHeadCount++) {
if (!mOpenHeadCount++) {
result=(mSink) ? mSink->OpenHead(*aNode) : NS_OK;
}
@ -3122,19 +3080,17 @@ nsresult CNavDTD::OpenHead(const nsIParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseHead(const nsIParserNode *aNode){
nsresult CNavDTD::CloseHead(){
nsresult result=NS_OK;
if(mOpenHeadCount && --mOpenHeadCount==0) {
if (mOpenHeadCount && --mOpenHeadCount==0) {
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseHead(), this=%p\n", this));
result=(mSink) ? mSink->CloseHead(*aNode) : NS_OK;
result = (mSink) ? mSink->CloseHead() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseHead(), this=%p\n", this));
START_TIMER();
}
return result;
@ -3148,7 +3104,8 @@ nsresult CNavDTD::CloseHead(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenBody(const nsCParserNode *aNode){
nsresult CNavDTD::OpenBody(const nsCParserNode *aNode)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
nsresult result = NS_OK;
@ -3166,7 +3123,7 @@ nsresult CNavDTD::OpenBody(const nsCParserNode *aNode){
START_TIMER();
if (!HasOpenContainer(eHTMLTag_body)) {
mBodyContext->Push(aNode);
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
mTokenizer->PrependTokens(mMisplacedContent);
}
}
@ -3182,13 +3139,12 @@ nsresult CNavDTD::OpenBody(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseBody(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
nsresult CNavDTD::CloseBody()
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseBody(), this=%p\n", this));
nsresult result=(mSink) ? mSink->CloseBody(*aNode) : NS_OK;
nsresult result= (mSink) ? mSink->CloseBody() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseBody(), this=%p\n", this));
START_TIMER();
@ -3204,19 +3160,18 @@ nsresult CNavDTD::CloseBody(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
nsresult result=NS_OK;
if(!(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
nsresult CNavDTD::OpenForm(const nsIParserNode *aNode)
{
nsresult result = NS_OK;
if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenForm(), this=%p\n", this));
result=(mSink) ? mSink->OpenForm(*aNode) : NS_OK;
result = (mSink) ? mSink->OpenForm(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenForm(), this=%p\n", this));
START_TIMER();
if(NS_OK==result) {
if (NS_OK == result) {
mFlags |= NS_DTD_FLAG_HAS_OPEN_FORM;
}
}
@ -3232,16 +3187,15 @@ nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
if(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM) {
nsresult CNavDTD::CloseForm()
{
nsresult result = NS_OK;
if (mFlags & NS_DTD_FLAG_HAS_OPEN_FORM) {
mFlags &= ~NS_DTD_FLAG_HAS_OPEN_FORM;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
result=(mSink) ? mSink->CloseForm(*aNode) : NS_OK;
result = (mSink) ? mSink->CloseForm() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
START_TIMER();
@ -3257,18 +3211,18 @@ nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenMap(const nsCParserNode *aNode){
nsresult CNavDTD::OpenMap(const nsCParserNode *aNode)
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
nsresult result=(mSink) ? mSink->OpenMap(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->OpenMap(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
START_TIMER();
if(NS_OK==result) {
mBodyContext->Push(aNode);
if (NS_OK == result) {
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
++mOpenMapCount;
}
return result;
@ -3282,20 +3236,18 @@ nsresult CNavDTD::OpenMap(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
if(mOpenMapCount) {
nsresult CNavDTD::CloseMap()
{
nsresult result = NS_OK;
if (mOpenMapCount) {
mOpenMapCount--;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
result=(mSink) ? mSink->CloseMap(*aNode) : NS_OK;
result = (mSink) ? mSink->CloseMap() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
START_TIMER();
}
return result;
}
@ -3308,20 +3260,19 @@ nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenFrameset(const nsCParserNode *aNode){
nsresult CNavDTD::OpenFrameset(const nsCParserNode *aNode)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
mFlags |= NS_DTD_FLAG_HAD_FRAMESET;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenFrameset(), this=%p\n", this));
nsresult result=(mSink) ? mSink->OpenFrameset(*aNode) : NS_OK;
nsresult result =( mSink) ? mSink->OpenFrameset(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenFrameset(), this=%p\n", this));
START_TIMER();
mBodyContext->Push(aNode);
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
return result;
}
@ -3334,13 +3285,12 @@ nsresult CNavDTD::OpenFrameset(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseFrameset(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult CNavDTD::CloseFrameset()
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseFrameset(), this=%p\n", this));
nsresult result=(mSink) ? mSink->CloseFrameset(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->CloseFrameset() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseFrameset(), this=%p\n", this));
START_TIMER();
@ -3358,14 +3308,18 @@ nsresult CNavDTD::CloseFrameset(const nsIParserNode *aNode){
* @return TRUE if ok, FALSE if error
*/
nsresult
CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedByStartTag,nsEntryStack* aStyleStack){
CNavDTD::OpenContainer(const nsCParserNode *aNode,
eHTMLTags aTag,
PRBool aClosedByStartTag,
nsEntryStack* aStyleStack)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
nsresult result=NS_OK;
PRBool done=PR_TRUE;
nsresult result = NS_OK;
PRBool done = PR_TRUE;
PRBool rs_tag = nsHTMLElement::IsResidualStyleTag(aTag);
if (nsHTMLElement::IsResidualStyleTag(aTag)) {
if (rs_tag) {
/***********************************************************************
* Here's an interesting problem:
*
@ -3385,8 +3339,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct));
#endif
switch(aTag) {
switch (aTag) {
case eHTMLTag_html:
result=OpenHTML(aNode); break;
@ -3404,7 +3357,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
mOpenHeadCount=1;
}
mFlags |= NS_DTD_FLAG_HAS_OPEN_BODY;
CloseHead(aNode); //do this just in case someone left it open...
CloseHead(); //do this just in case someone left the HEAD open...
result=OpenBody(aNode);
}
else {
@ -3437,7 +3390,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
// XXX - But what did we actually do in counting the heads?
mOpenHeadCount=1;
}
CloseHead(aNode); //do this just in case someone left it open...
CloseHead(); //do this just in case someone left it open...
result=OpenFrameset(aNode); break;
case eHTMLTag_script:
@ -3446,7 +3399,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
// XXX - But what did we actually do in counting the heads?
mOpenHeadCount=1;
}
CloseHead(aNode); //do this just in case someone left it open...
CloseHead(); //do this just in case someone left it open...
result=HandleScriptToken(aNode);
break;
@ -3475,7 +3428,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
break;
}
if(!done) {
if (!done) {
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenContainer(), this=%p\n", this));
@ -3483,8 +3436,9 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenContainer(), this=%p\n", this));
START_TIMER();
mBodyContext->Push(aNode,aStyleStack);
// For residual style tags rs_tag will be true and hence
// the body context will hold an extra reference to the node.
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), aStyleStack, rs_tag);
}
return result;
@ -3501,43 +3455,42 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
* @return TRUE if ok, FALSE if error
*/
nsresult
CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClosedByStartTag){
nsresult result=NS_OK;
eHTMLTags nodeType=(eHTMLTags)aNode->GetNodeType();
CNavDTD::CloseContainer(const eHTMLTags aTag, eHTMLTags aTarget,PRBool aClosedByStartTag)
{
nsresult result = NS_OK;
#ifdef ENABLE_CRC
#define K_CLOSEOP 200
CRCStruct theStruct(nodeType,K_CLOSEOP);
mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct));
#endif
switch(nodeType) {
switch (aTag) {
case eHTMLTag_html:
result=CloseHTML(aNode); break;
result=CloseHTML(); break;
case eHTMLTag_style:
case eHTMLTag_textarea:
break;
case eHTMLTag_head:
result=CloseHead(aNode);
result=CloseHead();
break;
case eHTMLTag_body:
result=CloseBody(aNode);
result=CloseBody();
break;
case eHTMLTag_map:
result=CloseMap(aNode);
result=CloseMap();
break;
case eHTMLTag_form:
result=CloseForm(aNode);
result=CloseForm();
break;
case eHTMLTag_frameset:
result=CloseFrameset(aNode);
result=CloseFrameset();
break;
case eHTMLTag_iframe:
@ -3548,15 +3501,13 @@ CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClo
// falling thro' intentionally....
case eHTMLTag_title:
default:
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
result=(mSink) ? mSink->CloseContainer(*aNode) : NS_OK;
result=(mSink) ? mSink->CloseContainer(aTag) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
START_TIMER();
break;
}
@ -3573,23 +3524,20 @@ CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClo
* @param aClosedByStartTag -- if TRUE, then we're closing something because a start tag caused it
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aClosedByStartTag){
nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aClosedByStartTag)
{
NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
nsresult result = NS_OK;
if ((anIndex<mBodyContext->GetCount()) && (anIndex>=0)) {
if((anIndex<mBodyContext->GetCount()) && (anIndex>=0)) {
PRInt32 count = 0;
while ((count = mBodyContext->GetCount()) > anIndex) {
nsEntryStack* theChildStyleStack = 0;
eHTMLTags theTag = mBodyContext->Last();
nsCParserNode* theNode = mBodyContext->Pop(theChildStyleStack);
result = CloseContainer(theTag, aTarget,aClosedByStartTag);
PRInt32 count=0;
while((count=mBodyContext->GetCount())>anIndex) {
nsEntryStack *theChildStyleStack=0;
eHTMLTags theTag=mBodyContext->Last();
nsCParserNode *theNode=mBodyContext->Pop(theChildStyleStack);
if(theNode) {
result=CloseContainer(theNode,aTarget,aClosedByStartTag);
#ifdef ENABLE_RESIDUALSTYLE
PRBool theTagIsStyle=nsHTMLElement::IsResidualStyleTag(theTag);
@ -3605,9 +3553,13 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
*************************************************************/
if(theTagIsStyle && !(mFlags & NS_DTD_FLAG_ALTERNATE_CONTENT)) {
PRBool theTargetTagIsStyle=nsHTMLElement::IsResidualStyleTag(aTarget);
NS_ASSERTION(theNode, "residual style node should not be null");
if (!theNode) {
if (theChildStyleStack)
mBodyContext->PushStyles(theChildStyleStack);
return NS_OK;
}
PRBool theTargetTagIsStyle = nsHTMLElement::IsResidualStyleTag(aTarget);
if(aClosedByStartTag) {
/***********************************************************
@ -3618,25 +3570,24 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
2. <body><a>text<a> //in this case, the target matches, so don't push style
***************************************************************************/
if(0==theNode->mUseCount){
if(theTag!=aTarget) {
if (theNode->mUseCount == 0){
if (theTag != aTarget) {
//don't push if thechild==theTarget
if(theChildStyleStack) {
if (theChildStyleStack)
theChildStyleStack->PushFront(theNode);
}
else mBodyContext->PushStyle(theNode);
else
mBodyContext->PushStyle(theNode);
}
}
else if((theTag==aTarget) && (!gHTMLElements[aTarget].CanContainSelf())) {
else if (theTag == aTarget && !gHTMLElements[aTarget].CanContainSelf()) {
//here's a case we missed: <a><div>text<a>text</a></div>
//The <div> pushes the 1st <a> onto the rs-stack, then the 2nd <a>
//pops the 1st <a> from the rs-stack altogether.
nsCParserNode* node=mBodyContext->PopStyle(theTag);
nsCParserNode* node = mBodyContext->PopStyle(theTag);
IF_FREE(node, &mNodeAllocator);
}
if(theChildStyleStack) {
if (theChildStyleStack) {
mBodyContext->PushStyles(theChildStyleStack);
}
}
@ -3666,14 +3617,14 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
In this case, the <b> is simply closed.
***************************************************************************/
if(theChildStyleStack) {
if(!theStyleDoesntLeakOut) {
if(theTag!=aTarget) {
if (0==theNode->mUseCount) {
if (theChildStyleStack) {
if (!theStyleDoesntLeakOut) {
if (theTag != aTarget) {
if (theNode->mUseCount == 0) {
theChildStyleStack->PushFront(theNode);
}
}
else if(1==theNode->mUseCount) {
else if (theNode->mUseCount == 1) {
// This fixes bug 30885,29626.
// Make sure that the node, which is about to
// get released does not stay on the style stack...
@ -3689,11 +3640,11 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
IF_DELETE(theChildStyleStack,&mNodeAllocator);
}
}
else if (0==theNode->mUseCount) {
else if (theNode->mUseCount == 0) {
//The old version of this only pushed if the targettag wasn't style.
//But that misses this case: <font><b>text</font>, where the b should leak
if(aTarget!=theTag) {
if (aTarget != theTag) {
mBodyContext->PushStyle(theNode);
}
}
@ -3712,16 +3663,15 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
} //if
else {
//the tag is not a style tag...
if(theChildStyleStack) {
if(theStyleDoesntLeakOut) {
if (theChildStyleStack) {
if (theStyleDoesntLeakOut)
IF_DELETE(theChildStyleStack,&mNodeAllocator);
}
else mBodyContext->PushStyles(theChildStyleStack);
else
mBodyContext->PushStyles(theChildStyleStack);
}
}
#endif
IF_FREE(theNode, &mNodeAllocator);
}//if theNode
}
} //if
@ -3867,7 +3817,7 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){
// Fix for Bug 31392
// Do not leave a head context open no matter what the result is.
nsresult rv=CloseHead(aNode);
nsresult rv = CloseHead();
NS_ENSURE_SUCCESS(rv,rv);
}

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

@ -280,7 +280,10 @@ public:
nsresult OpenForm(const nsIParserNode *aNode);
nsresult OpenMap(const nsCParserNode *aNode);
nsresult OpenFrameset(const nsCParserNode *aNode);
nsresult OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedByStartTag,nsEntryStack* aStyleStack=0);
nsresult OpenContainer(const nsCParserNode *aNode,
eHTMLTags aTag,
PRBool aClosedByStartTag,
nsEntryStack* aStyleStack=0);
/**
* The next set of methods close the given HTML element.
@ -289,12 +292,12 @@ public:
* @param HTML (node) to be opened in content sink.
* @return error code - 0 if all went well.
*/
nsresult CloseHTML(const nsIParserNode *aNode);
nsresult CloseHead(const nsIParserNode *aNode);
nsresult CloseBody(const nsIParserNode *aNode);
nsresult CloseForm(const nsIParserNode *aNode);
nsresult CloseMap(const nsIParserNode *aNode);
nsresult CloseFrameset(const nsIParserNode *aNode);
nsresult CloseHTML();
nsresult CloseHead();
nsresult CloseBody();
nsresult CloseForm();
nsresult CloseMap();
nsresult CloseFrameset();
/**
* The special purpose methods automatically close
@ -302,9 +305,14 @@ public:
* @update gess5/11/98
* @return error code - 0 if all went well.
*/
nsresult CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClosedByStartTag);
nsresult CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag);
nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aClosedByStartTag);
nsresult CloseContainer(const eHTMLTags aTag,
eHTMLTags aTarget,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(eHTMLTags aTag,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(PRInt32 anIndex,
eHTMLTags aTag,
PRBool aClosedByStartTag);
/**
* Causes leaf to be added to sink at current vector pos.

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

@ -443,37 +443,40 @@ nsresult COtherDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIPar
PRInt32 theIndex=mBodyContext->GetCount()-1;
eHTMLTags theChild = mBodyContext->TagAt(theIndex);
while(theIndex>0) {
eHTMLTags theParent= mBodyContext->TagAt(--theIndex);
CElement *theElement=gElementTable->mElements[theParent];
nsCParserNode *theNode=mBodyContext->PeekNode();
while (theIndex>0) {
eHTMLTags theParent = mBodyContext->TagAt(--theIndex);
CElement *theElement = gElementTable->mElements[theParent];
nsCParserNode *theNode = mBodyContext->PeekNode();
theElement->HandleEndToken(theNode,theChild,mBodyContext,mSink);
theChild=theParent;
theChild = theParent;
}
nsEntryStack *theChildStyles=0;
nsCParserNode* theNode=(nsCParserNode*)mBodyContext->Pop(theChildStyles);
if(theNode) {
mSink->CloseHTML(*theNode);
nsEntryStack* theChildStyles = 0;
nsCParserNode* theNode = (nsCParserNode*)mBodyContext->Pop(theChildStyles);
if (theNode) {
mSink->CloseHTML();
}
NS_ASSERTION(!theChildStyles, "there should no residual style information in this dtd");
IF_DELETE(theChildStyles, mNodeAllocator);
}
else {
//If you're here, then an error occured, but we still have nodes on the stack.
//At a minimum, we should grab the nodes and recycle them.
//Just to be correct, we'll also recycle the nodes.
while(mBodyContext->GetCount() > 0) {
while (mBodyContext->GetCount() > 0) {
nsEntryStack *theChildStyles=0;
nsCParserNode* theNode=(nsCParserNode*)mBodyContext->Pop(theChildStyles);
if(theNode) {
theNode->mUseCount=0;
if(theChildStyles) {
nsEntryStack *theChildStyles = 0;
nsCParserNode* theNode = (nsCParserNode*)mBodyContext->Pop(theChildStyles);
if (theNode) {
theNode->mUseCount = 0;
if (theChildStyles) {
delete theChildStyles;
}
IF_FREE(theNode, mNodeAllocator);
}
NS_ASSERTION(!theChildStyles, "there should no residual style information in this dtd");
IF_DELETE(theChildStyles, mNodeAllocator);
}
}
@ -481,7 +484,7 @@ nsresult COtherDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIPar
} //if aparser
//No matter what, you need to call did build model.
result=aSink->DidBuildModel(0);
result = aSink->DidBuildModel(0);
} //if asink
return result;
@ -721,7 +724,7 @@ nsresult COtherDTD::HandleStartToken(CToken* aToken) {
case eHTMLTag_html:
if(!mBodyContext->HasOpenContainer(theChildTag)){
mSink->OpenHTML(*theNode);
mBodyContext->Push(theNode,0);
mBodyContext->Push(theNode, 0, PR_FALSE);
}
theTagWasHandled=PR_TRUE;
break;

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

@ -305,11 +305,9 @@ public:
this gets called after each tag is opened in the given context
**********************************************************/
virtual nsresult OpenContext(nsCParserNode *aNode,eHTMLTags aTag,nsDTDContext *aContext,nsIHTMLContentSink *aSink) {
aContext->Push(aNode);
CElement *theElement=(aTag==mTag) ? this : GetElement(aTag);
theElement->NotifyOpen(aNode,aTag,aContext,aSink);
aContext->Push(aNode, 0, PR_FALSE);
CElement *theElement = (aTag == mTag) ? this : GetElement(aTag);
theElement->NotifyOpen(aNode, aTag, aContext,aSink);
return NS_OK;
}
@ -325,7 +323,7 @@ public:
this gets called to close a given tag in the sink
**********************************************************/
virtual nsresult CloseContainer(nsIParserNode *aNode,eHTMLTags aTag,nsDTDContext *aContext,nsIHTMLContentSink *aSink) {
return aSink->CloseContainer(*aNode);
return aSink->CloseContainer(aTag);
}
/**********************************************************
@ -1175,7 +1173,7 @@ public:
nsresult result=NS_OK;
if(aSink && aContext) {
if(aContext->mFlags.mHasOpenHead==PR_TRUE) {
result=aSink->CloseHead(*aNode);
result = aSink->CloseHead();
aContext->mFlags.mHasOpenHead=PR_FALSE;
}
}
@ -1668,14 +1666,14 @@ public:
switch(aTag) {
case eHTMLTag_html:
if(aContext->HasOpenContainer(aTag)) {
result=aSink->CloseHTML(*aNode);
result=aSink->CloseHTML();
CloseContext(aNode,aTag,aContext,aSink);
}
break;
case eHTMLTag_body:
if(aContext->HasOpenContainer(aTag)) {
result=aSink->CloseBody(*aNode);
result=aSink->CloseBody();
CloseContext(aNode,aTag,aContext,aSink);
}
break;
@ -1839,18 +1837,18 @@ public:
switch(aTag) {
case eHTMLTag_body:
aSink->CloseBody(*aNode);
aSink->CloseBody();
result=CloseContext(aNode,aTag,aContext,aSink);
break;
case eHTMLTag_frameset:
aSink->CloseFrameset(*aNode);
aSink->CloseFrameset();
result=CloseContext(aNode,aTag,aContext,aSink);
break;
case eHTMLTag_object:
result=CloseContainerInContext(aNode,aTag,aContext,aSink);
aSink->CloseHead(*aNode);
aSink->CloseHead();
break;
case eHTMLTag_script:

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

@ -155,18 +155,18 @@ void nsEntryStack::EnsureCapacityFor(PRInt32 aNewMax,PRInt32 aShiftOffset) {
*
* @update gess 04/22/99
*/
void nsEntryStack::Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
void nsEntryStack::Push(nsCParserNode* aNode,
nsEntryStack* aStyleStack,
PRBool aRefCntNode)
{
if(aNode) {
EnsureCapacityFor(mCount+1);
((nsCParserNode*)aNode)->mUseCount++;
mEntries[mCount].mTag=(eHTMLTags)aNode->GetNodeType();
mEntries[mCount].mNode=NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[mCount].mNode);
mEntries[mCount].mTag = (eHTMLTags)aNode->GetNodeType();
if (aRefCntNode) {
aNode->mUseCount++;
mEntries[mCount].mNode = NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[mCount].mNode);
}
mEntries[mCount].mParent=aStyleStack;
mEntries[mCount++].mStyles=0;
}
@ -178,25 +178,26 @@ void nsEntryStack::Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
*
* @update gess 11/10/99
*/
void nsEntryStack::PushFront(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
void nsEntryStack::PushFront(nsCParserNode* aNode,
nsEntryStack* aStyleStack,
PRBool aRefCntNode)
{
if(aNode) {
if(mCount<mCapacity) {
PRInt32 index=0;
for(index=mCount;index>0;index--) {
mEntries[index]=mEntries[index-1];
}
}
else EnsureCapacityFor(mCount+1,1);
((nsCParserNode*)aNode)->mUseCount++;
mEntries[0].mTag=(eHTMLTags)aNode->GetNodeType();
mEntries[0].mNode=NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[0].mNode);
else {
EnsureCapacityFor(mCount+1,1);
}
mEntries[0].mTag = (eHTMLTags)aNode->GetNodeType();
if (aRefCntNode) {
aNode->mUseCount++;
mEntries[0].mNode = NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[0].mNode);
}
mEntries[0].mParent=aStyleStack;
mEntries[0].mStyles=0;
++mCount;
@ -235,34 +236,30 @@ void nsEntryStack::Append(nsEntryStack *aStack) {
* aTag: the id of the tag to be removed
* @update gess 02/25/00
*/
nsCParserNode* nsEntryStack::Remove(PRInt32 anIndex,eHTMLTags aTag) {
nsCParserNode* result=0;
if((0<mCount) && (anIndex<mCount)){
result=mEntries[anIndex].mNode;
((nsCParserNode*)result)->mUseCount--;
PRInt32 theIndex=0;
mCount-=1;
for(theIndex=anIndex;theIndex<mCount;++theIndex){
mEntries[theIndex]=mEntries[theIndex+1];
nsCParserNode* nsEntryStack::Remove(PRInt32 anIndex,
eHTMLTags aTag)
{
nsCParserNode* result = 0;
if (0 < mCount && anIndex < mCount){
result = mEntries[anIndex].mNode;
if (result)
result->mUseCount--;
PRInt32 theIndex = 0;
mCount -= 1;
for( theIndex = anIndex; theIndex < mCount; ++theIndex){
mEntries[theIndex] = mEntries[theIndex+1];
}
mEntries[mCount].mNode=0;
mEntries[mCount].mStyles=0;
nsEntryStack* theStyleStack=mEntries[anIndex].mParent;
if(theStyleStack) {
mEntries[mCount].mNode = 0;
mEntries[mCount].mStyles = 0;
nsEntryStack* theStyleStack = mEntries[anIndex].mParent;
if (theStyleStack) {
//now we have to tell the residual style stack where this tag
//originated that it's no longer in use.
PRUint32 scount=theStyleStack->mCount;
PRUint32 sindex=0;
PRUint32 scount = theStyleStack->mCount;
PRUint32 sindex = 0;
nsTagEntry *theStyleEntry=theStyleStack->mEntries;
for(sindex=scount-1;sindex>0;--sindex){
if(theStyleEntry->mTag==aTag) {
for (sindex=scount-1;sindex>0;--sindex){
if (theStyleEntry->mTag==aTag) {
theStyleEntry->mParent=0; //this tells us that the style is not open at any level
break;
}
@ -278,29 +275,24 @@ nsCParserNode* nsEntryStack::Remove(PRInt32 anIndex,eHTMLTags aTag) {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
nsCParserNode* nsEntryStack::Pop(void) {
nsCParserNode* result=0;
if(0<mCount) {
result=mEntries[--mCount].mNode;
((nsCParserNode*)result)->mUseCount--;
mEntries[mCount].mNode=0;
mEntries[mCount].mStyles=0;
nsCParserNode* nsEntryStack::Pop(void)
{
nsCParserNode* result = 0;
if (0 < mCount) {
result = mEntries[--mCount].mNode;
if (result)
result->mUseCount--;
mEntries[mCount].mNode = 0;
mEntries[mCount].mStyles = 0;
nsEntryStack* theStyleStack=mEntries[mCount].mParent;
if(theStyleStack) {
if (theStyleStack) {
//now we have to tell the residual style stack where this tag
//originated that it's no longer in use.
PRUint32 scount=theStyleStack->mCount;
PRUint32 sindex=0;
PRUint32 scount = theStyleStack->mCount;
PRUint32 sindex = 0;
nsTagEntry *theStyleEntry=theStyleStack->mEntries;
for(sindex=scount-1;sindex>0;--sindex){
if(theStyleEntry->mTag==mEntries[mCount].mTag) {
for (sindex=scount-1;sindex>0;--sindex){
if (theStyleEntry->mTag==mEntries[mCount].mTag) {
theStyleEntry->mParent=0; //this tells us that the style is not open at any level
break;
}
@ -316,7 +308,8 @@ nsCParserNode* nsEntryStack::Pop(void) {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::First() const {
eHTMLTags nsEntryStack::First() const
{
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount){
result=mEntries[0].mTag;
@ -329,7 +322,8 @@ eHTMLTags nsEntryStack::First() const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
nsCParserNode* nsEntryStack::NodeAt(PRInt32 anIndex) const {
nsCParserNode* nsEntryStack::NodeAt(PRInt32 anIndex) const
{
nsCParserNode* result=0;
if((0<mCount) && (anIndex<mCount)) {
result=mEntries[anIndex].mNode;
@ -342,7 +336,8 @@ nsCParserNode* nsEntryStack::NodeAt(PRInt32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::TagAt(PRInt32 anIndex) const {
eHTMLTags nsEntryStack::TagAt(PRInt32 anIndex) const
{
eHTMLTags result=eHTMLTag_unknown;
if((0<mCount) && (anIndex<mCount)) {
result=mEntries[anIndex].mTag;
@ -354,7 +349,8 @@ eHTMLTags nsEntryStack::TagAt(PRInt32 anIndex) const {
*
* @update gess 04/21/99
*/
nsTagEntry* nsEntryStack::EntryAt(PRInt32 anIndex) const {
nsTagEntry* nsEntryStack::EntryAt(PRInt32 anIndex) const
{
nsTagEntry *result=0;
if((0<mCount) && (anIndex<mCount)) {
result=&mEntries[anIndex];
@ -368,7 +364,8 @@ nsTagEntry* nsEntryStack::EntryAt(PRInt32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const {
eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const
{
eHTMLTags result=eHTMLTag_unknown;
if((0<mCount) && (anIndex<mCount)) {
result=mEntries[anIndex].mTag;
@ -382,7 +379,8 @@ eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::Last() const {
eHTMLTags nsEntryStack::Last() const
{
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount) {
result=mEntries[mCount-1].mTag;
@ -390,6 +388,31 @@ eHTMLTags nsEntryStack::Last() const {
return result;
}
nsTagEntry*
nsEntryStack::PopEntry()
{
nsTagEntry* entry = EntryAt(mCount-1);
this->Pop();
return entry;
}
void nsEntryStack::PushEntry(nsTagEntry* aEntry,
PRBool aRefCntNode)
{
if (aEntry) {
EnsureCapacityFor(mCount+1);
mEntries[mCount].mNode = aEntry->mNode;
mEntries[mCount].mTag = aEntry->mTag;
mEntries[mCount].mParent = aEntry->mParent;
mEntries[mCount].mStyles = aEntry->mStyles;
if (aRefCntNode && mEntries[mCount].mNode) {
mEntries[mCount].mNode->mUseCount++;
IF_HOLD(mEntries[mCount].mNode);
}
mCount++;
}
}
/***************************************************************
Now define the dtdcontext class
***************************************************************/
@ -934,16 +957,62 @@ PRBool nsDTDContext::HasOpenContainer(eHTMLTags aTag) const {
*
* @update gess7/9/98
*/
void nsDTDContext::Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
void nsDTDContext::Push(nsCParserNode* aNode,
nsEntryStack* aStyleStack,
PRBool aRefCntNode) {
if(aNode) {
#ifdef NS_DEBUG
eHTMLTags theTag=(eHTMLTags)aNode->GetNodeType();
int size=mStack.mCount;
if(size< eMaxTags)
mXTags[size]=theTag;
eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
int size = mStack.mCount;
if (size < eMaxTags)
mXTags[size] = theTag;
#endif
mStack.Push(aNode,aStyleStack);
mStack.Push(aNode, aStyleStack, aRefCntNode);
}
}
nsTagEntry*
nsDTDContext::PopEntry()
{
PRInt32 theSize = mStack.mCount;
if(0<theSize) {
#ifdef NS_DEBUG
if (theSize <= eMaxTags)
mXTags[theSize-1]=eHTMLTag_unknown;
#endif
return mStack.PopEntry();
}
return 0;
}
void nsDTDContext::PushEntry(nsTagEntry* aEntry,
PRBool aRefCntNode)
{
#ifdef NS_DEBUG
int size=mStack.mCount;
if(size< eMaxTags && aEntry)
mXTags[size]=aEntry->mTag;
#endif
mStack.PushEntry(aEntry, aRefCntNode);
}
/* This method will move the top entires, in the entry-stack, into dest context.
* @param aDest - Destination context for the entries.
* @param aCount - Number of entries, on top of the entry-stack, to be moved.
*/
void
nsDTDContext::MoveEntries(nsDTDContext& aDest,
PRInt32 aCount)
{
NS_ASSERTION(aCount > 0 && mStack.mCount >= aCount, "cannot move entries");
if (aCount > 0 && mStack.mCount >= aCount) {
while (aCount) {
aDest.PushEntry(&mStack.mEntries[--mStack.mCount], PR_FALSE);
#ifdef NS_DEBUG
mXTags[mStack.mCount] = eHTMLTag_unknown;
#endif
--aCount;
}
}
}
@ -1002,7 +1071,6 @@ eHTMLTags nsDTDContext::TagAt(PRInt32 anIndex) const {
return mStack.TagAt(anIndex);
}
/**
*
* @update gess7/9/98
@ -1041,7 +1109,7 @@ nsEntryStack* nsDTDContext::GetStylesAt(PRInt32 anIndex) const {
*
* @update gess 04/28/99
*/
void nsDTDContext::PushStyle(const nsCParserNode* aNode){
void nsDTDContext::PushStyle(nsCParserNode* aNode){
nsTagEntry* theEntry=mStack.EntryAt(mStack.mCount-1);
if(theEntry ) {
@ -1352,9 +1420,9 @@ nsNodeAllocator::nsNodeAllocator():mSharedNodes(0){
mCount=0;
#endif
#else
static const size_t kNodeBuckets[] ={sizeof(nsCParserNode)};
static const size_t kNodeBuckets[] = { sizeof(nsCParserNode), sizeof(nsCParserStartNode) };
static const PRInt32 kNumNodeBuckets = sizeof(kNodeBuckets) / sizeof(size_t);
static const PRInt32 kInitialNodePoolSize = NS_SIZE_IN_HEAP(sizeof(nsCParserNode)) * 50;
static const PRInt32 kInitialNodePoolSize = NS_SIZE_IN_HEAP(sizeof(nsCParserNode)) * 35; // optimal size based on space-trace data
nsNodeAllocator::nsNodeAllocator() {
mNodePool.Init("NodePool", kNodeBuckets, kNumNodeBuckets, kInitialNodePoolSize);
#endif
@ -1365,7 +1433,7 @@ nsNodeAllocator::~nsNodeAllocator() {
MOZ_COUNT_DTOR(nsNodeAllocator);
#ifdef HEAP_ALLOCATED_NODES
nsCParserNode* theNode=0;
nsCParserNode* theNode = 0;
while((theNode=(nsCParserNode*)mSharedNodes.Pop())){
#ifdef DEBUG_TRACK_NODES
@ -1385,22 +1453,21 @@ nsNodeAllocator::~nsNodeAllocator() {
}
nsCParserNode* nsNodeAllocator::CreateNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator) {
nsCParserNode* result=0;
nsTokenAllocator* aTokenAllocator)
{
nsCParserNode* result = 0;
#ifdef HEAP_ALLOCATED_NODES
#if 0
if(gAllNodeCount!=mSharedNodes.GetSize()) {
int x=10; //this is very BAD!
}
#endif
result=NS_STATIC_CAST(nsCParserNode*,mSharedNodes.Pop());
if(result) {
result = NS_STATIC_CAST(nsCParserNode*,mSharedNodes.Pop());
if (result) {
result->Init(aToken, aTokenAllocator,this);
}
else{
result=nsCParserNode::Create(aToken, aTokenAllocator,this);
result = nsCParserNode::Create(aToken, aTokenAllocator,this);
#ifdef DEBUG_TRACK_NODES
++mCount;
AddNode(NS_STATIC_CAST(nsCParserNode*,result));
@ -1408,7 +1475,15 @@ nsCParserNode* nsNodeAllocator::CreateNode(CToken* aToken,
IF_HOLD(result);
}
#else
result=nsCParserNode::Create(aToken, aTokenAllocator,this);
eHTMLTokenTypes type = aToken ? eHTMLTokenTypes(aToken->GetTokenType()) : eToken_unknown;
switch (type) {
case eToken_start:
result = nsCParserStartNode::Create(aToken, aTokenAllocator,this);
break;
default :
result = nsCParserNode::Create(aToken, aTokenAllocator,this);
break;
}
IF_HOLD(result);
#endif
return result;

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

@ -71,7 +71,7 @@
// recycles _ptr
#define IF_FREE(_ptr, _allocator) \
PR_BEGIN_MACRO \
if(_ptr) { \
if(_ptr && _allocator) { \
_ptr->Release((_allocator)->GetArenaPool()); \
_ptr=0; \
} \
@ -107,6 +107,8 @@ PRUint32 AccumulateCRC(PRUint32 crc_accum, char *data_blk_ptr, int data_blk_size
class nsEntryStack; //forware declare to make compilers happy.
struct nsTagEntry {
nsTagEntry::nsTagEntry()
: mTag(eHTMLTag_unknown), mNode(0), mParent(0), mStyles(0){}
eHTMLTags mTag; //for speedier access to tag id
nsCParserNode* mNode;
nsEntryStack* mParent;
@ -119,9 +121,11 @@ public:
nsEntryStack();
~nsEntryStack();
nsTagEntry* PopEntry();
void PushEntry(nsTagEntry* aEntry, PRBool aRefCntNode = PR_TRUE);
void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0);
void Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack=0);
void PushFront(const nsCParserNode* aNode,nsEntryStack* aStyleStack=0);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void Append(nsEntryStack *theStack);
nsCParserNode* Pop(void);
nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag);
@ -329,7 +333,10 @@ public:
nsDTDContext();
~nsDTDContext();
void Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack=0);
nsTagEntry* PopEntry();
void PushEntry(nsTagEntry* aEntry, PRBool aRefCntNode = PR_TRUE);
void MoveEntries(nsDTDContext& aDest, PRInt32 aCount);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
nsCParserNode* Pop(nsEntryStack*& aChildStack);
nsCParserNode* Pop();
nsCParserNode* PeekNode() { return mStack.NodeAt(mStack.mCount-1); }
@ -346,7 +353,7 @@ public:
PRInt32 GetCount(void) {return mStack.mCount;}
PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;}
nsEntryStack* GetStylesAt(PRInt32 anIndex) const;
void PushStyle(const nsCParserNode* aNode);
void PushStyle(nsCParserNode* aNode);
void PushStyles(nsEntryStack *theStyles);
nsCParserNode* PopStyle(void);
nsCParserNode* PopStyle(eHTMLTags aTag);

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

@ -65,7 +65,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
@ -77,17 +77,17 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
@ -234,14 +234,15 @@ nsHTMLNullSink::OpenHTML(const nsIParserNode& aNode){
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseHTML(const nsIParserNode& aNode){
nsHTMLNullSink::CloseHTML(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos-1)*2);
PRUnichar html[] = {'h','t','m','l','\0'};
DebugDump("</",nsDependentString(html),(mNodeStackPos-1)*2);
#endif
return NS_OK;
@ -277,13 +278,14 @@ nsHTMLNullSink::OpenHead(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseHead(const nsIParserNode& aNode) {
nsHTMLNullSink::CloseHead() {
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar head[] = {'h','e','a','d','\0'};
DebugDump("</", nsDependentString(head), (mNodeStackPos)*2);
#endif
return NS_OK;
@ -331,12 +333,13 @@ nsHTMLNullSink::OpenBody(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseBody(const nsIParserNode& aNode){
nsHTMLNullSink::CloseBody(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar body[] = {'b','o','d','y','\0'};
DebugDump("</", nsDependentString(body), (mNodeStackPos)*2);
#endif
return NS_OK;
@ -370,13 +373,14 @@ nsHTMLNullSink::OpenForm(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseForm(const nsIParserNode& aNode){
nsHTMLNullSink::CloseForm(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar form[] = {'f','o','r','m','\0'};
DebugDump("</", nsDependentString(form),(mNodeStackPos)*2);
#endif
return NS_OK;
@ -410,13 +414,14 @@ nsHTMLNullSink::OpenMap(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseMap(const nsIParserNode& aNode){
nsHTMLNullSink::CloseMap(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar map[] = {'m','a','p','\0'};
DebugDump("</", nsDependentString(map), (mNodeStackPos)*2);
#endif
return NS_OK;
@ -450,13 +455,14 @@ nsHTMLNullSink::OpenFrameset(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseFrameset(const nsIParserNode& aNode){
nsHTMLNullSink::CloseFrameset(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar frameset[] = {'f','r','a','m','e', 's', 'e','t','\0'};
DebugDump("</", nsDependentString(frameset),(mNodeStackPos)*2);
#endif
return NS_OK;
@ -491,13 +497,14 @@ nsHTMLNullSink::OpenContainer(const nsIParserNode& aNode){
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseContainer(const nsIParserNode& aNode){
nsHTMLNullSink::CloseContainer(const nsHTMLTag aTag){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
const PRUnichar* name = nsHTMLTags::GetStringValue(aTag);
DebugDump("</", nsDependentString(name), (mNodeStackPos)*2);
#endif
return NS_OK;

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

@ -1062,4 +1062,3 @@ void nsHTMLTokenizer::RecordTrailingContent(CStartToken* aStartToken, nsScanner&
copy_string( aOrigin, theCurrentPosition, beginWriting );
}
}

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

@ -226,11 +226,11 @@ nsLoggingSink::OpenContainer(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseContainer(const nsIParserNode& aNode) {
nsLoggingSink::CloseContainer(const nsHTMLTag aTag) {
nsresult theResult=NS_OK;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsHTMLTag nodeType = nsHTMLTag(aTag);
if ((nodeType >= eHTMLTag_unknown) &&
(nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
@ -240,7 +240,7 @@ nsLoggingSink::CloseContainer(const nsIParserNode& aNode) {
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseContainer(aNode);
theResult=mSink->CloseContainer(aTag);
}
return theResult;
@ -379,14 +379,14 @@ nsLoggingSink::OpenHTML(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseHTML(const nsIParserNode& aNode) {
nsLoggingSink::CloseHTML() {
CloseNode("html");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseHTML(aNode);
theResult=mSink->CloseHTML();
}
return theResult;
@ -408,14 +408,14 @@ nsLoggingSink::OpenHead(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseHead(const nsIParserNode& aNode) {
nsLoggingSink::CloseHead() {
CloseNode("head");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseHead(aNode);
theResult=mSink->CloseHead();
}
return theResult;
@ -436,14 +436,14 @@ nsLoggingSink::OpenBody(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseBody(const nsIParserNode& aNode) {
nsLoggingSink::CloseBody() {
CloseNode("body");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseBody(aNode);
theResult=mSink->CloseBody();
}
return theResult;
@ -464,14 +464,14 @@ nsLoggingSink::OpenForm(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseForm(const nsIParserNode& aNode) {
nsLoggingSink::CloseForm() {
CloseNode("form");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseForm(aNode);
theResult=mSink->CloseForm();
}
return theResult;
@ -492,14 +492,14 @@ nsLoggingSink::OpenMap(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseMap(const nsIParserNode& aNode) {
nsLoggingSink::CloseMap() {
CloseNode("map");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseMap(aNode);
theResult=mSink->CloseMap();
}
return theResult;
@ -520,14 +520,14 @@ nsLoggingSink::OpenFrameset(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseFrameset(const nsIParserNode& aNode) {
nsLoggingSink::CloseFrameset() {
CloseNode("frameset");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseFrameset(aNode);
theResult=mSink->CloseFrameset();
}
return theResult;

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

@ -67,7 +67,7 @@ public:
NS_IMETHOD WillResume();
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
@ -79,17 +79,17 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }

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

@ -60,14 +60,13 @@ const nsString& GetEmptyString() {
*/
nsCParserNode::nsCParserNode()
: mToken(nsnull),
mAttributes(nsnull),
mUseCount(0),
mGenericState(PR_FALSE),
mTokenAllocator(nsnull)
{
MOZ_COUNT_CTOR(nsCParserNode);
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=nsnull;
mNodeAllocator = nsnull;
#endif
}
@ -80,21 +79,20 @@ nsCParserNode::nsCParserNode()
*/
nsCParserNode::nsCParserNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator):
nsIParserNode() {
nsNodeAllocator* aNodeAllocator): nsIParserNode()
{
mRefCnt = 0;
MOZ_COUNT_CTOR(nsCParserNode);
static int theNodeCount=0;
static int theNodeCount = 0;
++theNodeCount;
mAttributes=0;
mToken=aToken;
mToken = aToken;
IF_HOLD(mToken);
mTokenAllocator=aTokenAllocator;
mUseCount=0;
mGenericState=PR_FALSE;
mTokenAllocator = aTokenAllocator;
mUseCount = 0;
mGenericState = PR_FALSE;
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=aNodeAllocator;
mNodeAllocator = aNodeAllocator;
#endif
}
@ -113,9 +111,9 @@ nsCParserNode::~nsCParserNode() {
if(mNodeAllocator) {
mNodeAllocator->Recycle(this);
}
mNodeAllocator=nsnull;
mNodeAllocator = nsnull;
#endif
mTokenAllocator=0;
mTokenAllocator = 0;
}
@ -127,48 +125,25 @@ nsCParserNode::~nsCParserNode() {
* @return
*/
nsresult nsCParserNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator) {
if(mAttributes && (mAttributes->GetSize())) {
NS_ASSERTION(0!=mTokenAllocator, "Error: Attribute tokens on node without token allocator");
if(mTokenAllocator) {
CToken* theAttrToken=0;
while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
}
mTokenAllocator=aTokenAllocator;
mToken=aToken;
nsresult
nsCParserNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
mTokenAllocator = aTokenAllocator;
mToken = aToken;
IF_HOLD(mToken);
mGenericState=PR_FALSE;
mGenericState = PR_FALSE;
mUseCount=0;
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=aNodeAllocator;
mNodeAllocator = aNodeAllocator;
#endif
return NS_OK;
}
/**
* Causes the given attribute to be added to internal
* mAttributes list, and mAttributeCount to be incremented.
*
* @update gess 3/25/98
* @param aToken -- token to be added to attr list
* @return
*/
void nsCParserNode::AddAttribute(CToken* aToken) {
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
NS_PRECONDITION(0!=mTokenAllocator, "Error: Can't add attribute without token allocator");
if(mTokenAllocator) {
if(!mAttributes)
mAttributes=new nsDeque(0);
if(mAttributes) {
mAttributes->Push(aToken);
}
}
void
nsCParserNode::AddAttribute(CToken* aToken)
{
}
@ -179,9 +154,9 @@ void nsCParserNode::AddAttribute(CToken* aToken) {
* @param
* @return string ref containing node name
*/
const nsString& nsCParserNode::GetName() const {
const nsAString&
nsCParserNode::GetTagName() const {
return GetEmptyString();
// return mName;
}
@ -193,8 +168,13 @@ const nsString& nsCParserNode::GetName() const {
* @param
* @return string ref of text from internal token
*/
const nsAString& nsCParserNode::GetText() const {
return (mToken) ? mToken->GetStringValue() : NS_STATIC_CAST(const nsAString&,GetEmptyString());
const nsAString&
nsCParserNode::GetText() const
{
if (mToken) {
return mToken->GetStringValue();
}
return GetEmptyString();
}
/**
@ -205,7 +185,9 @@ const nsAString& nsCParserNode::GetText() const {
* @param
* @return int value that represents tag type
*/
PRInt32 nsCParserNode::GetNodeType(void) const{
PRInt32
nsCParserNode::GetNodeType(void) const
{
return (mToken) ? mToken->GetTypeID() : 0;
}
@ -218,7 +200,9 @@ PRInt32 nsCParserNode::GetNodeType(void) const{
* @param
* @return
*/
PRInt32 nsCParserNode::GetTokenType(void) const{
PRInt32
nsCParserNode::GetTokenType(void) const
{
return (mToken) ? mToken->GetTokenType() : 0;
}
@ -230,15 +214,10 @@ PRInt32 nsCParserNode::GetTokenType(void) const{
* @param
* @return int -- representing attribute count
*/
PRInt32 nsCParserNode::GetAttributeCount(PRBool askToken) const{
PRInt32 result=0;
if(PR_FALSE==askToken) {
if(mAttributes)
result=mAttributes->GetSize();
}
else result=mToken->GetAttributeCount();
return result;
PRInt32
nsCParserNode::GetAttributeCount(PRBool askToken) const
{
return 0;
}
/**
@ -249,12 +228,9 @@ PRInt32 nsCParserNode::GetAttributeCount(PRBool askToken) const{
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*/
const nsAString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
PRInt32 theCount = (mAttributes) ? mAttributes->GetSize() : 0;
if((PRInt32)anIndex<theCount) {
CAttributeToken* tkn=(CAttributeToken*)mAttributes->ObjectAt(anIndex);
return tkn->GetKey();
}
const nsAString&
nsCParserNode::GetKeyAt(PRUint32 anIndex) const
{
return GetEmptyString();
}
@ -266,20 +242,15 @@ const nsAString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsAString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
PRInt32 theCount = (mAttributes) ? mAttributes->GetSize() : 0;
NS_PRECONDITION(PRInt32(anIndex)<theCount, "Bad attr index");
if(PRInt32(anIndex)<theCount) {
CAttributeToken* tkn=(CAttributeToken*)mAttributes->ObjectAt(anIndex);
return tkn->GetValue();
}
const nsAString&
nsCParserNode::GetValueAt(PRUint32 anIndex) const
{
return GetEmptyString();
}
PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
PRInt32
nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
{
if (eToken_entity == mToken->GetTokenType()) {
return ((CEntityToken*)mToken)->TranslateToUnicodeStr(aString);
@ -293,7 +264,8 @@ PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
* @update gess7/24/98
* @return int containing the line number the token was found on
*/
PRInt32 nsCParserNode::GetSourceLineNumber(void) const {
PRInt32
nsCParserNode::GetSourceLineNumber(void) const {
return mToken ? mToken->GetLineNumber() : 0;
}
@ -303,39 +275,24 @@ PRInt32 nsCParserNode::GetSourceLineNumber(void) const {
* @return token at anIndex
*/
CToken* nsCParserNode::PopAttributeToken() {
CToken* result=0;
if(mAttributes) {
result =(CToken*)mAttributes->Pop();
}
return result;
CToken*
nsCParserNode::PopAttributeToken() {
return 0;
}
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
*/
void nsCParserNode::GetSource(nsString& aString) {
aString.Truncate();
eHTMLTags theTag=(eHTMLTags)mToken->GetTypeID();
aString.Append(PRUnichar('<'));
const PRUnichar* theTagName=nsHTMLTags::GetStringValue(theTag);
void
nsCParserNode::GetSource(nsString& aString)
{
eHTMLTags theTag = mToken ? (eHTMLTags)mToken->GetTypeID() : eHTMLTag_unknown;
aString.Assign(PRUnichar('<'));
const PRUnichar* theTagName = nsHTMLTags::GetStringValue(theTag);
if(theTagName) {
aString.Append(theTagName);
}
if(mAttributes) {
int index=0;
for(index=0;index<mAttributes->GetSize();++index) {
CAttributeToken *theToken=(CAttributeToken*)mAttributes->ObjectAt(index);
if(theToken) {
theToken->AppendSourceTo(aString);
aString.Append(PRUnichar(' ')); //this will get removed...
}
}
}
aString.Append(PRUnichar('>'));
}
@ -343,44 +300,104 @@ void nsCParserNode::GetSource(nsString& aString) {
* @update harishd 08/02/00
* @return void
*/
nsresult nsCParserNode::ReleaseAll() {
if(mAttributes) {
NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
if(mTokenAllocator) {
CToken* theAttrToken=0;
while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
delete mAttributes;
mAttributes=0;
}
nsresult
nsCParserNode::ReleaseAll()
{
if(mTokenAllocator) {
// It was heap allocated, so free it!
IF_FREE(mToken,mTokenAllocator);
}
return NS_OK;
}
nsresult
nsCParserNode::GetIDAttributeAtom(nsIAtom** aResult) const
nsresult
nsCParserStartNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mIDAttributeAtom;
NS_IF_ADDREF(*aResult);
return NS_OK;
NS_ASSERTION(mAttributes.GetSize() == 0, "attributes not recycled!");
return nsCParserNode::Init(aToken, aTokenAllocator, aNodeAllocator);
}
nsresult
nsCParserNode::SetIDAttributeAtom(nsIAtom* aID)
void nsCParserStartNode::AddAttribute(CToken* aToken)
{
NS_ENSURE_ARG(aID);
mIDAttributeAtom = aID;
return NS_OK;
NS_ASSERTION(0 != aToken, "Error: Token shouldn't be null!");
mAttributes.Push(aToken);
}
PRInt32
nsCParserStartNode::GetAttributeCount(PRBool askToken) const
{
PRInt32 result = 0;
if (askToken) {
result = mToken ? mToken->GetAttributeCount() : 0;
}
else {
result = mAttributes.GetSize();
}
return result;
}
const nsAString&
nsCParserStartNode::GetKeyAt(PRUint32 anIndex) const
{
if ((PRInt32)anIndex < mAttributes.GetSize()) {
CAttributeToken* attr =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
if (attr) {
return attr->GetKey();
}
}
return GetEmptyString();
}
const nsAString&
nsCParserStartNode::GetValueAt(PRUint32 anIndex) const
{
if (PRInt32(anIndex) < mAttributes.GetSize()) {
CAttributeToken* attr =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
if (attr) {
return attr->GetValue();
}
}
return GetEmptyString();
}
CToken*
nsCParserStartNode::PopAttributeToken()
{
return NS_STATIC_CAST(CToken*, mAttributes.Pop());
}
void nsCParserStartNode::GetSource(nsString& aString)
{
aString.Assign(PRUnichar('<'));
const PRUnichar* theTagName =
nsHTMLTags::GetStringValue(nsHTMLTag(mToken->GetTypeID()));
if (theTagName) {
aString.Append(theTagName);
}
PRInt32 index;
PRInt32 size = mAttributes.GetSize();
for (index = 0 ; index < size; ++index) {
CAttributeToken *theToken =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(index));
if (theToken) {
theToken->AppendSourceTo(aString);
aString.Append(PRUnichar(' ')); //this will get removed...
}
}
aString.Append(PRUnichar('>'));
}
nsresult nsCParserStartNode::ReleaseAll()
{
NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
CToken* theAttrToken;
while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
nsCParserNode::ReleaseAll();
return NS_OK;
}

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

@ -157,7 +157,7 @@ class nsCParserNode : public nsIParserNode {
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsString& GetName() const;
virtual const nsAString& GetTagName() const;
/**
* Retrieve the text from the given node
@ -245,15 +245,6 @@ class nsCParserNode : public nsIParserNode {
*/
virtual void GetSource(nsString& aString);
/*
* Get and set the ID attribute atom for this node.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult) const;
virtual nsresult SetIDAttributeAtom(nsIAtom* aID);
/**
* This pair of methods allows us to set a generic bit (for arbitrary use)
* on each node stored in the context.
@ -268,18 +259,66 @@ class nsCParserNode : public nsIParserNode {
*/
virtual nsresult ReleaseAll();
CToken* mToken;
nsDeque* mAttributes;
PRInt32 mUseCount;
PRBool mGenericState;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
nsTokenAllocator* mTokenAllocator;
CToken* mToken;
PRInt32 mUseCount;
PRPackedBool mGenericState;
nsTokenAllocator* mTokenAllocator;
#ifdef HEAP_ALLOCATED_NODES
nsNodeAllocator* mNodeAllocator; // weak
#endif
};
class nsCParserStartNode : public nsCParserNode
{
public:
static nsCParserNode* Create(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
#ifdef HEAP_ALLOCATED_NODES
return new
#else
nsFixedSizeAllocator& pool = aNodeAllocator->GetArenaPool();
void* place = pool.Alloc(sizeof(nsCParserStartNode));
return ::new (place)
#endif
nsCParserStartNode(aToken, aTokenAllocator, aNodeAllocator);
}
nsCParserStartNode()
: mAttributes(0), nsCParserNode() { }
nsCParserStartNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator = 0)
: mAttributes(0), nsCParserNode(aToken, aTokenAllocator, aNodeAllocator) { }
~nsCParserStartNode()
{
NS_ASSERTION(0 != mTokenAllocator, "Error: no token allocator");
CToken* theAttrToken = 0;
while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
virtual nsresult Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator = 0);
virtual void AddAttribute(CToken* aToken);
virtual PRInt32 GetAttributeCount(PRBool askToken = PR_FALSE) const;
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
virtual CToken* PopAttributeToken();
virtual void GetSource(nsString& aString);
virtual nsresult ReleaseAll();
protected:
nsDeque mAttributes;
};
#endif

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

@ -202,7 +202,6 @@ public:
mEndNode(),
mStartNode(),
mTokenNode(),
mErrorNode(),
mITextToken(),
mErrorToken(NS_LITERAL_STRING("error")) {
}
@ -216,9 +215,8 @@ public:
}
nsCParserNode mEndNode;
nsCParserNode mStartNode;
nsCParserNode mTokenNode;
nsCParserNode mErrorNode;
nsCParserStartNode mStartNode;
nsCParserStartNode mTokenNode;
CIndirectTextToken mITextToken;
CTextToken mErrorToken;
};
@ -565,7 +563,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
CStartToken* theToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_link,tag));
if(theToken) {
CAttributeToken *theAttr;
nsCParserNode theNode(theToken, theAllocator);
nsCParserStartNode theNode(theToken, theAllocator);
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_LITERAL_STRING("stylesheet"));
theAttr->SetKey(NS_LITERAL_STRING("rel"));
@ -586,7 +584,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
CEndToken endHeadToken(eHTMLTag_head);
nsCParserNode endHeadNode(&endHeadToken, 0/*stack token*/);
result = mSink->CloseHead(endHeadNode);
result = mSink->CloseHead();
if(NS_SUCCEEDED(result)) {
mHasOpenRoot = PR_TRUE;
if (didBlock) {
@ -599,7 +597,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
tag.Assign(NS_LITERAL_STRING("BODY"));
CStartToken* bodyToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start, eHTMLTag_body, tag));
if (bodyToken) {
nsCParserNode bodyNode(bodyToken, theAllocator);
nsCParserStartNode bodyNode(bodyToken, theAllocator);
CAttributeToken *theAttr=nsnull;
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kBodyId));
theAttr->SetKey(NS_LITERAL_STRING("id"));
@ -679,7 +677,7 @@ nsresult CViewSourceHTML::GenerateSummary() {
void CViewSourceHTML::StartNewPreBlock(void){
CEndToken endToken(eHTMLTag_pre);
nsCParserNode endNode(&endToken, 0/*stack token*/);
mSink->CloseContainer(endNode);
mSink->CloseContainer(eHTMLTag_pre);
CStartToken startToken(eHTMLTag_pre);
nsCParserNode startNode(&startToken, 0/*stack token*/);
@ -727,15 +725,15 @@ NS_IMETHODIMP CViewSourceHTML::DidBuildModel(nsresult anErrorCode,PRBool aNotify
if(ePlainText!=mDocType) {
CEndToken theToken(eHTMLTag_pre);
nsCParserNode preNode(&theToken, 0/*stack token*/);
mSink->CloseContainer(preNode);
mSink->CloseContainer(eHTMLTag_pre);
CEndToken bodyToken(eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken, 0/*stack token*/);
mSink->CloseBody(bodyNode);
mSink->CloseBody();
CEndToken htmlToken(eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken, 0/*stack token*/);
mSink->CloseHTML(htmlNode);
mSink->CloseHTML();
}
result = mSink->DidBuildModel(1);
}
@ -994,7 +992,7 @@ nsresult CViewSourceHTML::WriteTag(PRInt32 aTagType,const nsAString & aText,PRIn
theContext.mStartNode.ReleaseAll();
CEndToken theEndToken(eHTMLTag_span);
theContext.mEndNode.Init(&theEndToken, 0/*stack token*/);
mSink->CloseContainer(theContext.mEndNode); //emit </starttag>...
mSink->CloseContainer(eHTMLTag_span); //emit </starttag>...
#ifdef DUMP_TO_FILE
if (gDumpFile)
fprintf(gDumpFile, "</span>");

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

@ -1,8 +1,7 @@
<html><body>
<table>
<p><h3>Please Enter your Homesite Login, E-mail and Password to delete</h3></p>
<p><h3></h3></p>
<form method="POST">
<input type=submit>
</form>
</table>
</body></html>

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

@ -84,6 +84,7 @@
*/
#include "nsIParserNode.h"
#include "nsIContentSink.h"
#include "nsHTMLTags.h"
#define NS_IHTML_CONTENT_SINK_IID \
{ 0xa6cf9051, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
@ -95,8 +96,8 @@
#define MAX_REFLOW_DEPTH 200 //windows and linux (etc) can do much deeper structures.
#endif
class nsIHTMLContentSink : public nsIContentSink {
class nsIHTMLContentSink : public nsIContentSink
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
@ -108,7 +109,7 @@ public:
* @update 4/1/98 gess
* @param nsString reference to new title value
*/
NS_IMETHOD SetTitle(const nsString& aValue)=0;
NS_IMETHOD SetTitle(const nsString& aValue) = 0;
/**
* This method is used to open the outer HTML container.
@ -116,15 +117,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHTML(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenHTML(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHTML(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseHTML() = 0;
/**
* This method is used to open the only HEAD container.
@ -132,15 +131,12 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHead(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenHead(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseHead(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseHead() = 0;
/**
* This method is used to open the main BODY container.
@ -148,15 +144,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenBody(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenBody(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseBody(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseBody() = 0;
/**
* This method is used to open a new FORM container.
@ -164,15 +158,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenForm(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenForm(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the outer FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseForm(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseForm() = 0;
/**
* This method is used to open a new MAP container.
@ -180,15 +172,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenMap(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenMap(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseMap(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseMap() = 0;
/**
* This method is used to open the FRAMESET container.
@ -196,15 +186,13 @@ public:
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode)=0;
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode)=0;
NS_IMETHOD CloseFrameset() = 0;
/**
* This method tells the sink whether or not it is
@ -215,7 +203,7 @@ public:
* @param aFlag set to true if only encoding a fragment
*/
NS_IMETHOD DoFragment(PRBool aFlag)=0;
NS_IMETHOD DoFragment(PRBool aFlag) = 0;
/**
* This gets called when handling illegal contents, especially
@ -224,7 +212,7 @@ public:
* @update 04/04/99 harishd
* @param aPosition - The position from where the new context begins.
*/
NS_IMETHOD BeginContext(PRInt32 aPosition)=0;
NS_IMETHOD BeginContext(PRInt32 aPosition) = 0;
/**
* This method terminates any new context that got created by
@ -233,7 +221,7 @@ public:
* @update 04/04/99 harishd
* @param aPosition - Validates the end of a context.
*/
NS_IMETHOD EndContext(PRInt32 aPosition)=0;
NS_IMETHOD EndContext(PRInt32 aPosition) = 0;
/**
* Use this method to retrieve pref. for the tag.
@ -241,13 +229,13 @@ public:
* @update 04/11/01 harishd
* @param aTag - Check pref. for this tag.
*/
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref)=0;
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) = 0;
/**
* This method is called when parser is about to begin
* synchronously processing a chunk of tokens.
*/
NS_IMETHOD WillProcessTokens(void)=0;
NS_IMETHOD WillProcessTokens(void) = 0;
/**
* This method is called when parser has
@ -255,13 +243,13 @@ public:
* tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
* DidProcessAToken.
*/
NS_IMETHOD DidProcessTokens()=0;
NS_IMETHOD DidProcessTokens() = 0;
/**
* This method is called when parser is about to
* process a single token
*/
NS_IMETHOD WillProcessAToken(void)=0;
NS_IMETHOD WillProcessAToken(void) = 0;
/**
* This method is called when parser has completed
@ -269,7 +257,7 @@ public:
* @return NS_OK if processing should not be interrupted
* NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
*/
NS_IMETHOD DidProcessAToken(void)=0;
NS_IMETHOD DidProcessAToken(void) = 0;
/**
* This method is used to open a generic container in the sink.
@ -283,10 +271,9 @@ public:
* This method gets called by the parser when a close
* container tag has been consumed and needs to be closed.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
* @param aTag - The tag to be closed.
*/
NS_IMETHOD CloseContainer(const nsIParserNode& aNode) = 0;
NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
/**
* This gets called by the parser when you want to add
@ -326,7 +313,7 @@ public:
*
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode)=0;
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) = 0;
/**
* This gets called by the parser to notify observers of
@ -334,7 +321,7 @@ public:
*
* @param aErrorResult the error code
*/
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode)=0;
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) = 0;
/**
* Call this method to determnine if a FORM is on the sink's stack
@ -346,9 +333,7 @@ public:
};
#ifdef NS_DEBUG
extern nsresult NS_NewHTMLNullSink(nsIContentSink** aInstancePtrResult);
#endif
#endif /* nsIHTMLContentSink_h___ */

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

@ -90,14 +90,14 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsString& GetName() const =0; //to get name of tag
virtual const nsAString& GetTagName() const = 0; //to get name of tag
/**
* Retrieve the text from the given node
* @update gess5/11/98
* @return string containing node text
*/
virtual const nsAString& GetText() const =0; //get plain text if available
virtual const nsAString& GetText() const = 0; //get plain text if available
/**
* Retrieve the type of the parser node.
@ -126,7 +126,7 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const =0;
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const = 0;
/**
* Retrieve the value (of key/value pair) at given index
@ -134,7 +134,7 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsAString& GetValueAt(PRUint32 anIndex) const =0;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const = 0;
/**
* NOTE: When the node is an entity, this will translate the entity
@ -175,15 +175,6 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @return void
*/
virtual nsresult ReleaseAll()=0;
/*
* Get and set the ID attribute atom for this node.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult) const = 0;
virtual nsresult SetIDAttributeAtom(nsIAtom* aID) = 0;
};
#endif

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

@ -78,22 +78,22 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD CloseTopmostContainer();
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
@ -187,7 +187,7 @@ NS_IMETHODIMP RobotSink::OpenHTML(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseHTML(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseHTML()
{
return NS_OK;
}
@ -197,7 +197,7 @@ NS_IMETHODIMP RobotSink::OpenHead(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseHead(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseHead()
{
return NS_OK;
}
@ -207,7 +207,7 @@ NS_IMETHODIMP RobotSink::OpenBody(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseBody(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseBody()
{
return NS_OK;
}
@ -217,7 +217,7 @@ NS_IMETHODIMP RobotSink::OpenForm(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseForm(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseForm()
{
return NS_OK;
}
@ -227,7 +227,7 @@ NS_IMETHODIMP RobotSink::OpenMap(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseMap(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseMap()
{
return NS_OK;
}
@ -237,7 +237,7 @@ NS_IMETHODIMP RobotSink::OpenFrameset(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseFrameset(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseFrameset()
{
return NS_OK;
}
@ -277,7 +277,7 @@ NS_IMETHODIMP RobotSink::OpenContainer(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseContainer(const nsIParserNode& aNode)
NS_IMETHODIMP RobotSink::CloseContainer(const nsHTMLTag aTag)
{
return NS_OK;
}

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

@ -612,12 +612,9 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
//If you're here, then an error occured, but we still have nodes on the stack.
//At a minimum, we should grab the nodes and recycle them.
//Just to be correct, we'll also recycle the nodes.
while(mBodyContext->GetCount() > 0) {
nsEntryStack *theChildStyles=0;
nsCParserNode* theNode=mBodyContext->Pop(theChildStyles);
nsEntryStack* theChildStyles = 0;
nsCParserNode* theNode = mBodyContext->Pop(theChildStyles);
IF_DELETE(theChildStyles,&mNodeAllocator);
IF_FREE(theNode, &mNodeAllocator);
}
@ -1245,14 +1242,13 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
eProcessRule theRule=eNormalOp;
if((!theParentContains) &&
(IsBlockElement(aChildTag,theParentTag) &&
IsInlineElement(theParentTag,theParentTag))) { //broaden this to fix <inline><block></block></inline>
if(eHTMLTag_li!=aChildTag) { //remove test for table to fix 57554
nsCParserNode* theParentNode= NS_STATIC_CAST(nsCParserNode*, mBodyContext->PeekNode());
if(theParentNode->mToken->IsWellFormed()) {
theRule=eLetInlineContainBlock;
if (!theParentContains &&
(IsBlockElement(aChildTag,theParentTag) &&
IsInlineElement(theParentTag,theParentTag))) { //broaden this to fix <inline><block></block></inline>
if (eHTMLTag_li != aChildTag) { //remove test for table to fix 57554
nsCParserNode* theParentNode = NS_STATIC_CAST(nsCParserNode*, mBodyContext->PeekNode());
if (theParentNode && theParentNode->mToken->IsWellFormed()) {
theRule = eLetInlineContainBlock;
}
}
}
@ -1459,19 +1455,15 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
}
//this code is here to make sure the head is closed before we deal
//with any tags that don't belong in the head.
//this code is here to make sure the head is closed before we deal
//with any tags that don't belong in the head.
if(NS_OK==result) {
if(mOpenHeadCount>0){
static eHTMLTags skip2[]={eHTMLTag_newline,eHTMLTag_whitespace};
if(!FindTagInSet(aTag,skip2,sizeof(skip2)/sizeof(eHTMLTag_unknown))){
PRBool theExclusive=PR_FALSE;
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive)){
//because this code calls CloseHead() directly, stack-based token/nodes are ok.
CEndToken theToken(eHTMLTag_head);
nsCParserNode theNode(&theToken, 0 /*stack token*/);
result=CloseHead(&theNode);
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive)){
result = CloseHead();
}
}
}
@ -1943,16 +1935,13 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
break;
case eHTMLTag_head:
StripWSFollowingTag(theChildTag,mTokenizer,mTokenAllocator,mLineNumber);
StripWSFollowingTag(theChildTag,mTokenizer, mTokenAllocator, mLineNumber);
mFlags &= ~NS_DTD_FLAG_REQUESTED_HEAD;
//ok to fall through...
result = CloseContainer(eHTMLTag_head, theChildTag, PR_FALSE);
break;
case eHTMLTag_form:
{
//this is safe because we call close container directly. This node/token is not cached.
nsCParserNode theNode((CHTMLToken*)aToken, mTokenAllocator);
result=CloseContainer(&theNode,theChildTag,PR_FALSE);
}
result = CloseContainer(eHTMLTag_form, theChildTag, PR_FALSE);
break;
case eHTMLTag_br:
@ -2082,14 +2071,7 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
START_TIMER()
// The body context should contain contents only upto the marked position.
PRInt32 i=0;
nsEntryStack* theChildStyleStack=0;
for(i=0; i<(theTagCount - theTopIndex); ++i) {
nsCParserNode* node=mBodyContext->Pop(theChildStyleStack);
mTempContext->Push(node);
IF_FREE(node, &mNodeAllocator); //release the popped node since push will addref for us.
}
mBodyContext->MoveEntries(*mTempContext, theTagCount - theTopIndex);
// Now flush out all the bad contents.
while(theBadTokenCount-- > 0){
@ -2128,11 +2110,7 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
// Bad-contents were successfully processed. Now, itz time to get
// back to the original body context state.
for(PRInt32 k=0; k<(theTagCount - theTopIndex); ++k) {
nsCParserNode* node=mTempContext->Pop(theChildStyleStack);
mBodyContext->Push(node);
IF_FREE(node, &mNodeAllocator);
}
mTempContext->MoveEntries(*mBodyContext, theTagCount - theTopIndex);
STOP_TIMER()
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleSavedTokensAbove(), this=%p\n", this));
@ -2994,27 +2972,7 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aChildTag){
* @return 0 (for now)
*/
nsresult CNavDTD::CloseTransientStyles(eHTMLTags aChildTag){
nsresult result=NS_OK;
if(mFlags & NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE) {
#ifdef ENABLE_RESIDUALSTYLE
#if 0
int theTagPos=0;
//now iterate style set, and close the containers...
nsEntryStack* theStack=mBodyContext->GetStylesAt();
for(theTagPos=mBodyContext->mOpenStyles;theTagPos>0;theTagPos--){
eHTMLTags theTag=GetTopNode();
CStartToken token(theTag);
nsCParserNode theNode(&token, 0 /*stack token*/);
token.SetTypeID(theTag);
result=CloseContainer(theNode,theTag,PR_FALSE);
}
#endif
#endif
} //if
return result;
return NS_OK;
}
/**
@ -3054,14 +3012,14 @@ nsresult CNavDTD::OpenHTML(const nsCParserNode *aNode){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
nsresult result=(mSink) ? mSink->OpenHTML(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->OpenHTML(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
START_TIMER();
// Don't push more than one HTML tag into the stack...
if(mBodyContext->GetCount()==0)
mBodyContext->Push(aNode);
if (mBodyContext->GetCount() == 0)
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
return result;
}
@ -3075,12 +3033,12 @@ nsresult CNavDTD::OpenHTML(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseHTML(const nsIParserNode *aNode){
nsresult CNavDTD::CloseHTML(){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseHTML(), this=%p\n", this));
nsresult result=(mSink) ? mSink->CloseHTML(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->CloseHTML() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseHTML(), this=%p\n", this));
START_TIMER();
@ -3104,7 +3062,7 @@ nsresult CNavDTD::OpenHead(const nsIParserNode *aNode){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenHead(), this=%p\n", this));
if(!mOpenHeadCount++) {
if (!mOpenHeadCount++) {
result=(mSink) ? mSink->OpenHead(*aNode) : NS_OK;
}
@ -3122,19 +3080,17 @@ nsresult CNavDTD::OpenHead(const nsIParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseHead(const nsIParserNode *aNode){
nsresult CNavDTD::CloseHead(){
nsresult result=NS_OK;
if(mOpenHeadCount && --mOpenHeadCount==0) {
if (mOpenHeadCount && --mOpenHeadCount==0) {
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseHead(), this=%p\n", this));
result=(mSink) ? mSink->CloseHead(*aNode) : NS_OK;
result = (mSink) ? mSink->CloseHead() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseHead(), this=%p\n", this));
START_TIMER();
}
return result;
@ -3148,7 +3104,8 @@ nsresult CNavDTD::CloseHead(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenBody(const nsCParserNode *aNode){
nsresult CNavDTD::OpenBody(const nsCParserNode *aNode)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
nsresult result = NS_OK;
@ -3166,7 +3123,7 @@ nsresult CNavDTD::OpenBody(const nsCParserNode *aNode){
START_TIMER();
if (!HasOpenContainer(eHTMLTag_body)) {
mBodyContext->Push(aNode);
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
mTokenizer->PrependTokens(mMisplacedContent);
}
}
@ -3182,13 +3139,12 @@ nsresult CNavDTD::OpenBody(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseBody(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
nsresult CNavDTD::CloseBody()
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseBody(), this=%p\n", this));
nsresult result=(mSink) ? mSink->CloseBody(*aNode) : NS_OK;
nsresult result= (mSink) ? mSink->CloseBody() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseBody(), this=%p\n", this));
START_TIMER();
@ -3204,19 +3160,18 @@ nsresult CNavDTD::CloseBody(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
nsresult result=NS_OK;
if(!(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
nsresult CNavDTD::OpenForm(const nsIParserNode *aNode)
{
nsresult result = NS_OK;
if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenForm(), this=%p\n", this));
result=(mSink) ? mSink->OpenForm(*aNode) : NS_OK;
result = (mSink) ? mSink->OpenForm(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenForm(), this=%p\n", this));
START_TIMER();
if(NS_OK==result) {
if (NS_OK == result) {
mFlags |= NS_DTD_FLAG_HAS_OPEN_FORM;
}
}
@ -3232,16 +3187,15 @@ nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
if(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM) {
nsresult CNavDTD::CloseForm()
{
nsresult result = NS_OK;
if (mFlags & NS_DTD_FLAG_HAS_OPEN_FORM) {
mFlags &= ~NS_DTD_FLAG_HAS_OPEN_FORM;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
result=(mSink) ? mSink->CloseForm(*aNode) : NS_OK;
result = (mSink) ? mSink->CloseForm() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
START_TIMER();
@ -3257,18 +3211,18 @@ nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenMap(const nsCParserNode *aNode){
nsresult CNavDTD::OpenMap(const nsCParserNode *aNode)
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
nsresult result=(mSink) ? mSink->OpenMap(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->OpenMap(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
START_TIMER();
if(NS_OK==result) {
mBodyContext->Push(aNode);
if (NS_OK == result) {
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
++mOpenMapCount;
}
return result;
@ -3282,20 +3236,18 @@ nsresult CNavDTD::OpenMap(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
if(mOpenMapCount) {
nsresult CNavDTD::CloseMap()
{
nsresult result = NS_OK;
if (mOpenMapCount) {
mOpenMapCount--;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
result=(mSink) ? mSink->CloseMap(*aNode) : NS_OK;
result = (mSink) ? mSink->CloseMap() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
START_TIMER();
}
return result;
}
@ -3308,20 +3260,19 @@ nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenFrameset(const nsCParserNode *aNode){
nsresult CNavDTD::OpenFrameset(const nsCParserNode *aNode)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
mFlags |= NS_DTD_FLAG_HAD_FRAMESET;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenFrameset(), this=%p\n", this));
nsresult result=(mSink) ? mSink->OpenFrameset(*aNode) : NS_OK;
nsresult result =( mSink) ? mSink->OpenFrameset(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenFrameset(), this=%p\n", this));
START_TIMER();
mBodyContext->Push(aNode);
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
return result;
}
@ -3334,13 +3285,12 @@ nsresult CNavDTD::OpenFrameset(const nsCParserNode *aNode){
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseFrameset(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult CNavDTD::CloseFrameset()
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseFrameset(), this=%p\n", this));
nsresult result=(mSink) ? mSink->CloseFrameset(*aNode) : NS_OK;
nsresult result = (mSink) ? mSink->CloseFrameset() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseFrameset(), this=%p\n", this));
START_TIMER();
@ -3358,14 +3308,18 @@ nsresult CNavDTD::CloseFrameset(const nsIParserNode *aNode){
* @return TRUE if ok, FALSE if error
*/
nsresult
CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedByStartTag,nsEntryStack* aStyleStack){
CNavDTD::OpenContainer(const nsCParserNode *aNode,
eHTMLTags aTag,
PRBool aClosedByStartTag,
nsEntryStack* aStyleStack)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
nsresult result=NS_OK;
PRBool done=PR_TRUE;
nsresult result = NS_OK;
PRBool done = PR_TRUE;
PRBool rs_tag = nsHTMLElement::IsResidualStyleTag(aTag);
if (nsHTMLElement::IsResidualStyleTag(aTag)) {
if (rs_tag) {
/***********************************************************************
* Here's an interesting problem:
*
@ -3385,8 +3339,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct));
#endif
switch(aTag) {
switch (aTag) {
case eHTMLTag_html:
result=OpenHTML(aNode); break;
@ -3404,7 +3357,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
mOpenHeadCount=1;
}
mFlags |= NS_DTD_FLAG_HAS_OPEN_BODY;
CloseHead(aNode); //do this just in case someone left it open...
CloseHead(); //do this just in case someone left the HEAD open...
result=OpenBody(aNode);
}
else {
@ -3437,7 +3390,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
// XXX - But what did we actually do in counting the heads?
mOpenHeadCount=1;
}
CloseHead(aNode); //do this just in case someone left it open...
CloseHead(); //do this just in case someone left it open...
result=OpenFrameset(aNode); break;
case eHTMLTag_script:
@ -3446,7 +3399,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
// XXX - But what did we actually do in counting the heads?
mOpenHeadCount=1;
}
CloseHead(aNode); //do this just in case someone left it open...
CloseHead(); //do this just in case someone left it open...
result=HandleScriptToken(aNode);
break;
@ -3475,7 +3428,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
break;
}
if(!done) {
if (!done) {
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenContainer(), this=%p\n", this));
@ -3483,8 +3436,9 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenContainer(), this=%p\n", this));
START_TIMER();
mBodyContext->Push(aNode,aStyleStack);
// For residual style tags rs_tag will be true and hence
// the body context will hold an extra reference to the node.
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), aStyleStack, rs_tag);
}
return result;
@ -3501,43 +3455,42 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
* @return TRUE if ok, FALSE if error
*/
nsresult
CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClosedByStartTag){
nsresult result=NS_OK;
eHTMLTags nodeType=(eHTMLTags)aNode->GetNodeType();
CNavDTD::CloseContainer(const eHTMLTags aTag, eHTMLTags aTarget,PRBool aClosedByStartTag)
{
nsresult result = NS_OK;
#ifdef ENABLE_CRC
#define K_CLOSEOP 200
CRCStruct theStruct(nodeType,K_CLOSEOP);
mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct));
#endif
switch(nodeType) {
switch (aTag) {
case eHTMLTag_html:
result=CloseHTML(aNode); break;
result=CloseHTML(); break;
case eHTMLTag_style:
case eHTMLTag_textarea:
break;
case eHTMLTag_head:
result=CloseHead(aNode);
result=CloseHead();
break;
case eHTMLTag_body:
result=CloseBody(aNode);
result=CloseBody();
break;
case eHTMLTag_map:
result=CloseMap(aNode);
result=CloseMap();
break;
case eHTMLTag_form:
result=CloseForm(aNode);
result=CloseForm();
break;
case eHTMLTag_frameset:
result=CloseFrameset(aNode);
result=CloseFrameset();
break;
case eHTMLTag_iframe:
@ -3548,15 +3501,13 @@ CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClo
// falling thro' intentionally....
case eHTMLTag_title:
default:
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
result=(mSink) ? mSink->CloseContainer(*aNode) : NS_OK;
result=(mSink) ? mSink->CloseContainer(aTag) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
START_TIMER();
break;
}
@ -3573,23 +3524,20 @@ CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClo
* @param aClosedByStartTag -- if TRUE, then we're closing something because a start tag caused it
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aClosedByStartTag){
nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aClosedByStartTag)
{
NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
nsresult result = NS_OK;
if ((anIndex<mBodyContext->GetCount()) && (anIndex>=0)) {
if((anIndex<mBodyContext->GetCount()) && (anIndex>=0)) {
PRInt32 count = 0;
while ((count = mBodyContext->GetCount()) > anIndex) {
nsEntryStack* theChildStyleStack = 0;
eHTMLTags theTag = mBodyContext->Last();
nsCParserNode* theNode = mBodyContext->Pop(theChildStyleStack);
result = CloseContainer(theTag, aTarget,aClosedByStartTag);
PRInt32 count=0;
while((count=mBodyContext->GetCount())>anIndex) {
nsEntryStack *theChildStyleStack=0;
eHTMLTags theTag=mBodyContext->Last();
nsCParserNode *theNode=mBodyContext->Pop(theChildStyleStack);
if(theNode) {
result=CloseContainer(theNode,aTarget,aClosedByStartTag);
#ifdef ENABLE_RESIDUALSTYLE
PRBool theTagIsStyle=nsHTMLElement::IsResidualStyleTag(theTag);
@ -3605,9 +3553,13 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
*************************************************************/
if(theTagIsStyle && !(mFlags & NS_DTD_FLAG_ALTERNATE_CONTENT)) {
PRBool theTargetTagIsStyle=nsHTMLElement::IsResidualStyleTag(aTarget);
NS_ASSERTION(theNode, "residual style node should not be null");
if (!theNode) {
if (theChildStyleStack)
mBodyContext->PushStyles(theChildStyleStack);
return NS_OK;
}
PRBool theTargetTagIsStyle = nsHTMLElement::IsResidualStyleTag(aTarget);
if(aClosedByStartTag) {
/***********************************************************
@ -3618,25 +3570,24 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
2. <body><a>text<a> //in this case, the target matches, so don't push style
***************************************************************************/
if(0==theNode->mUseCount){
if(theTag!=aTarget) {
if (theNode->mUseCount == 0){
if (theTag != aTarget) {
//don't push if thechild==theTarget
if(theChildStyleStack) {
if (theChildStyleStack)
theChildStyleStack->PushFront(theNode);
}
else mBodyContext->PushStyle(theNode);
else
mBodyContext->PushStyle(theNode);
}
}
else if((theTag==aTarget) && (!gHTMLElements[aTarget].CanContainSelf())) {
else if (theTag == aTarget && !gHTMLElements[aTarget].CanContainSelf()) {
//here's a case we missed: <a><div>text<a>text</a></div>
//The <div> pushes the 1st <a> onto the rs-stack, then the 2nd <a>
//pops the 1st <a> from the rs-stack altogether.
nsCParserNode* node=mBodyContext->PopStyle(theTag);
nsCParserNode* node = mBodyContext->PopStyle(theTag);
IF_FREE(node, &mNodeAllocator);
}
if(theChildStyleStack) {
if (theChildStyleStack) {
mBodyContext->PushStyles(theChildStyleStack);
}
}
@ -3666,14 +3617,14 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
In this case, the <b> is simply closed.
***************************************************************************/
if(theChildStyleStack) {
if(!theStyleDoesntLeakOut) {
if(theTag!=aTarget) {
if (0==theNode->mUseCount) {
if (theChildStyleStack) {
if (!theStyleDoesntLeakOut) {
if (theTag != aTarget) {
if (theNode->mUseCount == 0) {
theChildStyleStack->PushFront(theNode);
}
}
else if(1==theNode->mUseCount) {
else if (theNode->mUseCount == 1) {
// This fixes bug 30885,29626.
// Make sure that the node, which is about to
// get released does not stay on the style stack...
@ -3689,11 +3640,11 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
IF_DELETE(theChildStyleStack,&mNodeAllocator);
}
}
else if (0==theNode->mUseCount) {
else if (theNode->mUseCount == 0) {
//The old version of this only pushed if the targettag wasn't style.
//But that misses this case: <font><b>text</font>, where the b should leak
if(aTarget!=theTag) {
if (aTarget != theTag) {
mBodyContext->PushStyle(theNode);
}
}
@ -3712,16 +3663,15 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
} //if
else {
//the tag is not a style tag...
if(theChildStyleStack) {
if(theStyleDoesntLeakOut) {
if (theChildStyleStack) {
if (theStyleDoesntLeakOut)
IF_DELETE(theChildStyleStack,&mNodeAllocator);
}
else mBodyContext->PushStyles(theChildStyleStack);
else
mBodyContext->PushStyles(theChildStyleStack);
}
}
#endif
IF_FREE(theNode, &mNodeAllocator);
}//if theNode
}
} //if
@ -3867,7 +3817,7 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){
// Fix for Bug 31392
// Do not leave a head context open no matter what the result is.
nsresult rv=CloseHead(aNode);
nsresult rv = CloseHead();
NS_ENSURE_SUCCESS(rv,rv);
}

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

@ -280,7 +280,10 @@ public:
nsresult OpenForm(const nsIParserNode *aNode);
nsresult OpenMap(const nsCParserNode *aNode);
nsresult OpenFrameset(const nsCParserNode *aNode);
nsresult OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedByStartTag,nsEntryStack* aStyleStack=0);
nsresult OpenContainer(const nsCParserNode *aNode,
eHTMLTags aTag,
PRBool aClosedByStartTag,
nsEntryStack* aStyleStack=0);
/**
* The next set of methods close the given HTML element.
@ -289,12 +292,12 @@ public:
* @param HTML (node) to be opened in content sink.
* @return error code - 0 if all went well.
*/
nsresult CloseHTML(const nsIParserNode *aNode);
nsresult CloseHead(const nsIParserNode *aNode);
nsresult CloseBody(const nsIParserNode *aNode);
nsresult CloseForm(const nsIParserNode *aNode);
nsresult CloseMap(const nsIParserNode *aNode);
nsresult CloseFrameset(const nsIParserNode *aNode);
nsresult CloseHTML();
nsresult CloseHead();
nsresult CloseBody();
nsresult CloseForm();
nsresult CloseMap();
nsresult CloseFrameset();
/**
* The special purpose methods automatically close
@ -302,9 +305,14 @@ public:
* @update gess5/11/98
* @return error code - 0 if all went well.
*/
nsresult CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClosedByStartTag);
nsresult CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag);
nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aClosedByStartTag);
nsresult CloseContainer(const eHTMLTags aTag,
eHTMLTags aTarget,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(eHTMLTags aTag,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(PRInt32 anIndex,
eHTMLTags aTag,
PRBool aClosedByStartTag);
/**
* Causes leaf to be added to sink at current vector pos.

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

@ -443,37 +443,40 @@ nsresult COtherDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIPar
PRInt32 theIndex=mBodyContext->GetCount()-1;
eHTMLTags theChild = mBodyContext->TagAt(theIndex);
while(theIndex>0) {
eHTMLTags theParent= mBodyContext->TagAt(--theIndex);
CElement *theElement=gElementTable->mElements[theParent];
nsCParserNode *theNode=mBodyContext->PeekNode();
while (theIndex>0) {
eHTMLTags theParent = mBodyContext->TagAt(--theIndex);
CElement *theElement = gElementTable->mElements[theParent];
nsCParserNode *theNode = mBodyContext->PeekNode();
theElement->HandleEndToken(theNode,theChild,mBodyContext,mSink);
theChild=theParent;
theChild = theParent;
}
nsEntryStack *theChildStyles=0;
nsCParserNode* theNode=(nsCParserNode*)mBodyContext->Pop(theChildStyles);
if(theNode) {
mSink->CloseHTML(*theNode);
nsEntryStack* theChildStyles = 0;
nsCParserNode* theNode = (nsCParserNode*)mBodyContext->Pop(theChildStyles);
if (theNode) {
mSink->CloseHTML();
}
NS_ASSERTION(!theChildStyles, "there should no residual style information in this dtd");
IF_DELETE(theChildStyles, mNodeAllocator);
}
else {
//If you're here, then an error occured, but we still have nodes on the stack.
//At a minimum, we should grab the nodes and recycle them.
//Just to be correct, we'll also recycle the nodes.
while(mBodyContext->GetCount() > 0) {
while (mBodyContext->GetCount() > 0) {
nsEntryStack *theChildStyles=0;
nsCParserNode* theNode=(nsCParserNode*)mBodyContext->Pop(theChildStyles);
if(theNode) {
theNode->mUseCount=0;
if(theChildStyles) {
nsEntryStack *theChildStyles = 0;
nsCParserNode* theNode = (nsCParserNode*)mBodyContext->Pop(theChildStyles);
if (theNode) {
theNode->mUseCount = 0;
if (theChildStyles) {
delete theChildStyles;
}
IF_FREE(theNode, mNodeAllocator);
}
NS_ASSERTION(!theChildStyles, "there should no residual style information in this dtd");
IF_DELETE(theChildStyles, mNodeAllocator);
}
}
@ -481,7 +484,7 @@ nsresult COtherDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIPar
} //if aparser
//No matter what, you need to call did build model.
result=aSink->DidBuildModel(0);
result = aSink->DidBuildModel(0);
} //if asink
return result;
@ -721,7 +724,7 @@ nsresult COtherDTD::HandleStartToken(CToken* aToken) {
case eHTMLTag_html:
if(!mBodyContext->HasOpenContainer(theChildTag)){
mSink->OpenHTML(*theNode);
mBodyContext->Push(theNode,0);
mBodyContext->Push(theNode, 0, PR_FALSE);
}
theTagWasHandled=PR_TRUE;
break;

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

@ -305,11 +305,9 @@ public:
this gets called after each tag is opened in the given context
**********************************************************/
virtual nsresult OpenContext(nsCParserNode *aNode,eHTMLTags aTag,nsDTDContext *aContext,nsIHTMLContentSink *aSink) {
aContext->Push(aNode);
CElement *theElement=(aTag==mTag) ? this : GetElement(aTag);
theElement->NotifyOpen(aNode,aTag,aContext,aSink);
aContext->Push(aNode, 0, PR_FALSE);
CElement *theElement = (aTag == mTag) ? this : GetElement(aTag);
theElement->NotifyOpen(aNode, aTag, aContext,aSink);
return NS_OK;
}
@ -325,7 +323,7 @@ public:
this gets called to close a given tag in the sink
**********************************************************/
virtual nsresult CloseContainer(nsIParserNode *aNode,eHTMLTags aTag,nsDTDContext *aContext,nsIHTMLContentSink *aSink) {
return aSink->CloseContainer(*aNode);
return aSink->CloseContainer(aTag);
}
/**********************************************************
@ -1175,7 +1173,7 @@ public:
nsresult result=NS_OK;
if(aSink && aContext) {
if(aContext->mFlags.mHasOpenHead==PR_TRUE) {
result=aSink->CloseHead(*aNode);
result = aSink->CloseHead();
aContext->mFlags.mHasOpenHead=PR_FALSE;
}
}
@ -1668,14 +1666,14 @@ public:
switch(aTag) {
case eHTMLTag_html:
if(aContext->HasOpenContainer(aTag)) {
result=aSink->CloseHTML(*aNode);
result=aSink->CloseHTML();
CloseContext(aNode,aTag,aContext,aSink);
}
break;
case eHTMLTag_body:
if(aContext->HasOpenContainer(aTag)) {
result=aSink->CloseBody(*aNode);
result=aSink->CloseBody();
CloseContext(aNode,aTag,aContext,aSink);
}
break;
@ -1839,18 +1837,18 @@ public:
switch(aTag) {
case eHTMLTag_body:
aSink->CloseBody(*aNode);
aSink->CloseBody();
result=CloseContext(aNode,aTag,aContext,aSink);
break;
case eHTMLTag_frameset:
aSink->CloseFrameset(*aNode);
aSink->CloseFrameset();
result=CloseContext(aNode,aTag,aContext,aSink);
break;
case eHTMLTag_object:
result=CloseContainerInContext(aNode,aTag,aContext,aSink);
aSink->CloseHead(*aNode);
aSink->CloseHead();
break;
case eHTMLTag_script:

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

@ -155,18 +155,18 @@ void nsEntryStack::EnsureCapacityFor(PRInt32 aNewMax,PRInt32 aShiftOffset) {
*
* @update gess 04/22/99
*/
void nsEntryStack::Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
void nsEntryStack::Push(nsCParserNode* aNode,
nsEntryStack* aStyleStack,
PRBool aRefCntNode)
{
if(aNode) {
EnsureCapacityFor(mCount+1);
((nsCParserNode*)aNode)->mUseCount++;
mEntries[mCount].mTag=(eHTMLTags)aNode->GetNodeType();
mEntries[mCount].mNode=NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[mCount].mNode);
mEntries[mCount].mTag = (eHTMLTags)aNode->GetNodeType();
if (aRefCntNode) {
aNode->mUseCount++;
mEntries[mCount].mNode = NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[mCount].mNode);
}
mEntries[mCount].mParent=aStyleStack;
mEntries[mCount++].mStyles=0;
}
@ -178,25 +178,26 @@ void nsEntryStack::Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
*
* @update gess 11/10/99
*/
void nsEntryStack::PushFront(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
void nsEntryStack::PushFront(nsCParserNode* aNode,
nsEntryStack* aStyleStack,
PRBool aRefCntNode)
{
if(aNode) {
if(mCount<mCapacity) {
PRInt32 index=0;
for(index=mCount;index>0;index--) {
mEntries[index]=mEntries[index-1];
}
}
else EnsureCapacityFor(mCount+1,1);
((nsCParserNode*)aNode)->mUseCount++;
mEntries[0].mTag=(eHTMLTags)aNode->GetNodeType();
mEntries[0].mNode=NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[0].mNode);
else {
EnsureCapacityFor(mCount+1,1);
}
mEntries[0].mTag = (eHTMLTags)aNode->GetNodeType();
if (aRefCntNode) {
aNode->mUseCount++;
mEntries[0].mNode = NS_CONST_CAST(nsCParserNode*,aNode);
IF_HOLD(mEntries[0].mNode);
}
mEntries[0].mParent=aStyleStack;
mEntries[0].mStyles=0;
++mCount;
@ -235,34 +236,30 @@ void nsEntryStack::Append(nsEntryStack *aStack) {
* aTag: the id of the tag to be removed
* @update gess 02/25/00
*/
nsCParserNode* nsEntryStack::Remove(PRInt32 anIndex,eHTMLTags aTag) {
nsCParserNode* result=0;
if((0<mCount) && (anIndex<mCount)){
result=mEntries[anIndex].mNode;
((nsCParserNode*)result)->mUseCount--;
PRInt32 theIndex=0;
mCount-=1;
for(theIndex=anIndex;theIndex<mCount;++theIndex){
mEntries[theIndex]=mEntries[theIndex+1];
nsCParserNode* nsEntryStack::Remove(PRInt32 anIndex,
eHTMLTags aTag)
{
nsCParserNode* result = 0;
if (0 < mCount && anIndex < mCount){
result = mEntries[anIndex].mNode;
if (result)
result->mUseCount--;
PRInt32 theIndex = 0;
mCount -= 1;
for( theIndex = anIndex; theIndex < mCount; ++theIndex){
mEntries[theIndex] = mEntries[theIndex+1];
}
mEntries[mCount].mNode=0;
mEntries[mCount].mStyles=0;
nsEntryStack* theStyleStack=mEntries[anIndex].mParent;
if(theStyleStack) {
mEntries[mCount].mNode = 0;
mEntries[mCount].mStyles = 0;
nsEntryStack* theStyleStack = mEntries[anIndex].mParent;
if (theStyleStack) {
//now we have to tell the residual style stack where this tag
//originated that it's no longer in use.
PRUint32 scount=theStyleStack->mCount;
PRUint32 sindex=0;
PRUint32 scount = theStyleStack->mCount;
PRUint32 sindex = 0;
nsTagEntry *theStyleEntry=theStyleStack->mEntries;
for(sindex=scount-1;sindex>0;--sindex){
if(theStyleEntry->mTag==aTag) {
for (sindex=scount-1;sindex>0;--sindex){
if (theStyleEntry->mTag==aTag) {
theStyleEntry->mParent=0; //this tells us that the style is not open at any level
break;
}
@ -278,29 +275,24 @@ nsCParserNode* nsEntryStack::Remove(PRInt32 anIndex,eHTMLTags aTag) {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
nsCParserNode* nsEntryStack::Pop(void) {
nsCParserNode* result=0;
if(0<mCount) {
result=mEntries[--mCount].mNode;
((nsCParserNode*)result)->mUseCount--;
mEntries[mCount].mNode=0;
mEntries[mCount].mStyles=0;
nsCParserNode* nsEntryStack::Pop(void)
{
nsCParserNode* result = 0;
if (0 < mCount) {
result = mEntries[--mCount].mNode;
if (result)
result->mUseCount--;
mEntries[mCount].mNode = 0;
mEntries[mCount].mStyles = 0;
nsEntryStack* theStyleStack=mEntries[mCount].mParent;
if(theStyleStack) {
if (theStyleStack) {
//now we have to tell the residual style stack where this tag
//originated that it's no longer in use.
PRUint32 scount=theStyleStack->mCount;
PRUint32 sindex=0;
PRUint32 scount = theStyleStack->mCount;
PRUint32 sindex = 0;
nsTagEntry *theStyleEntry=theStyleStack->mEntries;
for(sindex=scount-1;sindex>0;--sindex){
if(theStyleEntry->mTag==mEntries[mCount].mTag) {
for (sindex=scount-1;sindex>0;--sindex){
if (theStyleEntry->mTag==mEntries[mCount].mTag) {
theStyleEntry->mParent=0; //this tells us that the style is not open at any level
break;
}
@ -316,7 +308,8 @@ nsCParserNode* nsEntryStack::Pop(void) {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::First() const {
eHTMLTags nsEntryStack::First() const
{
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount){
result=mEntries[0].mTag;
@ -329,7 +322,8 @@ eHTMLTags nsEntryStack::First() const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
nsCParserNode* nsEntryStack::NodeAt(PRInt32 anIndex) const {
nsCParserNode* nsEntryStack::NodeAt(PRInt32 anIndex) const
{
nsCParserNode* result=0;
if((0<mCount) && (anIndex<mCount)) {
result=mEntries[anIndex].mNode;
@ -342,7 +336,8 @@ nsCParserNode* nsEntryStack::NodeAt(PRInt32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::TagAt(PRInt32 anIndex) const {
eHTMLTags nsEntryStack::TagAt(PRInt32 anIndex) const
{
eHTMLTags result=eHTMLTag_unknown;
if((0<mCount) && (anIndex<mCount)) {
result=mEntries[anIndex].mTag;
@ -354,7 +349,8 @@ eHTMLTags nsEntryStack::TagAt(PRInt32 anIndex) const {
*
* @update gess 04/21/99
*/
nsTagEntry* nsEntryStack::EntryAt(PRInt32 anIndex) const {
nsTagEntry* nsEntryStack::EntryAt(PRInt32 anIndex) const
{
nsTagEntry *result=0;
if((0<mCount) && (anIndex<mCount)) {
result=&mEntries[anIndex];
@ -368,7 +364,8 @@ nsTagEntry* nsEntryStack::EntryAt(PRInt32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const {
eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const
{
eHTMLTags result=eHTMLTag_unknown;
if((0<mCount) && (anIndex<mCount)) {
result=mEntries[anIndex].mTag;
@ -382,7 +379,8 @@ eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const {
* @update harishd 04/04/99
* @update gess 04/21/99
*/
eHTMLTags nsEntryStack::Last() const {
eHTMLTags nsEntryStack::Last() const
{
eHTMLTags result=eHTMLTag_unknown;
if(0<mCount) {
result=mEntries[mCount-1].mTag;
@ -390,6 +388,31 @@ eHTMLTags nsEntryStack::Last() const {
return result;
}
nsTagEntry*
nsEntryStack::PopEntry()
{
nsTagEntry* entry = EntryAt(mCount-1);
this->Pop();
return entry;
}
void nsEntryStack::PushEntry(nsTagEntry* aEntry,
PRBool aRefCntNode)
{
if (aEntry) {
EnsureCapacityFor(mCount+1);
mEntries[mCount].mNode = aEntry->mNode;
mEntries[mCount].mTag = aEntry->mTag;
mEntries[mCount].mParent = aEntry->mParent;
mEntries[mCount].mStyles = aEntry->mStyles;
if (aRefCntNode && mEntries[mCount].mNode) {
mEntries[mCount].mNode->mUseCount++;
IF_HOLD(mEntries[mCount].mNode);
}
mCount++;
}
}
/***************************************************************
Now define the dtdcontext class
***************************************************************/
@ -934,16 +957,62 @@ PRBool nsDTDContext::HasOpenContainer(eHTMLTags aTag) const {
*
* @update gess7/9/98
*/
void nsDTDContext::Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack) {
void nsDTDContext::Push(nsCParserNode* aNode,
nsEntryStack* aStyleStack,
PRBool aRefCntNode) {
if(aNode) {
#ifdef NS_DEBUG
eHTMLTags theTag=(eHTMLTags)aNode->GetNodeType();
int size=mStack.mCount;
if(size< eMaxTags)
mXTags[size]=theTag;
eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
int size = mStack.mCount;
if (size < eMaxTags)
mXTags[size] = theTag;
#endif
mStack.Push(aNode,aStyleStack);
mStack.Push(aNode, aStyleStack, aRefCntNode);
}
}
nsTagEntry*
nsDTDContext::PopEntry()
{
PRInt32 theSize = mStack.mCount;
if(0<theSize) {
#ifdef NS_DEBUG
if (theSize <= eMaxTags)
mXTags[theSize-1]=eHTMLTag_unknown;
#endif
return mStack.PopEntry();
}
return 0;
}
void nsDTDContext::PushEntry(nsTagEntry* aEntry,
PRBool aRefCntNode)
{
#ifdef NS_DEBUG
int size=mStack.mCount;
if(size< eMaxTags && aEntry)
mXTags[size]=aEntry->mTag;
#endif
mStack.PushEntry(aEntry, aRefCntNode);
}
/* This method will move the top entires, in the entry-stack, into dest context.
* @param aDest - Destination context for the entries.
* @param aCount - Number of entries, on top of the entry-stack, to be moved.
*/
void
nsDTDContext::MoveEntries(nsDTDContext& aDest,
PRInt32 aCount)
{
NS_ASSERTION(aCount > 0 && mStack.mCount >= aCount, "cannot move entries");
if (aCount > 0 && mStack.mCount >= aCount) {
while (aCount) {
aDest.PushEntry(&mStack.mEntries[--mStack.mCount], PR_FALSE);
#ifdef NS_DEBUG
mXTags[mStack.mCount] = eHTMLTag_unknown;
#endif
--aCount;
}
}
}
@ -1002,7 +1071,6 @@ eHTMLTags nsDTDContext::TagAt(PRInt32 anIndex) const {
return mStack.TagAt(anIndex);
}
/**
*
* @update gess7/9/98
@ -1041,7 +1109,7 @@ nsEntryStack* nsDTDContext::GetStylesAt(PRInt32 anIndex) const {
*
* @update gess 04/28/99
*/
void nsDTDContext::PushStyle(const nsCParserNode* aNode){
void nsDTDContext::PushStyle(nsCParserNode* aNode){
nsTagEntry* theEntry=mStack.EntryAt(mStack.mCount-1);
if(theEntry ) {
@ -1352,9 +1420,9 @@ nsNodeAllocator::nsNodeAllocator():mSharedNodes(0){
mCount=0;
#endif
#else
static const size_t kNodeBuckets[] ={sizeof(nsCParserNode)};
static const size_t kNodeBuckets[] = { sizeof(nsCParserNode), sizeof(nsCParserStartNode) };
static const PRInt32 kNumNodeBuckets = sizeof(kNodeBuckets) / sizeof(size_t);
static const PRInt32 kInitialNodePoolSize = NS_SIZE_IN_HEAP(sizeof(nsCParserNode)) * 50;
static const PRInt32 kInitialNodePoolSize = NS_SIZE_IN_HEAP(sizeof(nsCParserNode)) * 35; // optimal size based on space-trace data
nsNodeAllocator::nsNodeAllocator() {
mNodePool.Init("NodePool", kNodeBuckets, kNumNodeBuckets, kInitialNodePoolSize);
#endif
@ -1365,7 +1433,7 @@ nsNodeAllocator::~nsNodeAllocator() {
MOZ_COUNT_DTOR(nsNodeAllocator);
#ifdef HEAP_ALLOCATED_NODES
nsCParserNode* theNode=0;
nsCParserNode* theNode = 0;
while((theNode=(nsCParserNode*)mSharedNodes.Pop())){
#ifdef DEBUG_TRACK_NODES
@ -1385,22 +1453,21 @@ nsNodeAllocator::~nsNodeAllocator() {
}
nsCParserNode* nsNodeAllocator::CreateNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator) {
nsCParserNode* result=0;
nsTokenAllocator* aTokenAllocator)
{
nsCParserNode* result = 0;
#ifdef HEAP_ALLOCATED_NODES
#if 0
if(gAllNodeCount!=mSharedNodes.GetSize()) {
int x=10; //this is very BAD!
}
#endif
result=NS_STATIC_CAST(nsCParserNode*,mSharedNodes.Pop());
if(result) {
result = NS_STATIC_CAST(nsCParserNode*,mSharedNodes.Pop());
if (result) {
result->Init(aToken, aTokenAllocator,this);
}
else{
result=nsCParserNode::Create(aToken, aTokenAllocator,this);
result = nsCParserNode::Create(aToken, aTokenAllocator,this);
#ifdef DEBUG_TRACK_NODES
++mCount;
AddNode(NS_STATIC_CAST(nsCParserNode*,result));
@ -1408,7 +1475,15 @@ nsCParserNode* nsNodeAllocator::CreateNode(CToken* aToken,
IF_HOLD(result);
}
#else
result=nsCParserNode::Create(aToken, aTokenAllocator,this);
eHTMLTokenTypes type = aToken ? eHTMLTokenTypes(aToken->GetTokenType()) : eToken_unknown;
switch (type) {
case eToken_start:
result = nsCParserStartNode::Create(aToken, aTokenAllocator,this);
break;
default :
result = nsCParserNode::Create(aToken, aTokenAllocator,this);
break;
}
IF_HOLD(result);
#endif
return result;

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

@ -71,7 +71,7 @@
// recycles _ptr
#define IF_FREE(_ptr, _allocator) \
PR_BEGIN_MACRO \
if(_ptr) { \
if(_ptr && _allocator) { \
_ptr->Release((_allocator)->GetArenaPool()); \
_ptr=0; \
} \
@ -107,6 +107,8 @@ PRUint32 AccumulateCRC(PRUint32 crc_accum, char *data_blk_ptr, int data_blk_size
class nsEntryStack; //forware declare to make compilers happy.
struct nsTagEntry {
nsTagEntry::nsTagEntry()
: mTag(eHTMLTag_unknown), mNode(0), mParent(0), mStyles(0){}
eHTMLTags mTag; //for speedier access to tag id
nsCParserNode* mNode;
nsEntryStack* mParent;
@ -119,9 +121,11 @@ public:
nsEntryStack();
~nsEntryStack();
nsTagEntry* PopEntry();
void PushEntry(nsTagEntry* aEntry, PRBool aRefCntNode = PR_TRUE);
void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0);
void Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack=0);
void PushFront(const nsCParserNode* aNode,nsEntryStack* aStyleStack=0);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void Append(nsEntryStack *theStack);
nsCParserNode* Pop(void);
nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag);
@ -329,7 +333,10 @@ public:
nsDTDContext();
~nsDTDContext();
void Push(const nsCParserNode* aNode,nsEntryStack* aStyleStack=0);
nsTagEntry* PopEntry();
void PushEntry(nsTagEntry* aEntry, PRBool aRefCntNode = PR_TRUE);
void MoveEntries(nsDTDContext& aDest, PRInt32 aCount);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
nsCParserNode* Pop(nsEntryStack*& aChildStack);
nsCParserNode* Pop();
nsCParserNode* PeekNode() { return mStack.NodeAt(mStack.mCount-1); }
@ -346,7 +353,7 @@ public:
PRInt32 GetCount(void) {return mStack.mCount;}
PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;}
nsEntryStack* GetStylesAt(PRInt32 anIndex) const;
void PushStyle(const nsCParserNode* aNode);
void PushStyle(nsCParserNode* aNode);
void PushStyles(nsEntryStack *theStyles);
nsCParserNode* PopStyle(void);
nsCParserNode* PopStyle(eHTMLTags aTag);

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

@ -65,7 +65,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
@ -77,17 +77,17 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
@ -234,14 +234,15 @@ nsHTMLNullSink::OpenHTML(const nsIParserNode& aNode){
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseHTML(const nsIParserNode& aNode){
nsHTMLNullSink::CloseHTML(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos-1)*2);
PRUnichar html[] = {'h','t','m','l','\0'};
DebugDump("</",nsDependentString(html),(mNodeStackPos-1)*2);
#endif
return NS_OK;
@ -277,13 +278,14 @@ nsHTMLNullSink::OpenHead(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseHead(const nsIParserNode& aNode) {
nsHTMLNullSink::CloseHead() {
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar head[] = {'h','e','a','d','\0'};
DebugDump("</", nsDependentString(head), (mNodeStackPos)*2);
#endif
return NS_OK;
@ -331,12 +333,13 @@ nsHTMLNullSink::OpenBody(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseBody(const nsIParserNode& aNode){
nsHTMLNullSink::CloseBody(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar body[] = {'b','o','d','y','\0'};
DebugDump("</", nsDependentString(body), (mNodeStackPos)*2);
#endif
return NS_OK;
@ -370,13 +373,14 @@ nsHTMLNullSink::OpenForm(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseForm(const nsIParserNode& aNode){
nsHTMLNullSink::CloseForm(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar form[] = {'f','o','r','m','\0'};
DebugDump("</", nsDependentString(form),(mNodeStackPos)*2);
#endif
return NS_OK;
@ -410,13 +414,14 @@ nsHTMLNullSink::OpenMap(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseMap(const nsIParserNode& aNode){
nsHTMLNullSink::CloseMap(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar map[] = {'m','a','p','\0'};
DebugDump("</", nsDependentString(map), (mNodeStackPos)*2);
#endif
return NS_OK;
@ -450,13 +455,14 @@ nsHTMLNullSink::OpenFrameset(const nsIParserNode& aNode) {
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseFrameset(const nsIParserNode& aNode){
nsHTMLNullSink::CloseFrameset(){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
PRUnichar frameset[] = {'f','r','a','m','e', 's', 'e','t','\0'};
DebugDump("</", nsDependentString(frameset),(mNodeStackPos)*2);
#endif
return NS_OK;
@ -491,13 +497,14 @@ nsHTMLNullSink::OpenContainer(const nsIParserNode& aNode){
* @return
*/
NS_IMETHODIMP
nsHTMLNullSink::CloseContainer(const nsIParserNode& aNode){
nsHTMLNullSink::CloseContainer(const nsHTMLTag aTag){
NS_PRECONDITION(mNodeStackPos > 0, "node stack empty");
mNodeStack[--mNodeStackPos]=eHTMLTag_unknown;
#ifdef VERBOSE_DEBUG
DebugDump("</",aNode.GetText(),(mNodeStackPos)*2);
const PRUnichar* name = nsHTMLTags::GetStringValue(aTag);
DebugDump("</", nsDependentString(name), (mNodeStackPos)*2);
#endif
return NS_OK;

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

@ -1062,4 +1062,3 @@ void nsHTMLTokenizer::RecordTrailingContent(CStartToken* aStartToken, nsScanner&
copy_string( aOrigin, theCurrentPosition, beginWriting );
}
}

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

@ -226,11 +226,11 @@ nsLoggingSink::OpenContainer(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseContainer(const nsIParserNode& aNode) {
nsLoggingSink::CloseContainer(const nsHTMLTag aTag) {
nsresult theResult=NS_OK;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsHTMLTag nodeType = nsHTMLTag(aTag);
if ((nodeType >= eHTMLTag_unknown) &&
(nodeType <= nsHTMLTag(NS_HTML_TAG_MAX))) {
const PRUnichar* tag = nsHTMLTags::GetStringValue(nodeType);
@ -240,7 +240,7 @@ nsLoggingSink::CloseContainer(const nsIParserNode& aNode) {
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseContainer(aNode);
theResult=mSink->CloseContainer(aTag);
}
return theResult;
@ -379,14 +379,14 @@ nsLoggingSink::OpenHTML(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseHTML(const nsIParserNode& aNode) {
nsLoggingSink::CloseHTML() {
CloseNode("html");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseHTML(aNode);
theResult=mSink->CloseHTML();
}
return theResult;
@ -408,14 +408,14 @@ nsLoggingSink::OpenHead(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseHead(const nsIParserNode& aNode) {
nsLoggingSink::CloseHead() {
CloseNode("head");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseHead(aNode);
theResult=mSink->CloseHead();
}
return theResult;
@ -436,14 +436,14 @@ nsLoggingSink::OpenBody(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseBody(const nsIParserNode& aNode) {
nsLoggingSink::CloseBody() {
CloseNode("body");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseBody(aNode);
theResult=mSink->CloseBody();
}
return theResult;
@ -464,14 +464,14 @@ nsLoggingSink::OpenForm(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseForm(const nsIParserNode& aNode) {
nsLoggingSink::CloseForm() {
CloseNode("form");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseForm(aNode);
theResult=mSink->CloseForm();
}
return theResult;
@ -492,14 +492,14 @@ nsLoggingSink::OpenMap(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseMap(const nsIParserNode& aNode) {
nsLoggingSink::CloseMap() {
CloseNode("map");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseMap(aNode);
theResult=mSink->CloseMap();
}
return theResult;
@ -520,14 +520,14 @@ nsLoggingSink::OpenFrameset(const nsIParserNode& aNode) {
}
NS_IMETHODIMP
nsLoggingSink::CloseFrameset(const nsIParserNode& aNode) {
nsLoggingSink::CloseFrameset() {
CloseNode("frameset");
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->CloseFrameset(aNode);
theResult=mSink->CloseFrameset();
}
return theResult;

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

@ -67,7 +67,7 @@ public:
NS_IMETHOD WillResume();
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
@ -79,17 +79,17 @@ public:
// nsIHTMLContentSink
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }

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

@ -60,14 +60,13 @@ const nsString& GetEmptyString() {
*/
nsCParserNode::nsCParserNode()
: mToken(nsnull),
mAttributes(nsnull),
mUseCount(0),
mGenericState(PR_FALSE),
mTokenAllocator(nsnull)
{
MOZ_COUNT_CTOR(nsCParserNode);
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=nsnull;
mNodeAllocator = nsnull;
#endif
}
@ -80,21 +79,20 @@ nsCParserNode::nsCParserNode()
*/
nsCParserNode::nsCParserNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator):
nsIParserNode() {
nsNodeAllocator* aNodeAllocator): nsIParserNode()
{
mRefCnt = 0;
MOZ_COUNT_CTOR(nsCParserNode);
static int theNodeCount=0;
static int theNodeCount = 0;
++theNodeCount;
mAttributes=0;
mToken=aToken;
mToken = aToken;
IF_HOLD(mToken);
mTokenAllocator=aTokenAllocator;
mUseCount=0;
mGenericState=PR_FALSE;
mTokenAllocator = aTokenAllocator;
mUseCount = 0;
mGenericState = PR_FALSE;
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=aNodeAllocator;
mNodeAllocator = aNodeAllocator;
#endif
}
@ -113,9 +111,9 @@ nsCParserNode::~nsCParserNode() {
if(mNodeAllocator) {
mNodeAllocator->Recycle(this);
}
mNodeAllocator=nsnull;
mNodeAllocator = nsnull;
#endif
mTokenAllocator=0;
mTokenAllocator = 0;
}
@ -127,48 +125,25 @@ nsCParserNode::~nsCParserNode() {
* @return
*/
nsresult nsCParserNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator) {
if(mAttributes && (mAttributes->GetSize())) {
NS_ASSERTION(0!=mTokenAllocator, "Error: Attribute tokens on node without token allocator");
if(mTokenAllocator) {
CToken* theAttrToken=0;
while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
}
mTokenAllocator=aTokenAllocator;
mToken=aToken;
nsresult
nsCParserNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
mTokenAllocator = aTokenAllocator;
mToken = aToken;
IF_HOLD(mToken);
mGenericState=PR_FALSE;
mGenericState = PR_FALSE;
mUseCount=0;
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=aNodeAllocator;
mNodeAllocator = aNodeAllocator;
#endif
return NS_OK;
}
/**
* Causes the given attribute to be added to internal
* mAttributes list, and mAttributeCount to be incremented.
*
* @update gess 3/25/98
* @param aToken -- token to be added to attr list
* @return
*/
void nsCParserNode::AddAttribute(CToken* aToken) {
NS_PRECONDITION(0!=aToken, "Error: Token shouldn't be null!");
NS_PRECONDITION(0!=mTokenAllocator, "Error: Can't add attribute without token allocator");
if(mTokenAllocator) {
if(!mAttributes)
mAttributes=new nsDeque(0);
if(mAttributes) {
mAttributes->Push(aToken);
}
}
void
nsCParserNode::AddAttribute(CToken* aToken)
{
}
@ -179,9 +154,9 @@ void nsCParserNode::AddAttribute(CToken* aToken) {
* @param
* @return string ref containing node name
*/
const nsString& nsCParserNode::GetName() const {
const nsAString&
nsCParserNode::GetTagName() const {
return GetEmptyString();
// return mName;
}
@ -193,8 +168,13 @@ const nsString& nsCParserNode::GetName() const {
* @param
* @return string ref of text from internal token
*/
const nsAString& nsCParserNode::GetText() const {
return (mToken) ? mToken->GetStringValue() : NS_STATIC_CAST(const nsAString&,GetEmptyString());
const nsAString&
nsCParserNode::GetText() const
{
if (mToken) {
return mToken->GetStringValue();
}
return GetEmptyString();
}
/**
@ -205,7 +185,9 @@ const nsAString& nsCParserNode::GetText() const {
* @param
* @return int value that represents tag type
*/
PRInt32 nsCParserNode::GetNodeType(void) const{
PRInt32
nsCParserNode::GetNodeType(void) const
{
return (mToken) ? mToken->GetTypeID() : 0;
}
@ -218,7 +200,9 @@ PRInt32 nsCParserNode::GetNodeType(void) const{
* @param
* @return
*/
PRInt32 nsCParserNode::GetTokenType(void) const{
PRInt32
nsCParserNode::GetTokenType(void) const
{
return (mToken) ? mToken->GetTokenType() : 0;
}
@ -230,15 +214,10 @@ PRInt32 nsCParserNode::GetTokenType(void) const{
* @param
* @return int -- representing attribute count
*/
PRInt32 nsCParserNode::GetAttributeCount(PRBool askToken) const{
PRInt32 result=0;
if(PR_FALSE==askToken) {
if(mAttributes)
result=mAttributes->GetSize();
}
else result=mToken->GetAttributeCount();
return result;
PRInt32
nsCParserNode::GetAttributeCount(PRBool askToken) const
{
return 0;
}
/**
@ -249,12 +228,9 @@ PRInt32 nsCParserNode::GetAttributeCount(PRBool askToken) const{
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*/
const nsAString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
PRInt32 theCount = (mAttributes) ? mAttributes->GetSize() : 0;
if((PRInt32)anIndex<theCount) {
CAttributeToken* tkn=(CAttributeToken*)mAttributes->ObjectAt(anIndex);
return tkn->GetKey();
}
const nsAString&
nsCParserNode::GetKeyAt(PRUint32 anIndex) const
{
return GetEmptyString();
}
@ -266,20 +242,15 @@ const nsAString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsAString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
PRInt32 theCount = (mAttributes) ? mAttributes->GetSize() : 0;
NS_PRECONDITION(PRInt32(anIndex)<theCount, "Bad attr index");
if(PRInt32(anIndex)<theCount) {
CAttributeToken* tkn=(CAttributeToken*)mAttributes->ObjectAt(anIndex);
return tkn->GetValue();
}
const nsAString&
nsCParserNode::GetValueAt(PRUint32 anIndex) const
{
return GetEmptyString();
}
PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
PRInt32
nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
{
if (eToken_entity == mToken->GetTokenType()) {
return ((CEntityToken*)mToken)->TranslateToUnicodeStr(aString);
@ -293,7 +264,8 @@ PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
* @update gess7/24/98
* @return int containing the line number the token was found on
*/
PRInt32 nsCParserNode::GetSourceLineNumber(void) const {
PRInt32
nsCParserNode::GetSourceLineNumber(void) const {
return mToken ? mToken->GetLineNumber() : 0;
}
@ -303,39 +275,24 @@ PRInt32 nsCParserNode::GetSourceLineNumber(void) const {
* @return token at anIndex
*/
CToken* nsCParserNode::PopAttributeToken() {
CToken* result=0;
if(mAttributes) {
result =(CToken*)mAttributes->Pop();
}
return result;
CToken*
nsCParserNode::PopAttributeToken() {
return 0;
}
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
*/
void nsCParserNode::GetSource(nsString& aString) {
aString.Truncate();
eHTMLTags theTag=(eHTMLTags)mToken->GetTypeID();
aString.Append(PRUnichar('<'));
const PRUnichar* theTagName=nsHTMLTags::GetStringValue(theTag);
void
nsCParserNode::GetSource(nsString& aString)
{
eHTMLTags theTag = mToken ? (eHTMLTags)mToken->GetTypeID() : eHTMLTag_unknown;
aString.Assign(PRUnichar('<'));
const PRUnichar* theTagName = nsHTMLTags::GetStringValue(theTag);
if(theTagName) {
aString.Append(theTagName);
}
if(mAttributes) {
int index=0;
for(index=0;index<mAttributes->GetSize();++index) {
CAttributeToken *theToken=(CAttributeToken*)mAttributes->ObjectAt(index);
if(theToken) {
theToken->AppendSourceTo(aString);
aString.Append(PRUnichar(' ')); //this will get removed...
}
}
}
aString.Append(PRUnichar('>'));
}
@ -343,44 +300,104 @@ void nsCParserNode::GetSource(nsString& aString) {
* @update harishd 08/02/00
* @return void
*/
nsresult nsCParserNode::ReleaseAll() {
if(mAttributes) {
NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
if(mTokenAllocator) {
CToken* theAttrToken=0;
while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
delete mAttributes;
mAttributes=0;
}
nsresult
nsCParserNode::ReleaseAll()
{
if(mTokenAllocator) {
// It was heap allocated, so free it!
IF_FREE(mToken,mTokenAllocator);
}
return NS_OK;
}
nsresult
nsCParserNode::GetIDAttributeAtom(nsIAtom** aResult) const
nsresult
nsCParserStartNode::Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mIDAttributeAtom;
NS_IF_ADDREF(*aResult);
return NS_OK;
NS_ASSERTION(mAttributes.GetSize() == 0, "attributes not recycled!");
return nsCParserNode::Init(aToken, aTokenAllocator, aNodeAllocator);
}
nsresult
nsCParserNode::SetIDAttributeAtom(nsIAtom* aID)
void nsCParserStartNode::AddAttribute(CToken* aToken)
{
NS_ENSURE_ARG(aID);
mIDAttributeAtom = aID;
return NS_OK;
NS_ASSERTION(0 != aToken, "Error: Token shouldn't be null!");
mAttributes.Push(aToken);
}
PRInt32
nsCParserStartNode::GetAttributeCount(PRBool askToken) const
{
PRInt32 result = 0;
if (askToken) {
result = mToken ? mToken->GetAttributeCount() : 0;
}
else {
result = mAttributes.GetSize();
}
return result;
}
const nsAString&
nsCParserStartNode::GetKeyAt(PRUint32 anIndex) const
{
if ((PRInt32)anIndex < mAttributes.GetSize()) {
CAttributeToken* attr =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
if (attr) {
return attr->GetKey();
}
}
return GetEmptyString();
}
const nsAString&
nsCParserStartNode::GetValueAt(PRUint32 anIndex) const
{
if (PRInt32(anIndex) < mAttributes.GetSize()) {
CAttributeToken* attr =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
if (attr) {
return attr->GetValue();
}
}
return GetEmptyString();
}
CToken*
nsCParserStartNode::PopAttributeToken()
{
return NS_STATIC_CAST(CToken*, mAttributes.Pop());
}
void nsCParserStartNode::GetSource(nsString& aString)
{
aString.Assign(PRUnichar('<'));
const PRUnichar* theTagName =
nsHTMLTags::GetStringValue(nsHTMLTag(mToken->GetTypeID()));
if (theTagName) {
aString.Append(theTagName);
}
PRInt32 index;
PRInt32 size = mAttributes.GetSize();
for (index = 0 ; index < size; ++index) {
CAttributeToken *theToken =
NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(index));
if (theToken) {
theToken->AppendSourceTo(aString);
aString.Append(PRUnichar(' ')); //this will get removed...
}
}
aString.Append(PRUnichar('>'));
}
nsresult nsCParserStartNode::ReleaseAll()
{
NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
CToken* theAttrToken;
while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
nsCParserNode::ReleaseAll();
return NS_OK;
}

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

@ -157,7 +157,7 @@ class nsCParserNode : public nsIParserNode {
* @update gess5/11/98
* @return string containing node name
*/
virtual const nsString& GetName() const;
virtual const nsAString& GetTagName() const;
/**
* Retrieve the text from the given node
@ -245,15 +245,6 @@ class nsCParserNode : public nsIParserNode {
*/
virtual void GetSource(nsString& aString);
/*
* Get and set the ID attribute atom for this node.
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
* for the definition of an ID attribute.
*
*/
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult) const;
virtual nsresult SetIDAttributeAtom(nsIAtom* aID);
/**
* This pair of methods allows us to set a generic bit (for arbitrary use)
* on each node stored in the context.
@ -268,18 +259,66 @@ class nsCParserNode : public nsIParserNode {
*/
virtual nsresult ReleaseAll();
CToken* mToken;
nsDeque* mAttributes;
PRInt32 mUseCount;
PRBool mGenericState;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
nsTokenAllocator* mTokenAllocator;
CToken* mToken;
PRInt32 mUseCount;
PRPackedBool mGenericState;
nsTokenAllocator* mTokenAllocator;
#ifdef HEAP_ALLOCATED_NODES
nsNodeAllocator* mNodeAllocator; // weak
#endif
};
class nsCParserStartNode : public nsCParserNode
{
public:
static nsCParserNode* Create(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator)
{
#ifdef HEAP_ALLOCATED_NODES
return new
#else
nsFixedSizeAllocator& pool = aNodeAllocator->GetArenaPool();
void* place = pool.Alloc(sizeof(nsCParserStartNode));
return ::new (place)
#endif
nsCParserStartNode(aToken, aTokenAllocator, aNodeAllocator);
}
nsCParserStartNode()
: mAttributes(0), nsCParserNode() { }
nsCParserStartNode(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator = 0)
: mAttributes(0), nsCParserNode(aToken, aTokenAllocator, aNodeAllocator) { }
~nsCParserStartNode()
{
NS_ASSERTION(0 != mTokenAllocator, "Error: no token allocator");
CToken* theAttrToken = 0;
while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
}
}
virtual nsresult Init(CToken* aToken,
nsTokenAllocator* aTokenAllocator,
nsNodeAllocator* aNodeAllocator = 0);
virtual void AddAttribute(CToken* aToken);
virtual PRInt32 GetAttributeCount(PRBool askToken = PR_FALSE) const;
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
virtual CToken* PopAttributeToken();
virtual void GetSource(nsString& aString);
virtual nsresult ReleaseAll();
protected:
nsDeque mAttributes;
};
#endif

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

@ -202,7 +202,6 @@ public:
mEndNode(),
mStartNode(),
mTokenNode(),
mErrorNode(),
mITextToken(),
mErrorToken(NS_LITERAL_STRING("error")) {
}
@ -216,9 +215,8 @@ public:
}
nsCParserNode mEndNode;
nsCParserNode mStartNode;
nsCParserNode mTokenNode;
nsCParserNode mErrorNode;
nsCParserStartNode mStartNode;
nsCParserStartNode mTokenNode;
CIndirectTextToken mITextToken;
CTextToken mErrorToken;
};
@ -565,7 +563,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
CStartToken* theToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_link,tag));
if(theToken) {
CAttributeToken *theAttr;
nsCParserNode theNode(theToken, theAllocator);
nsCParserStartNode theNode(theToken, theAllocator);
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_LITERAL_STRING("stylesheet"));
theAttr->SetKey(NS_LITERAL_STRING("rel"));
@ -586,7 +584,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
CEndToken endHeadToken(eHTMLTag_head);
nsCParserNode endHeadNode(&endHeadToken, 0/*stack token*/);
result = mSink->CloseHead(endHeadNode);
result = mSink->CloseHead();
if(NS_SUCCEEDED(result)) {
mHasOpenRoot = PR_TRUE;
if (didBlock) {
@ -599,7 +597,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
tag.Assign(NS_LITERAL_STRING("BODY"));
CStartToken* bodyToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start, eHTMLTag_body, tag));
if (bodyToken) {
nsCParserNode bodyNode(bodyToken, theAllocator);
nsCParserStartNode bodyNode(bodyToken, theAllocator);
CAttributeToken *theAttr=nsnull;
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kBodyId));
theAttr->SetKey(NS_LITERAL_STRING("id"));
@ -679,7 +677,7 @@ nsresult CViewSourceHTML::GenerateSummary() {
void CViewSourceHTML::StartNewPreBlock(void){
CEndToken endToken(eHTMLTag_pre);
nsCParserNode endNode(&endToken, 0/*stack token*/);
mSink->CloseContainer(endNode);
mSink->CloseContainer(eHTMLTag_pre);
CStartToken startToken(eHTMLTag_pre);
nsCParserNode startNode(&startToken, 0/*stack token*/);
@ -727,15 +725,15 @@ NS_IMETHODIMP CViewSourceHTML::DidBuildModel(nsresult anErrorCode,PRBool aNotify
if(ePlainText!=mDocType) {
CEndToken theToken(eHTMLTag_pre);
nsCParserNode preNode(&theToken, 0/*stack token*/);
mSink->CloseContainer(preNode);
mSink->CloseContainer(eHTMLTag_pre);
CEndToken bodyToken(eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken, 0/*stack token*/);
mSink->CloseBody(bodyNode);
mSink->CloseBody();
CEndToken htmlToken(eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken, 0/*stack token*/);
mSink->CloseHTML(htmlNode);
mSink->CloseHTML();
}
result = mSink->DidBuildModel(1);
}
@ -994,7 +992,7 @@ nsresult CViewSourceHTML::WriteTag(PRInt32 aTagType,const nsAString & aText,PRIn
theContext.mStartNode.ReleaseAll();
CEndToken theEndToken(eHTMLTag_span);
theContext.mEndNode.Init(&theEndToken, 0/*stack token*/);
mSink->CloseContainer(theContext.mEndNode); //emit </starttag>...
mSink->CloseContainer(eHTMLTag_span); //emit </starttag>...
#ifdef DUMP_TO_FILE
if (gDumpFile)
fprintf(gDumpFile, "</span>");

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

@ -1,8 +1,7 @@
<html><body>
<table>
<p><h3>Please Enter your Homesite Login, E-mail and Password to delete</h3></p>
<p><h3></h3></p>
<form method="POST">
<input type=submit>
</form>
</table>
</body></html>