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

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (176059 => 176060)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-11-13 02:30:59 UTC (rev 176059)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-11-13 02:31:04 UTC (rev 176060)
@@ -1,3 +1,19 @@
+2014-11-12  Matthew Hanson  <[email protected]>
+
+        Merge r176037. <rdar://problem/18869900>
+
+    2014-11-12  Tim Horton  <[email protected]>
+
+            Need to show the text indicator when Data Detectors shows a popover
+            https://bugs.webkit.org/show_bug.cgi?id=138664
+            <rdar://problem/18869900>
+
+            Reviewed by Beth Dakin.
+
+            * platform/spi/mac/DataDetectorsSPI.h:
+            Add new DataDetectors SPI.
+
+
 2014-11-11  Tim Horton  <[email protected]>
 
         Add support for mailto: link action menus

Modified: branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h (176059 => 176060)


--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h	2014-11-13 02:30:59 UTC (rev 176059)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h	2014-11-13 02:31:04 UTC (rev 176060)
@@ -69,6 +69,8 @@
 @property (copy) void (^completionHandler)(void);
 @property (assign) BOOL forActionMenuContent;
 
+- (DDActionContext *)contextForView:(NSView *)view altMode:(BOOL)altMode interactionStartedHandler:(void (^)(void))interactionStartedHandler interactionChangedHandler:(void (^)(void))interactionChangedHandler interactionStoppedHandler:(void (^)(void))interactionStoppedHandler;
+
 @end
 
 @interface DDActionsManager : NSObject
@@ -78,4 +80,8 @@
 - (NSArray *)menuItemsForTargetURL:(NSString *)targetURL actionContext:(DDActionContext *)context;
 - (void)requestBubbleClosureUnanchorOnFailure:(BOOL)unanchorOnFailure;
 
++ (BOOL)shouldUseActionsWithContext:(DDActionContext *)context;
++ (void)didUseActions;
+
+
 @end

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (176059 => 176060)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-11-13 02:30:59 UTC (rev 176059)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-11-13 02:31:04 UTC (rev 176060)
@@ -1,5 +1,39 @@
 2014-11-12  Matthew Hanson  <[email protected]>
 
+        Merge r176037. <rdar://problem/18869900>
+
+    2014-11-12  Tim Horton  <[email protected]>
+
+            Need to show the text indicator when Data Detectors shows a popover
+            https://bugs.webkit.org/show_bug.cgi?id=138664
+            <rdar://problem/18869900>
+
+            Reviewed by Beth Dakin.
+
+            * UIProcess/mac/WKActionMenuController.h:
+            * UIProcess/mac/WKActionMenuController.mm:
+            (hasDataDetectorsCompletionAPI):
+            Determine if we have the new API.
+
+            (-[WKActionMenuController willDestroyView:]):
+            (-[WKActionMenuController willOpenMenu:withEvent:]):
+            Make use of the new API.
+            If we wanted to show a Data Detectors menu but have no items (or they're all
+            disabled), cancel the menu.
+            If we don't have it, manually manipulate the highlight.
+
+            (-[WKActionMenuController didCloseMenu:withEvent:]):
+            Make use of the new API.
+            If we don't have it, manually manipulate the highlight.
+
+            (-[WKActionMenuController _defaultMenuItemsForDataDetectedText]):
+            Set up completion handlers if we have the new API; when DataDetectors
+            presents UI, show the text indicator, when it dismisses, hide it.
+            If we don't have the API, manually manipulate the highlight.
+
+
+2014-11-12  Matthew Hanson  <[email protected]>
+
         Merge r176027. <rdar://problem/18909111>
 
     2014-11-12  Tim Horton  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h (176059 => 176060)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h	2014-11-13 02:30:59 UTC (rev 176059)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h	2014-11-13 02:31:04 UTC (rev 176060)
@@ -44,6 +44,7 @@
 };
 }
 
+@class DDActionContext;
 @class WKView;
 
 #if WK_API_ENABLED
@@ -68,6 +69,8 @@
 #if WK_API_ENABLED
     RetainPtr<WKPagePreviewViewController> _previewViewController;
 #endif
