Add plumbing to the UI process for TextIndicatorData when computing the drag image
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Feb 2017 21:21:18 +0000 (21:21 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Feb 2017 21:21:18 +0000 (21:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168583
Work towards <rdar://problem/30313681>

Source/WebCore:

Reviewed by Tim Horton.

Adds some additional arguments to drag image creation functions to allow platforms to specify TextIndicatorData
for a link or selection-based DragImage. This TextIndicatorData is an optional member of the DragImage, and is
propagated to the UI process via SetDragImage in the WebDragClient.

Additionally renames hasDataInteractionAtPosition to hasSelectionAtPosition to better reflect its purpose.

No new tests, since there is no behavior change.

* page/DragController.cpp:
(WebCore::DragController::startDrag):
* page/Page.cpp:
(WebCore::Page::hasSelectionAtPosition):
(WebCore::Page::hasDataInteractionAtPosition): Deleted.
* page/Page.h:
* platform/DragImage.cpp:
(WebCore::createDragImageForSelection):
(WebCore::createDragImageForLink):
(WebCore::DragImage::operator=):
* platform/DragImage.h:
* platform/gtk/DragImageGtk.cpp:
(WebCore::createDragImageForLink):
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageForLink):
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink):

Source/WebKit/mac:

Accounts for changes in WebCore -- see Source/WebCore/ChangeLog for more details.

Reviewed by Tim Horton.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _selectionDraggingImage]):
(-[WebHTMLView selectionImageForcingBlackText:selectionImageForcingBlackText:]):

Source/WebKit2:

Reviewed by Tim Horton.

Changes the SetDragImage IPC message to send TextIndicatorData over to the UI process. Also changes the boolean
isLink parameter to be a DragSourceAction instead, leaving it up to the receiving end (in the UI process) to
special case links.

Additionally, renames hasDataInteractionAtPosition to hasSelectionAtPosition to better reflect its purpose.

These changes are only infrastructural should not alter any behaviors.

* Shared/ios/InteractionInformationAtPosition.h:
* Shared/ios/InteractionInformationAtPosition.mm:
(WebKit::InteractionInformationAtPosition::encode):
(WebKit::InteractionInformationAtPosition::decode):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _simulateDataInteractionGestureRecognized]):
(-[WKWebView _simulateDataInteractionEntered:]):
(-[WKWebView _simulateDataInteractionUpdated:]):
(-[WKWebView _simulateDataInteractionPerformOperation:]):
(-[WKWebView _simulateDataInteractionEnded:]):
(-[WKWebView _simulateDataInteractionSessionDidEnd:withOperation:]):
(-[WKWebView _simulateFailedDataInteractionWithIndex:]):
(-[WKWebView _simulateWillBeginDataInteractionWithIndex:withSession:]):
(-[WKWebView _simulatedItemsForDataInteractionWithIndex:]):
* UIProcess/API/Cocoa/_WKTestingDelegate.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::setDragImage):
(WebKit::PageClientImpl::startDataInteractionWithImage):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView hasSelectablePositionAtPoint:]):
(-[WKContentView pointIsInDataInteractionContent:]):
(-[WKContentView _dataInteractionGestureRecognizer]):
(-[WKContentView pointIsInAssistedNode:]):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setDragImage):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::setDragImage):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):

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

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/DragImage.cpp
Source/WebCore/platform/DragImage.h
Source/WebCore/platform/gtk/DragImageGtk.cpp
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/platform/win/DragImageWin.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h
Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/_WKTestingDelegate.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index e789bdf..eb50e3a 100644 (file)
@@ -1,3 +1,37 @@
+2017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Add plumbing to the UI process for TextIndicatorData when computing the drag image
+        https://bugs.webkit.org/show_bug.cgi?id=168583
+        Work towards <rdar://problem/30313681>
+
+        Reviewed by Tim Horton.
+
+        Adds some additional arguments to drag image creation functions to allow platforms to specify TextIndicatorData
+        for a link or selection-based DragImage. This TextIndicatorData is an optional member of the DragImage, and is
+        propagated to the UI process via SetDragImage in the WebDragClient.
+
+        Additionally renames hasDataInteractionAtPosition to hasSelectionAtPosition to better reflect its purpose.
+
+        No new tests, since there is no behavior change.
+
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag):
+        * page/Page.cpp:
+        (WebCore::Page::hasSelectionAtPosition):
+        (WebCore::Page::hasDataInteractionAtPosition): Deleted.
+        * page/Page.h:
+        * platform/DragImage.cpp:
+        (WebCore::createDragImageForSelection):
+        (WebCore::createDragImageForLink):
+        (WebCore::DragImage::operator=):
+        * platform/DragImage.h:
+        * platform/gtk/DragImageGtk.cpp:
+        (WebCore::createDragImageForLink):
+        * platform/mac/DragImageMac.mm:
+        (WebCore::createDragImageForLink):
+        * platform/win/DragImageWin.cpp:
+        (WebCore::createDragImageForLink):
+
 2017-02-20  Brent Fulgham  <bfulgham@apple.com>
 
         Nullptr dereferences when stopping a load
