Bug 233764

Summary: Make enum values consistent in ApplicationManifest::Icon::Purpose and _WKApplicationManifestIconPurpose
Product: WebKit Reporter: rginsberg
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, rginsberg, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
bfulgham: review-
Patch none

Description rginsberg 2021-12-02 09:54:24 PST
`Icon::Purpose` values are 1 (`1 << 0`), 2 (`1 << 1`), and 4 (`1 << 2`), but the default values for an enum are 0, 1, 2, which is used in `_WKApplicationManifestIcon`. This results in the purpose values being mis-translated in `_WKApplicationManifest`. In `WKApplicationManifest` an icon with the `purpose` set to `Any` in the manifest file, will have it's `purposes` set to `_WKApplicationManifestIconPurposeMonochrome`.
Comment 1 Radar WebKit Bug Importer 2021-12-02 09:54:45 PST
<rdar://problem/85976270>
Comment 2 rginsberg 2021-12-02 10:56:22 PST
Created attachment 445744 [details]
Patch
Comment 3 Brent Fulgham 2021-12-02 14:03:54 PST
Comment on attachment 445744 [details]
Patch

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

This looks fine, but I suggest following the model of the underling WebCore type and use the bitwise-shift to show the mask values.

> Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:46
> +    _WKApplicationManifestIconPurposeAny = 1,

We should follow the behavior of the WebCore::ApplicationManifest::Icon::Purpose enum:

_WKApplicationManifestIconPurposeAny =  (1 << 0),

> Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:47
> +    _WKApplicationManifestIconPurposeMonochrome = 2,

_WKApplicationManifestIconPurposeMonochrome = (1 << 1),

> Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:48
> +    _WKApplicationManifestIconPurposeMaskable = 4,

_WKApplicationManifestIconPurposeMaskable = (1 << 2),
Comment 4 rginsberg 2021-12-02 15:11:58 PST
Created attachment 445778 [details]
Patch
Comment 5 rginsberg 2021-12-02 15:12:23 PST
(In reply to Brent Fulgham from comment #3)
> Comment on attachment 445744 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=445744&action=review
> 
> This looks fine, but I suggest following the model of the underling WebCore
> type and use the bitwise-shift to show the mask values.
> 
> > Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:46
> > +    _WKApplicationManifestIconPurposeAny = 1,
> 
> We should follow the behavior of the
> WebCore::ApplicationManifest::Icon::Purpose enum:
> 
> _WKApplicationManifestIconPurposeAny =  (1 << 0),
> 
> > Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:47
> > +    _WKApplicationManifestIconPurposeMonochrome = 2,
> 
> _WKApplicationManifestIconPurposeMonochrome = (1 << 1),
> 
> > Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:48
> > +    _WKApplicationManifestIconPurposeMaskable = 4,
> 
> _WKApplicationManifestIconPurposeMaskable = (1 << 2),

Thanks! Just uploaded a patch that uses this model
Comment 6 Brent Fulgham 2021-12-02 15:16:26 PST
Comment on attachment 445778 [details]
Patch

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

r=me

> Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h:48
> +    _WKApplicationManifestIconPurposeMaskable = (1 << 2),

Thank you for adjusting this!
Comment 7 Brent Fulgham 2021-12-02 15:16:49 PST
I'll cq+ this change once EWS finishes.
Comment 8 EWS 2021-12-02 17:42:23 PST
Committed r286470 (244810@main): <https://commits.webkit.org/244810@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 445778 [details].