mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 530275. Move more MIME types into nsMimeTypes.h so we don't have to hardcode the strings in various places. r=bzbarsky
This commit is contained in:
parent
f78442c0ad
commit
8b46e8bd69
@ -98,13 +98,12 @@
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsGUIEvent.h"
|
||||
#endif
|
||||
|
||||
#define kXSLType "text/xsl"
|
||||
|
||||
// XXX Open Issues:
|
||||
// 1) what's not allowed - We need to figure out which HTML tags
|
||||
// (prefixed with a HTML namespace qualifier) are explicitly not
|
||||
@ -745,9 +744,9 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
return NS_OK; // Do not load stylesheets when loading as data
|
||||
|
||||
NS_ConvertUTF16toUTF8 type(aType);
|
||||
if (type.EqualsIgnoreCase(kXSLType) ||
|
||||
type.EqualsIgnoreCase(kXMLTextContentType) ||
|
||||
type.EqualsIgnoreCase(kXMLApplicationContentType)) {
|
||||
if (type.EqualsIgnoreCase(TEXT_XSL) ||
|
||||
type.EqualsIgnoreCase(TEXT_XML) ||
|
||||
type.EqualsIgnoreCase(APPLICATION_XML)) {
|
||||
if (aAlternate) {
|
||||
// don't load alternate XSLT
|
||||
return NS_OK;
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
#include "imgILoader.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
// plugins
|
||||
#include "nsIPluginHost.h"
|
||||
@ -88,32 +89,32 @@ NS_NewDocumentViewer(nsIDocumentViewer** aResult);
|
||||
// XXXbz if you change the MIME types here, be sure to update
|
||||
// nsIParser.h and DetermineParseMode in nsParser.cpp accordingly.
|
||||
static const char* const gHTMLTypes[] = {
|
||||
"text/html",
|
||||
"text/plain",
|
||||
"text/css",
|
||||
"text/javascript",
|
||||
"text/ecmascript",
|
||||
"application/javascript",
|
||||
"application/ecmascript",
|
||||
"application/x-javascript",
|
||||
TEXT_HTML,
|
||||
TEXT_PLAIN,
|
||||
TEXT_CSS,
|
||||
TEXT_JAVASCRIPT,
|
||||
TEXT_ECMASCRIPT,
|
||||
APPLICATION_JAVASCRIPT,
|
||||
APPLICATION_ECMASCRIPT,
|
||||
APPLICATION_XJAVASCRIPT,
|
||||
#ifdef MOZ_VIEW_SOURCE
|
||||
"application/x-view-source", //XXX I wish I could just use nsMimeTypes.h here
|
||||
VIEWSOURCE_CONTENT_TYPE,
|
||||
#endif
|
||||
"application/xhtml+xml",
|
||||
APPLICATION_XHTML_XML,
|
||||
0
|
||||
};
|
||||
|
||||
static const char* const gXMLTypes[] = {
|
||||
"text/xml",
|
||||
"application/xml",
|
||||
"application/rdf+xml",
|
||||
"text/rdf",
|
||||
TEXT_XML,
|
||||
APPLICATION_XML,
|
||||
APPLICATION_RDF_XML,
|
||||
TEXT_RDF,
|
||||
0
|
||||
};
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static const char* const gSVGTypes[] = {
|
||||
"image/svg+xml",
|
||||
IMAGE_SVG_XML,
|
||||
0
|
||||
};
|
||||
|
||||
@ -121,8 +122,8 @@ PRBool NS_SVGEnabled();
|
||||
#endif
|
||||
|
||||
static const char* const gXULTypes[] = {
|
||||
"application/vnd.mozilla.xul+xml",
|
||||
"mozilla.application/cached-xul",
|
||||
TEXT_XUL,
|
||||
APPLICATION_CACHED_XUL,
|
||||
0
|
||||
};
|
||||
|
||||
@ -183,7 +184,7 @@ nsContentDLF::CreateInstance(const char* aCommand,
|
||||
PRInt32 typeIndex;
|
||||
for (typeIndex = 0; gHTMLTypes[typeIndex] && !knownType; ++typeIndex) {
|
||||
if (type.Equals(gHTMLTypes[typeIndex]) &&
|
||||
!type.EqualsLiteral("application/x-view-source")) {
|
||||
!type.EqualsLiteral(VIEWSOURCE_CONTENT_TYPE)) {
|
||||
knownType = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@ -217,11 +218,11 @@ nsContentDLF::CreateInstance(const char* aCommand,
|
||||
// Also note the lifetime of "type" allows us to safely use "get()" here.
|
||||
aContentType = type.get();
|
||||
} else {
|
||||
viewSourceChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
|
||||
viewSourceChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN));
|
||||
}
|
||||
} else if (0 == PL_strcmp("application/x-view-source", aContentType)) {
|
||||
aChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
|
||||
aContentType = "text/plain";
|
||||
} else if (0 == PL_strcmp(VIEWSOURCE_CONTENT_TYPE, aContentType)) {
|
||||
aChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN));
|
||||
aContentType = TEXT_PLAIN;
|
||||
}
|
||||
#endif
|
||||
// Try html
|
||||
|
@ -63,7 +63,9 @@
|
||||
#define APPLICATION_GZIP3 "application/x-gunzip"
|
||||
#define APPLICATION_ZIP "application/zip"
|
||||
#define APPLICATION_HTTP_INDEX_FORMAT "application/http-index-format"
|
||||
#define APPLICATION_JAVASCRIPT "application/x-javascript"
|
||||
#define APPLICATION_ECMASCRIPT "application/ecmascript"
|
||||
#define APPLICATION_JAVASCRIPT "application/javascript"
|
||||
#define APPLICATION_XJAVASCRIPT "application/x-javascript"
|
||||
#define APPLICATION_NETSCAPE_REVOCATION "application/x-netscape-revocation"
|
||||
#define APPLICATION_NS_PROXY_AUTOCONFIG "application/x-ns-proxy-autoconfig"
|
||||
#define APPLICATION_NS_JAVASCRIPT_AUTOCONFIG "application/x-javascript-config"
|
||||
@ -94,6 +96,9 @@
|
||||
#define APPLICATION_MARIMBA "application/marimba"
|
||||
#define APPLICATION_XMARIMBA "application/x-marimba"
|
||||
#define APPLICATION_XPINSTALL "application/x-xpinstall"
|
||||
#define APPLICATION_XML "application/xml"
|
||||
#define APPLICATION_XHTML_XML "application/xhtml+xml"
|
||||
#define APPLICATION_RDF_XML "application/rdf+xml"
|
||||
|
||||
#define AUDIO_BASIC "audio/basic"
|
||||
#define AUDIO_OGG "audio/ogg"
|
||||
@ -113,6 +118,7 @@
|
||||
#define IMAGE_ICO "image/x-icon"
|
||||
#define IMAGE_MNG "video/x-mng"
|
||||
#define IMAGE_JNG "image/x-jng"
|
||||
#define IMAGE_SVG_XML "image/svg+xml"
|
||||
|
||||
#define MESSAGE_EXTERNAL_BODY "message/external-body"
|
||||
#define MESSAGE_NEWS "message/news"
|
||||
@ -143,6 +149,9 @@
|
||||
#define TEXT_XML "text/xml"
|
||||
#define TEXT_RDF "text/rdf"
|
||||
#define TEXT_XUL "application/vnd.mozilla.xul+xml"
|
||||
#define TEXT_ECMASCRIPT "text/ecmascript"
|
||||
#define TEXT_JAVASCRIPT "text/javascript"
|
||||
#define TEXT_XSL "text/xsl"
|
||||
|
||||
#define VIDEO_MPEG "video/mpeg"
|
||||
#define VIDEO_OGG "video/ogg"
|
||||
@ -198,5 +207,6 @@
|
||||
#define VIEWSOURCE_CONTENT_TYPE "application/x-view-source"
|
||||
|
||||
#define APPLICATION_DIRECTORY "application/directory" /* text/x-vcard is synonym */
|
||||
#define APPLICATION_CACHED_XUL "mozilla.application/cached-xul"
|
||||
|
||||
#endif /* nsMimeTypes_h_ */
|
||||
|
@ -398,28 +398,6 @@ const PRUnichar kLeftSquareBracket = '[';
|
||||
const PRUnichar kRightSquareBracket = ']';
|
||||
const PRUnichar kNullCh = '\0';
|
||||
|
||||
// XXXbz these type defines should really just go away.... Until they
|
||||
// do, changes here should be reflected in nsContentDLF.cpp
|
||||
#define kHTMLTextContentType "text/html"
|
||||
#define kXMLTextContentType "text/xml"
|
||||
#define kXMLApplicationContentType "application/xml"
|
||||
#define kXHTMLApplicationContentType "application/xhtml+xml"
|
||||
#define kXULTextContentType "application/vnd.mozilla.xul+xml"
|
||||
#define kRDFTextContentType "text/rdf"
|
||||
#define kRDFApplicationContentType "application/rdf+xml"
|
||||
#define kXIFTextContentType "text/xif"
|
||||
#define kPlainTextContentType "text/plain"
|
||||
#define kViewSourceCommand "view-source"
|
||||
#define kViewFragmentCommand "view-fragment"
|
||||
#define kTextCSSContentType "text/css"
|
||||
#define kApplicationJSContentType "application/javascript"
|
||||
#define kApplicationXJSContentType "application/x-javascript"
|
||||
#define kTextECMAScriptContentType "text/ecmascript"
|
||||
#define kApplicationECMAScriptContentType "application/ecmascript"
|
||||
#define kTextJSContentType "text/javascript"
|
||||
#define kSGMLTextContentType "text/sgml"
|
||||
#define kSVGTextContentType "image/svg+xml"
|
||||
|
||||
#define NS_IPARSER_FLAG_UNKNOWN_MODE 0x00000000
|
||||
#define NS_IPARSER_FLAG_QUIRKS_MODE 0x00000002
|
||||
#define NS_IPARSER_FLAG_STRICT_MODE 0x00000004
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "prenv.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
CParserContext::CParserContext(CParserContext* aPrevContext,
|
||||
nsScanner* aScanner,
|
||||
@ -80,17 +81,17 @@ CParserContext::SetMimeType(const nsACString& aMimeType)
|
||||
|
||||
mDocType = ePlainText;
|
||||
|
||||
if (mMimeType.EqualsLiteral(kHTMLTextContentType))
|
||||
if (mMimeType.EqualsLiteral(TEXT_HTML))
|
||||
mDocType = eHTML_Strict;
|
||||
else if (mMimeType.EqualsLiteral(kXMLTextContentType) ||
|
||||
mMimeType.EqualsLiteral(kXMLApplicationContentType) ||
|
||||
mMimeType.EqualsLiteral(kXHTMLApplicationContentType) ||
|
||||
mMimeType.EqualsLiteral(kXULTextContentType) ||
|
||||
else if (mMimeType.EqualsLiteral(TEXT_XML) ||
|
||||
mMimeType.EqualsLiteral(APPLICATION_XML) ||
|
||||
mMimeType.EqualsLiteral(APPLICATION_XHTML_XML) ||
|
||||
mMimeType.EqualsLiteral(TEXT_XUL) ||
|
||||
#ifdef MOZ_SVG
|
||||
mMimeType.EqualsLiteral(kSVGTextContentType) ||
|
||||
mMimeType.EqualsLiteral(IMAGE_SVG_XML) ||
|
||||
#endif
|
||||
mMimeType.EqualsLiteral(kRDFApplicationContentType) ||
|
||||
mMimeType.EqualsLiteral(kRDFTextContentType))
|
||||
mMimeType.EqualsLiteral(APPLICATION_RDF_XML) ||
|
||||
mMimeType.EqualsLiteral(TEXT_RDF))
|
||||
mDocType = eXML;
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
#ifdef MOZ_VIEW_SOURCE
|
||||
#include "nsViewSourceHTML.h"
|
||||
@ -962,9 +963,9 @@ NS_IMETHODIMP_(void)
|
||||
nsParser::SetCommand(const char* aCommand)
|
||||
{
|
||||
mCommandStr.Assign(aCommand);
|
||||
if (mCommandStr.Equals(kViewSourceCommand)) {
|
||||
if (mCommandStr.Equals("view-source")) {
|
||||
mCommand = eViewSource;
|
||||
} else if (mCommandStr.Equals(kViewFragmentCommand)) {
|
||||
} else if (mCommandStr.Equals("view-fragment")) {
|
||||
mCommand = eViewFragment;
|
||||
} else {
|
||||
mCommand = eViewNormal;
|
||||
@ -1433,15 +1434,15 @@ static void
|
||||
DetermineParseMode(const nsString& aBuffer, nsDTDMode& aParseMode,
|
||||
eParserDocType& aDocType, const nsACString& aMimeType)
|
||||
{
|
||||
if (aMimeType.EqualsLiteral(kHTMLTextContentType)) {
|
||||
if (aMimeType.EqualsLiteral(TEXT_HTML)) {
|
||||
DetermineHTMLParseMode(aBuffer, aParseMode, aDocType);
|
||||
} else if (aMimeType.EqualsLiteral(kPlainTextContentType) ||
|
||||
aMimeType.EqualsLiteral(kTextCSSContentType) ||
|
||||
aMimeType.EqualsLiteral(kApplicationJSContentType) ||
|
||||
aMimeType.EqualsLiteral(kApplicationXJSContentType) ||
|
||||
aMimeType.EqualsLiteral(kTextECMAScriptContentType) ||
|
||||
aMimeType.EqualsLiteral(kApplicationECMAScriptContentType) ||
|
||||
aMimeType.EqualsLiteral(kTextJSContentType)) {
|
||||
} else if (aMimeType.EqualsLiteral(TEXT_PLAIN) ||
|
||||
aMimeType.EqualsLiteral(TEXT_CSS) ||
|
||||
aMimeType.EqualsLiteral(APPLICATION_JAVASCRIPT) ||
|
||||
aMimeType.EqualsLiteral(APPLICATION_XJAVASCRIPT) ||
|
||||
aMimeType.EqualsLiteral(TEXT_ECMASCRIPT) ||
|
||||
aMimeType.EqualsLiteral(APPLICATION_ECMASCRIPT) ||
|
||||
aMimeType.EqualsLiteral(TEXT_JAVASCRIPT)) {
|
||||
aDocType = ePlainText;
|
||||
aParseMode = eDTDMode_quirks;
|
||||
} else { // Some form of XML
|
||||
@ -2714,7 +2715,7 @@ nsParser::DetectMetaTag(const char* aBytes,
|
||||
|
||||
// XXX Only look inside HTML documents for now. For XML
|
||||
// documents we should be looking inside the XMLDecl.
|
||||
if (!mParserContext->mMimeType.EqualsLiteral(kHTMLTextContentType)) {
|
||||
if (!mParserContext->mMimeType.EqualsLiteral(TEXT_HTML)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ static nsExtraMimeTypeEntry extraMimeEntries [] =
|
||||
{ "application/x-arj", "arj", "ARJ file" },
|
||||
{ APPLICATION_XPINSTALL, "xpi", "XPInstall Install" },
|
||||
{ APPLICATION_POSTSCRIPT, "ps,eps,ai", "Postscript File" },
|
||||
{ APPLICATION_JAVASCRIPT, "js", "Javascript Source File" },
|
||||
{ APPLICATION_XJAVASCRIPT, "js", "Javascript Source File" },
|
||||
{ IMAGE_ART, "art", "ART Image" },
|
||||
{ IMAGE_BMP, "bmp", "BMP Image" },
|
||||
{ IMAGE_GIF, "gif", "GIF Image" },
|
||||
|
Loading…
Reference in New Issue
Block a user