index bdadd73..a45cfbf 100644 (file)
@@ -875,7 +875,10 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
         }
         m_client.willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, dataTransfer);
         if (!dragImage) {
-            dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src), DragImageAlpha) };
+            TextIndicatorData textIndicator;
+            dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src, textIndicator), DragImageAlpha) };
+            if (textIndicator.contentImage)
+                dragImage.setIndicatorData(textIndicator);
             dragLoc = dragLocForSelectionDrag(src);
             dragImageAnchorPoint = dragImageAnchorPointForSelectionDrag(src, mouseDraggedPoint);
             m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
@@ -956,11 +959,14 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
 
         m_client.willPerformDragSourceAction(DragSourceActionLink, dragOrigin, dataTransfer);
         if (!dragImage) {
-            dragImage = DragImage { createDragImageForLink(linkURL, hitTestResult.textContent(), src.settings().fontRenderingMode()) };
+            TextIndicatorData textIndicator;
+            dragImage = DragImage { createDragImageForLink(element, linkURL, hitTestResult.textContent(), textIndicator, src.settings().fontRenderingMode(), m_page.deviceScaleFactor()) };
             IntSize size = dragImageSize(dragImage.get());
             m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
             dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y());
             dragImage = DragImage { platformAdjustDragImageForDeviceScaleFactor(dragImage.get(), m_page.deviceScaleFactor()) };
+            if (textIndicator.contentImage)
+                dragImage.setIndicatorData(textIndicator);
         }
         doSystemDrag(WTFMove(dragImage), dragLoc, mouseDraggedPoint, { }, dataTransfer, src, DragSourceActionLink);
 
@@ -978,7 +984,10 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
         m_client.willPerformDragSourceAction(DragSourceActionAttachment, dragOrigin, dataTransfer);
         
         if (!dragImage) {
-            dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src), DragImageAlpha) };
+            TextIndicatorData textIndicator;
+            dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src, textIndicator), DragImageAlpha) };
+            if (textIndicator.contentImage)
+                dragImage.setIndicatorData(textIndicator);
             dragLoc = dragLocForSelectionDrag(src);
             m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
         }
index 2f78e6d..5670447 100644 (file)
@@ -2191,7 +2191,7 @@ void Page::accessibilitySettingsDidChange()
 
 #if ENABLE(DATA_INTERACTION)
 
