Source/WebCore:
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Apr 2015 01:16:24 +0000 (01:16 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Apr 2015 01:16:24 +0000 (01:16 +0000)
commita30531bf682a4f42ed39932a65268968d11122e8
tree63b5cbedb8c5e3c211f7cdf2d895082a4fe1856b
parenta18771da334f5baaff8f32ac090cdc310956d363
Source/WebCore:
Unreviewed: Reapplied Change after rollout.

Expose the "Share" menu for text selections on platforms where it's available.
rdar://problem/20034174 and https://bugs.webkit.org/show_bug.cgi?id=143318

Patch by Brady Eidson <beidson@apple.com> on 2015-04-02

* page/ContextMenuClient.h:
(WebCore::ContextMenuClient::shareSelectedTextMenuItem):

* page/ContextMenuContext.h:
(WebCore::ContextMenuContext::setSelectedText):
(WebCore::ContextMenuContext::selectedText):

* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate): Add a Share menu item returned from the client.
(WebCore::ContextMenuController::checkOrEnableIfNeeded):

* platform/ContextMenuItem.cpp:
(WebCore::ContextMenuItem::shareSelectedTextMenuItem):

* platform/ContextMenuItem.h:
(WebCore::ContextMenuItem::supportsShareMenu):

* platform/gtk/ContextMenuItemGtk.cpp:
(WebCore::ContextMenuItem::shareSelectedTextMenuItem):

* platform/mac/ContextMenuItemMac.mm:
(WebCore::ContextMenuItem::releasePlatformDescription):
(WebCore::ContextMenuItem::getPlatformDescription):
(WebCore::ContextMenuItem::supportsShareMenu):
(WebCore::ContextMenuItem::shareSelectedTextMenuItem): Use NSMenu SPI to get the Share menu.

* platform/spi/mac/NSMenuSPI.h: Forward declare instead of #include

Source/WebKit/mac:
Unreviewed: Reland change after rollout.

Expose the "Share" menu for text selections on platforms where it's available.
rdar://problem/20034174 and https://bugs.webkit.org/show_bug.cgi?id=143318

Patch by Brady Eidson <beidson@apple.com> on 2015-04-02

* WebView/WebImmediateActionController.mm: Update for required #include

Source/WebKit2:
Unreviewed: Re-applied change after rollout.

Expose the "Share" menu for text selections on platforms where it's available.
rdar://problem/20034174 and https://bugs.webkit.org/show_bug.cgi?id=143318

Patch by Brady Eidson <beidson@apple.com> on 2015-04-02

* Shared/API/c/WKContextMenuItemTypes.h: Add a constant for the Share menu.
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toAPI):
(WebKit::toImpl):

* Shared/ContextMenuContextData.cpp:
(WebKit::ContextMenuContextData::ContextMenuContextData):
(WebKit::ContextMenuContextData::encode):
(WebKit::ContextMenuContextData::decode):
* Shared/ContextMenuContextData.h:
(WebKit::ContextMenuContextData::selectedText):

Add a "cross platform" menu item wrapper, right now only for NSMenuItem.
* Shared/NativeContextMenuItem.h:
(WebKit::NativeContextMenuItem::~NativeContextMenuItem):
(WebKit::NativeContextMenuItem::nsMenuItem):
* Shared/mac/NativeContextMenuItem.mm:
(WebKit::NativeContextMenuItem::NativeContextMenuItem):

Let WebContextMenuItem hold on to a NativeContextMenuItem to maintain full fidelity of the platform.
* Shared/WebContextMenuItem.cpp:
(WebKit::WebContextMenuItem::WebContextMenuItem):
* Shared/WebContextMenuItem.h:
(WebKit::WebContextMenuItem::create):
(WebKit::WebContextMenuItem::nativeContextMenuItem):

* UIProcess/API/APIContextMenuClient.h:
(API::ContextMenuClient::getContextMenuFromProposedMenu):
(API::ContextMenuClient::showContextMenu):

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageContextMenuClient):

* UIProcess/WebContextMenuProxy.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::internalShowContextMenu): Translate the placeholder item from the web process into the
  native Share menu before consulting the context menu client. Also create the API items here so the native NSMenuItem
  can be attached to them.

* UIProcess/mac/WebContextMenuProxyMac.h:
* UIProcess/mac/WebContextMenuProxyMac.mm:
(-[WKMenuTarget forwardContextMenuAction:]):
(WebKit::nsMenuItem):
(WebKit::nsMenuItemVector):
(WebKit::WebContextMenuProxyMac::populate):
(WebKit::WebContextMenuProxyMac::showContextMenu):

* WebKit2.xcodeproj/project.pbxproj:

* WebProcess/WebCoreSupport/WebContextMenuClient.h:
* WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
(WebKit::WebContextMenuClient::shareSelectedTextMenuItem): In the web process, mark the Share menu's place in the
  context menu with a placeholder item. It will be translated into the real Share menu in the UI process.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/ContextMenuClient.h
Source/WebCore/page/ContextMenuContext.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/platform/ContextMenuItem.cpp
Source/WebCore/platform/ContextMenuItem.h
Source/WebCore/platform/gtk/ContextMenuItemGtk.cpp
Source/WebCore/platform/mac/ContextMenuItemMac.mm
Source/WebCore/platform/spi/mac/NSMenuSPI.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebImmediateActionController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
Source/WebKit2/Shared/API/c/WKSharedAPICast.h
Source/WebKit2/Shared/ContextMenuContextData.cpp
Source/WebKit2/Shared/ContextMenuContextData.h
Source/WebKit2/Shared/NativeContextMenuItem.h [new file with mode: 0644]
Source/WebKit2/Shared/WebContextMenuItem.cpp
Source/WebKit2/Shared/WebContextMenuItem.h
Source/WebKit2/Shared/mac/NativeContextMenuItem.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/API/APIContextMenuClient.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/WebContextMenuProxy.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.cpp
Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h
Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp
Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm