WebKit Bugzilla
Attachment 360583 Details for
Bug 193756
: Simplify and streamline code that creates an appropriate document based on MIME type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193756-20190130085542.patch (text/plain), 6.78 KB, created by
Darin Adler
on 2019-01-30 08:55:42 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2019-01-30 08:55:42 PST
Size:
6.78 KB
patch
obsolete
>Subversion Revision: 240711 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1a8fcec8cf1b5755551da9d5d1fc506f45682e12..4afb0650e9df67b21edcaf36d1e02b34c702900a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-01-23 Darin Adler <darin@apple.com> >+ >+ Simplify and streamline code that creates an appropriate document based on MIME type >+ https://bugs.webkit.org/show_bug.cgi?id=193756 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * dom/DOMImplementation.cpp: >+ (WebCore::DOMImplementation::createDocument): Use equalLettersIgnoringASCIICase rather >+ than == for all the MIME type checks. Use MIMETypeRegistry::isSupportedImageMIMEType >+ instead of Image::supportsType. Rearranged checks so that all the combinations that >+ that take precedence over plug-ins are checked first, fixing some unimportant edge >+ cases where the plug-in database is initialized and doesn't need to be. Straightened >+ out the logic for various special types so that the checks are more independent from >+ each other and hence easier to understand. >+ > 2019-01-30 Zalan Bujtas <zalan@apple.com> > > [LFC] Use the used margin values in outOfFlowReplacedVerticalGeometry consistently >diff --git a/Source/WebCore/dom/DOMImplementation.cpp b/Source/WebCore/dom/DOMImplementation.cpp >index a9832c820fb25a71a7008a0823a1623f4550455d..3a2ed2004cb0edbbf5ad9bfb7a61c0e4728bae99 100644 >--- a/Source/WebCore/dom/DOMImplementation.cpp >+++ b/Source/WebCore/dom/DOMImplementation.cpp >@@ -133,65 +133,59 @@ Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title) > > Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url) > { >- // FIXME: Confusing to have this here with public DOM APIs for creating documents. This is different enough that it should perhaps be moved. >- // FIXME: This function is doing case insensitive comparisons on MIME types. Should do equalLettersIgnoringASCIICase instead. >+ // FIXME: Inelegant to have this here just because this is the home of DOM APIs for creating documents. >+ // This is internal, not a DOM API. Maybe we should put it in a new class called DocumentFactory, >+ // because of the analogy with HTMLElementFactory. > >- // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. >- if (type == "text/html") >+ // Plug-ins cannot take over for HTML, XHTML, plain text, or non-PDF images. >+ if (equalLettersIgnoringASCIICase(type, "text/html")) > return HTMLDocument::create(frame, url); >- if (type == "application/xhtml+xml") >+ if (equalLettersIgnoringASCIICase(type, "application/xhtml+xml")) > return XMLDocument::createXHTML(frame, url); >- >-#if ENABLE(FTPDIR) >- // Plugins cannot take FTP from us either >- if (type == "application/x-ftp-directory") >- return FTPDirectoryDocument::create(frame, url); >-#endif >- >- // If we want to useImageDocumentForSubframePDF, we'll let that override plugin support. >- if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF()) >+ if (equalLettersIgnoringASCIICase(type, "text/plain")) >+ return TextDocument::create(frame, url); >+ bool isImage = MIMETypeRegistry::isSupportedImageMIMEType(type); >+ if (frame && isImage && !MIMETypeRegistry::isPDFOrPostScriptMIMEType(type)) > return ImageDocument::create(*frame, url); > >- PluginData* pluginData = nullptr; >- auto allowedPluginTypes = PluginData::OnlyApplicationPlugins; >- if (frame && frame->page()) { >- if (frame->loader().subframeLoader().allowPlugins()) >- allowedPluginTypes = PluginData::AllPlugins; >- >- pluginData = &frame->page()->pluginData(); >- } >- >- // PDF is one image type for which a plugin can override built-in support. >- // We do not want QuickTime to take over all image types, obviously. >- if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(type) && pluginData && pluginData->supportsWebVisibleMimeType(type, allowedPluginTypes)) >- return PluginDocument::create(frame, url); >- if (Image::supportsType(type)) >+ // The "image documents for subframe PDFs" mode will override a PDF plug-in. >+ if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF()) > return ImageDocument::create(*frame, url); > > #if ENABLE(VIDEO) >- // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument >- // Key system is not applicable here. > MediaEngineSupportParameters parameters; >- parameters.type = ContentType(type); >+ parameters.type = ContentType { type }; > parameters.url = url; > if (MediaPlayer::supportsType(parameters)) > return MediaDocument::create(frame, url); > #endif > >- // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed. >- // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle, >- // and also serves as an optimization to prevent loading the plug-in database in the common case. >- if (type != "text/plain" && ((pluginData && pluginData->supportsWebVisibleMimeType(type, allowedPluginTypes)) || (frame && frame->loader().client().shouldAlwaysUsePluginDocument(type)))) >+#if ENABLE(FTPDIR) >+ if (equalLettersIgnoringASCIICase(type, "application/x-ftp-directory")) >+ return FTPDirectoryDocument::create(frame, url); >+#endif >+ >+ if (frame && frame->loader().client().shouldAlwaysUsePluginDocument(type)) > return PluginDocument::create(frame, url); >+ >+ // The following is the relatively costly lookup that requires initializing the plug-in database. >+ if (frame && frame->page()) { >+ auto allowedPluginTypes = frame->loader().subframeLoader().allowPlugins() >+ ? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins; >+ if (frame->page()->pluginData().supportsWebVisibleMimeType(type, allowedPluginTypes)) >+ return PluginDocument::create(frame, url); >+ } >+ >+ // Items listed here, after the plug-in checks, can be overridden by plug-ins. >+ // For example, plug-ins can take over support for PDF or SVG. >+ if (frame && isImage) >+ return ImageDocument::create(*frame, url); > if (MIMETypeRegistry::isTextMIMEType(type)) > return TextDocument::create(frame, url); >- >- if (type == "image/svg+xml") >+ if (equalLettersIgnoringASCIICase(type, "image/svg+xml")) > return SVGDocument::create(frame, url); >- > if (MIMETypeRegistry::isXMLMIMEType(type)) > return XMLDocument::create(frame, url); >- > return HTMLDocument::create(frame, url); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193756
:
359989
| 360583