Skip to content

Commit

Permalink
[Cocoa] Make WebContextMenuProxy::copySubjectResult return a RetainPtr
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263567

Reviewed by Tim Horton.

Clarify the ownership model around this method by returning a `RetainPtr`, and additionally rename
the method so that it doesn't read like it copies the result.

* Source/WebKit/UIProcess/WebContextMenuProxy.h:
(WebKit::WebContextMenuProxy::imageForCopySubject const):
(WebKit::WebContextMenuProxy::copySubjectResult const): Deleted.
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h:
* Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::handleContextMenuCopySubject):

Canonical link: https://commits.webkit.org/269695@main
  • Loading branch information
whsieh committed Oct 24, 2023
1 parent 728c252 commit 21a5d7f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/WebContextMenuProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WebContextMenuProxy : public RefCounted<WebContextMenuProxy>, public WebCo
#endif // PLATFORM(COCOA)

#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
virtual CGImageRef copySubjectResult() const { return nullptr; }
virtual RetainPtr<CGImageRef> imageForCopySubject() const { return { }; }
#endif

protected:
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class WebContextMenuProxyMac final : public WebContextMenuProxy {
NSWindow *window() const;

#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
CGImageRef copySubjectResult() const final { return m_copySubjectResult.get(); }
RetainPtr<CGImageRef> imageForCopySubject() const final { return m_copySubjectResult; }
#endif

private:
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ static inline bool expectsLegacyImplicitRubberBandControl()
if (!m_activeContextMenu)
return;

RetainPtr image = m_activeContextMenu->copySubjectResult();
auto image = m_activeContextMenu->imageForCopySubject();
if (!image)
return;

Expand Down

0 comments on commit 21a5d7f

Please sign in to comment.