-bool Page::hasDataInteractionAtPosition(const FloatPoint& position) const
+bool Page::hasSelectionAtPosition(const FloatPoint& position) const
 {
     auto currentSelection = m_mainFrame->selection().selection();
     if (!currentSelection.isRange())
index 4e18fdb..b95a58e 100644 (file)
@@ -571,7 +571,7 @@ public:
     bool isUtilityPage() const { return m_isUtilityPage; }
 
 #if ENABLE(DATA_INTERACTION)
-    WEBCORE_EXPORT bool hasDataInteractionAtPosition(const FloatPoint&) const;
+    WEBCORE_EXPORT bool hasSelectionAtPosition(const FloatPoint&) const;
 #endif
 
 private:
index c7203a1..b8b4590 100644 (file)
@@ -34,6 +34,7 @@
 #include "RenderElement.h"
 #include "RenderObject.h"
 #include "RenderView.h"
+#include "TextIndicator.h"
 
 namespace WebCore {
 
@@ -122,7 +123,7 @@ DragImageRef createDragImageForNode(Frame& frame, Node& node)
 
 #if !ENABLE(DATA_INTERACTION)
 
-DragImageRef createDragImageForSelection(Frame& frame, bool forceBlackText)
+DragImageRef createDragImageForSelection(Frame& frame, TextIndicatorData&, bool forceBlackText)
 {
     SnapshotOptions options = forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone;
     return createDragImageFromSnapshot(snapshotSelection(frame, options), nullptr);
@@ -219,7 +220,7 @@ DragImageRef platformAdjustDragImageForDeviceScaleFactor(DragImageRef image, flo
 #endif
 
 #if !PLATFORM(COCOA) && !PLATFORM(WIN)
-DragImageRef createDragImageForLink(URL&, const String&, FontRenderingMode)
+DragImageRef createDragImageForLink(Element&, URL&, const String&, FontRenderingMode, float)
 {
     return nullptr;
 }
@@ -238,6 +239,7 @@ DragImage::DragImage(DragImageRef dragImageRef)
 DragImage::DragImage(DragImage&& other)
     : m_dragImageRef { std::exchange(other.m_dragImageRef, nullptr) }
 {
+    m_indicatorData = other.m_indicatorData;
 }
 
 DragImage& DragImage::operator=(DragImage&& other)
@@ -246,6 +248,7 @@ DragImage& DragImage::operator=(DragImage&& other)
         deleteDragImage(m_dragImageRef);
 
     m_dragImageRef = std::exchange(other.m_dragImageRef, nullptr);
+    m_indicatorData = other.m_indicatorData;
 
     return *this;
 }
index b30f34f..e3255d1 100644 (file)
@@ -29,7 +29,9 @@
 #include "ImageOrientation.h"
 #include "IntSize.h"
 #include "TextFlags.h"
+#include "TextIndicator.h"
 #include <wtf/Forward.h>
+#include <wtf/Optional.h>
 
 #if PLATFORM(IOS)
 #include <wtf/RetainPtr.h>
@@ -48,6 +50,7 @@ typedef struct HBITMAP__* HBITMAP;
 
 namespace WebCore {
 
+class Element;
 class Frame;
 class Image;
 class IntRect;
@@ -83,10 +86,10 @@ DragImageRef createDragImageFromImage(Image*, ImageOrientationDescription);
 DragImageRef createDragImageIconForCachedImageFilename(const String&);
 
 WEBCORE_EXPORT DragImageRef createDragImageForNode(Frame&, Node&);
-WEBCORE_EXPORT DragImageRef createDragImageForSelection(Frame&, bool forceBlackText = false);
+WEBCORE_EXPORT DragImageRef createDragImageForSelection(Frame&, TextIndicatorData&, bool forceBlackText = false);
 WEBCORE_EXPORT DragImageRef createDragImageForRange(Frame&, Range&, bool forceBlackText = false);
 DragImageRef createDragImageForImage(Frame&, Node&, IntRect& imageRect, IntRect& elementRect);
-DragImageRef createDragImageForLink(URL&, const String& label, FontRenderingMode);
+DragImageRef createDragImageForLink(Element&, URL&, const String& label, TextIndicatorData&, FontRenderingMode, float deviceScaleFactor);
 void deleteDragImage(DragImageRef);
 
 class DragImage final {
@@ -98,11 +101,16 @@ public:
 
     DragImage& operator=(DragImage&&);
 
+    void setIndicatorData(const TextIndicatorData& data) { m_indicatorData = data; }
+    bool hasIndicatorData() const { return !!m_indicatorData; }
+    std::optional<TextIndicatorData> indicatorData() const { return m_indicatorData; }
+
     explicit operator bool() const { return !!m_dragImageRef; }
     DragImageRef get() const { return m_dragImageRef; }
 
 private:
     DragImageRef m_dragImageRef;
+    std::optional<TextIndicatorData> m_indicatorData;
 };
 
 }
index c99f8ac..d41a4e5 100644 (file)
 #include "config.h"
 #include "DragImage.h"
 
+#include "Element.h"
 #include "Image.h"
+#include "TextFlags.h"
+#include "TextIndicator.h"
+#include "URL.h"
 #include <cairo.h>
 #include <gdk/gdk.h>
 
@@ -88,4 +92,9 @@ DragImageRef createDragImageIconForCachedImageFilename(const String&)
     return nullptr;
 }
 
+DragImageRef createDragImageForLink(Element&, URL&, const String&, TextIndicatorData&, FontRenderingMode, float)
+{
+    return nullptr;
+}
+
 }
index 0e9dca1..2a8dfd3 100644 (file)
@@ -30,6 +30,7 @@
 
 #import "BitmapImage.h"
 #import "CoreGraphicsSPI.h"
+#import "Element.h"
 #import "FontCascade.h"
 #import "FontDescription.h"
 #import "FontSelector.h"
@@ -37,6 +38,7 @@
 #import "Image.h"
 #import "URL.h"
 #import "StringTruncator.h"
+#import "TextIndicator.h"
 #import "TextRun.h"
 #import <wtf/NeverDestroyed.h>
 
@@ -265,7 +267,7 @@ static void drawDoubledAtPoint(NSString *string, NSPoint textPoint, NSColor *top
         drawAtPoint(string, textPoint, font, topColor);
 }
 
-DragImageRef createDragImageForLink(URL& url, const String& title, FontRenderingMode)
+DragImageRef createDragImageForLink(Element&, URL& url, const String& title, TextIndicatorData&, FontRenderingMode, float)
 {
     NSString *label = nsStringNilIfEmpty(title);
     NSURL *cocoaURL = url;
index 989a0b5..1abc008 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "DragImage.h"
 
+#include "Element.h"
 #include "FloatRoundedRect.h"
 #include "FontCascade.h"
 #include "FontDescription.h"
@@ -35,6 +36,7 @@
 #include "Image.h"
 #include "URL.h"
 #include "StringTruncator.h"
+#include "TextIndicator.h"
 #include "TextRun.h"
 #include "WebCoreTextRenderer.h"
 #include <wtf/RetainPtr.h>
@@ -119,7 +121,7 @@ static FontCascade dragLabelFont(int size, bool bold, FontRenderingMode renderin
     return result;
 }
 
-DragImageRef createDragImageForLink(URL& url, const String& inLabel, FontRenderingMode fontRenderingMode)
+DragImageRef createDragImageForLink(Element&, URL& url, const String& inLabel, TextIndicatorData&, FontRenderingMode fontRenderingMode, float)
 {
     // This is more or less an exact match for the Mac OS X code.
 
index 558c708..9f14d5b 100644 (file)
@@ -1,3 +1,17 @@
+2017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Add plumbing to the UI process for TextIndicatorData when computing the drag image
+        https://bugs.webkit.org/show_bug.cgi?id=168583
+        Work towards <rdar://problem/30313681>
+
+        Accounts for changes in WebCore -- see Source/WebCore/ChangeLog for more details.
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _selectionDraggingImage]):
+        (-[WebHTMLView selectionImageForcingBlackText:selectionImageForcingBlackText:]):
+
 2017-02-17  Anders Carlsson  <andersca@apple.com>
 
         Add a new drag code path and use it for dragging plain text
index dee0324..a024dfb 100644 (file)
@@ -2389,7 +2389,8 @@ static bool mouseEventIsPartOfClickOrDrag(NSEvent *event)
     if (!coreFrame)
         return nil;
 
-    auto dragImage = createDragImageForSelection(*coreFrame);
+    TextIndicatorData textIndicator;
+    auto dragImage = createDragImageForSelection(*coreFrame, textIndicator);
     [dragImage _web_dissolveToFraction:WebDragImageAlpha];
 
     return dragImage.autorelease();
@@ -7373,7 +7374,8 @@ static CGImageRef selectionImage(Frame* frame, bool forceBlackText)
 #if PLATFORM(IOS)
     return selectionImage(coreFrame, forceBlackText);
 #else
-    return createDragImageForSelection(*coreFrame, forceBlackText).autorelease();
+    TextIndicatorData textIndicator;
+    return createDragImageForSelection(*coreFrame, textIndicator, forceBlackText).autorelease();
 #endif
 }
 
