Title: [211199] trunk/Source
Revision
211199
Author
wenson_hs...@apple.com
Date
2017-01-25 20:22:05 -0800 (Wed, 25 Jan 2017)

Log Message

Add infrastructure to support data interaction in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=167443

Reviewed by Simon Fraser.

Source/WebCore:

Adds support in WebCore to determine whether there is interactive data at a given position. No new tests, since
there should be no behavior change yet.

* page/EventHandler.h:
* page/Page.cpp:
(WebCore::Page::hasDataInteractionAtPosition):
* page/Page.h:

Source/WebKit2:

Adds plumbing for two new XPC messages: WebPageProxy::DidPerformDataInteractionControllerOperation and
WebPage::RequestStartDataInteraction. Additionally, adds a new field to InteractionInformationAtPosition that
indicates whether or not there is data to interact with at a given location.

This patch only adds infrastructure, and does not change any behavior.

* Shared/ios/InteractionInformationAtPosition.h:
* Shared/ios/InteractionInformationAtPosition.mm:
(WebKit::InteractionInformationAtPosition::encode):
(WebKit::InteractionInformationAtPosition::decode):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didPerformDataInteractionControllerOperation):
(WebKit::PageClientImpl::startDataInteractionWithImage):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didPerformDataInteractionControllerOperation):
(WebKit::requestStartDataInteraction):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didPerformDataInteractionControllerOperation):
(WebKit::PageClientImpl::startDataInteractionWithImage):
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestStartDataInteraction):
(WebKit::WebPage::getPositionInformation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211198 => 211199)


--- trunk/Source/WebCore/ChangeLog	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebCore/ChangeLog	2017-01-26 04:22:05 UTC (rev 211199)
@@ -1,3 +1,18 @@
+2017-01-25  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add infrastructure to support data interaction in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=167443
+
+        Reviewed by Simon Fraser.
+
+        Adds support in WebCore to determine whether there is interactive data at a given position. No new tests, since
+        there should be no behavior change yet.
+
+        * page/EventHandler.h:
+        * page/Page.cpp:
+        (WebCore::Page::hasDataInteractionAtPosition):
+        * page/Page.h:
+
 2017-01-25  Matt Rajca  <mra...@apple.com>
 
         Notify clients when the user plays media otherwise prevented from autoplaying

Modified: trunk/Source/WebCore/page/EventHandler.h (211198 => 211199)


--- trunk/Source/WebCore/page/EventHandler.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebCore/page/EventHandler.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -315,6 +315,10 @@
 
     static Widget* widgetForEventTarget(Element* eventTarget);
 
+#if ENABLE(DATA_INTERACTION)
+    WEBCORE_EXPORT bool tryToBeginDataInteractionAtPoint(const IntPoint& clientPosition, const IntPoint& globalPosition);
+#endif
+
 private:
 #if ENABLE(DRAG_SUPPORT)
     static DragState& dragState();

Modified: trunk/Source/WebCore/page/Page.cpp (211198 => 211199)


--- trunk/Source/WebCore/page/Page.cpp	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebCore/page/Page.cpp	2017-01-26 04:22:05 UTC (rev 211199)
@@ -127,6 +127,10 @@
 #include "InProcessIDBServer.h"
 #endif
 
+#if ENABLE(DATA_INTERACTION)
+#include "SelectionRect.h"
+#endif
+
 namespace WebCore {
 
 static HashSet<Page*>* allPages;
@@ -2152,4 +2156,26 @@
         LOG(Layout, "hasMediaQueriesAffectedByAccessibilitySettingsChange, enqueueing style recalc");
 }
 
+#if ENABLE(DATA_INTERACTION)
+
+bool Page::hasDataInteractionAtPosition(const FloatPoint& position) const
+{
+    auto currentSelection = m_mainFrame->selection().selection();
+    if (!currentSelection.isRange())
+        return false;
+
+    if (auto selectedRange = currentSelection.toNormalizedRange()) {
+        Vector<SelectionRect> selectionRects;
+        selectedRange->collectSelectionRects(selectionRects);
+        for (auto selectionRect : selectionRects) {
+            if (FloatRect(selectionRect.rect()).contains(position))
+                return true;
+        }
+    }
+
+    return false;
+}
+
+#endif
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/Page.h (211198 => 211199)


--- trunk/Source/WebCore/page/Page.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebCore/page/Page.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -566,6 +566,10 @@
     bool isOnlyNonUtilityPage() const;
     bool isUtilityPage() const { return m_isUtilityPage; }
 
