Always show the arrow for text selection services
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Dec 2014 19:49:34 +0000 (19:49 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Dec 2014 19:49:34 +0000 (19:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139191
<rdar://problem/18903995>

Reviewed by Anders Carlsson.

* platform/spi/mac/DataDetectorsSPI.h:
* page/mac/ServicesOverlayController.mm:
Move a few things to DataDetectorsSPI.h.

(WebCore::ServicesOverlayController::buildPhoneNumberHighlights):
(WebCore::ServicesOverlayController::buildSelectionHighlight):
Make use of the real DDHighlightStyle names.
Add DDHighlightStyleButtonShowAlways for selection services.

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

Source/WebCore/ChangeLog
Source/WebCore/page/mac/ServicesOverlayController.mm
Source/WebCore/platform/spi/mac/DataDetectorsSPI.h

index af55892874dd9a8d4f4890f1456ecd24c9059167..1d99a41ca9fa199b52561372ae48c100997cf5c6 100644 (file)
@@ -1,3 +1,20 @@
+2014-12-02  Tim Horton  <timothy_horton@apple.com>
+
+        Always show the arrow for text selection services
+        https://bugs.webkit.org/show_bug.cgi?id=139191
+        <rdar://problem/18903995>
+
+        Reviewed by Anders Carlsson.
+
+        * platform/spi/mac/DataDetectorsSPI.h:
+        * page/mac/ServicesOverlayController.mm:
+        Move a few things to DataDetectorsSPI.h.
+
+        (WebCore::ServicesOverlayController::buildPhoneNumberHighlights):
+        (WebCore::ServicesOverlayController::buildSelectionHighlight):
+        Make use of the real DDHighlightStyle names.
+        Add DDHighlightStyleButtonShowAlways for selection services.
+
 2014-12-02  Anders Carlsson  <andersca@apple.com>
 
         Fix iOS build.
index dea3f8b041a61c3b7217743ef8850844a7286a86..6cd34cff8929374933a07edef4fe9183ef8959a7 100644 (file)
@@ -30,6 +30,7 @@
 
 #import "Chrome.h"
 #import "ChromeClient.h"
+#import "DataDetectorsSPI.h"
 #import "Document.h"
 #import "Editor.h"
 #import "EventHandler.h"
 #import "SoftLinking.h"
 #import <QuartzCore/QuartzCore.h>
 
-#if __has_include(<DataDetectors/DDHighlightDrawing.h>)
-#import <DataDetectors/DDHighlightDrawing.h>
-#else
-typedef struct __DDHighlight DDHighlight, *DDHighlightRef;
-#endif
-
-#if __has_include(<DataDetectors/DDHighlightDrawing_Private.h>)
-#import <DataDetectors/DDHighlightDrawing_Private.h>
-#endif
-
 const float highlightFadeAnimationDuration = 0.3;
 
-typedef NSUInteger DDHighlightStyle;
-static const DDHighlightStyle DDHighlightNoOutlineWithArrow = (1 << 16);
-static const DDHighlightStyle DDHighlightOutlineWithArrow = (1 << 16) | 1;
-
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(DataDetectors)
+// FIXME: Move more of this to DataDetectorsSPI.h.
 SOFT_LINK(DataDetectors, DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection, DDHighlightRef, (CFAllocatorRef allocator, CGRect* rects, CFIndex count, CGRect globalVisibleRect, DDHighlightStyle style, Boolean withArrow, NSWritingDirection writingDirection, Boolean endsWithEOL, Boolean flipped), (allocator, rects, count, globalVisibleRect, style, withArrow, writingDirection, endsWithEOL, flipped))
 SOFT_LINK(DataDetectors, DDHighlightGetLayerWithContext, CGLayerRef, (DDHighlightRef highlight, CGContextRef context), (highlight, context))
 SOFT_LINK(DataDetectors, DDHighlightGetBoundingRect, CGRect, (DDHighlightRef highlight), (highlight))
@@ -511,7 +498,7 @@ void ServicesOverlayController::buildPhoneNumberHighlights()
             rect.setLocation(mainFrameView.windowToContents(viewForRange->contentsToWindow(rect.location())));
 
             CGRect cgRect = rect;
-            RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &cgRect, 1, mainFrameView.visibleContentRect(), DDHighlightOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
+            RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &cgRect, 1, mainFrameView.visibleContentRect(), DDHighlightStyleBubbleStandard | DDHighlightStyleStandardIconArrow, YES, NSWritingDirectionNatural, NO, YES));
 
             newPotentialHighlights.add(Highlight::createForTelephoneNumber(*this, ddHighlight, range));
         }
@@ -555,7 +542,7 @@ void ServicesOverlayController::buildSelectionHighlight()
 
         if (!cgRects.isEmpty()) {
             CGRect visibleRect = mainFrameView->visibleContentRect();
-            RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects.data(), cgRects.size(), visibleRect, DDHighlightNoOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
+            RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects.data(), cgRects.size(), visibleRect, DDHighlightStyleBubbleNone | DDHighlightStyleStandardIconArrow | DDHighlightStyleButtonShowAlways, YES, NSWritingDirectionNatural, NO, YES));
             
             newPotentialHighlights.add(Highlight::createForSelection(*this, ddHighlight, selectionRange));
         }
index 285c7f9101bffc77f85b820b802ecd2a11d2071c..7538b4baf18586f47e1f364da8604f6b3b260efe 100644 (file)
 #import "SoftLinking.h"
 #import <objc/runtime.h>
 
+// FIXME: This header should include various DataDetectors SPI headers if using the internal SDK.
+
 typedef struct __DDScanner DDScanner, *DDScannerRef;
 typedef struct __DDScanQuery *DDScanQueryRef;
 typedef struct __DDResult *DDResultRef;
+typedef struct __DDHighlight DDHighlight, *DDHighlightRef;
 
 typedef enum {
     DDScannerTypeStandard = 0,
@@ -72,6 +75,22 @@ SOFT_LINK_CLASS(DataDetectors, DDActionContext)
 - (DDActionContext *)contextForView:(NSView *)view altMode:(BOOL)altMode interactionStartedHandler:(void (^)(void))interactionStartedHandler interactionChangedHandler:(void (^)(void))interactionChangedHandler interactionStoppedHandler:(void (^)(void))interactionStoppedHandler;
 
 @end
+
+enum {
+    DDHighlightStyleBubbleNone = 0,
+    DDHighlightStyleBubbleStandard = 1
+};
+
+enum {
+    DDHighlightStyleIconNone = (0 << 16),
+    DDHighlightStyleStandardIconArrow = (1 << 16)
+};
+
+enum {
+    DDHighlightStyleButtonShowAlways  = (1 << 24),
+};
+
+typedef NSUInteger DDHighlightStyle;
 #endif
 
 SOFT_LINK_CLASS(DataDetectors, DDActionsManager)