Bug 211660 - Adapt LocalCurrentGraphicsContext for iOS
Summary: Adapt LocalCurrentGraphicsContext for iOS
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on: 208891 210814 211274
Blocks:
  Show dependency treegraph
 
Reported: 2020-05-08 21:09 PDT by David Kilzer (:ddkilzer)
Modified: 2020-05-09 16:11 PDT (History)
8 users (show)

See Also:


Attachments
Patch v1 (32.37 KB, patch)
2020-05-08 21:14 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Interesting changes to WebCore/platform (6.11 KB, patch)
2020-05-08 21:16 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch for landing (32.15 KB, patch)
2020-05-09 14:02 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch for landing v2 (32.01 KB, patch)
2020-05-09 14:33 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2020-05-08 21:09:35 PDT
Adapt LocalCurrentGraphicsContext for iOS.

The original motivation was a small clean up in UIProcess/Cocoa/WebPageProxyCocoa.mm, but this resulted in a really nice cleanup in WebProcess/WebCoreSupport/mac/WebDragClientMac.mm.
Comment 1 David Kilzer (:ddkilzer) 2020-05-08 21:14:38 PDT
Created attachment 398915 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2020-05-08 21:16:54 PDT
Created attachment 398916 [details]
Interesting changes to WebCore/platform
Comment 3 Darin Adler 2020-05-09 07:28:59 PDT
Comment on attachment 398915 [details]
Patch v1

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

> Source/WebCore/platform/cocoa/LocalCurrentGraphicsContext.h:60
> +class ContextContainer {
> +    WTF_MAKE_NONCOPYABLE(ContextContainer);
> +public:
> +    ContextContainer(GraphicsContext& graphicsContext)
> +        : m_graphicsContext(graphicsContext.platformContext())
> +    {
> +    }
> +
> +    CGContextRef context() { return m_graphicsContext; }
> +private:
> +    PlatformGraphicsContext* m_graphicsContext;
> +};

This class is not new, but it seems pointless. Should be removed. The two places that use it should just be calling the platformContext function. Also, the use of both CGContextRef and PlatformGraphicsContext* in the implementation of the class is puzzling.

> Source/WebCore/platform/ios/LocalCurrentGraphicsContextIOS.mm:58
> +CGContextRef LocalCurrentGraphicsContext::cgContext()
> +{
> +    return m_savedGraphicsContext.platformContext();
> +}

Should be inlined in the header. And not have separate versions for macOS and iOS.

> Source/WebCore/platform/mac/LocalCurrentGraphicsContextMac.mm:60
> +CGContextRef LocalCurrentGraphicsContext::cgContext()
> +{
> +    return m_savedGraphicsContext.platformContext();
> +}

Should be inlined in the header. And not have separate versions for macOS and iOS.

> Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:56
> +using PlatformDragImage = NSImage *;

Not a big fan of the word "Platform" in the class name here, but I don’t have a better idea.

> Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:60
>  #import "UIKitSPI.h"
> +
> +using PlatformDragImage = CGImageRef;

Not a big fan of combining the "using" and the include like this. I would do the include in a separate paragraph above.
Comment 4 David Kilzer (:ddkilzer) 2020-05-09 13:31:11 PDT
Comment on attachment 398915 [details]
Patch v1

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

>> Source/WebCore/platform/cocoa/LocalCurrentGraphicsContext.h:60
>> +};
> 
> This class is not new, but it seems pointless. Should be removed. The two places that use it should just be calling the platformContext function. Also, the use of both CGContextRef and PlatformGraphicsContext* in the implementation of the class is puzzling.

Will do in a separate patch.

>> Source/WebCore/platform/ios/LocalCurrentGraphicsContextIOS.mm:58
>> +}
> 
> Should be inlined in the header. And not have separate versions for macOS and iOS.

Will fix.

>> Source/WebCore/platform/mac/LocalCurrentGraphicsContextMac.mm:60
>> +}
> 
> Should be inlined in the header. And not have separate versions for macOS and iOS.

Will fix.

>> Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:56
>> +using PlatformDragImage = NSImage *;
> 
> Not a big fan of the word "Platform" in the class name here, but I don’t have a better idea.

How about just "DragImage"?  I guess we need to be careful about defining this in unified sources, but it's probably fine for now.

We could have reused CocoaImage if the iOS code has used UIImage instead of CGImageRef.  Not sure it's worth a FIXME, though.

>> Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:60
>> +using PlatformDragImage = CGImageRef;
> 
> Not a big fan of combining the "using" and the include like this. I would do the include in a separate paragraph above.

Will separate before landing.
Comment 5 David Kilzer (:ddkilzer) 2020-05-09 14:01:34 PDT
Comment on attachment 398915 [details]
Patch v1

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

>>> Source/WebCore/platform/cocoa/LocalCurrentGraphicsContext.h:60
>>> +};
>> 
>> This class is not new, but it seems pointless. Should be removed. The two places that use it should just be calling the platformContext function. Also, the use of both CGContextRef and PlatformGraphicsContext* in the implementation of the class is puzzling.
> 
> Will do in a separate patch.

(Will change PlatformGraphicsContext* to CGContextRef in this patch, though.)
Comment 6 David Kilzer (:ddkilzer) 2020-05-09 14:02:58 PDT
Created attachment 398940 [details]
Patch for landing
Comment 7 David Kilzer (:ddkilzer) 2020-05-09 14:33:04 PDT
Created attachment 398941 [details]
Patch for landing v2
Comment 8 David Kilzer (:ddkilzer) 2020-05-09 14:33:32 PDT
Comment on attachment 398940 [details]
Patch for landing

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

> Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:57
> -#if PLATFORM(IOS_FAMILY)
> +#if USE(APPKIT)
>  #import "UIKitSPI.h"
>  #endif

That's...not correct.
Comment 9 EWS 2020-05-09 16:10:45 PDT
Committed r261442: <https://trac.webkit.org/changeset/261442>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 398941 [details].
Comment 10 Radar WebKit Bug Importer 2020-05-09 16:11:17 PDT
<rdar://problem/63057667>