+#if ENABLE(DATA_INTERACTION)
+    WEBCORE_EXPORT bool hasDataInteractionAtPosition(const FloatPoint&) const;
+#endif
+
 private:
     WEBCORE_EXPORT void initGroup();
 

Modified: trunk/Source/WebKit2/ChangeLog (211198 => 211199)


--- trunk/Source/WebKit2/ChangeLog	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-26 04:22:05 UTC (rev 211199)
@@ -1,3 +1,41 @@
+2017-01-25  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add infrastructure to support data interaction in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=167443
+
+        Reviewed by Simon Fraser.
+
+        Adds plumbing for two new XPC messages: WebPageProxy::DidPerformDataInteractionControllerOperation and
+        WebPage::RequestStartDataInteraction. Additionally, adds a new field to InteractionInformationAtPosition that
+        indicates whether or not there is data to interact with at a given location.
+
+        This patch only adds infrastructure, and does not change any behavior.
+
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * Shared/ios/InteractionInformationAtPosition.mm:
+        (WebKit::InteractionInformationAtPosition::encode):
+        (WebKit::InteractionInformationAtPosition::decode):
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::didPerformDataInteractionControllerOperation):
+        (WebKit::PageClientImpl::startDataInteractionWithImage):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didPerformDataInteractionControllerOperation):
+        (WebKit::requestStartDataInteraction):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::didPerformDataInteractionControllerOperation):
+        (WebKit::PageClientImpl::startDataInteractionWithImage):
+        * WebProcess/WebPage/WebPage.cpp:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestStartDataInteraction):
+        (WebKit::WebPage::getPositionInformation):
+
 2017-01-25  Tim Horton  <timothy_hor...@apple.com>
 
         Stop inheriting from UIWebScrollView, just use UIScrollView

Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h (211198 => 211199)


--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -41,6 +41,9 @@
     InteractionInformationRequest request;
 
     bool nodeAtPositionIsAssistedNode { false };
+#if ENABLE(DATA_INTERACTION)
+    bool hasDataInteractionAtPosition { false };
+#endif
     bool isSelectable { false };
     bool isNearMarkedText { false };
     bool touchCalloutEnabled { true };

Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm (211198 => 211199)


--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm	2017-01-26 04:22:05 UTC (rev 211199)
@@ -43,6 +43,9 @@
     encoder << request;
 
     encoder << nodeAtPositionIsAssistedNode;
+#if ENABLE(DATA_INTERACTION)
+    encoder << hasDataInteractionAtPosition;
+#endif
     encoder << isSelectable;
     encoder << isNearMarkedText;
     encoder << touchCalloutEnabled;
@@ -87,6 +90,11 @@
     if (!decoder.decode(result.nodeAtPositionIsAssistedNode))
         return false;
 
+#if ENABLE(DATA_INTERACTION)
+    if (!decoder.decode(result.hasDataInteractionAtPosition))
+        return false;
+#endif
+
     if (!decoder.decode(result.isSelectable))
         return false;
 

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -380,6 +380,11 @@
 #if USE(QUICK_LOOK)
     virtual void requestPasswordForQuickLookDocument(const String& fileName, std::function<void(const String&)>&&) = 0;
 #endif
+
+#if ENABLE(DATA_INTERACTION)
+    virtual void didPerformDataInteractionControllerOperation() = 0;
+    virtual void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, bool isLink) = 0;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -543,7 +543,11 @@
     void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
     void setForceAlwaysUserScalable(bool);
     void setIsScrollingOrZooming(bool);
+#if ENABLE(DATA_INTERACTION)
+    void didPerformDataInteractionControllerOperation();
+    void requestStartDataInteraction(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition);
 #endif
+#endif
 #if ENABLE(DATA_DETECTION)
     void setDataDetectionResult(const DataDetectionResult&);
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-26 04:22:05 UTC (rev 211199)
@@ -316,6 +316,10 @@
     StartDrag(struct WebKit::WebSelectionData selection, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
 #endif
 
+#if ENABLE(DATA_INTERACTION)
+    DidPerformDataInteractionControllerOperation()
+#endif
+
 #if PLATFORM(COCOA)
     # Dictionary support.
     DidPerformDictionaryLookup(struct WebCore::DictionaryPopupInfo dictionaryPopupInfo)

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -199,6 +199,11 @@
 
     void requestPasswordForQuickLookDocument(const String& fileName, std::function<void(const String&)>&&) override;
 
+#if ENABLE(DATA_INTERACTION)
+    void didPerformDataInteractionControllerOperation() override;
+    void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, bool isLink) override;
+#endif
+
     WKContentView *m_contentView;
     WKWebView *m_webView;
     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2017-01-26 04:22:05 UTC (rev 211199)
@@ -762,6 +762,16 @@
     return ValidationBubble::create(m_contentView, message);
 }
 
+#if ENABLE(DATA_INTERACTION)
+void PageClientImpl::didPerformDataInteractionControllerOperation()
+{
+}
+
+void PageClientImpl::startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, bool isLink)
+{
+}
+#endif
+
 void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
 {
     [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2017-01-26 04:22:05 UTC (rev 211199)
@@ -1081,6 +1081,21 @@
         m_validationBubble->show();
 }
 
+#if ENABLE(DATA_INTERACTION)
+
+void WebPageProxy::didPerformDataInteractionControllerOperation()
+{
+    m_pageClient.didPerformDataInteractionControllerOperation();
+}
+
+void WebPageProxy::requestStartDataInteraction(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition)
+{
+    if (isValid())
+        m_process->send(Messages::WebPage::RequestStartDataInteraction(clientPosition, globalPosition), m_pageID);
+}
+
+#endif
+
 #if USE(QUICK_LOOK)
     
 void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -232,6 +232,11 @@
     _WKRemoteObjectRegistry *remoteObjectRegistry() override;
 #endif
 
+#if ENABLE(DATA_INTERACTION)
+    void didPerformDataInteractionControllerOperation() override;
+    void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, bool isLink) override;
+#endif
+
     NSView *m_view;
     WKWebView *m_webView;
     WebViewImpl* m_impl { nullptr };

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (211198 => 211199)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2017-01-26 04:22:05 UTC (rev 211199)
@@ -875,6 +875,18 @@
     return m_impl->windowIsFrontWindowUnderMouse(event.nativeEvent());
 }
 
+#if ENABLE(DATA_INTERACTION)
+void PageClientImpl::didPerformDataInteractionControllerOperation()
+{
+    // FIXME: Implement me.
+}
+
+void PageClientImpl::startDataInteractionWithImage(const IntPoint&, const ShareableBitmap::Handle&, bool)
+{
+    // FIXME: Implement me.
+}
+#endif
+
 WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
 {
     if (!m_view)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (211198 => 211199)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-01-26 04:22:05 UTC (rev 211199)
@@ -3527,6 +3527,9 @@
         m_pendingDropSandboxExtension = nullptr;
 
         m_pendingDropExtensionsForFileUpload.clear();
+#if ENABLE(DATA_INTERACTION)
+        send(Messages::WebPageProxy::DidPerformDataInteractionControllerOperation());
+#endif
         break;
     }
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (211198 => 211199)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2017-01-26 04:22:05 UTC (rev 211199)
@@ -1014,7 +1014,10 @@
     PassRefPtr<WebCore::Range> rangeForGranularityAtPoint(const WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithAssistedNode);
     bool shouldSwitchToBlockModeForHandle(const WebCore::IntPoint& handlePoint, SelectionHandlePosition);
     RefPtr<WebCore::Range> switchToBlockSelectionAtPoint(const WebCore::IntPoint&, SelectionHandlePosition);
+#if ENABLE(DATA_INTERACTION)
+    void requestStartDataInteraction(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition);
 #endif
+#endif
 
 #if !PLATFORM(COCOA)
     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (211198 => 211199)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2017-01-26 04:22:05 UTC (rev 211199)
@@ -246,6 +246,10 @@
     DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation)
 #endif
 
+#if ENABLE(DATA_INTERACTION)
+    RequestStartDataInteraction(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition)
+#endif
+
     # Popup menu.
     DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex)
     SetTextForActivePopupMenu(int32_t index)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (211198 => 211199)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2017-01-26 04:19:00 UTC (rev 211198)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2017-01-26 04:22:05 UTC (rev 211199)
@@ -620,6 +620,13 @@
         handleSyntheticClick(nodeRespondingToClick, adjustedPoint);
 }
 
+#if ENABLE(DATA_INTERACTION)
+void WebPage::requestStartDataInteraction(const IntPoint& clientPosition, const IntPoint& globalPosition)
+{
+    m_page->mainFrame().eventHandler().tryToBeginDataInteractionAtPoint(clientPosition, globalPosition);
+}
+#endif
+
 void WebPage::sendTapHighlightForNodeIfNecessary(uint64_t requestID, Node* node)
 {
 #if ENABLE(TOUCH_EVENTS)
@@ -2463,6 +2470,10 @@
             }
         }
     }
+
+#if ENABLE(DATA_INTERACTION)
+    info.hasDataInteractionAtPosition = m_page->hasDataInteractionAtPosition(adjustedPoint);
+#endif
 }
 
 void WebPage::requestPositionInformation(const InteractionInformationRequest& request)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to