Bug 1932125 - Use standard mime type type constants/defines rather than individual string literals r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D229488
This commit is contained in:
longsonr 2024-11-19 15:41:23 +00:00
parent e4591254c7
commit 58246c6748
5 changed files with 11 additions and 9 deletions

View File

@ -112,7 +112,7 @@ bool nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
// Allow data: images as long as they are not SVGs
if (StringBeginsWith(contentType, "image/"_ns) &&
!contentType.EqualsLiteral("image/svg+xml")) {
!contentType.EqualsLiteral(IMAGE_SVG_XML)) {
return true;
}
// Allow all data: PDFs. or JSON documents

View File

@ -31,6 +31,7 @@
#include "mozilla/dom/Selection.h"
#include "nsContentUtils.h"
#include "nsElementTable.h"
#include "nsMimeTypes.h"
#include "nsUnicharUtils.h"
#include "nsReadableUtils.h"
#include "nsTArray.h"
@ -1534,12 +1535,12 @@ nsDocumentEncoder::SetNodeFixup(nsIDocumentEncoderNodeFixup* aFixup) {
}
bool do_getDocumentTypeSupportedForEncoding(const char* aContentType) {
if (!nsCRT::strcmp(aContentType, "text/xml") ||
!nsCRT::strcmp(aContentType, "application/xml") ||
!nsCRT::strcmp(aContentType, "application/xhtml+xml") ||
!nsCRT::strcmp(aContentType, "image/svg+xml") ||
!nsCRT::strcmp(aContentType, "text/html") ||
!nsCRT::strcmp(aContentType, "text/plain")) {
if (!nsCRT::strcmp(aContentType, TEXT_XML) ||
!nsCRT::strcmp(aContentType, APPLICATION_XML) ||
!nsCRT::strcmp(aContentType, APPLICATION_XHTML_XML) ||
!nsCRT::strcmp(aContentType, IMAGE_SVG_XML) ||
!nsCRT::strcmp(aContentType, TEXT_HTML) ||
!nsCRT::strcmp(aContentType, TEXT_PLAIN)) {
return true;
}
return false;

View File

@ -129,7 +129,7 @@ gfxSVGGlyphsDocument* gfxSVGGlyphs::FindOrCreateGlyphsDocument(
nsresult gfxSVGGlyphsDocument::SetupPresentation() {
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
nsContentUtils::FindInternalDocumentViewer("image/svg+xml"_ns);
nsContentUtils::FindInternalDocumentViewer(SVG_CONTENT_TYPE);
NS_ASSERTION(docLoaderFactory, "Couldn't get DocumentLoaderFactory");
nsCOMPtr<nsIDocumentViewer> viewer;

View File

@ -2845,7 +2845,7 @@ bool imgLoader::SupportImageWithMimeType(const nsACString& aMimeType,
ToLowerCase(mimeType);
if (aAccept == AcceptedMimeTypes::IMAGES_AND_DOCUMENTS &&
mimeType.EqualsLiteral("image/svg+xml")) {
mimeType.EqualsLiteral(IMAGE_SVG_XML)) {
return true;
}

View File

@ -31,6 +31,7 @@ interface nsIReferrerInfo;
#define kJPEGImageMime "image/jpeg"
#define kJPGImageMime "image/jpg"
#define kGIFImageMime "image/gif"
#define kSVGImageMime "image/svg+xml"
#define kFileMime "application/x-moz-file"
#define kURLMime "text/x-moz-url" // data contains url\ntitle