Install a TextIndicator for link immediate actions
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Dec 2014 00:14:53 +0000 (00:14 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Dec 2014 00:14:53 +0000 (00:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139897
<rdar://problem/19333076>

Reviewed by Anders Carlsson.

* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _defaultAnimationController]):
Install the link's TextIndicator.

(-[WKImmediateActionController menuItemDidClose:]):
Dismiss the TextIndicator and clean up when the item closes.

* WebView/WebImmediateActionController.h:
* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _clearImmediateActionState]):
Tear down the TextIndicator, just like WebKit2.

(-[WebImmediateActionController _defaultAnimationController]):
Install a TextIndicator for links.

(-[WebImmediateActionController menuItemDidClose:]):
Tear down the TextIndicator when the QL preview closes.

(-[WebImmediateActionController _menuItemForDataDetectedText]):
Directly install and uninstall the TextIndicator for DataDetectors.

(-[WebImmediateActionController _showTextIndicator]): Deleted.
(-[WebImmediateActionController _hideTextIndicator]): Deleted.
Remove the isShowingTextIndicator mechanism, just like it was removed from WebKit2.

* platform/spi/mac/QuickLookMacSPI.h:
Add a new piece of SPI.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177705 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/spi/mac/QuickLookMacSPI.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebImmediateActionController.h
Source/WebKit/mac/WebView/WebImmediateActionController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm

index 00e8ddb..2208bad 100644 (file)
@@ -1,3 +1,14 @@
+2014-12-23  Timothy Horton  <timothy_horton@apple.com>
+
+        Install a TextIndicator for link immediate actions
+        https://bugs.webkit.org/show_bug.cgi?id=139897
+        <rdar://problem/19333076>
+
+        Reviewed by Anders Carlsson.
+
+        * platform/spi/mac/QuickLookMacSPI.h:
+        Add a new piece of SPI.
+
 2014-12-23  Sam Weinig  <sam@webkit.org>
 
         Rename WebContext to WebProcessPool
index 52f59c3..5e060a0 100644 (file)
@@ -31,6 +31,7 @@
 - (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint;
 - (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point;
 - (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point;
+- (void)menuItemDidClose:(NSMenuItem *)menuItem;
 
 @end
 
index 8c91960..06a1c55 100644 (file)
@@ -1,3 +1,29 @@
+2014-12-23  Timothy Horton  <timothy_horton@apple.com>
+
+        Install a TextIndicator for link immediate actions
+        https://bugs.webkit.org/show_bug.cgi?id=139897
+        <rdar://problem/19333076>
+
+        Reviewed by Anders Carlsson.
+
+        * WebView/WebImmediateActionController.h:
+        * WebView/WebImmediateActionController.mm:
+        (-[WebImmediateActionController _clearImmediateActionState]):
+        Tear down the TextIndicator, just like WebKit2.
+
+        (-[WebImmediateActionController _defaultAnimationController]):
+        Install a TextIndicator for links.
+
+        (-[WebImmediateActionController menuItemDidClose:]):
+        Tear down the TextIndicator when the QL preview closes.
+
+        (-[WebImmediateActionController _menuItemForDataDetectedText]):
+        Directly install and uninstall the TextIndicator for DataDetectors.
+
+        (-[WebImmediateActionController _showTextIndicator]): Deleted.
+        (-[WebImmediateActionController _hideTextIndicator]): Deleted.
+        Remove the isShowingTextIndicator mechanism, just like it was removed from WebKit2.
+
 2014-12-20  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] add optimized fullscreen API
index 9cc600c..be7166b 100644 (file)
 @class DDActionContext;
 @class WebView;
 
-namespace WebCore {
-class Range;
-class TextIndicator;
-}
-
 @interface WebImmediateActionController : NSObject <NSImmediateActionGestureRecognizerDelegate> {
 @private
     WebView *_webView;
@@ -46,8 +41,6 @@ class TextIndicator;
     NSImmediateActionGestureRecognizer *_immediateActionRecognizer;
 
     RetainPtr<DDActionContext> _currentActionContext;
-    RefPtr<WebCore::Range> _currentDetectedDataRange;
-    RefPtr<WebCore::TextIndicator> _currentDetectedDataTextIndicator;
     BOOL _isShowingTextIndicator;
     BOOL _hasActivatedActionContext;
 }
index 11213c8..e4e4eac 100644 (file)
@@ -100,6 +100,8 @@ using namespace WebCore;
 
 - (void)_clearImmediateActionState
 {
+    [_webView _clearTextIndicator];
+
     _type = WebImmediateActionNone;
     _currentActionContext = nil;
 }
@@ -182,9 +184,13 @@ using namespace WebCore;
 {
     NSURL *url = _hitTestResult.absoluteLinkURL();
     NSString *absoluteURLString = [url absoluteString];
-    if (url && WebCore::protocolIsInHTTPFamily(absoluteURLString)) {
+    if (url && WebCore::protocolIsInHTTPFamily(absoluteURLString) && _hitTestResult.innerNode()) {
         _type = WebImmediateActionLinkPreview;
 
+        RefPtr<Range> linkRange = rangeOfContents(*_hitTestResult.innerNode());
+        RefPtr<TextIndicator> linkTextIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorPresentationTransition::FadeIn);
+        [_webView _setTextIndicator:linkTextIndicator.get() fadeOut:NO];
+
         RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
         [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
         [qlPreviewLinkItem setDelegate:self];
@@ -250,6 +256,11 @@ using namespace WebCore;
     return NSMaxYEdge;
 }
 
+- (void)menuItemDidClose:(NSMenuItem *)menuItem
+{
+    [self _clearImmediateActionState];
+}
+
 #pragma mark Data Detectors actions
 
 - (NSMenuItem *)_menuItemForDataDetectedText
@@ -282,15 +293,14 @@ using namespace WebCore;
             return nil;
     }
 
-    _currentDetectedDataTextIndicator = TextIndicator::createWithRange(*detectedDataRange, TextIndicatorPresentationTransition::FadeIn);
+    RefPtr<TextIndicator> detectedDataTextIndicator = TextIndicator::createWithRange(*detectedDataRange, TextIndicatorPresentationTransition::FadeIn);
 
     _currentActionContext = [actionContext contextForView:_webView altMode:YES interactionStartedHandler:^() {
     } interactionChangedHandler:^() {
-        [self _showTextIndicator];
+        [_webView _setTextIndicator:detectedDataTextIndicator.get() fadeOut:NO];
     } interactionStoppedHandler:^() {
-        [self _hideTextIndicator];
+        [_webView _clearTextIndicator];
     }];
-    _currentDetectedDataRange = detectedDataRange;
 
     [_currentActionContext setHighlightFrame:[_webView.window convertRectToScreen:detectedDataBoundingBox]];
 
@@ -370,28 +380,6 @@ static DictionaryPopupInfo dictionaryPopupInfoForRange(Frame* frame, Range& rang
     return [_webView _animationControllerForDictionaryLookupPopupInfo:dictionaryPopupInfo];
 }
 
-#pragma mark Text Indicator
-
-- (void)_showTextIndicator
-{
-    if (_isShowingTextIndicator)
-        return;
-
-    if (_type == WebImmediateActionDataDetectedItem && _currentDetectedDataTextIndicator) {
-        [_webView _setTextIndicator:_currentDetectedDataTextIndicator.get() fadeOut:NO];
-        _isShowingTextIndicator = YES;
-    }
-}
-
-- (void)_hideTextIndicator
-{
-    if (!_isShowingTextIndicator)
-        return;
-
-    [_webView _clearTextIndicator];
-    _isShowingTextIndicator = NO;
-}
-
 @end
 
 #endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
index 724d79d..9104646 100644 (file)
@@ -1,5 +1,20 @@
 2014-12-23  Timothy Horton  <timothy_horton@apple.com>
 
+        Install a TextIndicator for link immediate actions
+        https://bugs.webkit.org/show_bug.cgi?id=139897
+        <rdar://problem/19333076>
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/mac/WKImmediateActionController.mm:
+        (-[WKImmediateActionController _defaultAnimationController]):
+        Install the link's TextIndicator.
+
+        (-[WKImmediateActionController menuItemDidClose:]):
+        Dismiss the TextIndicator and clean up when the item closes.
+
+2014-12-23  Timothy Horton  <timothy_horton@apple.com>
+
         Expose ElementBoundingBox on WKHitTestResult
         https://bugs.webkit.org/show_bug.cgi?id=139895
         <rdar://problem/19333075>
index 9767c98..307642c 100644 (file)
@@ -219,6 +219,9 @@ using namespace WebKit;
     if (!absoluteLinkURL.isEmpty() && WebCore::protocolIsInHTTPFamily(absoluteLinkURL)) {
         _type = kWKImmediateActionLinkPreview;
 
+        if (TextIndicator *textIndicator = _hitTestResult.linkTextIndicator.get())
+            _page->setTextIndicator(textIndicator->data(), false);
+
         RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
         [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
         [qlPreviewLinkItem setDelegate:self];
@@ -279,6 +282,11 @@ using namespace WebKit;
     return NSMaxYEdge;
 }
 
+- (void)menuItemDidClose:(NSMenuItem *)menuItem
+{
+    [self _clearImmediateActionState];
+}
+
 #pragma mark Data Detectors actions
 
 - (NSMenuItem *)_menuItemForDataDetectedText