index 7ed24e6..ed33a0c 100644 (file)
@@ -1,3 +1,57 @@
+2017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Add plumbing to the UI process for TextIndicatorData when computing the drag image
+        https://bugs.webkit.org/show_bug.cgi?id=168583
+        Work towards <rdar://problem/30313681>
+
+        Reviewed by Tim Horton.
+
+        Changes the SetDragImage IPC message to send TextIndicatorData over to the UI process. Also changes the boolean
+        isLink parameter to be a DragSourceAction instead, leaving it up to the receiving end (in the UI process) to
+        special case links.
+
+        Additionally, renames hasDataInteractionAtPosition to hasSelectionAtPosition to better reflect its purpose.
+
+        These changes are only infrastructural should not alter any behaviors.
+
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * Shared/ios/InteractionInformationAtPosition.mm:
+        (WebKit::InteractionInformationAtPosition::encode):
+        (WebKit::InteractionInformationAtPosition::decode):
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _simulateDataInteractionGestureRecognized]):
+        (-[WKWebView _simulateDataInteractionEntered:]):
+        (-[WKWebView _simulateDataInteractionUpdated:]):
+        (-[WKWebView _simulateDataInteractionPerformOperation:]):
+        (-[WKWebView _simulateDataInteractionEnded:]):
+        (-[WKWebView _simulateDataInteractionSessionDidEnd:withOperation:]):
+        (-[WKWebView _simulateFailedDataInteractionWithIndex:]):
+        (-[WKWebView _simulateWillBeginDataInteractionWithIndex:withSession:]):
+        (-[WKWebView _simulatedItemsForDataInteractionWithIndex:]):
+        * UIProcess/API/Cocoa/_WKTestingDelegate.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::setDragImage):
+        (WebKit::PageClientImpl::startDataInteractionWithImage):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView hasSelectablePositionAtPoint:]):
+        (-[WKContentView pointIsInDataInteractionContent:]):
+        (-[WKContentView _dataInteractionGestureRecognizer]):
+        (-[WKContentView pointIsInAssistedNode:]):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setDragImage):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::setDragImage):
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+
 2017-02-20  David Quesada  <david_quesada@apple.com>
 
         Don’t set NSURLSessionConfiguration’s _sourceApplicationAuditTokenData if _sourceApplicationBundleIdentifier is also set.
