Bug 233764 - Make enum values consistent in ApplicationManifest::Icon::Purpose and _WKApplicationManifestIconPurpose
Summary: Make enum values consistent in ApplicationManifest::Icon::Purpose and _WKAppl...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Safari 15
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-02 09:54 PST by rginsberg
Modified: 2021-12-02 17:42 PST (History)
3 users (show)

See Also:


Attachments
Patch (2.02 KB, patch)
2021-12-02 10:56 PST, rginsberg
bfulgham: review-
Details | Formatted Diff | Diff
Patch (1.88 KB, patch)
2021-12-02 15:11 PST, rginsberg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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].