- Revision
- 175966
- Author
- [email protected]
- Date
- 2014-11-11 12:12:02 -0800 (Tue, 11 Nov 2014)
Log Message
DataDetectors' menu items aren't presented in the telephone number menu
https://bugs.webkit.org/show_bug.cgi?id=138602
<rdar://problem/18866308>
Reviewed by Beth Dakin.
We currently round-trip the DataDetectors telephone number NSMenuItems
through the very-lossy WebContextMenuItemData, for no real reason.
We should avoid this so that DataDetectors' actual NSMenuItems are
presented in the final menu, so that they can adjust their items after
providing them to us.
* Platform/mac/MenuUtilities.h:
* Platform/mac/MenuUtilities.mm:
(WebKit::menuItemTitleForTelephoneNumber): Deleted.
Stop adjusting the menu item titles, as they come correct now.
(WebKit::menuItemsForTelephoneNumber): Deleted.
(WebKit::menuForTelephoneNumber):
Return a fully-formed menu for the single telephone number case.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::showTelephoneNumberMenu):
Present the fully-formed menu, without round-tripping through
WebContextMenuItemData, because we do not need to hand the items to
the context menu client (and indeed, were not), and because this
allows us to use the exact items returned by DataDetectors, so they
can keep ahold of the items that we actually present.
* UIProcess/PageClient.h:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::showPlatformContextMenu):
Add a Mac-only PageClient function for presenting a NSMenu at a
WKView-relative point.
* English.lproj/Localizable.strings:
Remove a now-unused localized string.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (175965 => 175966)
--- trunk/Source/WebCore/ChangeLog 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebCore/ChangeLog 2014-11-11 20:12:02 UTC (rev 175966)
@@ -1,3 +1,14 @@
+2014-11-11 Tim Horton <[email protected]>
+
+ DataDetectors' menu items aren't presented in the telephone number menu
+ https://bugs.webkit.org/show_bug.cgi?id=138602
+ <rdar://problem/18866308>
+
+ Reviewed by Beth Dakin.
+
+ * English.lproj/Localizable.strings:
+ Remove a now-unused localized string.
+
2014-11-11 Daniel Bates <[email protected]>
[Frame Flattening] ASSERT(transaction->view == &view()) fails in RenderBlock::removeFromUpdateScrollInfoAfterLayoutTransaction()
Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (175965 => 175966)
--- trunk/Source/WebCore/English.lproj/Localizable.strings 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings 2014-11-11 20:12:02 UTC (rev 175966)
@@ -124,9 +124,6 @@
/* menu item title for phone number */
"Call Using iPhone:" = "Call Using iPhone:";
-/* menu item for making a telephone call to a telephone number */
-"Call “%@” Using iPhone" = "Call “%@” Using iPhone";
-
/* File Upload alert sheet button string to cancel */
"Cancel (file upload action sheet)" = "Cancel";
Modified: trunk/Source/WebKit2/ChangeLog (175965 => 175966)
--- trunk/Source/WebKit2/ChangeLog 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/ChangeLog 2014-11-11 20:12:02 UTC (rev 175966)
@@ -1,5 +1,43 @@
2014-11-11 Tim Horton <[email protected]>
+ DataDetectors' menu items aren't presented in the telephone number menu
+ https://bugs.webkit.org/show_bug.cgi?id=138602
+ <rdar://problem/18866308>
+
+ Reviewed by Beth Dakin.
+
+ We currently round-trip the DataDetectors telephone number NSMenuItems
+ through the very-lossy WebContextMenuItemData, for no real reason.
+ We should avoid this so that DataDetectors' actual NSMenuItems are
+ presented in the final menu, so that they can adjust their items after
+ providing them to us.
+
+ * Platform/mac/MenuUtilities.h:
+ * Platform/mac/MenuUtilities.mm:
+ (WebKit::menuItemTitleForTelephoneNumber): Deleted.
+ Stop adjusting the menu item titles, as they come correct now.
+
+ (WebKit::menuItemsForTelephoneNumber): Deleted.
+ (WebKit::menuForTelephoneNumber):
+ Return a fully-formed menu for the single telephone number case.
+
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::showTelephoneNumberMenu):
+ Present the fully-formed menu, without round-tripping through
+ WebContextMenuItemData, because we do not need to hand the items to
+ the context menu client (and indeed, were not), and because this
+ allows us to use the exact items returned by DataDetectors, so they
+ can keep ahold of the items that we actually present.
+
+ * UIProcess/PageClient.h:
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::showPlatformContextMenu):
+ Add a Mac-only PageClient function for presenting a NSMenu at a
+ WKView-relative point.
+
+2014-11-11 Tim Horton <[email protected]>
+
Adopt DDActionContext menu type SPI
https://bugs.webkit.org/show_bug.cgi?id=138603
<rdar://problem/18867627>
Modified: trunk/Source/WebKit2/Platform/mac/MenuUtilities.h (175965 => 175966)
--- trunk/Source/WebKit2/Platform/mac/MenuUtilities.h 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/Platform/mac/MenuUtilities.h 2014-11-11 20:12:02 UTC (rev 175966)
@@ -32,8 +32,8 @@
namespace WebKit {
#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
-NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumberString);
-NSArray *menuItemsForTelephoneNumber(const String& telephoneNumber);
+NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber);
+RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber);
NSString *menuItemTitleForTelephoneNumberGroup();
#endif
Modified: trunk/Source/WebKit2/Platform/mac/MenuUtilities.mm (175965 => 175966)
--- trunk/Source/WebKit2/Platform/mac/MenuUtilities.mm 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/Platform/mac/MenuUtilities.mm 2014-11-11 20:12:02 UTC (rev 175966)
@@ -53,11 +53,6 @@
#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
-static NSString *menuItemTitleForTelephoneNumber(const String& telephoneNumber)
-{
- return [NSString stringWithFormat:WEB_UI_STRING("Call “%@” Using iPhone", "menu item for making a telephone call to a telephone number"), formattedPhoneNumberString(telephoneNumber)];
-}
-
NSString *menuItemTitleForTelephoneNumberGroup()
{
return WEB_UI_STRING("Call Using iPhone:", "menu item title for phone number");
@@ -84,9 +79,9 @@
return nil;
}
-NSArray *menuItemsForTelephoneNumber(const String& telephoneNumber)
+RetainPtr<NSMenu> menuForTelephoneNumber(const String& telephoneNumber)
{
- NSMutableArray *items = [NSMutableArray array];
+ RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]);
NSMutableArray *faceTimeItems = [NSMutableArray array];
NSMenuItem *dialItem = nil;
@@ -101,7 +96,6 @@
continue;
if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) {
- item.title = menuItemTitleForTelephoneNumber(telephoneNumber);
dialItem = item;
continue;
}
@@ -111,15 +105,16 @@
}
if (dialItem)
- [items addObject:dialItem];
+ [menu addItem:dialItem];
if (faceTimeItems.count) {
- if (items.count)
- [items addObject:[NSMenuItem separatorItem]];
- [items addObjectsFromArray:faceTimeItems];
+ if ([menu numberOfItems])
+ [menu addItem:[NSMenuItem separatorItem]];
+ for (NSMenuItem *item in faceTimeItems)
+ [menu addItem:item];
}
- return items.count ? items : nil;
+ return menu;
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (175965 => 175966)
--- trunk/Source/WebKit2/UIProcess/PageClient.h 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h 2014-11-11 20:12:02 UTC (rev 175966)
@@ -237,6 +237,8 @@
virtual ColorSpaceData colorSpace() = 0;
+ virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) = 0;
+
#if USE(APPKIT)
virtual WKView* wkView() const = 0;
virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) = 0;
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (175965 => 175966)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2014-11-11 20:12:02 UTC (rev 175966)
@@ -188,6 +188,7 @@
virtual void removeNavigationGestureSnapshot() override;
virtual void didPerformActionMenuHitTest(const ActionMenuHitTestResult&, API::Object*) override;
+ virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
WKView *m_wkView;
WKWebView *m_webView;
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (175965 => 175966)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2014-11-11 20:12:02 UTC (rev 175966)
@@ -766,6 +766,12 @@
#endif
}
+void PageClientImpl::showPlatformContextMenu(NSMenu *menu, IntPoint location)
+{
+ [menu popUpMenuPositioningItem:nil atLocation:location inView:m_wkView];
+}
+
+
} // namespace WebKit
#endif // PLATFORM(MAC)
Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (175965 => 175966)
--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-11-11 19:38:37 UTC (rev 175965)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-11-11 20:12:02 UTC (rev 175966)
@@ -643,21 +643,8 @@
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const WebCore::IntPoint& point)
{
- NSArray *menuItems = menuItemsForTelephoneNumber(telephoneNumber);
-
- Vector<WebContextMenuItemData> items;
- for (NSMenuItem *item in menuItems) {
- RetainPtr<NSMenuItem> retainedItem = item;
- std::function<void()> handler = [retainedItem]() {
- NSMenuItem *item = retainedItem.get();
- [[item target] performSelector:[item action] withObject:item];
- };
-
- items.append(WebContextMenuItemData(ContextMenuItem(item), handler));
- }
-
- ContextMenuContextData contextData(TelephoneNumberContext);
- internalShowContextMenu(point, contextData, items, ContextMenuClientEligibility::NotEligibleForClient, nullptr);
+ RetainPtr<NSMenu> menu = menuForTelephoneNumber(telephoneNumber);
+ m_pageClient.showPlatformContextMenu(menu.get(), point);
}
#endif