index 8bece1b..72a44bf 100644 (file)
@@ -42,7 +42,7 @@ struct InteractionInformationAtPosition {
 
     bool nodeAtPositionIsAssistedNode { false };
 #if ENABLE(DATA_INTERACTION)
-    bool hasDataInteractionAtPosition { false };
+    bool hasSelectionAtPosition { false };
 #endif
     bool isSelectable { false };
     bool isNearMarkedText { false };
index 163eda5..70a2eb7 100644 (file)
@@ -44,7 +44,7 @@ void InteractionInformationAtPosition::encode(IPC::Encoder& encoder) const
 
     encoder << nodeAtPositionIsAssistedNode;
 #if ENABLE(DATA_INTERACTION)
-    encoder << hasDataInteractionAtPosition;
+    encoder << hasSelectionAtPosition;
 #endif
     encoder << isSelectable;
     encoder << isNearMarkedText;
@@ -92,7 +92,7 @@ bool InteractionInformationAtPosition::decode(IPC::Decoder& decoder, Interaction
         return false;
 
 #if ENABLE(DATA_INTERACTION)
-    if (!decoder.decode(result.hasDataInteractionAtPosition))
+    if (!decoder.decode(result.hasSelectionAtPosition))
         return false;
 #endif
 
index 6846891..445341f 100644 (file)
@@ -5174,67 +5174,39 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 
 - (void)_simulateDataInteractionGestureRecognized
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionGestureRecognized:_testingDelegate.dataInteractionGestureRecognizer];
-#endif
 }
 
 - (void)_simulateDataInteractionEntered:(id)info
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionEntered:info];
-#endif
 }
 
 - (void)_simulateDataInteractionUpdated:(id)info
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionUpdated:info];
-#endif
 }
 
 - (void)_simulateDataInteractionPerformOperation:(id)info
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionPerformOperation:info];
-#endif
 }
 
 - (void)_simulateDataInteractionEnded:(id)info
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionEnded:info];
-#endif
 }
 
 - (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionSessionDidEnd:session withOperation:operation];
