Title: [176793] branches/safari-600.3-branch/Source

Diff

Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (176792 => 176793)


--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-04 15:54:45 UTC (rev 176792)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-04 16:35:23 UTC (rev 176793)
@@ -1,3 +1,32 @@
+2014-12-04  Dana Burkart  <[email protected]>
+
+        Merge r176763. <rdar://problem/19115662>
+
+    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  Dana Burkart  <[email protected]>
 
         Merge r176695. <rdar://problem/19120929>

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (176792 => 176793)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-04 15:54:45 UTC (rev 176792)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-04 16:35:23 UTC (rev 176793)
@@ -126,7 +126,7 @@
 
 - (void)webView:(WebView *)webView willHandleMouseDown:(NSEvent *)event
 {
-    if (_type == WebActionMenuDataDetectedItem && _currentActionContext && _hasActivatedActionContext) {
+    if (_currentActionContext && _hasActivatedActionContext) {
         [getDDActionsManagerClass() didUseActions];
         _hasActivatedActionContext = NO;
     }
@@ -159,7 +159,7 @@
     for (NSMenuItem *item in menuItems)
         [actionMenu addItem:item];
 
-    if (_type == WebActionMenuDataDetectedItem && _currentActionContext) {
+    if (_currentActionContext) {
         _hasActivatedActionContext = YES;
         if (![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
             [menu cancelTracking];
@@ -230,7 +230,7 @@
     if (menu != _webView.actionMenu)
         return;
 
-    if (_type == WebActionMenuDataDetectedItem && _currentActionContext && _hasActivatedActionContext) {
+    if (_currentActionContext && _hasActivatedActionContext) {
         [getDDActionsManagerClass() didUseActions];
         _hasActivatedActionContext = NO;
     }
@@ -297,19 +297,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()];
 }
 
@@ -847,16 +852,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];
+    }
+
     Image* image = _hitTestResult.image();
     if (image && !_hitTestResult.absoluteImageURL().isEmpty() && !image->filenameExtension().isEmpty() && image->data() && !image->data()->isEmpty()) {
         _type = WebActionMenuImage;

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h (176792 => 176793)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h	2014-12-04 15:54:45 UTC (rev 176792)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h	2014-12-04 16:35:23 UTC (rev 176793)
@@ -140,7 +140,8 @@
     WebActionMenuImage,
     WebActionMenuVideo,
     WebActionMenuDataDetectedItem,
-    WebActionMenuMailtoLink
+    WebActionMenuMailtoLink,
+    WebActionMenuTelLink
 } WebActionMenuType;
 
 // Message Sources.

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (176792 => 176793)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-12-04 15:54:45 UTC (rev 176792)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-12-04 16:35:23 UTC (rev 176793)
@@ -1,3 +1,31 @@
+2014-12-04  Dana Burkart  <[email protected]>
+
+        Merge r176763. <rdar://problem/19115662>
+
+    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  Dana Burkart  <[email protected]>
 
         Merge r176753. <rdar://problem/19052381>

Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h (176792 => 176793)


--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h	2014-12-04 15:54:45 UTC (rev 176792)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h	2014-12-04 16:35:23 UTC (rev 176793)
@@ -42,7 +42,8 @@
     kWKActionMenuEditableTextWithSuggestions,
     kWKActionMenuWhitespaceInEditableArea,
     kWKActionMenuVideo,
-    kWKActionMenuMailtoLink
+    kWKActionMenuMailtoLink,
+    kWKActionMenuTelLink
 };
 typedef uint32_t _WKActionMenuType;
 

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (176792 => 176793)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-04 15:54:45 UTC (rev 176792)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-04 16:35:23 UTC (rev 176793)
@@ -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