Title: [176763] trunk/Source
Revision
176763
Author
[email protected]
Date
2014-12-03 16:33:07 -0800 (Wed, 03 Dec 2014)

Log Message

Implement action menus for tel: URLs
https://bugs.webkit.org/show_bug.cgi?id=139240
<rdar://problem/19115662>

Reviewed by Anders Carlsson.

* WebView/WebActionMenuController.mm:
(-[WebActionMenuController _defaultMenuItemsForDataDetectableLink]):
Rename this function as it will work for both mailto and tel URLs.
Adjust it to use contextForView:.

(-[WebActionMenuController webView:willHandleMouseDown:]):
(-[WebActionMenuController prepareForMenu:withEvent:]):
(-[WebActionMenuController didCloseMenu:withEvent:]):
(-[WebActionMenuController _defaultMenuItems]):
Don't check the menu type when going to interact with _currentActionContext.
We'll only have a _currentActionContext if we have a data detected item,
and there are multiple menu types that end up using DDActionContext.

* WebView/WebUIDelegatePrivate.h:
Add a new type.

* Shared/API/c/WKActionMenuTypes.h:
Add a new type.

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController _defaultMenuItemsForDataDetectableLink]):
Rename this function as it will work for both mailto and tel URLs.
Adjust it to use contextForView:.

(-[WKActionMenuController _clearActionMenuState]):
(-[WKActionMenuController menuNeedsUpdate:]):
(-[WKActionMenuController _defaultMenuItems]):
Don't check the menu type when going to interact with _currentActionContext.
We'll only have a _currentActionContext if we have a data detected item,
and there are multiple menu types that end up using DDActionContext.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (176762 => 176763)


--- trunk/Source/WebKit/mac/ChangeLog	2014-12-04 00:16:38 UTC (rev 176762)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-12-04 00:33:07 UTC (rev 176763)
@@ -1,3 +1,27 @@
+2014-12-03  Tim Horton  <[email protected]>
+
+        Implement action menus for tel: URLs
+        https://bugs.webkit.org/show_bug.cgi?id=139240
+        <rdar://problem/19115662>
+
+        Reviewed by Anders Carlsson.
+
+        * WebView/WebActionMenuController.mm:
+        (-[WebActionMenuController _defaultMenuItemsForDataDetectableLink]):
+        Rename this function as it will work for both mailto and tel URLs.
+        Adjust it to use contextForView:.
+
+        (-[WebActionMenuController webView:willHandleMouseDown:]):
+        (-[WebActionMenuController prepareForMenu:withEvent:]):
+        (-[WebActionMenuController didCloseMenu:withEvent:]):
+        (-[WebActionMenuController _defaultMenuItems]):
+        Don't check the menu type when going to interact with _currentActionContext.
+        We'll only have a _currentActionContext if we have a data detected item,
+        and there are multiple menu types that end up using DDActionContext.
+
+        * WebView/WebUIDelegatePrivate.h:
+        Add a new type.
+
 2014-12-03  Anders Carlsson  <[email protected]>
 
         Set a visited link store when creating a simple WebView

Modified: trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm (176762 => 176763)


--- trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-04 00:16:38 UTC (rev 176762)
+++ trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-04 00:33:07 UTC (rev 176763)
@@ -125,7 +125,7 @@
 
 - (void)webView:(WebView *)webView willHandleMouseDown:(NSEvent *)event
 {
-    if (_type == WebActionMenuDataDetectedItem && _currentActionContext && _hasActivatedActionContext) {
+    if (_currentActionContext && _hasActivatedActionContext) {
         [getDDActionsManagerClass() didUseActions];
         _hasActivatedActionContext = NO;
     }
@@ -158,7 +158,7 @@
     for (NSMenuItem *item in menuItems)
         [actionMenu addItem:item];
 
-    if (_type == WebActionMenuDataDetectedItem && _currentActionContext) {
+    if (_currentActionContext) {
         _hasActivatedActionContext = YES;
         if (![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
             [menu cancelTracking];
@@ -229,7 +229,7 @@
     if (menu != _webView.actionMenu)
         return;
 
-    if (_type == WebActionMenuDataDetectedItem && _currentActionContext && _hasActivatedActionContext) {
+    if (_currentActionContext && _hasActivatedActionContext) {
         [getDDActionsManagerClass() didUseActions];
         _hasActivatedActionContext = NO;
     }
@@ -296,19 +296,24 @@
     return @[ openLinkItem.get(), shouldUseStandardQuickLookPreview ? qlPreviewLinkItem.get() : previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
 }
 
-#pragma mark Mailto Link actions
+#pragma mark mailto: and tel: Link actions
 
-- (NSArray *)_defaultMenuItemsForMailtoLink
+- (NSArray *)_defaultMenuItemsForDataDetectableLink
 {
     Node* node = _hitTestResult.innerNode();
     if (!node)
         return @[ ];
 
     RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
-    [actionContext setAltMode:YES];
 
     // FIXME: Should this show a yellow highlight?
+    _currentActionContext = [actionContext contextForView:_webView altMode:YES interactionStartedHandler:^() {
+    } interactionChangedHandler:^() {
+    } interactionStoppedHandler:^() {
+    }];
+
     [actionContext setHighlightFrame:elementBoundingBoxInWindowCoordinatesFromNode(node)];
+
     return [[getDDActionsManagerClass() sharedManager] menuItemsForTargetURL:_hitTestResult.absoluteLinkURL() actionContext:actionContext.get()];
 }
 
@@ -846,16 +851,22 @@
 - (NSArray *)_defaultMenuItems
 {
     NSURL *url = ""
-    if (url && WebCore::protocolIsInHTTPFamily([url absoluteString])) {
+    NSString *absoluteURLString = [url absoluteString];
+    if (url && WebCore::protocolIsInHTTPFamily(absoluteURLString)) {
         _type = WebActionMenuLink;
         return [self _defaultMenuItemsForLink];
     }
 
-    if (url && WebCore::protocolIs([url absoluteString], "mailto")) {
+    if (url && WebCore::protocolIs(absoluteURLString, "mailto")) {
         _type = WebActionMenuMailtoLink;
-        return [self _defaultMenuItemsForMailtoLink];
+        return [self _defaultMenuItemsForDataDetectableLink];
     }
 
+    if (url && WebCore::protocolIs(absoluteURLString, "tel")) {
+        _type = WebActionMenuTelLink;
+        return [self _defaultMenuItemsForDataDetectableLink];
+    }
+
     if (!_hitTestResult.absoluteMediaURL().isEmpty()) {
         _type = WebActionMenuVideo;
         return [self _defaultMenuItemsForVideo];

Modified: trunk/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h (176762 => 176763)


--- trunk/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h	2014-12-04 00:16:38 UTC (rev 176762)
+++ trunk/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h	2014-12-04 00:33:07 UTC (rev 176763)
@@ -140,7 +140,8 @@
     WebActionMenuImage,
     WebActionMenuVideo,
     WebActionMenuDataDetectedItem,
-    WebActionMenuMailtoLink
+    WebActionMenuMailtoLink,
+    WebActionMenuTelLink
 } WebActionMenuType;
 
 // Message Sources.

Modified: trunk/Source/WebKit2/ChangeLog (176762 => 176763)


--- trunk/Source/WebKit2/ChangeLog	2014-12-04 00:16:38 UTC (rev 176762)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-04 00:33:07 UTC (rev 176763)
@@ -1,3 +1,26 @@
+2014-12-03  Tim Horton  <[email protected]>
+
+        Implement action menus for tel: URLs
+        https://bugs.webkit.org/show_bug.cgi?id=139240
+        <rdar://problem/19115662>
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/API/c/WKActionMenuTypes.h:
+        Add a new type.
+
+        * UIProcess/mac/WKActionMenuController.mm:
+        (-[WKActionMenuController _defaultMenuItemsForDataDetectableLink]):
+        Rename this function as it will work for both mailto and tel URLs.
+        Adjust it to use contextForView:.
+
+        (-[WKActionMenuController _clearActionMenuState]):
+        (-[WKActionMenuController menuNeedsUpdate:]):
+        (-[WKActionMenuController _defaultMenuItems]):
+        Don't check the menu type when going to interact with _currentActionContext.
+        We'll only have a _currentActionContext if we have a data detected item,
+        and there are multiple menu types that end up using DDActionContext.
+
 2014-12-03  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r176452 and r176559.

Modified: trunk/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h (176762 => 176763)


--- trunk/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h	2014-12-04 00:16:38 UTC (rev 176762)
+++ trunk/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h	2014-12-04 00:33:07 UTC (rev 176763)
@@ -42,7 +42,8 @@
     kWKActionMenuEditableTextWithSuggestions,
     kWKActionMenuWhitespaceInEditableArea,
     kWKActionMenuVideo,
-    kWKActionMenuMailtoLink
+    kWKActionMenuMailtoLink,
+    kWKActionMenuTelLink
 };
 typedef uint32_t _WKActionMenuType;
 

Modified: trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (176762 => 176763)


--- trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-04 00:16:38 UTC (rev 176762)
+++ trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-04 00:33:07 UTC (rev 176763)
@@ -321,7 +321,7 @@
 
 - (void)_clearActionMenuState
 {
-    if (_type == kWKActionMenuDataDetectedItem && _currentActionContext && _hasActivatedActionContext) {
+    if (_currentActionContext && _hasActivatedActionContext) {
         [getDDActionsManagerClass() didUseActions];
         _hasActivatedActionContext = NO;
     }
@@ -859,17 +859,22 @@
     return @[ [NSMenuItem separatorItem], [NSMenuItem separatorItem], pasteItem.get() ];
 }
 
-#pragma mark Mailto Link actions
+#pragma mark mailto: and tel: Link actions
 
-- (NSArray *)_defaultMenuItemsForMailtoLink
+- (NSArray *)_defaultMenuItemsForDataDetectableLink
 {
     RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
+    RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
 
     // FIXME: Should this show a yellow highlight?
-    RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
-    [actionContext setAltMode:YES];
-    [actionContext setHighlightFrame:[_wkView.window convertRectToScreen:[_wkView convertRect:hitTestResult->elementBoundingBox() toView:nil]]];
-    return [[getDDActionsManagerClass() sharedManager] menuItemsForTargetURL:hitTestResult->absoluteLinkURL() actionContext:actionContext.get()];
+    _currentActionContext = [actionContext contextForView:_wkView altMode:YES interactionStartedHandler:^() {
+    } interactionChangedHandler:^() {
+    } interactionStoppedHandler:^() {
+    }];
+
+    [_currentActionContext setHighlightFrame:[_wkView.window convertRectToScreen:[_wkView convertRect:_hitTestResult.detectedDataBoundingBox toView:nil]]];
+
+    return [[getDDActionsManagerClass() sharedManager] menuItemsForTargetURL:hitTestResult->absoluteLinkURL() actionContext:_currentActionContext.get()];
 }
 
 #pragma mark NSMenuDelegate implementation
@@ -891,7 +896,7 @@
     if (_state != ActionMenuState::Ready)
         [self _updateActionMenuItems];
 
-    if (_type == kWKActionMenuDataDetectedItem && _currentActionContext) {
+    if (_currentActionContext) {
         _hasActivatedActionContext = YES;
         if (![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
             [menu cancelTracking];
@@ -1100,8 +1105,13 @@
 
         if (protocolIs(absoluteLinkURL, "mailto")) {
             _type = kWKActionMenuMailtoLink;
-            return [self _defaultMenuItemsForMailtoLink];
+            return [self _defaultMenuItemsForDataDetectableLink];
         }
+
+        if (protocolIs(absoluteLinkURL, "tel")) {
+            _type = kWKActionMenuTelLink;
+            return [self _defaultMenuItemsForDataDetectableLink];
+        }
     }
 
     if (!hitTestResult->absoluteMediaURL().isEmpty()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to