Bug 108798

Summary: [EFL][WK2] Port EwkPopupMenuItem to the C API
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit EFLAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: abecsi, andersca, ap, benjamin, buildbot, cmarcelo, gyuyoung.kim, kenneth, laszlo.gombos, lucas.de.marchi, menard, mikhail.pozdnyakov, rakuco, rniwa, sam, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 109083    
Bug Blocks: 107657    
Attachments:
Description Flags
Patch
none
Patch
buildbot: commit-queue-
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2013-02-04 00:01:06 PST
As per Bug 107657, we should stop using internal C++ API in ewk_popup_menu and start using the C API instead of avoid violating API layering.
Comment 1 Chris Dumez 2013-02-04 03:38:48 PST
Created attachment 186337 [details]
Patch
Comment 2 Kenneth Rohde Christiansen 2013-02-04 03:41:37 PST
Comment on attachment 186337 [details]
Patch

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

> Source/WebKit2/UIProcess/API/C/efl/WKPopupMenuEfl.cpp:34
> +void WKPopupMenuEflSetSelectedIndex(WKPopupMenuRef menuRef, int selectedIndex)

Efl would be wrong style. Please use EFL. Maybe we don't even need it, it is just an extension for our platform.

What about multi select?
Comment 3 Chris Dumez 2013-02-04 03:48:46 PST
Created attachment 186339 [details]
Patch

Take Kenneth's feedback into consideration.
Comment 4 Build Bot 2013-02-04 03:57:15 PST
Comment on attachment 186339 [details]
Patch

Attachment 186339 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://queues.webkit.org/results/16371168
Comment 5 Chris Dumez 2013-02-04 04:10:56 PST
Created attachment 186344 [details]
Patch

Attempt to fix mac-wk2 ews.
Comment 6 Chris Dumez 2013-02-04 04:58:02 PST
Created attachment 186355 [details]
Patch

Rebase on master as the XCode project change started conflicting.
Comment 7 Kenneth Rohde Christiansen 2013-02-04 07:31:52 PST
Comment on attachment 186355 [details]
Patch

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

> Source/WebKit2/UIProcess/efl/WebPopupMenuProxyEfl.cpp:55
> +    // requestPopupMenu() takes ownership of the menu items.
> +    m_view->requestPopupMenu(toAPI(static_cast<WebPopupMenuProxy*>(this)), rect, textDirection, pageScaleFactor, popupMenuItems, selectedIndex);

So still this class knows about our view implementation (actually depends on it). I guess it could depend on our WebView (WKView) in the near future
Comment 8 Chris Dumez 2013-02-04 07:36:33 PST
(In reply to comment #7)
> (From update of attachment 186355 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=186355&action=review
> 
> > Source/WebKit2/UIProcess/efl/WebPopupMenuProxyEfl.cpp:55
> > +    // requestPopupMenu() takes ownership of the menu items.
> > +    m_view->requestPopupMenu(toAPI(static_cast<WebPopupMenuProxy*>(this)), rect, textDirection, pageScaleFactor, popupMenuItems, selectedIndex);
> 
> So still this class knows about our view implementation (actually depends on it). I guess it could depend on our WebView (WKView) in the near future

Yes. Likely, we'll need to use the new WebView class once it is introduced (that patch has not landed yet). Until then, this will do fine :)
Comment 9 Chris Dumez 2013-02-05 04:44:02 PST
Created attachment 186599 [details]
Patch

Refactor the implementation so that we do not require any C API anymore.
Comment 10 Kenneth Rohde Christiansen 2013-02-05 05:13:38 PST
Comment on attachment 186599 [details]
Patch

Great changelog, looks good
Comment 11 Mikhail Pozdnyakov 2013-02-05 05:20:16 PST
Comment on attachment 186599 [details]
Patch

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

looks good.

> Source/WebKit2/UIProcess/efl/WebPopupMenuProxyEfl.cpp:78
> +    const size_t size = items.size();

const local variables are not due to coding style.
Comment 12 Chris Dumez 2013-02-19 01:04:31 PST
Created attachment 189016 [details]
Patch
Comment 13 Kenneth Rohde Christiansen 2013-02-19 01:29:39 PST
Comment on attachment 189016 [details]
Patch

LGTM
Comment 14 Benjamin Poulain 2013-02-19 13:47:11 PST
Comment on attachment 189016 [details]
Patch

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

Looks great. I sign off on this.

> Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp:38
> +COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_SEPARATOR, kWKPopupItemTypeSeparator);
> +COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_ITEM, kWKPopupItemTypeItem);

