Bug 190838 - Cleanup: MIMETypeRegistry functions
Summary: Cleanup: MIMETypeRegistry functions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks: 190454
  Show dependency treegraph
 
Reported: 2018-10-23 12:24 PDT by Said Abou-Hallawa
Modified: 2018-10-24 11:44 PDT (History)
8 users (show)

See Also:


Attachments
Patch (42.94 KB, patch)
2018-10-23 12:53 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (44.22 KB, patch)
2018-10-23 16:28 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (44.77 KB, patch)
2018-10-23 18:08 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (44.77 KB, patch)
2018-10-24 09:56 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2018-10-23 12:24:05 PDT
Some of the functions in MIMETypeRegistry return HashSet<Sting>. For these functions, we need to do the following:

1. Use NeverDestroyed<> instead of allocating raw pointers with the new operator.
2. Use std::initializer_list to initialize the static HashSet<String> when the list of supported mime types is static list of strings.
3. Use makeNeverDestroyed() to initialize the static HashSet<String> when the list of supported mime types is retrieved from a system call.
3. Replace the functions MIMETypeRegistry::getSupported...() with MIMETypeRegistry::supported...(). The functions whose names are MIMETypeRegistry::supported...() will be responsible of filling and validating their local NeverDestroyed<> and returning the underlaying HashSets.
4. As a preparation for landing 190454, the term UTI will be replaced by ImageSourceType. A new SPI will be added and adding UTI in its name does not seem  appealing.
Comment 1 Said Abou-Hallawa 2018-10-23 12:53:36 PDT
Created attachment 352990 [details]
Patch
Comment 2 Said Abou-Hallawa 2018-10-23 16:28:21 PDT
Created attachment 353000 [details]
Patch
Comment 3 Said Abou-Hallawa 2018-10-23 18:08:26 PDT
Created attachment 353011 [details]
Patch
Comment 4 Simon Fraser (smfr) 2018-10-24 08:35:40 PDT
Comment on attachment 353011 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=353011&action=review

> Source/WebCore/platform/MIMETypeRegistry.h:112
> +    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& supportedImageMIMETypes();
> +    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& supportedNonImageMIMETypes();
> +    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& supportedMediaMIMETypes();
> +    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& pdfMIMETypes();
> +    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& unsupportedTextMIMETypes();

I think static const HashSet<> reads better.

Is there a reason supportedNonImageMIMETypes() doesn't return a const HashSet<>?
Comment 5 Said Abou-Hallawa 2018-10-24 09:56:39 PDT
Created attachment 353037 [details]
Patch
Comment 6 Said Abou-Hallawa 2018-10-24 11:21:59 PDT
Comment on attachment 353011 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=353011&action=review

>> Source/WebCore/platform/MIMETypeRegistry.h:112
>> +    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& unsupportedTextMIMETypes();
> 
> I think static const HashSet<> reads better.
> 
> Is there a reason supportedNonImageMIMETypes() doesn't return a const HashSet<>?

Yes.

[WebView _unregisterViewClassAndRepresentationClassForMIMEType]
[WebView _registerViewClass]
[WebView registerViewClass]

need to change it by adding and removing mime types.
Comment 7 WebKit Commit Bot 2018-10-24 11:42:31 PDT
Comment on attachment 353037 [details]
Patch

Clearing flags on attachment: 353037

Committed r237393: <https://trac.webkit.org/changeset/237393>
Comment 8 WebKit Commit Bot 2018-10-24 11:42:33 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2018-10-24 11:44:43 PDT
<rdar://problem/45527724>