Bug 221779

Summary: Review usage of adoptNS()
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ddkilzer, eric.carlson, ews-watchlist, ggaren, glenn, jer.noble, philipj, sergio, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Chris Dumez 2021-02-11 14:06:44 PST
Review usage of adoptNS():
1. Make sure we call adoptNS() as soon as we allocate the object instead of doing it later on, as this is less error-prone
2. Fix cases where we called adoptNS() but really should have retained instead of adopting
Comment 1 Chris Dumez 2021-02-11 14:08:14 PST
Created attachment 420042 [details]
Patch
Comment 2 Alex Christensen 2021-02-11 14:14:14 PST
Comment on attachment 420042 [details]
Patch

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

> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510
>          [webAnimationDelegate setOwner:this];

If you use [m_delegate setOwner:this] instead, this can only be two lines.
Comment 3 Chris Dumez 2021-02-11 14:16:37 PST
Comment on attachment 420042 [details]
Patch

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

>> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510
>>          [webAnimationDelegate setOwner:this];
> 
> If you use [m_delegate setOwner:this] instead, this can only be two lines.

The issue is that the type of m_delegate is NSObject, not WebAnimationDelegate. Maybe that still works in ObjC?
Comment 4 Chris Dumez 2021-02-11 14:20:55 PST
(In reply to Chris Dumez from comment #3)
> Comment on attachment 420042 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=420042&action=review
> 
> >> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510
> >>          [webAnimationDelegate setOwner:this];
> > 
> > If you use [m_delegate setOwner:this] instead, this can only be two lines.
> 
> The issue is that the type of m_delegate is NSObject, not
> WebAnimationDelegate. Maybe that still works in ObjC?

As I thought, this does not work:
./platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510:21: error: 'NSObject' may not respond to 'setOwner:' [-Werror]
Comment 5 EWS 2021-02-11 16:48:52 PST
Committed r272760: <https://commits.webkit.org/r272760>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 420042 [details].
Comment 6 Radar WebKit Bug Importer 2021-02-11 16:49:14 PST
<rdar://problem/74256841>