Bug 311785: Simplify the nsIHTMLContentSink interface

r=mrbkap sr=peterv


git-svn-id: svn://10.0.0.236/trunk@182699 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cvshook%sicking.cc
2005-10-21 15:39:06 +00:00
parent 09f59f232b
commit f95c92ff95
14 changed files with 197 additions and 1180 deletions

View File

@@ -316,34 +316,6 @@ mozSanitizingHTMLSerializer::AddLeaf(const nsIParserNode& aNode)
return DoAddLeaf(type, text);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenHTML(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseHTML()
{
return CloseContainer(eHTMLTag_html);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::SetTitle(const nsString& aValue)
{
if (IsAllowedTag(eHTMLTag_title))
{
// See bug 195020 for a good reason to output the tags.
// It will make sure we have a closing tag, and a
// missing </title> tag won't result in everything
// being eaten up as the title.
Write(NS_LITERAL_STRING("<title>"));
Write(nsAdoptingString(escape(aValue)));
Write(NS_LITERAL_STRING("</title>"));
}
return NS_OK;
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AddDocTypeDecl(const nsIParserNode& aNode)
{
@@ -362,12 +334,6 @@ mozSanitizingHTMLSerializer::SetDocumentCharset(nsACString& aCharset)
return NS_OK;
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenHead(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenHead()
{
@@ -376,61 +342,6 @@ mozSanitizingHTMLSerializer::OpenHead()
return NS_OK;
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseHead()
{
return CloseContainer(eHTMLTag_head);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenBody(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseBody()
{
return CloseContainer(eHTMLTag_body);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenForm(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseForm()
{
return CloseContainer(eHTMLTag_form);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenMap(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseMap()
{
return CloseContainer(eHTMLTag_map);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::OpenFrameset(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::CloseFrameset()
{
return CloseContainer(eHTMLTag_frameset);
}
// Here comes the actual code...
nsresult

View File

@@ -109,20 +109,7 @@ public:
virtual nsISupports *GetTarget() { return nsnull; }
// nsIHTMLContentSink
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD OpenHead();
NS_IMETHOD CloseHead();
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn);
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }

View File

@@ -456,12 +456,22 @@ nsPlainTextSerializer::OpenContainer(const nsIParserNode& aNode)
{
PRInt32 type = aNode.GetNodeType();
if (type == eHTMLTag_head) {
mInHead = PR_TRUE;
return NS_OK;
}
return DoOpenContainer(&aNode, type);
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseContainer(const nsHTMLTag aTag)
{
if (aTag == eHTMLTag_head) {
mInHead = PR_FALSE;
return NS_OK;
}
return DoCloseContainer(aTag);
}
@@ -492,25 +502,6 @@ nsPlainTextSerializer::AddLeaf(const nsIParserNode& aNode)
}
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenHTML(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseHTML()
{
return CloseContainer(eHTMLTag_html);
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenHead(const nsIParserNode& aNode)
{
mInHead = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenHead()
{
@@ -518,61 +509,6 @@ nsPlainTextSerializer::OpenHead()
return NS_OK;
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseHead()
{
mInHead = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenBody(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseBody()
{
return CloseContainer(eHTMLTag_body);
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenForm(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseForm()
{
return CloseContainer(eHTMLTag_form);
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenMap(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseMap()
{
return CloseContainer(eHTMLTag_map);
}
NS_IMETHODIMP
nsPlainTextSerializer::OpenFrameset(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsPlainTextSerializer::CloseFrameset()
{
return CloseContainer(eHTMLTag_frameset);
}
NS_IMETHODIMP
nsPlainTextSerializer::IsEnabled(PRInt32 aTag, PRBool* aReturn)
{

View File

@@ -105,19 +105,7 @@ public:
virtual nsISupports *GetTarget() { return nsnull; }
// nsIHTMLContentSink
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD OpenHead();
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn);
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }

View File

@@ -247,19 +247,7 @@ public:
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode);
NS_IMETHOD BeginContext(PRInt32 aID);
NS_IMETHOD EndContext(PRInt32 aID);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD OpenHead();
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn);
NS_IMETHOD_(PRBool) IsFormOnStack();
@@ -334,7 +322,7 @@ protected:
nsGenericHTMLElement* mRoot;
nsGenericHTMLElement* mBody;
nsGenericHTMLElement* mFrameset;
nsRefPtr<nsGenericHTMLElement> mFrameset;
nsGenericHTMLElement* mHead;
// Do we notify based on time?
@@ -402,10 +390,16 @@ protected:
void ProcessBaseTarget(const nsAString& aBaseTarget);
// Routines for tags that require special handling
nsresult CloseHTML();
nsresult OpenFrameset(const nsIParserNode& aNode);
nsresult CloseFrameset();
nsresult OpenBody(const nsIParserNode& aNode);
nsresult CloseBody();
nsresult OpenForm(const nsIParserNode& aNode);
nsresult CloseForm();
nsresult ProcessAREATag(const nsIParserNode& aNode);
nsresult ProcessBASETag(const nsIParserNode& aNode);
nsresult ProcessLINKTag(const nsIParserNode& aNode);
nsresult ProcessMAPTag(nsIContent* aContent);
nsresult ProcessMETATag(const nsIParserNode& aNode);
// Routines for tags that require special handling when we reach their end
@@ -415,7 +409,7 @@ protected:
nsresult ProcessSTYLEEndTag(nsGenericHTMLElement* content);
nsresult OpenHeadContext();
nsresult CloseHeadContext();
void CloseHeadContext();
// nsContentSink overrides
virtual void PreEvaluateScript();
@@ -724,7 +718,6 @@ public:
PRBool IsCurrentContainer(nsHTMLTag mType);
PRBool IsAncestorContainer(nsHTMLTag mType);
nsGenericHTMLElement* GetCurrentContainer();
void DidAddContent(nsIContent* aContent, PRBool aDidNotify = PR_FALSE);
void UpdateChildCounts();
@@ -958,17 +951,7 @@ MakeContentObject(nsHTMLTag aNodeType, nsINodeInfo *aNodeInfo,
nsGenericHTMLElement* aForm,
PRBool aInsideNoXXXTag, PRBool aFromParser)
{
if (aNodeType == eHTMLTag_form) {
if (aForm) {
// the form was already created
NS_ADDREF(aForm);
return aForm;
}
nsGenericHTMLElement* result = NS_NewHTMLFormElement(aNodeInfo);
NS_IF_ADDREF(result);
return result;
}
NS_PRECONDITION(aNodeType != eHTMLTag_form || !aForm, "Creating form in form");
contentCreatorCallback cb = sContentCreatorCallbacks[aNodeType];
@@ -1083,15 +1066,6 @@ SinkContext::IsAncestorContainer(nsHTMLTag aTag)
return PR_FALSE;
}
nsGenericHTMLElement*
SinkContext::GetCurrentContainer()
{
nsGenericHTMLElement* content = mStack[mStackPos - 1].mContent;
NS_ADDREF(content);
return content;
}
void
SinkContext::DidAddContent(nsIContent* aContent, PRBool aDidNotify)
{
@@ -1256,13 +1230,27 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
// Special handling for certain tags
switch (nodeType) {
case eHTMLTag_form:
mSink->mCurrentForm = content;
break;
case eHTMLTag_frameset:
if (!mSink->mFrameset &&
mSink->mFlags & NS_SINK_FLAG_FRAMES_ENABLED) {
mSink->mFrameset = content;
}
break;
case eHTMLTag_noembed:
case eHTMLTag_noframes:
mSink->mInsideNoXXXTag++;
break;
case eHTMLTag_map:
mSink->ProcessMAPTag(content);
// We used to strip whitespace from the NAME attribute, to match
// a 4.x quirk, but it proved too quirky for us, and IE never
// did that. See bug 79738 for details.
mSink->mCurrentMap = content;
break;
case eHTMLTag_iframe:
@@ -1392,6 +1380,12 @@ SinkContext::CloseContainer(const nsHTMLTag aTag)
mSink->mNumOpenIFRAMES--;
break;
case eHTMLTag_map:
mSink->mCurrentMap = nsnull;
break;
case eHTMLTag_select:
case eHTMLTag_textarea:
case eHTMLTag_object:
@@ -1462,9 +1456,13 @@ SinkContext::AddLeaf(const nsIParserNode& aNode)
case eHTMLTag_frame:
case eHTMLTag_input:
case eHTMLTag_embed:
mSink->AddBaseTagInfo(content);
break;
// <form> can end up as a leaf if it's misnested with table elements
case eHTMLTag_form:
mSink->AddBaseTagInfo(content);
mSink->mCurrentForm = content;
break;
default:
@@ -1908,7 +1906,6 @@ HTMLContentSink::~HTMLContentSink()
{
NS_IF_RELEASE(mHead);
NS_IF_RELEASE(mBody);
NS_IF_RELEASE(mFrameset);
NS_IF_RELEASE(mRoot);
if (mDocument) {
@@ -2537,29 +2534,7 @@ HTMLContentSink::EndContext(PRInt32 aPosition)
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenHTML(const nsIParserNode& aNode)
{
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHTML",
eHTMLTag_html, 0, this);
if (mRoot) {
// Add attributes to the node...if found.
PRInt32 ac = aNode.GetAttributeCount();
if (ac > 0) {
AddAttributes(aNode, mRoot, PR_TRUE, PR_TRUE);
}
}
MOZ_TIMER_STOP(mWatch);
return NS_OK;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::CloseHTML()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseHTML()\n"));
@@ -2589,33 +2564,7 @@ HTMLContentSink::CloseHTML()
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::OpenHead(const nsIParserNode& aNode)
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenHead(nsIParserNode)\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenHead",
eHTMLTag_head, 0, this);
nsresult rv = OpenHeadContext();
if (NS_FAILED(rv)) {
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenHead(nsIParserNode)\n"));
MOZ_TIMER_STOP(mWatch);
return rv;
}
if (mHead && aNode.GetNodeType() == eHTMLTag_head) {
rv = AddAttributes(aNode, mHead, PR_FALSE, PR_TRUE);
}
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenHead()\n"));
MOZ_TIMER_STOP(mWatch);
return rv;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::OpenHead()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenHead()\n"));
@@ -2629,23 +2578,7 @@ HTMLContentSink::OpenHead()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseHead()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseHead()\n"));
MOZ_TIMER_START(mWatch);
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseHead",
eHTMLTag_head, 0, this);
CloseHeadContext();
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseHead()\n"));
MOZ_TIMER_STOP(mWatch);
return NS_OK;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::OpenBody(const nsIParserNode& aNode)
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenBody()\n"));
@@ -2708,7 +2641,7 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
return NS_OK;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::CloseBody()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseBody()\n"));
@@ -2741,7 +2674,7 @@ HTMLContentSink::CloseBody()
return NS_OK;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::OpenForm(const nsIParserNode& aNode)
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenForm()\n"));
@@ -2770,25 +2703,11 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
mCurrentContext->IsCurrentContainer(eHTMLTag_tr) ||
mCurrentContext->IsCurrentContainer(eHTMLTag_col) ||
mCurrentContext->IsCurrentContainer(eHTMLTag_colgroup)) {
nsCOMPtr<nsINodeInfo> nodeInfo;
result = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::form, nsnull,
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
NS_ENSURE_SUCCESS(result, result);
mCurrentForm = NS_NewHTMLFormElement(nodeInfo);
if (!mCurrentForm) {
return NS_ERROR_OUT_OF_MEMORY;
}
result = AddLeaf(aNode);
result = mCurrentContext->AddLeaf(aNode);
} else {
mFlags |= NS_SINK_FLAG_FORM_ON_STACK;
// Otherwise the form can be a content parent.
result = mCurrentContext->OpenContainer(aNode);
if (NS_SUCCEEDED(result)) {
mCurrentForm = dont_AddRef(mCurrentContext->GetCurrentContainer());
}
}
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenForm()\n"));
@@ -2797,9 +2716,7 @@ HTMLContentSink::OpenForm(const nsIParserNode& aNode)
return result;
}
// XXX MAYBE add code to place close form tag into the content model
// for navigator layout compatability.
NS_IMETHODIMP
nsresult
HTMLContentSink::CloseForm()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseForm()\n"));
@@ -2816,7 +2733,6 @@ HTMLContentSink::CloseForm()
if (mCurrentForm) {
// if this is a well-formed form, close it too
if (mCurrentContext->IsCurrentContainer(eHTMLTag_form)) {
mCurrentContext->FlushTextAndRelease();
result = mCurrentContext->CloseContainer(eHTMLTag_form);
mFlags &= ~NS_SINK_FLAG_FORM_ON_STACK;
}
@@ -2830,7 +2746,7 @@ HTMLContentSink::CloseForm()
return result;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenFrameset()\n"));
@@ -2880,7 +2796,7 @@ HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
return rv;
}
NS_IMETHODIMP
nsresult
HTMLContentSink::CloseFrameset()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseFrameset()\n"));
@@ -2925,56 +2841,6 @@ HTMLContentSink::CloseFrameset()
return rv;
}
NS_IMETHODIMP
HTMLContentSink::OpenMap(const nsIParserNode& aNode)
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenMap()\n"));
MOZ_TIMER_START(mWatch);
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"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.
// HTML 4.0 says that MAP elements can have block content
// as children.
rv = mCurrentContext->OpenContainer(aNode);
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenMap()\n"));
MOZ_TIMER_STOP(mWatch);
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseMap()
{
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseMap()\n"));
MOZ_TIMER_START(mWatch);
nsresult rv = NS_OK;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::CloseMap",
eHTMLTag_map,
mCurrentContext->mStackPos - 1,
this);
mCurrentMap = nsnull;
rv = mCurrentContext->CloseContainer(eHTMLTag_map);
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseMap()\n"));
MOZ_TIMER_STOP(mWatch);
return rv;
}
NS_IMETHODIMP
HTMLContentSink::IsEnabled(PRInt32 aTag, PRBool* aReturn)
{
@@ -2999,11 +2865,30 @@ HTMLContentSink::OpenContainer(const nsIParserNode& aNode)
nsresult rv = NS_OK;
// XXX work around parser bug
if (eHTMLTag_frameset == aNode.GetNodeType()) {
rv = OpenFrameset(aNode);
} else {
rv = mCurrentContext->OpenContainer(aNode);
switch (aNode.GetNodeType()) {
case eHTMLTag_frameset:
rv = OpenFrameset(aNode);
break;
case eHTMLTag_head:
rv = OpenHeadContext();
if (NS_SUCCEEDED(rv)) {
rv = AddAttributes(aNode, mHead, PR_FALSE, PR_TRUE);
}
break;
case eHTMLTag_body:
rv = OpenBody(aNode);
break;
case eHTMLTag_html:
if (mRoot) {
AddAttributes(aNode, mRoot, PR_TRUE, PR_TRUE);
}
break;
case eHTMLTag_form:
rv = OpenForm(aNode);
break;
default:
rv = mCurrentContext->OpenContainer(aNode);
break;
}
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenContainer()\n"));
@@ -3018,14 +2903,28 @@ HTMLContentSink::CloseContainer(const eHTMLTags aTag)
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::CloseContainer()\n"));
MOZ_TIMER_START(mWatch);
// XXX work around parser bug
if (eHTMLTag_frameset == aTag) {
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseContainer()\n"));
MOZ_TIMER_STOP(mWatch);
return CloseFrameset();
}
nsresult rv = NS_OK;
nsresult rv = mCurrentContext->CloseContainer(aTag);
switch (aTag) {
case eHTMLTag_frameset:
rv = CloseFrameset();
break;
case eHTMLTag_head:
CloseHeadContext();
break;
case eHTMLTag_body:
rv = CloseBody();
break;
case eHTMLTag_html:
rv = CloseHTML();
break;
case eHTMLTag_form:
rv = CloseForm();
break;
default:
rv = mCurrentContext->CloseContainer(aTag);
break;
}
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::CloseContainer()\n"));
MOZ_TIMER_STOP(mWatch);
@@ -3695,17 +3594,15 @@ HTMLContentSink::OpenHeadContext()
return NS_OK;
}
nsresult
void
HTMLContentSink::CloseHeadContext()
{
if (mCurrentContext && !mCurrentContext->IsCurrentContainer(eHTMLTag_head))
return NS_OK;
return;
PRInt32 n = mContextStack.Count() - 1;
mCurrentContext = (SinkContext*) mContextStack.ElementAt(n);
mContextStack.RemoveElementAt(n);
return NS_OK;
}
void
@@ -3835,28 +3732,6 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
return result;
}
nsresult
HTMLContentSink::ProcessMAPTag(nsIContent* aContent)
{
mCurrentMap = nsnull;
nsCOMPtr<nsIDOMHTMLMapElement> domMap(do_QueryInterface(aContent));
if (!domMap) {
return NS_ERROR_UNEXPECTED;
}
// We used to strip whitespace from the NAME attribute here, to
// match a 4.x quirk, but it proved too quirky for us, and IE never
// did that. See bug 79738 for details.
// Don't need to add the map to the document here anymore.
// The map adds itself
mCurrentMap = aContent;
return NS_OK;
}
nsresult
HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
{

View File

@@ -90,24 +90,12 @@ public:
// nsIHTMLContentSink
NS_IMETHOD BeginContext(PRInt32 aID);
NS_IMETHOD EndContext(PRInt32 aID);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD OpenHead();
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) {
*aReturn = PR_TRUE;
return NS_OK;
}
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
@@ -299,24 +287,6 @@ nsHTMLFragmentContentSink::EndContext(PRInt32 aID)
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenHTML(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseHTML()
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenHead(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenHead()
{
@@ -324,72 +294,6 @@ nsHTMLFragmentContentSink::OpenHead()
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseHead()
{
if (mIgnoreNextCloseHead) {
mIgnoreNextCloseHead = PR_FALSE;
return NS_OK;
}
return CloseContainer(eHTMLTag_head);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenBody(const nsIParserNode& aNode)
{
// Ignore repeated BODY elements. The DTD is just sending them
// to us for compatibility reasons that don't apply here.
if (!mSeenBody) {
mSeenBody = PR_TRUE;
return OpenContainer(aNode);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseBody()
{
return CloseContainer(eHTMLTag_body);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenForm(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseForm()
{
return CloseContainer(eHTMLTag_form);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenFrameset(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseFrameset()
{
return CloseContainer(eHTMLTag_frameset);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenMap(const nsIParserNode& aNode)
{
return OpenContainer(aNode);
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseMap()
{
return CloseContainer(eHTMLTag_map);
}
void
nsHTMLFragmentContentSink::ProcessBaseTag(nsIContent* aContent)
{
@@ -422,6 +326,19 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
nsresult result = NS_OK;
if (aNode.GetNodeType() == eHTMLTag_html) {
return NS_OK;
}
// Ignore repeated BODY elements. The DTD is just sending them
// to us for compatibility reasons that don't apply here.
if (aNode.GetNodeType() == eHTMLTag_body) {
if (mSeenBody) {
return NS_OK;
}
mSeenBody = PR_TRUE;
}
if (mProcessing && !mIgnoreContainer) {
FlushText();
@@ -485,6 +402,14 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseContainer(const nsHTMLTag aTag)
{
if (aTag == eHTMLTag_html) {
return NS_OK;
}
if (mIgnoreNextCloseHead && aTag == eHTMLTag_head) {
mIgnoreNextCloseHead = PR_FALSE;
return NS_OK;
}
if (mProcessing && (nsnull != GetCurrentContent())) {
nsIContent* content;
FlushText();

View File

@@ -98,7 +98,7 @@ HTML_TAG(em, Span)
HTML_TAG(embed, Shared)
HTML_TAG(fieldset, FieldSet)
HTML_TAG(font, Font)
HTML_TAG(form, NOTUSED)
HTML_TAG(form, Form)
HTML_TAG(frame, Frame)
HTML_TAG(frameset, FrameSet)
HTML_TAG(h1, Heading)

View File

@@ -101,28 +101,6 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
/**
* This method is used to open the outer HTML container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHTML(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the outer HTML container.
*
*/
NS_IMETHOD CloseHTML() = 0;
/**
* This method is used to open the only HEAD container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenHead(const nsIParserNode& aNode) = 0;
/**
* This method is used to open the HEAD container. It is useful if a tag
* is forcing us to open the head (probably again), like if we find a <meta>
@@ -130,67 +108,6 @@ public:
*/
NS_IMETHOD OpenHead() = 0;
/**
* This method is used to close the only HEAD container.
*/
NS_IMETHOD CloseHead() = 0;
/**
* This method is used to open the main BODY container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenBody(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the main BODY container.
*
*/
NS_IMETHOD CloseBody() = 0;
/**
* This method is used to open a new FORM container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenForm(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the outer FORM container.
*
*/
NS_IMETHOD CloseForm() = 0;
/**
* This method is used to open a new MAP container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenMap(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the MAP container.
*
*/
NS_IMETHOD CloseMap() = 0;
/**
* This method is used to open the FRAMESET container.
*
* @update 4/1/98 gess
* @param nsIParserNode reference to parser node interface
*/
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode) = 0;
/**
* This method is used to close the FRAMESET container.
*
*/
NS_IMETHOD CloseFrameset() = 0;
/**
* This gets called when handling illegal contents, especially
* in dealing with tables. This method creates a new context.

View File

@@ -75,19 +75,7 @@ public:
NS_DECL_ISUPPORTS
// nsIHTMLContentSink
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD OpenHead();
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) { return NS_OK; }
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
@@ -176,71 +164,11 @@ NS_IMETHODIMP RobotSink::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
NS_IMETHODIMP RobotSink::OpenHTML(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseHTML()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenHead(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenHead()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseHead()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenBody(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseBody()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenForm(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseForm()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenMap(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseMap()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenFrameset(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::CloseFrameset()
{
return NS_OK;
}
NS_IMETHODIMP RobotSink::OpenContainer(const nsIParserNode& aNode)
{
nsAutoString tmp; tmp.Assign(aNode.GetText());

View File

@@ -1158,7 +1158,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
}
if(theChildIsContainer){
result=OpenContainer(aNode,aChildTag,PR_TRUE);
result=OpenContainer(aNode,aChildTag);
}
else { //we're writing a leaf...
result=AddLeaf(aNode);
@@ -1439,13 +1439,13 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
switch(theChildTag){
case eHTMLTag_html:
if(mBodyContext->GetCount()>0) {
result=OpenContainer(theNode,theChildTag,PR_FALSE);
result=OpenContainer(theNode,theChildTag);
isTokenHandled=PR_TRUE;
}
break;
case eHTMLTag_body:
if(mFlags & NS_DTD_FLAG_HAS_OPEN_BODY) {
result=OpenContainer(theNode,theChildTag,PR_FALSE);
result=OpenContainer(theNode,theChildTag);
isTokenHandled=PR_TRUE;
}
break;
@@ -1704,11 +1704,11 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
case eHTMLTag_head:
StripWSFollowingTag(theChildTag,mTokenizer, mTokenAllocator, mLineNumber);
result = CloseContainer(eHTMLTag_head, theChildTag, PR_FALSE);
result = CloseContainer(eHTMLTag_head);
break;
case eHTMLTag_form:
result = CloseContainer(eHTMLTag_form, theChildTag, PR_FALSE);
result = CloseContainer(eHTMLTag_form);
break;
case eHTMLTag_br:
@@ -1742,7 +1742,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
}
mBodyContext->Pop();
result = CloseContainer(eHTMLTag_script, theChildTag, PR_FALSE);
result = CloseContainer(eHTMLTag_script);
break;
default:
@@ -2570,11 +2570,11 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aChildTag, PRBool aCloseInvalid)
// should not get carried over to cases other than heading.
CAttributeToken theAttrToken(NS_LITERAL_STRING("_moz-rs-heading"), EmptyString());
theNode->AddAttribute(&theAttrToken);
result = OpenContainer(theNode,theNodeTag,PR_FALSE,theStack);
result = OpenContainer(theNode,theNodeTag,theStack);
theNode->PopAttributeToken();
}
else {
result = OpenContainer(theNode,theNodeTag,PR_FALSE,theStack);
result = OpenContainer(theNode,theNodeTag,theStack);
}
}
else if (aCloseInvalid) {
@@ -2650,7 +2650,7 @@ 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->OpenContainer(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
START_TIMER();
@@ -2662,87 +2662,6 @@ nsresult CNavDTD::OpenHTML(const nsCParserNode *aNode){
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
*
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseHTML(){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseHTML(), this=%p\n", this));
nsresult result = (mSink) ? mSink->CloseHTML() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseHTML(), this=%p\n", this));
START_TIMER();
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::OpenHead(const nsIParserNode *aNode)
{
nsresult result = NS_OK;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenHead(), this=%p\n", this));
if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
mFlags |= NS_DTD_FLAG_HAS_OPEN_HEAD;
if (mSink && aNode) {
result = mSink->OpenHead(*aNode);
}
else if (mSink) {
result = mSink->OpenHead();
}
}
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenHead(), this=%p\n", this));
START_TIMER();
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseHead()
{
nsresult result = NS_OK;
if (mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD) {
mFlags &= ~NS_DTD_FLAG_HAS_OPEN_HEAD;
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseHead(), this=%p\n", this));
result = mSink ? mSink->CloseHead() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseHead(), this=%p\n", this));
START_TIMER();
}
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
@@ -2765,10 +2684,10 @@ nsresult CNavDTD::OpenBody(const nsCParserNode *aNode)
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenBody(), this=%p\n", this));
// Make sure the head is closed by the time the body is opened.
CloseHead();
CloseContainer(eHTMLTag_head);
// Now we can open the body.
result = (mSink) ? mSink->OpenBody(*aNode) : NS_OK;
result = (mSink) ? mSink->OpenContainer(*aNode) : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenBody(), this=%p\n", this));
START_TIMER();
@@ -2782,173 +2701,6 @@ nsresult CNavDTD::OpenBody(const nsCParserNode *aNode)
return result;
}
/**
* This method does two things: 1st, help close
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseBody()
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseBody(), this=%p\n", this));
nsresult result= (mSink) ? mSink->CloseBody() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseBody(), this=%p\n", this));
START_TIMER();
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @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
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenForm(), this=%p\n", this));
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) {
mFlags |= NS_DTD_FLAG_HAS_OPEN_FORM;
}
}
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
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() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
START_TIMER();
}
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
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;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
START_TIMER();
if (NS_OK == result) {
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
++mOpenMapCount;
}
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
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() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
START_TIMER();
}
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be added to model
* @return TRUE if ok, FALSE if error
*/
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;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenFrameset(), this=%p\n", this));
START_TIMER();
mBodyContext->Push(NS_CONST_CAST(nsCParserNode*, aNode), 0, PR_FALSE);
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @return TRUE if ok, FALSE if error
*/
nsresult CNavDTD::CloseFrameset()
{
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseFrameset(), this=%p\n", this));
nsresult result = (mSink) ? mSink->CloseFrameset() : NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseFrameset(), this=%p\n", this));
START_TIMER();
return result;
}
/**
* This method does two things: 1st, help construct
* our own internal model of the content-stack; and
@@ -2961,7 +2713,6 @@ nsresult CNavDTD::CloseFrameset()
nsresult
CNavDTD::OpenContainer(const nsCParserNode *aNode,
eHTMLTags aTag,
PRBool aClosedByStartTag,
nsEntryStack* aStyleStack)
{
NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
@@ -2992,7 +2743,10 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,
result=OpenHTML(aNode); break;
case eHTMLTag_head:
result=OpenHead(aNode);
if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
mFlags |= NS_DTD_FLAG_HAS_OPEN_HEAD;
done = PR_FALSE;
}
break;
case eHTMLTag_body:
@@ -3009,15 +2763,20 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,
break;
case eHTMLTag_map:
result = OpenMap(aNode);
++mOpenMapCount;
done = PR_FALSE;
break;
case eHTMLTag_form:
result = OpenForm(aNode);
if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
mFlags |= NS_DTD_FLAG_HAS_OPEN_FORM;
done = PR_FALSE;
}
break;
case eHTMLTag_frameset:
result = OpenFrameset(aNode);
mFlags |= NS_DTD_FLAG_HAD_FRAMESET;
done = PR_FALSE;
break;
case eHTMLTag_noembed:
@@ -3072,42 +2831,37 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,
* our own internal model of the content-stack; and
* 2nd, pass this message on to the sink.
* @update gess4/6/98
* @param aNode -- next node to be removed from our model
* @param aTag -- id of tag to be closed
* @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container.
* @return TRUE if ok, FALSE if error
*/
nsresult
CNavDTD::CloseContainer(const eHTMLTags aTag, eHTMLTags aTarget,PRBool aClosedByStartTag)
CNavDTD::CloseContainer(const eHTMLTags aTag)
{
nsresult result = NS_OK;
PRBool done = PR_TRUE;
switch (aTag) {
case eHTMLTag_html:
result=CloseHTML();
break;
case eHTMLTag_head:
result=CloseHead();
break;
case eHTMLTag_body:
result=CloseBody();
if (mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD) {
mFlags &= ~NS_DTD_FLAG_HAS_OPEN_HEAD;
done = PR_FALSE;
}
break;
case eHTMLTag_map:
result=CloseMap();
if (mOpenMapCount) {
mOpenMapCount--;
done = PR_FALSE;
}
break;
case eHTMLTag_form:
result=CloseForm();
if (mFlags & NS_DTD_FLAG_HAS_OPEN_FORM) {
mFlags &= ~NS_DTD_FLAG_HAS_OPEN_FORM;
done = PR_FALSE;
}
break;
case eHTMLTag_frameset:
result=CloseFrameset();
break;
case eHTMLTag_iframe:
case eHTMLTag_noembed:
case eHTMLTag_noscript:
@@ -3116,32 +2870,34 @@ CNavDTD::CloseContainer(const eHTMLTags aTag, eHTMLTags aTarget,PRBool aClosedBy
mFlags &= ~NS_DTD_FLAG_ALTERNATE_CONTENT;
// falling thro' intentionally....
default:
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
done = PR_FALSE;
}
result = mSink
? mSink->CloseContainer(aTag)
: NS_OK; // XXX Can this case really happen?
if (!done) {
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
// If we were dealing with a head container in the body, make sure to
// close the head context now, so that body content doesn't get sucked
// into the head.
if (mBodyContext->GetCount() == mHeadContainerPosition) {
nsresult headresult = CloseHead();
result = mSink
? mSink->CloseContainer(aTag)
: NS_OK; // XXX Can this case really happen?
// Note: we could be assigning NS_OK into NS_OK here, but that's ok.
// This test is to avoid a successful CloseHead result stomping over a
// request to block the parser.
if (NS_SUCCEEDED(result)) {
result = headresult;
}
// If we were dealing with a head container in the body, make sure to
// close the head context now, so that body content doesn't get sucked
// into the head.
if (mBodyContext->GetCount() == mHeadContainerPosition) {
mHeadContainerPosition = -1;
nsresult headresult = CloseContainer(eHTMLTag_head);
mHeadContainerPosition = -1;
// Note: we could be assigning NS_OK into NS_OK here, but that's ok.
// This test is to avoid a successful CloseHead result stomping over a
// request to block the parser.
if (NS_SUCCEEDED(result)) {
result = headresult;
}
}
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
START_TIMER();
break;
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
START_TIMER();
}
return result;
@@ -3169,7 +2925,7 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
nsEntryStack* theChildStyleStack = 0;
eHTMLTags theTag = mBodyContext->Last();
nsCParserNode* theNode = mBodyContext->Pop(theChildStyleStack);
result = CloseContainer(theTag, aTarget,aClosedByStartTag);
result = CloseContainer(theTag);
#ifdef ENABLE_RESIDUALSTYLE
@@ -3416,8 +3172,11 @@ nsresult CNavDTD::AddHeadContent(nsIParserNode *aNode){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadContent(), this=%p\n", this));
// Make sure the head is opened. This might just be a no-op.
result = OpenHead(nsnull);
// Make sure the head is opened.
if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
mFlags |= NS_DTD_FLAG_HAS_OPEN_HEAD;
result = mSink->OpenHead();
}
// Note: userdefined tags in the head are treated as leaves.
if (!nsHTMLElement::IsContainer(theTag) || theTag == eHTMLTag_userdefined) {
@@ -3425,7 +3184,7 @@ nsresult CNavDTD::AddHeadContent(nsIParserNode *aNode){
if (mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER) {
// Close the head now so that body content doesn't get sucked into it.
CloseHead();
CloseContainer(eHTMLTag_head);
}
}
else {

View File

@@ -291,29 +291,15 @@ public:
* @return error code representing error condition-- usually 0.
*/
nsresult OpenHTML(const nsCParserNode *aNode);
nsresult OpenHead(const nsIParserNode *aNode);
nsresult OpenBody(const nsCParserNode *aNode);
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);
/**
* The next set of methods close the given HTML element.
*
* @update gess5/11/98
* @param HTML (node) to be opened in content sink.
* @return error code - 0 if all went well.
* Close head element if it is open.
*/
nsresult CloseHTML();
nsresult CloseHead();
nsresult CloseBody();
nsresult CloseForm();
nsresult CloseMap();
nsresult CloseFrameset();
/**
* The special purpose methods automatically close
@@ -321,9 +307,7 @@ public:
* @update gess5/11/98
* @return error code - 0 if all went well.
*/
nsresult CloseContainer(const eHTMLTags aTag,
eHTMLTags aTarget,
PRBool aClosedByStartTag);
nsresult CloseContainer(const eHTMLTags aTag);
nsresult CloseContainersTo(eHTMLTags aTag,
PRBool aClosedByStartTag);
nsresult CloseContainersTo(PRInt32 anIndex,

View File

@@ -326,50 +326,6 @@ nsLoggingSink::AddComment(const nsIParserNode& aNode){
}
NS_IMETHODIMP
nsLoggingSink::OpenHTML(const nsIParserNode& aNode) {
OpenNode("html", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenHTML(aNode);
}
return theResult;
}
NS_IMETHODIMP
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();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenHead(const nsIParserNode& aNode) {
OpenNode("head", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenHead(aNode);
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenHead() {
WriteTabs(mOutput,++mLevel);
@@ -385,133 +341,6 @@ nsLoggingSink::OpenHead() {
return theResult;
}
NS_IMETHODIMP
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();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenBody(const nsIParserNode& aNode) {
OpenNode("body", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenBody(aNode);
}
return theResult;
}
NS_IMETHODIMP
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();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenForm(const nsIParserNode& aNode) {
OpenNode("form", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenForm(aNode);
}
return theResult;
}
NS_IMETHODIMP
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();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenMap(const nsIParserNode& aNode) {
OpenNode("map", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenMap(aNode);
}
return theResult;
}
NS_IMETHODIMP
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();
}
return theResult;
}
NS_IMETHODIMP
nsLoggingSink::OpenFrameset(const nsIParserNode& aNode) {
OpenNode("frameset", aNode);
nsresult theResult=NS_OK;
//then proxy the call to the real sink if you have one.
if(mSink) {
theResult=mSink->OpenFrameset(aNode);
}
return theResult;
}
NS_IMETHODIMP
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();
}
return theResult;
}
nsresult
nsLoggingSink::OpenNode(const char* aKind, const nsIParserNode& aNode) {
WriteTabs(mOutput,++mLevel);

View File

@@ -76,19 +76,7 @@ public:
virtual nsISupports *GetTarget() { return nsnull; }
// nsIHTMLContentSink
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML();
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD OpenHead();
NS_IMETHOD CloseHead();
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody();
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm();
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap();
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn)
/* Take the largest possible feature set. */
{ NS_ENSURE_ARG_POINTER(aReturn); *aReturn = PR_TRUE; return NS_OK; }

View File

@@ -526,11 +526,11 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
CStartToken htmlToken(NS_LITERAL_STRING("HTML"), eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken, 0/*stack token*/);
mSink->OpenHTML(htmlNode);
mSink->OpenContainer(htmlNode);
CStartToken headToken(NS_LITERAL_STRING("HEAD"), eHTMLTag_head);
nsCParserNode headNode(&headToken, 0/*stack token*/);
mSink->OpenHead(headNode);
mSink->OpenContainer(headNode);
CStartToken titleToken(NS_LITERAL_STRING("TITLE"), eHTMLTag_title);
nsCParserNode titleNode(&titleToken, 0/*stack token*/);
@@ -578,9 +578,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
}
}
CEndToken endHeadToken(eHTMLTag_head);
nsCParserNode endHeadNode(&endHeadToken, 0/*stack token*/);
result = mSink->CloseHead();
result = mSink->CloseContainer(eHTMLTag_head);
if(NS_SUCCEEDED(result)) {
mHasOpenRoot = PR_TRUE;
if (didBlock) {
@@ -607,7 +605,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
NS_LITERAL_STRING("class"),
NS_ConvertASCIItoUCS2(kBodyClassWrap));
}
result = mSink->OpenBody(bodyNode);
result = mSink->OpenContainer(bodyNode);
if(NS_SUCCEEDED(result)) mHasOpenBody=PR_TRUE;
}
@@ -768,17 +766,9 @@ NS_IMETHODIMP CViewSourceHTML::DidBuildModel(nsresult anErrorCode,PRBool aNotify
#endif // DUMP_TO_FILE
if(ePlainText!=mDocType) {
CEndToken theToken(eHTMLTag_pre);
nsCParserNode preNode(&theToken, 0/*stack token*/);
mSink->CloseContainer(eHTMLTag_pre);
CEndToken bodyToken(eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken, 0/*stack token*/);
mSink->CloseBody();
CEndToken htmlToken(eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken, 0/*stack token*/);
mSink->CloseHTML();
mSink->CloseContainer(eHTMLTag_body);
mSink->CloseContainer(eHTMLTag_html);
}
result = mSink->DidBuildModel();
}