diff --git a/mozilla/content/html/content/src/nsHTMLAtomList.h b/mozilla/content/html/content/src/nsHTMLAtomList.h
index 8612c5c4698..cad9a53d4bd 100644
--- a/mozilla/content/html/content/src/nsHTMLAtomList.h
+++ b/mozilla/content/html/content/src/nsHTMLAtomList.h
@@ -229,6 +229,7 @@ HTML_ATOM(pagex, "pagex")
HTML_ATOM(pagey, "pagey")
HTML_ATOM(param, "param")
HTML_ATOM(phase, "phase") //XML Events
+HTML_ATOM(plaintext, "plaintext")
HTML_ATOM(pointSize, "point-size")
HTML_ATOM(pre, "pre")
HTML_ATOM(profile, "profile")
diff --git a/mozilla/content/html/content/src/nsHTMLSpanElement.cpp b/mozilla/content/html/content/src/nsHTMLSpanElement.cpp
index b7049f34173..7dc3cd8a2cf 100644
--- a/mozilla/content/html/content/src/nsHTMLSpanElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLSpanElement.cpp
@@ -96,7 +96,8 @@ NS_IMPL_DOM_CLONENODE(nsHTMLSpanElement)
nsresult
nsHTMLSpanElement::GetInnerHTML(nsAString& aInnerHTML)
{
- if (mNodeInfo->Equals(nsHTMLAtoms::xmp)) {
+ if (mNodeInfo->Equals(nsHTMLAtoms::xmp) ||
+ mNodeInfo->Equals(nsHTMLAtoms::plaintext)) {
GetContentsAsText(aInnerHTML);
return NS_OK;
}
@@ -107,7 +108,8 @@ nsHTMLSpanElement::GetInnerHTML(nsAString& aInnerHTML)
nsresult
nsHTMLSpanElement::SetInnerHTML(const nsAString& aInnerHTML)
{
- if (mNodeInfo->Equals(nsHTMLAtoms::xmp)) {
+ if (mNodeInfo->Equals(nsHTMLAtoms::xmp) ||
+ mNodeInfo->Equals(nsHTMLAtoms::plaintext)) {
return ReplaceContentsWithText(aInnerHTML, PR_TRUE);
}
diff --git a/mozilla/parser/htmlparser/public/nsHTMLTagList.h b/mozilla/parser/htmlparser/public/nsHTMLTagList.h
index 230472e2d59..9e7f563c167 100644
--- a/mozilla/parser/htmlparser/public/nsHTMLTagList.h
+++ b/mozilla/parser/htmlparser/public/nsHTMLTagList.h
@@ -140,6 +140,7 @@ HTML_TAG(optgroup, OptGroup)
HTML_TAG(option, Option)
HTML_TAG(p, Paragraph)
HTML_TAG(param, Shared)
+HTML_TAG(plaintext, Span)
HTML_TAG(pre, Pre)
HTML_TAG(q, Shared)
HTML_TAG(s, Span)
diff --git a/mozilla/parser/htmlparser/public/nsITokenizer.h b/mozilla/parser/htmlparser/public/nsITokenizer.h
index 3027b43d925..76b276ba45a 100644
--- a/mozilla/parser/htmlparser/public/nsITokenizer.h
+++ b/mozilla/parser/htmlparser/public/nsITokenizer.h
@@ -86,6 +86,7 @@ public:
NS_IMETHOD_(PRInt32) GetCount(void)=0;
NS_IMETHOD_(nsTokenAllocator*) GetTokenAllocator(void)=0;
NS_IMETHOD_(void) PrependTokens(nsDeque& aDeque)=0;
+ NS_IMETHOD CopyState(nsITokenizer* aTokenizer)=0;
};
@@ -100,7 +101,8 @@ public:
NS_IMETHOD_(CToken*) GetTokenAt(PRInt32 anIndex);\
NS_IMETHOD_(PRInt32) GetCount(void);\
NS_IMETHOD_(nsTokenAllocator*) GetTokenAllocator(void);\
- NS_IMETHOD_(void) PrependTokens(nsDeque& aDeque);
+ NS_IMETHOD_(void) PrependTokens(nsDeque& aDeque);\
+ NS_IMETHOD CopyState(nsITokenizer* aTokenizer);
#endif
diff --git a/mozilla/parser/htmlparser/src/COtherElements.h b/mozilla/parser/htmlparser/src/COtherElements.h
index f881f52dc57..9f1cfc72433 100644
--- a/mozilla/parser/htmlparser/src/COtherElements.h
+++ b/mozilla/parser/htmlparser/src/COtherElements.h
@@ -2344,6 +2344,7 @@ void CElementTable::InitializeElements() {
mDfltElements[eHTMLTag_p].mContainsGroups.mBits.mSelf=0;
CElement::InitializeLeaf( mDfltElements[eHTMLTag_param], eHTMLTag_param, CElement::GetEmptyGroup(), CLeafElement::GetContainedGroups());
+ CElement::Initialize( mDfltElements[eHTMLTag_plaintext], eHTMLTag_plaintext);
CBlockElement::Initialize( mDfltElements[eHTMLTag_pre], eHTMLTag_pre);
mDfltElements[eHTMLTag_pre].mExcludeKids=kPreExcludeKids;
diff --git a/mozilla/parser/htmlparser/src/CParserContext.cpp b/mozilla/parser/htmlparser/src/CParserContext.cpp
index 5197a6488bb..4adf1cb316a 100644
--- a/mozilla/parser/htmlparser/src/CParserContext.cpp
+++ b/mozilla/parser/htmlparser/src/CParserContext.cpp
@@ -197,6 +197,11 @@ CParserContext::GetTokenizer(PRInt32 aType,
result = NS_NewHTMLTokenizer(&mTokenizer,mDTDMode,mDocType,
mParserCommand,theFlags);
+ // Make sure the new tokenizer has all of the necessary information.
+ // XXX this might not be necessary.
+ if (mTokenizer && mPrevContext) {
+ mTokenizer->CopyState(mPrevContext->mTokenizer);
+ }
}
else if (aType == NS_IPARSER_FLAG_XML)
{
diff --git a/mozilla/parser/htmlparser/src/nsElementTable.cpp b/mozilla/parser/htmlparser/src/nsElementTable.cpp
index 18ea78ceee4..a270e4706ca 100644
--- a/mozilla/parser/htmlparser/src/nsElementTable.cpp
+++ b/mozilla/parser/htmlparser/src/nsElementTable.cpp
@@ -970,6 +970,16 @@ const nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gParamParents,0,eHTMLTag_unknown,
/*contain-func*/ 0
},
+ {
+ /*tag*/ eHTMLTag_plaintext,
+ /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
+ /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
+ /*autoclose starttags and endtags*/ 0,0,0,0,
+ /*parent,incl,exclgroups*/ kExtensions, kCDATA, kNone,
+ /*special props, prop-range*/ 0, kDefaultPropRange,
+ /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown,
+ /*contain-func*/ 0
+ },
{
/*tag*/ eHTMLTag_pre,
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
diff --git a/mozilla/parser/htmlparser/src/nsExpatDriver.cpp b/mozilla/parser/htmlparser/src/nsExpatDriver.cpp
index e5d8b3dc3d2..f49822ccb4b 100644
--- a/mozilla/parser/htmlparser/src/nsExpatDriver.cpp
+++ b/mozilla/parser/htmlparser/src/nsExpatDriver.cpp
@@ -1166,6 +1166,12 @@ nsExpatDriver::PrependTokens(nsDeque& aDeque)
{
}
+NS_IMETHODIMP
+nsExpatDriver::CopyState(nsITokenizer* aTokenizer)
+{
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsExpatDriver::HandleToken(CToken* aToken,nsIParser* aParser)
{
diff --git a/mozilla/parser/htmlparser/src/nsHTMLTags.cpp b/mozilla/parser/htmlparser/src/nsHTMLTags.cpp
index 942bebcaf42..3173e7ed49f 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLTags.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLTags.cpp
@@ -199,6 +199,8 @@ static const PRUnichar sHTMLTagUnicodeName_p[] =
{'p', '\0'};
static const PRUnichar sHTMLTagUnicodeName_param[] =
{'p', 'a', 'r', 'a', 'm', '\0'};
+static const PRUnichar sHTMLTagUnicodeName_plaintext[] =
+ {'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_pre[] =
{'p', 'r', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_q[] =
diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
index 5d68999dea7..070780e8077 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
@@ -342,6 +342,23 @@ void nsHTMLTokenizer::PrependTokens(nsDeque& aDeque)
}
+/**
+ * Copies the state flags from aTokenizer into this tokenizer. This is used
+ * to pass information around between the main tokenizer and tokenizers
+ * created for document.write() calls.
+ *
+ * @param aTokenizer The tokenizer with more information in it.
+ * @return NS_OK
+ */
+nsresult nsHTMLTokenizer::CopyState(nsITokenizer* aTokenizer)
+{
+ if (aTokenizer) {
+ mFlags = ((nsHTMLTokenizer*)aTokenizer)->mFlags;
+ }
+
+ return NS_OK;
+}
+
/**
* This is a utilty method for ScanDocStructure, which finds a given
* tag in the stack. The return value is meant to be used with
@@ -834,6 +851,16 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,
isCDATA = PR_TRUE;
}
+ // Plaintext contains CDATA, but it's special, so we handle it
+ // differently than the other CDATA elements
+ if (eHTMLTag_plaintext == theTag) {
+ isCDATA = PR_FALSE;
+
+ // Note: We check in ConsumeToken() for this flag, and if we see it
+ // we only construct text tokens (which is what we want).
+ mFlags |= NS_IPARSER_FLAG_PLAIN_TEXT;
+ }
+
if (isCDATA || isPCDATA) {
PRBool done = PR_FALSE;