Skip to content
  • bweinstein@apple.com's avatar
    Part of Layering Violation in ContextMenu · 60350d69
    bweinstein@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=50586
            
    Reviewed by John Sullivan.
    
    WebCore: 
    
    ContextMenuMac.mm had a WebCoreMenuTarget class, which was responsible for wrapping
    a ContextMenuItem, and calling through to the ContextMenuController to validate it
    and call a function when it was selected.
            
    It was a layering violation to have this class here, because ContextMenu can't know
    about ContextMenuController.
            
    This patch moves the class that wraps the ContextMenuItems to WebKit/mac/WebHTMLView.mm,
    and sets up the menu targets there.
    
    No change in behavior, no new tests.
    
    * WebCore.exp.in: Added function that needs to be exported.
    * platform/mac/ContextMenuMac.mm:
    (WebCore::ContextMenu::ContextMenu): Don't set the sharedMenuTarget anymore.
    (WebCore::ContextMenu::appendItem): Don't call setMenuItemTarget (this is done in WebKit now).
    (WebCore::ContextMenu::insertItem): Ditto.
    
    WebKit/mac: 
    
    Move WebMenuTarget from ContextMenuMac to here, because having it in ContextMenuMac
    was a layering violation. Also, make sure we set the menu item targets for all menu
    items before showing them, because the ContextMenu constructor doesn't do that anymore.
    
    * WebView/WebHTMLView.mm:
    (+[WebMenuTarget sharedMenuTarget]): Moved from ContextMenuMac.mm.
    (-[WebMenuTarget WebCore::]): Ditto.
    (-[WebMenuTarget setMenuController:WebCore::]): Ditto.
    (-[WebMenuTarget forwardContextMenuAction:]): Ditto.
    (-[WebMenuTarget validateMenuItem:]): Ditto.
    
    (setMenuItemTarget): Sets the target of the NSMenuItem to the shared WebMenuTarget.
    (setMenuTargets): Recursively iterates over all NSMenuItems in an NSMenu (including
        submenus), and calls setMenuItemTarget on them.
    (-[WebHTMLView menuForEvent:]): Call setMenuTarget on all the menu items before adding
        them to the menu.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73469 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    60350d69