MIME types in nsContentDLF.cpp and nsIParser.h should be shared and moved to nsMimeTypes.h

RESOLVED FIXED

Status

()

defect
RESOLVED FIXED
10 years ago
10 years ago

People

(Reporter: fredw, Assigned: fredw)

Tracking

Trunk
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Assignee

Description

10 years ago
Posted patch Patch (obsolete) — Splinter Review
Currently, layout/build/nsContentDLF.cpp uses hardedcoded strings of MIME types. The same values are defined in parser/htmlparser/public/nsIParser.h and used in various files. These declarations should be shared and moved to netwerk/mime/public/nsMimeTypes.h
Frédéric, is the patch still in progress, or ready for review?
Assignee

Comment 2

10 years ago
(In reply to comment #1)
> Frédéric, is the patch still in progress, or ready for review?

It is ready for review.
Assignee

Updated

10 years ago
Attachment #413793 - Flags: review?(bzbarsky)
Assignee

Comment 3

10 years ago
I was just looking at the application/mathml+xml bug, and I saw that there were hardcoded mime types in several places. Maybe I should attach another patch that would use the new types introduced by attachment 413793 [details] [diff] [review]?

fred@localhost:~/mozilla/src$ find -type f -name *.cpp -o -name *.h -path netwerk/mime/public -prune | xargs egrep "\"application/ecmascript\"|\"application/javascript\"|\"application/x-javascript\"|\"application/xml\"|\"application/xhtml\+xml\"|\"application/rdf\+xml\"|\"image/svg\+xml\"|\"text/ecmascript\"|\"text/javascript\"|\"text/xsl\"|\"mozilla.application/cached-xul\"|\"view-source\"|\"view-fragment\""
./xpfe/components/directory/nsDirectoryViewer.cpp:  PRBool viewSource = (PL_strstr(aContentType,"view-source") != 0);
./xpfe/components/directory/nsDirectoryViewer.cpp:  (void)aChannel->SetContentType(NS_LITERAL_CSTRING("application/xhtml+xml"));
./xpfe/components/directory/nsDirectoryViewer.cpp:  rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "application/xhtml+xml",
./xpfe/components/directory/nsDirectoryViewer.cpp:    rv = factory->CreateInstance("view-source", aChannel, aLoadGroup, "application/xhtml+xml; x-view-type=view-source",
./xpfe/components/directory/nsDirectoryViewer.cpp:    rv = factory->CreateInstance("view", aChannel, aLoadGroup, "application/xhtml+xml",
./docshell/base/nsDocShell.cpp:    // nsLayoutDLF makes the determination if it should be a "view-source" instead of "view"
./docshell/base/nsGlobalHistoryAdapter.cpp:    rv |= aURI->SchemeIs("view-source", &isViewSource);
./docshell/base/nsDefaultURIFixup.cpp:    if (scheme.LowerCaseEqualsLiteral("view-source"))
./xpcom/tests/TestStrings.cpp:    PRBool r = s.LowerCaseEqualsLiteral("view-source");
./extensions/metrics/src/nsMetricsConfig.cpp:  parser->ParseFromStream(stream, nsnull, PRInt32(fileSize), "application/xml",
./dom/src/threads/nsDOMWorkerScriptLoader.cpp:                                   NS_LITERAL_CSTRING("text/javascript"),
./dom/base/nsDOMScriptObjectFactory.cpp:    if (aLanguageName.Equals(NS_LITERAL_STRING("application/javascript")))
./browser/components/shell/src/nsGNOMEShellService.cpp:  { "application/xhtml+xml", "xhtml xht"      }
./browser/components/feeds/src/nsFeedSniffer.cpp:  if (scheme.EqualsLiteral("view-source")) {
./netwerk/streamconv/converters/nsIndexedToHTML.cpp:    channel->SetContentType(NS_LITERAL_CSTRING("application/xhtml+xml"));
./netwerk/protocol/viewsource/src/nsViewSourceHandler.cpp:#define VIEW_SOURCE "view-source"
./netwerk/protocol/about/src/nsAboutCacheEntry.cpp:                                    NS_LITERAL_CSTRING("application/xhtml+xml"),
./netwerk/build/nsNetModule.cpp:      NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source",
./security/manager/boot/src/nsSecureBrowserUIImpl.cpp:    nsresult rv = aLocation->SchemeIs("view-source", &vs);
./toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp:      contentType = NS_LITERAL_CSTRING("application/xhtml+xml");
./toolkit/components/places/src/nsNavHistory.cpp:      scheme.EqualsLiteral("view-source") ||
./uriloader/exthandler/nsExternalHelperAppService.cpp:  { "application/xhtml+xml", "xhtml" },
./uriloader/exthandler/nsExternalHelperAppService.cpp:  { "application/xhtml+xml", "xht" },
./uriloader/exthandler/nsExternalHelperAppService.cpp:  { "image/svg+xml", "svg", "Scalable Vector Graphics" },
./uriloader/exthandler/nsExternalHelperAppService.cpp:  { "application/xhtml+xml", "xhtml,xht", "Extensible HyperText Markup Language" },
./content/xslt/src/xslt/txStandaloneXSLTProcessor.cpp: * given XML document. If a stylesheet PIs is found with type="text/xsl",
./content/xslt/src/xslt/txStandaloneXSLTProcessor.cpp: * type="text/xml" or type="application/xml" the href pseudo attribute
./content/xslt/src/xslt/txStandaloneXSLTProcessor.cpp:                if (type.EqualsLiteral("text/xsl") ||
./content/xslt/src/xslt/txStandaloneXSLTProcessor.cpp:                    type.EqualsLiteral("application/xml")) {
./content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp:                                   NS_LITERAL_CSTRING("application/xml"),
./content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp:                                  NS_LITERAL_CSTRING("application/xml"),
./content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp:                                   NS_LITERAL_CSTRING("application/xml"),
./content/xslt/src/xslt/txMozillaXMLOutput.cpp:        mDocument->SetContentType(NS_LITERAL_STRING("application/xml"));
./content/xul/document/src/nsXULContentSink.cpp:              "application/x-javascript",
./content/xul/document/src/nsXULContentSink.cpp:              "text/javascript",
./content/xul/document/src/nsXULContentSink.cpp:              "text/ecmascript",
./content/xul/document/src/nsXULContentSink.cpp:              "application/javascript",
./content/xul/document/src/nsXULContentSink.cpp:              "application/ecmascript",
./content/xul/document/src/nsXULDocument.cpp:    parser->SetCommand(nsCRT::strcmp(aCommand, "view-source") ? eViewNormal :
./content/xul/document/src/nsXULDocument.cpp:                            NS_LITERAL_STRING("application/x-javascript"));
./content/html/content/src/nsGenericHTMLElement.cpp:    contentType.AssignLiteral("application/xml");
./content/html/content/src/nsGenericHTMLElement.cpp:    docEncoder = do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "application/xml");
./content/html/document/src/nsHTMLDocument.cpp:  if (contentType.Equals("application/xhtml+xml") &&
./content/html/document/src/nsHTMLDocument.cpp:      (!aCommand || nsCRT::strcmp(aCommand, "view-source") != 0)) {
./content/base/src/nsDOMSerializer.cpp:    do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "application/xhtml+xml", &rv);
./content/base/src/nsDOMSerializer.cpp:  rv = encoder->Init(domDoc, NS_LITERAL_STRING("application/xhtml+xml"),
./content/base/src/nsXMLHttpRequest.cpp:          defaultContentType.AssignLiteral("application/xml");
./content/base/src/nsXMLHttpRequest.cpp:  mChannel->SetContentType(NS_LITERAL_CSTRING("application/xml"));
./content/base/src/nsScriptLoader.cpp:      "text/javascript",
./content/base/src/nsScriptLoader.cpp:      "text/ecmascript",
./content/base/src/nsScriptLoader.cpp:      "application/javascript",
./content/base/src/nsScriptLoader.cpp:      "application/ecmascript",
./content/base/src/nsScriptLoader.cpp:      "application/x-javascript",
./content/base/src/nsDOMParser.cpp:      (nsCRT::strcmp(contentType, "application/xml") != 0) &&
./content/base/src/nsDOMParser.cpp:      (nsCRT::strcmp(contentType, "application/xhtml+xml") != 0))
./content/base/src/nsObjectLoadingContent.cpp:  PRBool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml");
./parser/htmlparser/src/nsViewSourceHTML.cpp:  // Construct a "view-source" URL for the HREF.
./layout/build/nsLayoutModule.cpp:    NS_DOC_ENCODER_CONTRACTID_BASE "application/xml",
./layout/build/nsLayoutModule.cpp:    NS_DOC_ENCODER_CONTRACTID_BASE "application/xhtml+xml",
./layout/build/nsLayoutModule.cpp:    NS_DOC_ENCODER_CONTRACTID_BASE "image/svg+xml",
./layout/build/nsLayoutModule.cpp:    NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xml",
./layout/build/nsLayoutModule.cpp:    NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xhtml+xml",
./layout/build/nsLayoutModule.cpp:    NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "image/svg+xml",
./editor/composer/src/nsEditingSession.cpp:  "text/xsl",
./editor/composer/src/nsEditingSession.cpp:  "text/javascript",           // obsolete type
./editor/composer/src/nsEditingSession.cpp:  "text/ecmascript",           // obsolete type
./editor/composer/src/nsEditingSession.cpp:  "application/javascript",
./editor/composer/src/nsEditingSession.cpp:  "application/ecmascript",
./editor/composer/src/nsEditingSession.cpp:  "application/x-javascript",  // obsolete type
./editor/composer/src/nsEditingSession.cpp:               !mimeCType.EqualsLiteral("application/xhtml+xml"))
There's some in widget/public/nsITransferable.idl as well.
Comment on attachment 413793 [details] [diff] [review]
Patch

VIEW_SOURCE and VIEW_FRAGMENT shouldn't be in nsMimeTypes.h.  Other than that, r=bzbarsky.  Sorry for the lag.  Let me know if you need this pushed once you update the VIEW_* thing?
Attachment #413793 - Flags: review?(bzbarsky) → review+
Assignee

Comment 6

10 years ago
> VIEW_SOURCE and VIEW_FRAGMENT shouldn't be in nsMimeTypes.h.

Do you prefer I replace VIEW_SOURCE/VIEW_FRAGMENT by hardcoded strings or should I move their definitions in other file?

In the former option, I guess I need not restore kViewSourceCommand and kViewFragmentCommand in parser/htmlparser/public/nsIParser.h?
Assignee

Comment 7

10 years ago
(In reply to comment #5)
> (From update of attachment 413793 [details] [diff] [review])
> VIEW_SOURCE and VIEW_FRAGMENT shouldn't be in nsMimeTypes.h.  Other than that,

I've replaced kViewSourceCommand and kViewFragmentCommand by hardcoded strings (there were used only at one place). 

> r=bzbarsky.  Sorry for the lag.  Let me know if you need this pushed once you
> update the VIEW_* thing?

Yes, I would appreciate if you can commit it for me.


For the issues mentioned in comment 3 and comment 4, I've opened bug 547707, so that they won't be lost.
Assignee

Comment 8

10 years ago
Posted patch Final PatchSplinter Review
Attachment #413793 - Attachment is obsolete: true
Pushed http://hg.mozilla.org/mozilla-central/rev/cd08315ca47e
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.