Bug 181423

Summary: Merge sync and async code paths for getting context menus
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: berto, cgarcia, commit-queue, ews-watchlist, gustavo, joepeck, mcatanzaro, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 181564    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Alex Christensen 2018-01-08 18:44:41 PST
Merge sync and async code paths for getting context menus
Comment 1 Alex Christensen 2018-01-08 18:53:08 PST
Created attachment 330777 [details]
Patch
Comment 2 Alex Christensen 2018-01-08 18:53:34 PST
Could someone double check that context menus on linux work as before?
Comment 3 EWS Watchlist 2018-01-08 18:56:42 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 4 Michael Catanzaro 2018-01-08 19:41:37 PST
(In reply to Alex Christensen from comment #2)
> Could someone double check that context menus on linux work as before?

I can look at it tomorrow, sure.

Note:

lib/libwebkit2gtk-4.0.so.37.26.1: error: undefined reference to 'WebKit::WebContextMenuListenerProxy::useContextMenuItems(WTF::Vector<WTF::Ref<WebKit::WebContextMenuItem, WTF::DumbPtrTraits<WebKit::WebContextMenuItem> >, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc>&&)'
lib/libwebkit2gtk-4.0.so.37.26.1: error: undefined reference to 'WebKit::WebContextMenuListenerProxy::WebContextMenuListenerProxy(WebKit::WebContextMenuProxy*)'
Comment 5 Alex Christensen 2018-01-08 22:15:05 PST
Created attachment 330794 [details]
Patch
Comment 6 Michael Catanzaro 2018-01-09 09:23:08 PST
(In reply to Alex Christensen from comment #2)
> Could someone double check that context menus on linux work as before?

Yes, they're working fine!
Comment 7 Joseph Pecoraro 2018-01-10 19:22:29 PST
Comment on attachment 330794 [details]
Patch

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

r=me

> Source/WebKit/UIProcess/API/glib/WebKitContextMenuClient.cpp:51
>          webkitWebViewPopulateContextMenu(m_webView, menuItems, hitTestResultData, variant.get());
> -        return true;
> +        contextMenuListener.useContextMenuItems({ });

So Glib does something special in `webkitWebViewPopulateContextMenu` instead of passing the new items to `contextMenuListener.useContextMenuItems`? I'm surprised this always passes an empty list to useContextMenuItems.

Edit: Oh I think I see, gtk/WebContextMenuProxyGtk.cpp calls this with a mostly stub WebContextMenuListenerProxy, since WebContextMenuProxyGtk::showContextMenuWithItems does nothing (and which you just removed). I suppose it could be a real WebContextMenuListenerProxy that does the webkitWebViewPopulateContextMenu call instead of happening here in the client? Seems like it would amount to doing the same thing in the end.
Comment 8 Alex Christensen 2018-01-11 11:23:08 PST
http://trac.webkit.org/r226789
Comment 9 Radar WebKit Bug Importer 2018-01-11 11:24:26 PST
<rdar://problem/36444419>
Comment 10 Alex Christensen 2018-01-11 13:15:49 PST
https://trac.webkit.org/changeset/226794/webkit
Comment 11 WebKit Commit Bot 2018-01-11 16:13:25 PST
Re-opened since this is blocked by bug 181564
Comment 12 Alex Christensen 2018-01-11 16:14:15 PST
This broke API tests 
  WebKit.ContextMenuImgWithVideo
  _WKDownload.RedirectedDownload
Comment 13 Alex Christensen 2018-01-16 13:52:44 PST
Comment on attachment 330794 [details]
Patch

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

> Source/WebKit/UIProcess/API/APIContextMenuClient.h:54
> +    virtual void getContextMenuFromProposedMenu(WebKit::WebPageProxy&, Vector<Ref<WebKit::WebContextMenuItem>>&& /* proposedMenu */, WebKit::WebContextMenuListenerProxy& listener, const WebKit::WebHitTestResultData&, API::Object* /* userData */) { listener.useContextMenuItems({ }); }

This broke the tests.  Instead of calling the listener with an empty list, I needed to move proposedMenu into the listener.  Oops.
Comment 14 Alex Christensen 2018-01-16 13:52:58 PST
Created attachment 331427 [details]
Patch
Comment 15 Alex Christensen 2018-01-16 13:58:50 PST
http://trac.webkit.org/r227001