Bug 484121 (1/6) - Decompose nsHTMLTokenizer::GetFlags. r+sr=mrbkap

This commit is contained in:
Ben Newman 2009-06-23 14:22:16 -07:00
Родитель 7964c8f00a
Коммит a56545afcb
4 изменённых файлов: 26 добавлений и 32 удалений

Просмотреть файл

@ -233,18 +233,8 @@ CNavDTD::WillBuildModel(const CParserContext& aParserContext,
}
#endif
if (mSink) {
PRBool enabled = PR_TRUE;
mSink->IsEnabled(eHTMLTag_frameset, &enabled);
if (enabled) {
mFlags |= NS_IPARSER_FLAG_FRAMES_ENABLED;
}
mSink->IsEnabled(eHTMLTag_script, &enabled);
if (enabled) {
mFlags |= NS_IPARSER_FLAG_SCRIPT_ENABLED;
}
}
mFlags |= nsHTMLTokenizer::GetFlags(aSink);
}
return result;

Просмотреть файл

@ -105,25 +105,8 @@ CParserContext::GetTokenizer(nsIDTD* aDTD,
if (!mTokenizer) {
if (type == NS_IPARSER_FLAG_HTML || mParserCommand == eViewSource) {
nsCOMPtr<nsIHTMLContentSink> theSink = do_QueryInterface(aSink);
PRUint16 theFlags = 0;
if (theSink) {
// XXX This code is repeated both here and in CNavDTD. Can the two
// callsites be combined?
PRBool enabled;
theSink->IsEnabled(eHTMLTag_frameset, &enabled);
if(enabled) {
theFlags |= NS_IPARSER_FLAG_FRAMES_ENABLED;
}
theSink->IsEnabled(eHTMLTag_script, &enabled);
if(enabled) {
theFlags |= NS_IPARSER_FLAG_SCRIPT_ENABLED;
}
}
mTokenizer = new nsHTMLTokenizer(mDTDMode, mDocType,
mParserCommand, theFlags);
mTokenizer = new nsHTMLTokenizer(mDTDMode, mDocType, mParserCommand,
nsHTMLTokenizer::GetFlags(aSink));
if (!mTokenizer) {
return NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -118,7 +118,26 @@ nsHTMLTokenizer::~nsHTMLTokenizer()
mTokenDeque.ForEach(theDeallocator);
}
}
/*static*/ PRUint32
nsHTMLTokenizer::GetFlags(const nsIContentSink* aSink)
{
PRUint32 flags = 0;
nsCOMPtr<nsIHTMLContentSink> sink =
do_QueryInterface(const_cast<nsIContentSink*>(aSink));
if (sink) {
PRBool enabled = PR_TRUE;
sink->IsEnabled(eHTMLTag_frameset, &enabled);
if (enabled) {
flags |= NS_IPARSER_FLAG_FRAMES_ENABLED;
}
sink->IsEnabled(eHTMLTag_script, &enabled);
if (enabled) {
flags |= NS_IPARSER_FLAG_SCRIPT_ENABLED;
}
}
return flags;
}
/*******************************************************************
Here begins the real working methods for the tokenizer.

Просмотреть файл

@ -73,6 +73,8 @@ public:
PRUint16 aFlags = 0);
virtual ~nsHTMLTokenizer();
static PRUint32 GetFlags(const nsIContentSink* aSink);
protected:
nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens);