Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[iOS] DocumentWriter::createDocument can spend ~100ms unnecessarily c…
…onverting image UTIs to MIME types https://bugs.webkit.org/show_bug.cgi?id=178618 <rdar://problem/35108852> Reviewed by Said Abou-Hallawa. Currently, in setting up a new Document, DocumentWriter::createDocument() always asks whether or not the Document should be a PDF document by calling MIMETypeRegistry::isPDFMIMEType(), which forces lazy initialization of every MIME type dictionary (e.g. image types, PDF types, JavaScript types, etc.). As evidenced by traces, this can be an expensive operation on certain devices. This patch implements two optimizations. First, we refactor the initializeSupportedImageMIMETypes() helper to stop asking for MIMETypeForImageSourceType for each of the supported UTIs. This is because the known MIME types corresponding to these hard-coded UTI types is a fixed set anyways, so we can simply iterate over a constant array of MIME types and populate the supported image (and image resource) types. Also, add assertions to ensure that we keep allowed image MIME types in sync with allowed image UTIs. The second optimization removes initializeMIMETypeRegistry() altogether in favor of calling just the initialize*MIMETypes() functions needed to ensure the information required. For instance, getPDFMIMETypes() currently calls initializeMIMETypeRegistry() if the pdfMIMETypes dictionary doesn't exist, when it really only needs to ensure that the pdfMIMETypes is initialized, for which initializePDFMIMETypes() is sufficient. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): (WebCore::initializeSupportedJavaScriptMIMETypes): (WebCore::initializePDFMIMETypes): (WebCore::initializeSupportedNonImageMimeTypes): (WebCore::initializeUnsupportedTextMIMETypes): Move MIME type dictionary creation into initialize*MIMETypes() helpers. Additionally, remove initializePDFAndPostScriptMIMETypes, which is no longer necessary. (WebCore::MIMETypeRegistry::isSupportedImageMIMEType): (WebCore::MIMETypeRegistry::isSupportedImageResourceMIMEType): (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType): (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType): (WebCore::MIMETypeRegistry::isUnsupportedTextMIMEType): (WebCore::MIMETypeRegistry::isPDFOrPostScriptMIMEType): Tweak to check that the type isPDFMIMEType(), or that it's otherwise "application/postscript". (WebCore::MIMETypeRegistry::isPDFMIMEType): (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): (WebCore::MIMETypeRegistry::getPDFMIMETypes): (WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes): Call only the relevant MIME type initializers when needed. (WebCore::initializePostScriptMIMETypes): Deleted. (WebCore::initializeMIMETypeRegistry): Deleted. (WebCore::MIMETypeRegistry::getPDFAndPostScriptMIMETypes): Deleted. Remove an unused and unexported function. * platform/MIMETypeRegistry.h: Canonical link: https://commits.webkit.org/194856@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
3 changed files
with
101 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters