diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
index 4d96889a6f5..49d3a23f802 100644
--- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
@@ -929,6 +929,32 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, const nsString& aTag)
return rv;
}
+nsresult
+NS_CreateHTMLElement(nsIHTMLContent** aResult, PRInt32 aID)
+{
+ nsresult rv = NS_OK;
+
+ if (eHTMLTag_userdefined == nsHTMLTag(aID)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+
+ NS_WITH_SERVICE(nsIParserService,
+ parserService,
+ kParserServiceCID,
+ &rv);
+
+ if (NS_SUCCEEDED(rv)) {
+ // Create atom for tag and then create content object
+ nsAutoString tag;
+ rv = parserService->HTMLIdToStringTag(aID, tag);
+ nsIAtom* atom = NS_NewAtom(tag.GetUnicode());
+ rv = MakeContentObject(nsHTMLTag(aID), atom, nsnull, nsnull, aResult);
+ NS_RELEASE(atom);
+ }
+
+ return rv;
+}
+
//----------------------------------------------------------------------
diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp
index 96c430ecbb9..d9b52413de1 100644
--- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp
@@ -24,6 +24,7 @@
#include "nsIParser.h"
#include "nsIHTMLContent.h"
#include "nsIHTMLContentContainer.h"
+#include "nsHTMLAtoms.h"
#include "nsHTMLTokens.h"
#include "nsHTMLEntities.h"
#include "nsHTMLParts.h"
@@ -107,6 +108,9 @@ public:
nsresult AddText(const nsString& aString);
nsresult FlushText();
+ void ProcessBaseTag(nsIHTMLContent* aContent);
+ void AddBaseTagInfo(nsIHTMLContent* aContent);
+
PRBool mHitSentinel;
PRBool mSeenBody;
@@ -120,6 +124,9 @@ public:
PRUnichar* mText;
PRInt32 mTextLength;
PRInt32 mTextSize;
+
+ nsString mBaseHREF;
+ nsString mBaseTarget;
};
@@ -360,6 +367,31 @@ nsHTMLFragmentContentSink::CloseMap(const nsIParserNode& aNode)
return CloseContainer(aNode);
}
+void
+nsHTMLFragmentContentSink::ProcessBaseTag(nsIHTMLContent* aContent)
+{
+ nsAutoString value;
+ if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::href, value)) {
+ mBaseHREF = value;
+ }
+ if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::target, value)) {
+ mBaseTarget = value;
+ }
+}
+
+void
+nsHTMLFragmentContentSink::AddBaseTagInfo(nsIHTMLContent* aContent)
+{
+ if (aContent) {
+ if (mBaseHREF.Length() > 0) {
+ aContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::_baseHref, mBaseHREF, PR_FALSE);
+ }
+ if (mBaseTarget.Length() > 0) {
+ aContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::_baseTarget, mBaseTarget, PR_FALSE);
+ }
+ }
+}
+
static char* kSentinelStr = "endnote";
NS_IMETHODIMP
@@ -375,8 +407,9 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
else if (mHitSentinel) {
FlushText();
+ nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsIHTMLContent *content = nsnull;
- result = NS_CreateHTMLElement(&content, tag);
+ result = NS_CreateHTMLElement(&content, nodeType);
if (NS_OK == result) {
result = AddAttributes(aNode, content);
@@ -391,6 +424,19 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
PushContent(content);
}
}
+
+ switch(nodeType) {
+ case eHTMLTag_table:
+ case eHTMLTag_thead:
+ case eHTMLTag_tbody:
+ case eHTMLTag_tfoot:
+ case eHTMLTag_tr:
+ case eHTMLTag_td:
+ case eHTMLTag_th:
+ // XXX if navigator_quirks_mode (only body in html supports background)
+ AddBaseTagInfo(content);
+ break;
+ }
}
return result;
@@ -408,6 +454,7 @@ nsHTMLFragmentContentSink::CloseContainer(const nsIParserNode& aNode)
return NS_OK;
}
+
NS_IMETHODIMP
nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
{
@@ -419,9 +466,9 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
FlushText();
// Create new leaf content object
- nsIHTMLContent* content;
- nsAutoString tag = aNode.GetText();
- result = NS_CreateHTMLElement(&content, tag);
+ nsCOMPtr content;
+ nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
+ result = NS_CreateHTMLElement(getter_AddRefs(content), nodeType);
if (NS_OK == result) {
result = AddAttributes(aNode, content);
@@ -434,7 +481,17 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
parent->AppendChildTo(content, PR_FALSE);
}
- NS_RELEASE(content);
+ }
+
+ switch(nodeType) {
+ case eHTMLTag_img: // elements with 'SRC='
+ case eHTMLTag_frame:
+ case eHTMLTag_input:
+ AddBaseTagInfo(content);
+ break;
+ case eHTMLTag_base:
+ ProcessBaseTag(content);
+ break;
}
}
break;
diff --git a/mozilla/layout/generic/nsHTMLParts.h b/mozilla/layout/generic/nsHTMLParts.h
index acc1ec6812c..2d8f336bb19 100644
--- a/mozilla/layout/generic/nsHTMLParts.h
+++ b/mozilla/layout/generic/nsHTMLParts.h
@@ -239,6 +239,9 @@ NS_NewHTMLWBRElement(nsIHTMLContent** aResult, nsIAtom* aTag);
PR_EXTERN(nsresult)
NS_CreateHTMLElement(nsIHTMLContent** aResult,
const nsString& aTag);
+PR_EXTERN(nsresult)
+NS_CreateHTMLElement(nsIHTMLContent** aResult,
+ PRInt32 aID);
// Factory methods for creating html layout objects
diff --git a/mozilla/layout/html/base/src/nsHTMLParts.h b/mozilla/layout/html/base/src/nsHTMLParts.h
index acc1ec6812c..2d8f336bb19 100644
--- a/mozilla/layout/html/base/src/nsHTMLParts.h
+++ b/mozilla/layout/html/base/src/nsHTMLParts.h
@@ -239,6 +239,9 @@ NS_NewHTMLWBRElement(nsIHTMLContent** aResult, nsIAtom* aTag);
PR_EXTERN(nsresult)
NS_CreateHTMLElement(nsIHTMLContent** aResult,
const nsString& aTag);
+PR_EXTERN(nsresult)
+NS_CreateHTMLElement(nsIHTMLContent** aResult,
+ PRInt32 aID);
// Factory methods for creating html layout objects
diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
index 4d96889a6f5..49d3a23f802 100644
--- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
@@ -929,6 +929,32 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, const nsString& aTag)
return rv;
}
+nsresult
+NS_CreateHTMLElement(nsIHTMLContent** aResult, PRInt32 aID)
+{
+ nsresult rv = NS_OK;
+
+ if (eHTMLTag_userdefined == nsHTMLTag(aID)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+
+ NS_WITH_SERVICE(nsIParserService,
+ parserService,
+ kParserServiceCID,
+ &rv);
+
+ if (NS_SUCCEEDED(rv)) {
+ // Create atom for tag and then create content object
+ nsAutoString tag;
+ rv = parserService->HTMLIdToStringTag(aID, tag);
+ nsIAtom* atom = NS_NewAtom(tag.GetUnicode());
+ rv = MakeContentObject(nsHTMLTag(aID), atom, nsnull, nsnull, aResult);
+ NS_RELEASE(atom);
+ }
+
+ return rv;
+}
+
//----------------------------------------------------------------------
diff --git a/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp
index 96c430ecbb9..d9b52413de1 100644
--- a/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp
@@ -24,6 +24,7 @@
#include "nsIParser.h"
#include "nsIHTMLContent.h"
#include "nsIHTMLContentContainer.h"
+#include "nsHTMLAtoms.h"
#include "nsHTMLTokens.h"
#include "nsHTMLEntities.h"
#include "nsHTMLParts.h"
@@ -107,6 +108,9 @@ public:
nsresult AddText(const nsString& aString);
nsresult FlushText();
+ void ProcessBaseTag(nsIHTMLContent* aContent);
+ void AddBaseTagInfo(nsIHTMLContent* aContent);
+
PRBool mHitSentinel;
PRBool mSeenBody;
@@ -120,6 +124,9 @@ public:
PRUnichar* mText;
PRInt32 mTextLength;
PRInt32 mTextSize;
+
+ nsString mBaseHREF;
+ nsString mBaseTarget;
};
@@ -360,6 +367,31 @@ nsHTMLFragmentContentSink::CloseMap(const nsIParserNode& aNode)
return CloseContainer(aNode);
}
+void
+nsHTMLFragmentContentSink::ProcessBaseTag(nsIHTMLContent* aContent)
+{
+ nsAutoString value;
+ if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::href, value)) {
+ mBaseHREF = value;
+ }
+ if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::target, value)) {
+ mBaseTarget = value;
+ }
+}
+
+void
+nsHTMLFragmentContentSink::AddBaseTagInfo(nsIHTMLContent* aContent)
+{
+ if (aContent) {
+ if (mBaseHREF.Length() > 0) {
+ aContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::_baseHref, mBaseHREF, PR_FALSE);
+ }
+ if (mBaseTarget.Length() > 0) {
+ aContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::_baseTarget, mBaseTarget, PR_FALSE);
+ }
+ }
+}
+
static char* kSentinelStr = "endnote";
NS_IMETHODIMP
@@ -375,8 +407,9 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
else if (mHitSentinel) {
FlushText();
+ nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsIHTMLContent *content = nsnull;
- result = NS_CreateHTMLElement(&content, tag);
+ result = NS_CreateHTMLElement(&content, nodeType);
if (NS_OK == result) {
result = AddAttributes(aNode, content);
@@ -391,6 +424,19 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
PushContent(content);
}
}
+
+ switch(nodeType) {
+ case eHTMLTag_table:
+ case eHTMLTag_thead:
+ case eHTMLTag_tbody:
+ case eHTMLTag_tfoot:
+ case eHTMLTag_tr:
+ case eHTMLTag_td:
+ case eHTMLTag_th:
+ // XXX if navigator_quirks_mode (only body in html supports background)
+ AddBaseTagInfo(content);
+ break;
+ }
}
return result;
@@ -408,6 +454,7 @@ nsHTMLFragmentContentSink::CloseContainer(const nsIParserNode& aNode)
return NS_OK;
}
+
NS_IMETHODIMP
nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
{
@@ -419,9 +466,9 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
FlushText();
// Create new leaf content object
- nsIHTMLContent* content;
- nsAutoString tag = aNode.GetText();
- result = NS_CreateHTMLElement(&content, tag);
+ nsCOMPtr content;
+ nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
+ result = NS_CreateHTMLElement(getter_AddRefs(content), nodeType);
if (NS_OK == result) {
result = AddAttributes(aNode, content);
@@ -434,7 +481,17 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
parent->AppendChildTo(content, PR_FALSE);
}
- NS_RELEASE(content);
+ }
+
+ switch(nodeType) {
+ case eHTMLTag_img: // elements with 'SRC='
+ case eHTMLTag_frame:
+ case eHTMLTag_input:
+ AddBaseTagInfo(content);
+ break;
+ case eHTMLTag_base:
+ ProcessBaseTag(content);
+ break;
}
}
break;