RESOLVED FIXED 109698
[EFL][WK2] Use C API in ewk_context_menu
https://bugs.webkit.org/show_bug.cgi?id=109698
Summary [EFL][WK2] Use C API in ewk_context_menu
Michal Pakula vel Rutka
Reported 2013-02-13 08:13:18 PST
Currently EFL port in ewk_context_menu uses internal C++ classes directly, it should start using WK2 C API.
Attachments
patch (53.25 KB, patch)
2013-02-15 06:49 PST, Michal Pakula vel Rutka
eflews.bot: commit-queue-
fixed changelog (53.25 KB, patch)
2013-02-15 07:21 PST, Michal Pakula vel Rutka
no flags
rebased patch (53.25 KB, patch)
2013-02-18 05:24 PST, Michal Pakula vel Rutka
eflews.bot: commit-queue-
fixes after review (53.05 KB, patch)
2013-02-21 03:15 PST, Michal Pakula vel Rutka
no flags
rebased (53.09 KB, patch)
2013-02-22 01:40 PST, Michal Pakula vel Rutka
no flags
fixes (57.05 KB, patch)
2013-02-28 05:02 PST, Michal Pakula vel Rutka
no flags
patch (49.64 KB, patch)
2013-03-06 05:15 PST, Michal Pakula vel Rutka
no flags
rebased after 111552 changes (41.58 KB, patch)
2013-03-25 07:42 PDT, Michal Pakula vel Rutka
no flags
rebased (41.64 KB, patch)
2013-04-15 03:16 PDT, Michal Pakula vel Rutka
no flags
Michal Pakula vel Rutka
Comment 1 2013-02-15 06:49:22 PST
EFL EWS Bot
Comment 2 2013-02-15 06:58:21 PST
Michal Pakula vel Rutka
Comment 3 2013-02-15 07:21:43 PST
Created attachment 188565 [details] fixed changelog this patch won't build until https://bugs.webkit.org/show_bug.cgi?id=109815 will land
Michal Pakula vel Rutka
Comment 4 2013-02-18 05:24:51 PST
Created attachment 188859 [details] rebased patch rebased patch after WebView class introduction
WebKit Review Bot
Comment 5 2013-02-18 12:57:23 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
EFL EWS Bot
Comment 6 2013-02-18 13:56:23 PST
Comment on attachment 188859 [details] rebased patch Attachment 188859 [details] did not pass efl-ews (efl): Output: http://queues.webkit.org/results/16626201
Mikhail Pozdnyakov
Comment 7 2013-02-20 23:57:58 PST
Comment on attachment 188859 [details] rebased patch View in context: https://bugs.webkit.org/attachment.cgi?id=188859&action=review > Source/WebKit2/UIProcess/API/C/WKPage.cpp:802 > +void WKPageContextMenuItemSelected(WKPageRef page, WKContextMenuItemRef item) WKPageGetSelectedContextMenuItem ? > Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:44 > + const size_t size = WKArrayGetSize(items); const local variables are not up to the coding style. > Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:145 > + wkItem = WKContextMenuItemCreateAsAction(static_cast<WKContextMenuItemTag>(item->action()), WKStringCreateWithUTF8CString(item->title()), item->enabled()); WKStringCreateWithUTF8CString needs adoption. > Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:148 > + wkItem = WKContextMenuItemCreateAsCheckableAction(static_cast<WKContextMenuItemTag>(item->action()), WKStringCreateWithUTF8CString(item->title()), item->enabled(), item->checked()); same here. > Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:151 > + return false; is it expected? shouldn't ASSERT_NOT_REACHED be here? > Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.cpp:29 > +#include "WKContextMenuItemTypes.h" #include <WebKit2/WKContextMenuItemTypes.h> > Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.cpp:39 > + , m_title(WKEinaSharedString(WKContextMenuItemCopyTitle(item))) needs adoption > Source/WebKit2/UIProcess/PageClient.h:183 > +#if !PLATFORM(EFL) could you explain why ? > Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp:44 > + contextMenuClient->view()->showContextMenu(menuLocation, menuItems); nit: could be one line: toContextClientEfl(clientInfo)->view.. > Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp:51 > + contextMenuClient->view()->hideContextMenu(); ditto
Michal Pakula vel Rutka
Comment 8 2013-02-21 01:00:13 PST
Comment on attachment 188859 [details] rebased patch View in context: https://bugs.webkit.org/attachment.cgi?id=188859&action=review >> Source/WebKit2/UIProcess/API/C/WKPage.cpp:802 >> +void WKPageContextMenuItemSelected(WKPageRef page, WKContextMenuItemRef item) > > WKPageGetSelectedContextMenuItem ? This function is called to select context menu item, so word Get may be confusing. >> Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:44 >> + const size_t size = WKArrayGetSize(items); > > const local variables are not up to the coding style. OK >> Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:145 >> + wkItem = WKContextMenuItemCreateAsAction(static_cast<WKContextMenuItemTag>(item->action()), WKStringCreateWithUTF8CString(item->title()), item->enabled()); > > WKStringCreateWithUTF8CString needs adoption. OK >> Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:148 >> + wkItem = WKContextMenuItemCreateAsCheckableAction(static_cast<WKContextMenuItemTag>(item->action()), WKStringCreateWithUTF8CString(item->title()), item->enabled(), item->checked()); > > same here. OK >> Source/WebKit2/UIProcess/API/efl/ewk_context_menu.cpp:151 >> + return false; > > is it expected? shouldn't ASSERT_NOT_REACHED be here? OK I will add it here before return >> Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.cpp:29 >> +#include "WKContextMenuItemTypes.h" > > #include <WebKit2/WKContextMenuItemTypes.h> OK >> Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.cpp:39 >> + , m_title(WKEinaSharedString(WKContextMenuItemCopyTitle(item))) > > needs adoption OK >> Source/WebKit2/UIProcess/PageClient.h:183 >> +#if !PLATFORM(EFL) > > could you explain why ? Context menu WK client is located inside WKPage.h, so we do not need separate ContextMenuProxy the same as i.e. for WKPageFindClient. >> Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp:44 >> + contextMenuClient->view()->showContextMenu(menuLocation, menuItems); > > nit: could be one line: toContextClientEfl(clientInfo)->view.. OK >> Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp:51 >> + contextMenuClient->view()->hideContextMenu(); > > ditto OK
Michal Pakula vel Rutka
Comment 9 2013-02-21 03:15:02 PST
Created attachment 189496 [details] fixes after review
Michal Pakula vel Rutka
Comment 10 2013-02-22 01:40:10 PST
Jesus Sanchez-Palencia
Comment 11 2013-02-25 11:51:29 PST
Comment on attachment 189716 [details] rebased View in context: https://bugs.webkit.org/attachment.cgi?id=189716&action=review > Source/WebKit2/UIProcess/WebPageProxy.cpp:3071 > +#if PLATFORM(EFL) Why adding more platform-specific code to this common file if this could go through WebContextMenuProxy (m_activeContextMenu, in this context). > Source/WebKit2/UIProcess/WebPageProxy.cpp:3087 > +#if PLATFORM(EFL) Ditto. I have checked your ContextMenuClientEfl and neither its showContextMenu or hideContextMenu end up using the WebPageProxy ptr, so again this could be going through m_activeContextMenu.
Michal Pakula vel Rutka
Comment 12 2013-02-26 04:24:32 PST
Comment on attachment 189716 [details] rebased View in context: https://bugs.webkit.org/attachment.cgi?id=189716&action=review >> Source/WebKit2/UIProcess/WebPageProxy.cpp:3087 >> +#if PLATFORM(EFL) > > Ditto. > I have checked your ContextMenuClientEfl and neither its showContextMenu or hideContextMenu end up using the WebPageProxy ptr, so again this could be going through m_activeContextMenu. If I want to use WK API I have to call the methods on WebContextMenuClient (m_contextMenuClient) which has a member m_client of WKPageContextMenuClient type. WebContextMenuProxy currently does not have access to WebContextMenuClient, and adding it will need to introduce a change in context menu implementation, as WebContextMenuProxy will have to be changed to APIObject. My intention was to make a small patch, and change other ports' implementation as little as it is possible.
Michal Pakula vel Rutka
Comment 13 2013-02-26 08:13:31 PST
Comment on attachment 189716 [details] rebased View in context: https://bugs.webkit.org/attachment.cgi?id=189716&action=review >>> Source/WebKit2/UIProcess/WebPageProxy.cpp:3087 >>> +#if PLATFORM(EFL) >> >> Ditto. >> I have checked your ContextMenuClientEfl and neither its showContextMenu or hideContextMenu end up using the WebPageProxy ptr, so again this could be going through m_activeContextMenu. > > If I want to use WK API I have to call the methods on WebContextMenuClient (m_contextMenuClient) which has a member m_client of WKPageContextMenuClient type. WebContextMenuProxy currently does not have access to WebContextMenuClient, and adding it will need to introduce a change in context menu implementation, as WebContextMenuProxy will have to be changed to APIObject. My intention was to make a small patch, and change other ports' implementation as little as it is possible. I checked and this can be done in easier way by adding WebPageContexMenuClient (m_contextMenuClient), as one of arguments in showContextMenu and hideContextMenu, but this solution has two disadvantages: this argument will be unused in all other ports, WebContextMenuProxy in EFL port will be created only to share WebPageProxy implementation with others. In this case I think it is better to add EFL-only code rather than adding unneeded code.
Jesus Sanchez-Palencia
Comment 14 2013-02-26 09:51:53 PST
(In reply to comment #13) > I checked and this can be done in easier way by adding WebPageContexMenuClient (m_contextMenuClient), as one of arguments in showContextMenu and hideContextMenu, but this solution has two disadvantages: this argument will be unused in all other ports, WebContextMenuProxy in EFL port will be created only to share WebPageProxy implementation with others. In this case I think it is better to add EFL-only code rather than adding unneeded code. Hi! I've applied your patch locally and I was having a closer look at it. It would be great if we could reach a common code for us all (EFL, Nix, Qt, and perhaps GTK). If we all decide to go through the C client like this, then keeping m_activeContextMenu in WebPageProxy will only make sense for Mac. All I wished is that we could route all ContextMenu code path through a single entity instead of having both a WebContextMenuProxy and a WebPageContextMenuClient in WebPageProxy. Anyway, I guess we should get some feedback from a reviewer now.
Kenneth Rohde Christiansen
Comment 15 2013-02-26 10:46:33 PST
Comment on attachment 189716 [details] rebased View in context: https://bugs.webkit.org/attachment.cgi?id=189716&action=review > Source/WebKit2/ChangeLog:13 > + to avoid violating layering. > + This patch changes EFL context menu API to use only WK2 C API, also adds two functions to WKPageContextMenuClient. > + Maybe the patch adding those should be separate and come with a unit test?
Jesus Sanchez-Palencia
Comment 16 2013-02-26 11:26:02 PST
Comment on attachment 189716 [details] rebased View in context: https://bugs.webkit.org/attachment.cgi?id=189716&action=review > Source/WebKit2/UIProcess/PageClient.h:183 > +#if !PLATFORM(EFL) There is no need for this. > Source/WebKit2/UIProcess/WebPageProxy.cpp:3088 > + m_contextMenuClient.showContextMenu(this, menuLocation, proposedItems); I believe here you should call m_contextMenuClient.getContextMenuFromProposedMenu() as it is done on the lines below (inside the #else block). Otherwise ports going through this code path will lose the option of customizing the menu through their context menu client.
Michal Pakula vel Rutka
Comment 17 2013-02-27 09:10:59 PST
Comment on attachment 189716 [details] rebased View in context: https://bugs.webkit.org/attachment.cgi?id=189716&action=review >> Source/WebKit2/ChangeLog:13 >> + > > Maybe the patch adding those should be separate and come with a unit test? OK I can split it into two parts: common and EFL-only. Maybe I wrote it wrong, but this patch does not change any Webkit-EFL API functions, only the way it communicates with WebKit, so no changes in unit tests are needed. >> Source/WebKit2/UIProcess/PageClient.h:183 >> +#if !PLATFORM(EFL) > > There is no need for this. If I will leave this declaration here, I will have to leave the createContextMenuProxy implementation also in WebView class. >> Source/WebKit2/UIProcess/WebPageProxy.cpp:3088 >> + m_contextMenuClient.showContextMenu(this, menuLocation, proposedItems); > > I believe here you should call m_contextMenuClient.getContextMenuFromProposedMenu() as it is done on the lines below (inside the #else block). Otherwise ports going through this code path will lose the option of customizing the menu through their context menu client. OK, I will add this.
Michal Pakula vel Rutka
Comment 18 2013-02-28 05:02:25 PST
Created attachment 190708 [details] fixes added possibility to customize context menu items, replace COMPILE_ASSERT_MATCHING_ENUM macro with functions converting enums between WK API and EWK
Michal Pakula vel Rutka
Comment 19 2013-03-06 05:15:38 PST
Created attachment 191723 [details] patch patch splitted into WK2 C API and EFL part
Gyuyoung Kim
Comment 20 2013-03-06 18:06:28 PST
(In reply to comment #18) > Created an attachment (id=190708) [details] > fixes > > added possibility to customize context menu items, replace COMPILE_ASSERT_MATCHING_ENUM macro with functions converting enums between WK API and EWK I'm wondering if the functions can guarantee that EWK_CONTEXT_MENU_ITEM_TAG_XXX is sync with WebCore::ContextMenuItemTagXXX. Can the functions check if WebCore::ContextMenuItemTagXXX is removed or changed ?
Michal Pakula vel Rutka
Comment 21 2013-03-07 01:01:27 PST
(In reply to comment #20) > (In reply to comment #18) > > Created an attachment (id=190708) [details] [details] > > fixes > > > > added possibility to customize context menu items, replace COMPILE_ASSERT_MATCHING_ENUM macro with functions converting enums between WK API and EWK > > I'm wondering if the functions can guarantee that EWK_CONTEXT_MENU_ITEM_TAG_XXX is sync with WebCore::ContextMenuItemTagXXX. Can the functions check if WebCore::ContextMenuItemTagXXX is removed or changed ? There functions I have added (WK2 C API <-> EWK) are similar to ones from here: https://trac.webkit.org/browser/trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h#L321, converting between WebCore and WK2 C API. If new context menu tags/actions will be added to WebCore, they won't be just visible for application using ewk_context_menu API. If I will keep using COMPILE_ASSERT_MATCHING_ENUM, Ewk_Context_Menu_Item_Action will have to be in sync with WKContextMenuItemTag, which contains items not used by EFL port.
Gyuyoung Kim
Comment 22 2013-03-07 01:45:54 PST
https://trac.webkit.org/browser/trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h#L321 I think this case is reasonable because this map WebCore's context menu enum on WK2's enum. However, getWKTagFromEwkAction() and getEwkActionFromWKTag() just deal with WK2 enum defined by us. I still think COMPILE_ASSERT_MATCHING_ENUM will help that we realize this removal when one of WebCore::ContextMenuAction enums is removed. >> If I will keep using COMPILE_ASSERT_MATCHING_ENUM, Ewk_Context_Menu_Item_Action will have to be in sync with WKContextMenuItemTag, which contains items not used by EFL port. Basically, when I added Ewk_Context_Menu_Item, I considered it is in sync with WebCore's ContextMenuItem.h. Look at http://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.h#L56 Isn't WKContextMenuItemTag in sync with ContextMenuItem.h as well ? If EFL port doesn't want not to support some items, I think we disable it in ContextMenuItem.h. If you wanna remove COMPILE_ASSERT_MATCHING_ENUM, how about using ContextMenuItem.h directly as GTK port ?
Michal Pakula vel Rutka
Comment 23 2013-03-07 02:46:04 PST
(In reply to comment #22) > https://trac.webkit.org/browser/trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h#L321 > > I think this case is reasonable because this map WebCore's context menu enum on WK2's enum. However, getWKTagFromEwkAction() and getEwkActionFromWKTag() just deal with WK2 enum defined by us. I still think COMPILE_ASSERT_MATCHING_ENUM will help that we realize this removal when one of WebCore::ContextMenuAction enums is removed. > If some of WebCore's items will be removed also WKContextMenuItemTag should be removed or at least it has to be removed from from toAPI, toImpl functions. In first case Ewk_Context_Menu_Item_Tag should be also removed or it will cause build break, in second case using non-existent tag will generate error message. > >> If I will keep using COMPILE_ASSERT_MATCHING_ENUM, Ewk_Context_Menu_Item_Action will have to be in sync with WKContextMenuItemTag, which contains items not used by EFL port. > > Basically, when I added Ewk_Context_Menu_Item, I considered it is in sync with WebCore's ContextMenuItem.h. Look at http://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/ewk_context_menu_item.h#L56 I guess I forgot to remove this comment :) > > Isn't WKContextMenuItemTag in sync with ContextMenuItem.h as well ? If EFL port doesn't want not to support some items, I think we disable it in ContextMenuItem.h. I have checked and WKContextMenuItemTag is not in sync with ContextMenuAction from WebCore. Also some of ContextMenuAction enum are surrounded by ifdefs, while WK2 API are not. > > If you wanna remove COMPILE_ASSERT_MATCHING_ENUM, how about using ContextMenuItem.h directly as GTK port ? Main purpose of this patch was stop relaying on WebKit2 internal C++ classes and start using WK2 API directly, and I thought it also concerns using WK2 C API enum instead of WebCore.
Gyuyoung Kim
Comment 24 2013-03-07 02:54:18 PST
(In reply to comment #23) > > If you wanna remove COMPILE_ASSERT_MATCHING_ENUM, how about using ContextMenuItem.h directly as GTK port ? > > Main purpose of this patch was stop relaying on WebKit2 internal C++ classes and start using WK2 API directly, and I thought it also concerns using WK2 C API enum instead of WebCore. Ok, I'm fine from the point of using WK2 API. And, as you said, it looks that toAPI, toImpl functions will guarantee my concern implicitly. Thank you for your explanation. >> I guess I forgot to remove this comment :) Yes, please modify this comment as well. :)
Michal Pakula vel Rutka
Comment 25 2013-03-25 07:42:23 PDT
Created attachment 194852 [details] rebased after 111552 changes
Michal Pakula vel Rutka
Comment 26 2013-04-15 03:16:27 PDT
Gyuyoung Kim
Comment 27 2013-04-15 05:23:19 PDT
Comment on attachment 198046 [details] rebased LGTM based on previous informal reviews.
WebKit Commit Bot
Comment 28 2013-04-15 06:42:05 PDT
Comment on attachment 198046 [details] rebased Clearing flags on attachment: 198046 Committed r148434: <http://trac.webkit.org/changeset/148434>
WebKit Commit Bot
Comment 29 2013-04-15 06:42:10 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.