+
+    RetainPtr<DDActionContext> _currentActionContext;
 }
 
 - (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView;

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


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-11-13 02:30:59 UTC (rev 176059)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-11-13 02:31:04 UTC (rev 176060)
@@ -54,6 +54,15 @@
 SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
 SOFT_LINK_CLASS(ImageKit, IKSlideshow)
 
+static bool hasDataDetectorsCompletionAPI() {
+    static bool hasCompletionAPI;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        hasCompletionAPI = [getDDActionsManagerClass() respondsToSelector:@selector(shouldUseActionsWithContext:)] && [getDDActionsManagerClass() respondsToSelector:@selector(didUseActions)];
+    });
+    return hasCompletionAPI;
+}
+
 using namespace WebCore;
 using namespace WebKit;
 
@@ -156,9 +165,9 @@
 - (void)willDestroyView:(WKView *)view
 {
     _page = nullptr;
-    _wkView = nullptr;
+    _wkView = nil;
     _hitTestResult = ActionMenuHitTestResult();
-
+    _currentActionContext = nil;
 }
 
 - (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event
@@ -192,9 +201,16 @@
         return;
 
     if (_type == kWKActionMenuDataDetectedItem) {
+        if (_currentActionContext && hasDataDetectorsCompletionAPI()) {
+            if (![getDDActionsManagerClass() shouldUseActionsWithContext:_currentActionContext.get()]) {
+                [menu cancelTracking];
+                return;
+            }
+        }
         if (menu.numberOfItems == 1) {
             _page->clearSelection();
-            [self _showTextIndicator];
+            if (!hasDataDetectorsCompletionAPI())
+                [self _showTextIndicator];
         } else
             _page->selectLastActionMenuRange();
         return;
@@ -217,8 +233,15 @@
     if (menu != _wkView.actionMenu)
         return;
 
-    if (_type == kWKActionMenuDataDetectedItem && menu.numberOfItems > 1)
-        [self _hideTextIndicator];
+    if (_type == kWKActionMenuDataDetectedItem) {
+        if (hasDataDetectorsCompletionAPI()) {
+            if (_currentActionContext)
+                [getDDActionsManagerClass() didUseActions];
+        } else {
+            if (menu.numberOfItems > 1)
+                [self _hideTextIndicator];
+        }
+    }
 
     if (!_shouldKeepPreviewPopoverOpen)
         [self _clearPreviewPopover];
@@ -227,6 +250,7 @@
     _hitTestResult = ActionMenuHitTestResult();
     _type = kWKActionMenuNone;
     _sharingServicePicker = nil;
+    _currentActionContext = nil;
 }
 
 - (void)didPerformActionMenuHitTest:(const ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData
@@ -560,13 +584,26 @@
     if (!actionContext)
         return @[ ];
 
-    actionContext.completionHandler = ^() {
-        [self _hideTextIndicator];
-    };
+    if (hasDataDetectorsCompletionAPI()) {
+        _currentActionContext = [actionContext contextForView:_wkView altMode:YES interactionStartedHandler:^() {
+        } interactionChangedHandler:^() {
+            [self _showTextIndicator];
+        } interactionStoppedHandler:^() {
+            [self _hideTextIndicator];
+        }];
+    } else {
+        _currentActionContext = actionContext;
 
-    actionContext.forActionMenuContent = YES;
-    actionContext.highlightFrame = [_wkView.window convertRectToScreen:[_wkView convertRect:_hitTestResult.detectedDataBoundingBox toView:nil]];
-    return [[getDDActionsManagerClass() sharedManager] menuItemsForResult:[_hitTestResult.actionContext mainResult] actionContext:actionContext];
+        [_currentActionContext setCompletionHandler:^() {
+            [self _hideTextIndicator];
+        }];
+
+        [_currentActionContext setForActionMenuContent:YES];
+    }
+
+    [_currentActionContext setHighlightFrame:[_wkView.window convertRectToScreen:[_wkView convertRect:_hitTestResult.detectedDataBoundingBox toView:nil]]];
+
+    return [[getDDActionsManagerClass() sharedManager] menuItemsForResult:[_currentActionContext mainResult] actionContext:_currentActionContext.get()];
 }
 
 - (NSArray *)_defaultMenuItemsForText
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to