-#endif
 }
 
 - (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateFailedDataInteractionWithIndex:sourceIndex];
-#endif
 }
 
 - (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session
 {
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateWillBeginDataInteractionWithIndex:sourceIndex withSession:session];
-#endif
 }
 
 - (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex
 {
-#if ENABLE(DATA_INTERACTION)
-    return [_contentView _simulatedItemsForDataInteractionWithIndex:sourceIndex];
-#else
     return @[ ];
-#endif
 }
 
 @end
index f37f9af..b49bc3b 100644 (file)
 
 @class WKWebView;
 
-#if TARGET_OS_IPHONE
-@class UIGestureRecognizer;
-@class UILongPressGestureRecognizer;
-#endif
-
 NS_ASSUME_NONNULL_BEGIN
 
 @protocol _WKTestingDelegate <NSObject>
 @optional
 
 #if TARGET_OS_IPHONE
-@property (nonatomic, readonly) UILongPressGestureRecognizer *dataInteractionGestureRecognizer;
-- (void)webViewDidSendDataInteractionStartRequest:(WKWebView *)webView;
-- (void)webView:(WKWebView *)webView didReceiveDataInteractionStartResponse:(BOOL)started;
 - (void)webViewDidPerformDataInteractionControllerOperation:(WKWebView *)webView;
-- (void)webView:(WKWebView *)webView beginDataInteractionWithSourceIndex:(NSInteger)sourceIndex gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
 #endif // TARGET_OS_PHONE
 
 @end
index a5467f9..5b2b33f 100644 (file)
@@ -170,7 +170,7 @@ public:
 #if PLATFORM(COCOA)
     virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&) = 0;
     virtual bool executeSavedCommandBySelector(const String& selector) = 0;
-    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
+    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, WebCore::DragSourceAction) = 0;
     virtual void updateSecureInputState() = 0;
     virtual void resetSecureInputState() = 0;
     virtual void notifyInputContextAboutDiscardedComposition() = 0;
@@ -380,7 +380,7 @@ public:
 #if ENABLE(DATA_INTERACTION)
     virtual void didPerformDataInteractionControllerOperation() = 0;
     virtual void didHandleStartDataInteractionRequest(bool started) = 0;
-    virtual void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, const WebCore::FloatPoint& anchorPoint, bool isLink) = 0;
+    virtual void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) = 0;
 #endif
 };
 
index 0a290fc..21abb9c 100644 (file)
@@ -832,7 +832,7 @@ public:
     void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
     void dragCancelled();
 #if PLATFORM(COCOA)
-    void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, const WebCore::FloatPoint& dragImageAnchor, bool isLinkDrag);
+    void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& dragImageAnchor, uint64_t action);
     void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
                          const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize);
 #if ENABLE(ATTACHMENT_ELEMENT)
index ac46314..5a14ac8 100644 (file)
@@ -302,7 +302,7 @@ messages -> WebPageProxy {
     DidPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted)
 #endif
 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
-    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, WebCore::FloatPoint dragImageAnchor, bool linkDrag)
+    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, std::optional<WebCore::TextIndicatorData> textIndicator, WebCore::FloatPoint dragImageAnchor, uint64_t action)
     SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
 #if ENABLE(ATTACHMENT_ELEMENT)
     SetPromisedDataForAttachment(String pasteboardName, String filename, String extension, String title, String url, String visibleURL)
index e91617b..47a9f94 100644 (file)
@@ -78,7 +78,7 @@ private:
     void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
     void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
     bool executeSavedCommandBySelector(const String& selector) override;
-    void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) override;
+    void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, WebCore::DragSourceAction) override;
     void updateSecureInputState() override;
     void resetSecureInputState() override;
     void notifyInputContextAboutDiscardedComposition() override;
@@ -204,7 +204,7 @@ private:
 #if ENABLE(DATA_INTERACTION)
     void didPerformDataInteractionControllerOperation() override;
     void didHandleStartDataInteractionRequest(bool started) override;
-    void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, const WebCore::FloatPoint& anchorPoint, bool isLink) override;
+    void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) override;
 #endif
 
     WKContentView *m_contentView;
index 3c0d7b8..8049f15 100644 (file)
@@ -353,7 +353,7 @@ bool PageClientImpl::executeSavedCommandBySelector(const String&)
     return false;
 }
 
-void PageClientImpl::setDragImage(const IntPoint&, PassRefPtr<ShareableBitmap>, bool)
+void PageClientImpl::setDragImage(const IntPoint&, PassRefPtr<ShareableBitmap>, DragSourceAction)
 {
     notImplemented();
 }
@@ -773,9 +773,9 @@ void PageClientImpl::didHandleStartDataInteractionRequest(bool started)
     [m_contentView _didHandleStartDataInteractionRequest:started];
 }
 
-void PageClientImpl::startDataInteractionWithImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& image, const FloatPoint& anchorPoint, bool isLink)
+void PageClientImpl::startDataInteractionWithImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData> indicatorData, const FloatPoint& anchorPoint, uint64_t action)
 {
-    [m_contentView _startDataInteractionWithImage:ShareableBitmap::create(image)->makeCGImageCopy() atClientPosition:CGPointMake(clientPosition.x(), clientPosition.y()) anchorPoint:anchorPoint isLink:isLink];
+    [m_contentView _startDataInteractionWithImage:ShareableBitmap::create(image)->makeCGImageCopy() withIndicatorData:indicatorData atClientPosition:CGPointMake(clientPosition.x(), clientPosition.y()) anchorPoint:anchorPoint action:action];
 }
 #endif
 
