Remove bogus data-sniffing code in CanParse() impls, clean up signature, don't

peek a buffer if we're not planning to autodetect the parsemode.  Bug 113201,
r=rbs, sr=jst


git-svn-id: svn://10.0.0.236/trunk@156393 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2004-05-13 23:39:06 +00:00
parent 2d3ba6ffa2
commit 6a3b796123
9 changed files with 76 additions and 245 deletions

View File

@@ -411,32 +411,18 @@ nsresult CViewSourceHTML::CreateNewInstance(nsIDTD** aInstancePtrResult){
* @return TRUE if this DTD can satisfy the request; FALSE otherwise.
*/
NS_IMETHODIMP_(eAutoDetectResult)
CViewSourceHTML::CanParse(CParserContext& aParserContext,
const nsString& aBuffer, PRInt32 aVersion)
CViewSourceHTML::CanParse(CParserContext& aParserContext)
{
eAutoDetectResult result=eUnknownDetect;
if (eViewSource == aParserContext.mParserCommand) {
if (aParserContext.mDocType == ePlainText) {
return eValidDetect;
}
if(eViewSource==aParserContext.mParserCommand) {
if(aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kPlainTextContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kTextCSSContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kTextJSContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kApplicationJSContentType))) {
result=eValidDetect;
}
if(aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kXMLTextContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kXMLApplicationContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kXHTMLApplicationContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kRDFTextContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kHTMLTextContentType)) ||
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kXULTextContentType)) ||
#ifdef MOZ_SVG
aParserContext.mMimeType.Equals(NS_LITERAL_CSTRING(kSVGTextContentType)) ||
#endif
aParserContext.mMimeType.Equals(kSGMLTextContentType)) {
result=ePrimaryDetect;
}
// We claim to parse XML... now _that_ is funny.
return ePrimaryDetect;
}
return result;
return eUnknownDetect;
}