From aba7d2a324f1a18dbbb7dfb94e2d6405cf76e2b1 Mon Sep 17 00:00:00 2001 From: "vidur%netscape.com" Date: Wed, 16 Jun 1999 00:44:50 +0000 Subject: [PATCH] sink now creates content for BASE element git-svn-id: svn://10.0.0.236/trunk@35583 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLContentSink.cpp | 36 ++++++++++++------- .../html/document/src/nsHTMLContentSink.cpp | 36 ++++++++++++------- 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index b71e3f4185e..bf86f220084 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -2214,21 +2214,33 @@ HTMLContentSink::ProcessBaseTarget(const nsString& aBaseTarget) nsresult HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) { + nsresult result = NS_OK; nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner(); - PRInt32 ac = aNode.GetAttributeCount(); - for (PRInt32 i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); - nsAutoString value; - if (key.EqualsIgnoreCase("href")) { - GetAttributeValueAt(aNode, i, value, sco); - ProcessBaseHref(value); - } else if (key.EqualsIgnoreCase("target")) { - GetAttributeValueAt(aNode, i, value, sco); - ProcessBaseTarget(value); + + // Create content object + nsAutoString tag("BASE"); + nsIHTMLContent* element = nsnull; + result = NS_CreateHTMLElement(&element, tag); + if (NS_SUCCEEDED(result)) { + // Add in the attributes and add the style content object to the + // head container. + element->SetDocument(mDocument, PR_FALSE); + result = AddAttributes(aNode, element, sco); + if (NS_SUCCEEDED(result)) { + mHead->AppendChildTo(element, PR_FALSE); + + nsAutoString value; + if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, value)) { + ProcessBaseHref(value); + } + if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, value)) { + ProcessBaseTarget(value); + } } } - NS_RELEASE(sco); - return NS_OK; + + NS_IF_RELEASE(sco); + return result; } diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index b71e3f4185e..bf86f220084 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -2214,21 +2214,33 @@ HTMLContentSink::ProcessBaseTarget(const nsString& aBaseTarget) nsresult HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) { + nsresult result = NS_OK; nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner(); - PRInt32 ac = aNode.GetAttributeCount(); - for (PRInt32 i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); - nsAutoString value; - if (key.EqualsIgnoreCase("href")) { - GetAttributeValueAt(aNode, i, value, sco); - ProcessBaseHref(value); - } else if (key.EqualsIgnoreCase("target")) { - GetAttributeValueAt(aNode, i, value, sco); - ProcessBaseTarget(value); + + // Create content object + nsAutoString tag("BASE"); + nsIHTMLContent* element = nsnull; + result = NS_CreateHTMLElement(&element, tag); + if (NS_SUCCEEDED(result)) { + // Add in the attributes and add the style content object to the + // head container. + element->SetDocument(mDocument, PR_FALSE); + result = AddAttributes(aNode, element, sco); + if (NS_SUCCEEDED(result)) { + mHead->AppendChildTo(element, PR_FALSE); + + nsAutoString value; + if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, value)) { + ProcessBaseHref(value); + } + if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, value)) { + ProcessBaseTarget(value); + } } } - NS_RELEASE(sco); - return NS_OK; + + NS_IF_RELEASE(sco); + return result; }