Bug 190838

Summary: Cleanup: MIMETypeRegistry functions
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: ImagesAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, dbates, ews-watchlist, japhet, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 190454    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

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>