bug 287990: Bring back <plaintext> support. This supports it "properly" (i.e., no end tag). r=jst sr=dbaron a=shaver
git-svn-id: svn://10.0.0.236/trunk@173992 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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[] =
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user