Just a comment.

I know this style is spread in EFL already, but you can write conversion function from one enum type to an other to have the same flexibility without using tricks.
With a switch()-case() and a good compiler, there should be no additional cost.

> Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp:70
> +    if (!m_text)
> +        m_text = WKEinaSharedString(AdoptWK, WKPopupItemCopyText(m_wkItem.get()));
> +
>      return m_text;
>  }
>  
>  const char* EwkPopupMenuItem::tooltipText() const
>  {
> +    if (!m_tooltipText)
> +        m_tooltipText = WKEinaSharedString(AdoptWK, WKPopupItemCopyToolTipText(m_wkItem.get()));
> +
>      return m_tooltipText;
>  }
>  
>  const char* EwkPopupMenuItem::accessibilityText() const
>  {
> +    if (!m_accessibilityText)
> +        m_accessibilityText = WKEinaSharedString(AdoptWK, WKPopupItemCopyAccessibilityText(m_wkItem.get()));
> +

m_test, m_tooltipText and m_accessibilityText should be initialized to 0 in the constructor.
Comment 15 Chris Dumez 2013-02-19 16:15:01 PST
(In reply to comment #14)
> (From update of attachment 189016 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=189016&action=review
> 
> Looks great. I sign off on this.
> 
> > Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp:38
> > +COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_SEPARATOR, kWKPopupItemTypeSeparator);
> > +COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_ITEM, kWKPopupItemTypeItem);
> 
> Just a comment.
> 
> I know this style is spread in EFL already, but you can write conversion function from one enum type to an other to have the same flexibility without using tricks.
> With a switch()-case() and a good compiler, there should be no additional cost.
> 
> > Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp:70
> > +    if (!m_text)
> > +        m_text = WKEinaSharedString(AdoptWK, WKPopupItemCopyText(m_wkItem.get()));
> > +
> >      return m_text;
> >  }
> >  
> >  const char* EwkPopupMenuItem::tooltipText() const
> >  {
> > +    if (!m_tooltipText)
> > +        m_tooltipText = WKEinaSharedString(AdoptWK, WKPopupItemCopyToolTipText(m_wkItem.get()));
> > +
> >      return m_tooltipText;
> >  }
> >  
> >  const char* EwkPopupMenuItem::accessibilityText() const
> >  {
> > +    if (!m_accessibilityText)
> > +        m_accessibilityText = WKEinaSharedString(AdoptWK, WKPopupItemCopyAccessibilityText(m_wkItem.get()));
> > +
> 
> m_test, m_tooltipText and m_accessibilityText should be initialized to 0 in the constructor.

Those are WKEinaSharedString objects so there is no need for initializing to 0. The default constructor takes care of initializing the internal const char* to 0.
Comment 16 Kenneth Rohde Christiansen 2013-02-20 02:50:29 PST
Comment on attachment 189016 [details]
Patch

r=me as signed of by ben
Comment 17 WebKit Review Bot 2013-02-20 03:10:11 PST
Comment on attachment 189016 [details]
Patch

Clearing flags on attachment: 189016

Committed r143444: <http://trac.webkit.org/changeset/143444>
Comment 18 WebKit Review Bot 2013-02-20 03:10:18 PST
All reviewed patches have been landed.  Closing bug.