index bdcd04c..b6bfc6d 100644 (file)
@@ -270,7 +270,7 @@ struct WKAutoCorrectionData {
 #if ENABLE(DATA_INTERACTION)
 - (void)_didPerformDataInteractionControllerOperation;
 - (void)_didHandleStartDataInteractionRequest:(BOOL)started;
-- (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint isLink:(BOOL)isLink;
+- (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image withIndicatorData:(std::optional<WebCore::TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;
 - (void)_simulateDataInteractionGestureRecognized:(UILongPressGestureRecognizer *)gestureRecognizer WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (void)_simulateDataInteractionEntered:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (void)_simulateDataInteractionUpdated:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
index 69a957f..f957c6c 100644 (file)
@@ -1441,7 +1441,7 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
     [self ensurePositionInformationIsUpToDate:request];
 
 #if ENABLE(DATA_INTERACTION)
-    if (_positionInformation.hasDataInteractionAtPosition) {
+    if (_positionInformation.hasSelectionAtPosition) {
         // If the position might initiate a data interaction, we don't want to consider the content at this position to be selectable.
         // FIXME: This should be renamed to something more precise, such as textSelectionShouldRecognizeGestureAtPoint:
         return NO;
@@ -1461,14 +1461,11 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
     if (_positionInformation.isImage || _positionInformation.isLink)
         return YES;
 
-    return _positionInformation.hasDataInteractionAtPosition;
+    return _positionInformation.hasSelectionAtPosition;
 }
 
 - (UILongPressGestureRecognizer *)_dataInteractionGestureRecognizer
 {
-    if ([_webView._testingDelegate respondsToSelector:@selector(dataInteractionGestureRecognizer)])
-        return _webView._testingDelegate.dataInteractionGestureRecognizer;
-
     return _dataInteractionGestureRecognizer.get();
 }
 
@@ -1487,7 +1484,7 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
     [self ensurePositionInformationIsUpToDate:request];
 
 #if ENABLE(DATA_INTERACTION)
-    if (_positionInformation.hasDataInteractionAtPosition) {
+    if (_positionInformation.hasSelectionAtPosition) {
         // If the position might initiate data interaction, we don't want to change the selection.
         // FIXME: This should be renamed to something more precise, such as textInteractionShouldRecognizeGestureAtPoint:
         return NO;
index e7322be..3ea32dc 100644 (file)
@@ -95,7 +95,7 @@ private:
     bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
     void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
     bool executeSavedCommandBySelector(const String& selector) override;
-    void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) override;
+    void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, WebCore::DragSourceAction) override;
     void setPromisedDataForImage(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
         const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer) override;
 #if ENABLE(ATTACHMENT_ELEMENT)
index b06f74b..de2a277 100644 (file)
@@ -337,7 +337,7 @@ void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
     return (undoOrRedo == WebPageProxy::Undo) ? [[m_view undoManager] undo] : [[m_view undoManager] redo];
 }
 
-void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, DragSourceAction action)
 {
     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
     RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
@@ -345,7 +345,7 @@ void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<Sha
     size.scale(1.0 / m_impl->page().deviceScaleFactor());
     [dragNSImage setSize:size];
 
-    m_impl->dragImageForView(m_view, dragNSImage.get(), clientPosition, isLinkDrag);
+    m_impl->dragImageForView(m_view, dragNSImage.get(), clientPosition, action == DragSourceActionLink);
 }
 
 void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL, PassRefPtr<SharedBuffer> archiveBuffer)
index 897689c..40b868a 100644 (file)
@@ -269,10 +269,10 @@ void WebPageProxy::replaceSelectionWithPasteboardData(const Vector<String>& type
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
-void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, const FloatPoint&, bool isLinkDrag)
+void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<TextIndicatorData>, const FloatPoint&, uint64_t action)
 {
     if (auto dragImage = ShareableBitmap::create(dragImageHandle))
-        m_pageClient.setDragImage(clientPosition, WTFMove(dragImage), isLinkDrag);
+        m_pageClient.setDragImage(clientPosition, WTFMove(dragImage), static_cast<DragSourceAction>(action));
 
     process().send(Messages::WebPage::DidStartDrag(), m_pageID);
 }
index 2453c90..d5f69d6 100644 (file)
@@ -93,7 +93,7 @@ void WebDragClient::startDrag(DragImage image, const IntPoint& point, const IntP
     m_page->willStartDrag();
 
     // FIXME: Seems this message should be named StartDrag, not SetDragImage.
-    m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, { }, dragSourceAction == DragSourceActionLink));
+    m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, std::nullopt, { }, dragSourceAction));
 }
 
 static WebCore::CachedImage* cachedImage(Element& element)
index e769502..66b92a1 100644 (file)
@@ -2549,7 +2549,7 @@ void WebPage::getPositionInformation(const InteractionInformationRequest& reques
     }
 
 #if ENABLE(DATA_INTERACTION)
-    info.hasDataInteractionAtPosition = m_page->hasDataInteractionAtPosition(adjustedPoint);
+    info.hasSelectionAtPosition = m_page->hasSelectionAtPosition(adjustedPoint);
 #endif
     info.adjustedPointForNodeRespondingToClickEvents = adjustedPoint;
 }