Changeset 191412 in webkit


Ignore:
Timestamp:
Oct 21, 2015 4:14:31 PM (9 years ago)
Author:
andersca@apple.com
Message:

Move services menu handling out into a separate function
https://bugs.webkit.org/show_bug.cgi?id=150420

Reviewed by Tim Horton.

  • UIProcess/mac/WebContextMenuProxyMac.h:
  • UIProcess/mac/WebContextMenuProxyMac.mm:

(WebKit::WebContextMenuProxyMac::showServicesMenu):
(WebKit::WebContextMenuProxyMac::show):
(WebKit::WebContextMenuProxyMac::showContextMenu):
(WebKit::WebContextMenuProxyMac::populate): Deleted.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r191409 r191412  
     12015-10-21  Anders Carlsson  <andersca@apple.com>
     2
     3        Move services menu handling out into a separate function
     4        https://bugs.webkit.org/show_bug.cgi?id=150420
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/mac/WebContextMenuProxyMac.h:
     9        * UIProcess/mac/WebContextMenuProxyMac.mm:
     10        (WebKit::WebContextMenuProxyMac::showServicesMenu):
     11        (WebKit::WebContextMenuProxyMac::show):
     12        (WebKit::WebContextMenuProxyMac::showContextMenu):
     13        (WebKit::WebContextMenuProxyMac::populate): Deleted.
     14
    1152015-10-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    216
  • trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h

    r191407 r191412  
    6060    virtual void show() override;
    6161
    62     void populate(const Vector<RefPtr<WebContextMenuItem>>&);
     62    void showContextMenu();
    6363
    6464#if ENABLE(SERVICE_CONTROLS)
     65    void showServicesMenu();
    6566    void setupServicesMenu();
    6667    WebCore::ContextMenuItem shareMenuItem();
  • trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm

    r191407 r191412  
    319319}
    320320
     321void WebContextMenuProxyMac::showServicesMenu()
     322{
     323    setupServicesMenu();
     324
     325    [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setMenuProxy:this];
     326    [m_menu popUpMenuPositioningItem:nil atLocation:m_context.menuLocation() inView:m_webView];
     327}
     328
    321329void WebContextMenuProxyMac::clearServicesMenu()
    322330{
     
    361369#endif
    362370
    363 void WebContextMenuProxyMac::populate(const Vector<RefPtr<WebContextMenuItem>>& items)
    364 {
     371void WebContextMenuProxyMac::show()
     372{
     373    Ref<WebPageProxy> protect(m_page);
     374
    365375#if ENABLE(SERVICE_CONTROLS)
    366376    if (m_context.isServicesMenu()) {
    367         setupServicesMenu();
     377        showServicesMenu();
    368378        return;
    369379    }
    370380#endif
    371381
    372     m_menu = [[NSMenu alloc] initWithTitle:@""];
    373     [m_menu setAutoenablesItems:NO];
    374 
    375     populateNSMenu(m_menu.get(), nsMenuItemVector(items));
    376 }
    377 
    378 void WebContextMenuProxyMac::show()
    379 {
    380     // Unless this is an image control, give the PageContextMenuClient one last swipe at changing the menu.
    381     bool askClientToChangeMenu = true;
    382 #if ENABLE(SERVICE_CONTROLS)
    383     if (m_context.isServicesMenu() || m_context.controlledImage())
    384         askClientToChangeMenu = false;
    385 #endif
    386 
     382    showContextMenu();
     383}
     384
     385void WebContextMenuProxyMac::showContextMenu()
     386{
    387387    Vector<RefPtr<WebContextMenuItem>> proposedAPIItems;
    388388    for (auto& item : m_context.menuItems()) {
     
    402402    bool useProposedItems = true;
    403403
    404     if (askClientToChangeMenu && m_page.contextMenuClient().getContextMenuFromProposedMenu(m_page, proposedAPIItems, clientItems, m_context.webHitTestResultData(), m_page.process().transformHandlesToObjects(m_userData.object()).get()))
     404    if (m_page.contextMenuClient().getContextMenuFromProposedMenu(m_page, proposedAPIItems, clientItems, m_context.webHitTestResultData(), m_page.process().transformHandlesToObjects(m_userData.object()).get()))
    405405        useProposedItems = false;
    406406
    407407    const Vector<RefPtr<WebContextMenuItem>>& items = useProposedItems ? proposedAPIItems : clientItems;
    408408
    409 #if ENABLE(SERVICE_CONTROLS)
    410     if (items.isEmpty() && !m_context.isServicesMenu())
    411         return;
    412 #else
    413409    if (items.isEmpty())
    414410        return;
    415 #endif
    416 
    417     populate(items);
     411
     412    m_menu = [[NSMenu alloc] initWithTitle:@""];
     413    [m_menu setAutoenablesItems:NO];
     414
     415    populateNSMenu(m_menu.get(), nsMenuItemVector(items));
    418416
    419417    [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
    420 
    421 #if ENABLE(SERVICE_CONTROLS)
    422     if (m_context.isServicesMenu())
    423         [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setMenuProxy:this];
    424 #endif
    425 
    426     Ref<WebPageProxy> protect(m_page);
    427 
    428418    [m_menu popUpMenuPositioningItem:nil atLocation:m_context.menuLocation() inView:m_webView];
    429419}
Note: See TracChangeset for help on using the changeset viewer.