Page overlay action context override should indicate the source of the request
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2015 17:38:51 +0000 (17:38 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2015 17:38:51 +0000 (17:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144832
<rdar://problem/20562594>

Reviewed by Darin Adler.

* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h:
* WebProcess/WebPage/WebPageOverlay.cpp:
(WebKit::WebPageOverlay::actionContextForResultAtPoint):
* WebProcess/WebPage/WebPageOverlay.h:
(WebKit::WebPageOverlay::Client::actionContextForResultAtPoint):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performActionMenuHitTestAtLocation):
Add a parameter to WKBundlePageOverlayActionContextForResultAtPoint so that
clients can tell whether the requested action context should be targetted
at an action menu or immediate action.

* TestWebKitAPI/Tests/WebKit2ObjC/ActionMenusBundle.mm:
(TestWebKitAPI::ActionMenuTest::actionContextForResultAtPoint):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h
Source/WebKit2/WebProcess/WebPage/WebPageOverlay.cpp
Source/WebKit2/WebProcess/WebPage/WebPageOverlay.h
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2ObjC/ActionMenusBundle.mm

index c9dc11d..3037574 100644 (file)
@@ -1,3 +1,23 @@
+2015-05-11  Tim Horton  <timothy_horton@apple.com>
+
+        Page overlay action context override should indicate the source of the request
+        https://bugs.webkit.org/show_bug.cgi?id=144832
+        <rdar://problem/20562594>
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
+        * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h:
+        * WebProcess/WebPage/WebPageOverlay.cpp:
+        (WebKit::WebPageOverlay::actionContextForResultAtPoint):
+        * WebProcess/WebPage/WebPageOverlay.h:
+        (WebKit::WebPageOverlay::Client::actionContextForResultAtPoint):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performActionMenuHitTestAtLocation):
+        Add a parameter to WKBundlePageOverlayActionContextForResultAtPoint so that
+        clients can tell whether the requested action context should be targetted
+        at an action menu or immediate action.
+
 2015-05-11  Daniel Bates  <dabates@apple.com>
 
         [iOS] Close all open databases in expiration handler of process assertion
index ae45aaf..a8ac692 100644 (file)
@@ -44,7 +44,7 @@
 namespace API {
 
 template<> struct ClientTraits<WKBundlePageOverlayClientBase> {
-    typedef std::tuple<WKBundlePageOverlayClientV0, WKBundlePageOverlayClientV1> Versions;
+    typedef std::tuple<WKBundlePageOverlayClientV0, WKBundlePageOverlayClientV1, WKBundlePageOverlayClientV2> Versions;
 };
 
 template<> struct ClientTraits<WKBundlePageOverlayAccessibilityClientBase> {
@@ -135,18 +135,29 @@ private:
     }
 
 #if PLATFORM(MAC)
-    virtual DDActionContext *actionContextForResultAtPoint(WebPageOverlay& pageOverlay, WebCore::FloatPoint location, RefPtr<WebCore::Range>& rangeHandle) override
+    virtual DDActionContext *actionContextForResultAtPoint(WebPageOverlay& pageOverlay, WebCore::FloatPoint location, RefPtr<WebCore::Range>& rangeHandle, bool forImmediateAction) override
     {
-        if (!m_client.actionContextForResultAtPoint)
-            return nil;
+        if (m_client.actionContextForResultAtPoint) {
+            WKBundleRangeHandleRef apiRange = nullptr;
+            DDActionContext *actionContext = (DDActionContext *)m_client.actionContextForResultAtPoint(toAPI(&pageOverlay), WKPointMake(location.x(), location.y()), &apiRange, forImmediateAction ? kWKBundlePageOverlayActionContextForImmediateActionRequestType : kWKBundlePageOverlayActionContextForActionMenuRequestType, m_client.base.clientInfo);
 
-        WKBundleRangeHandleRef apiRange = nullptr;
-        DDActionContext *actionContext = (DDActionContext *)m_client.actionContextForResultAtPoint(toAPI(&pageOverlay), WKPointMake(location.x(), location.y()), &apiRange, m_client.base.clientInfo);
+            if (apiRange)
+                rangeHandle = toImpl(apiRange)->coreRange();
 
-        if (apiRange)
-            rangeHandle = toImpl(apiRange)->coreRange();
+            return actionContext;
+        }
+
+        if (m_client.actionContextForResultAtPoint_deprecatedForUseWithV1) {
+            WKBundleRangeHandleRef apiRange = nullptr;
+            DDActionContext *actionContext = (DDActionContext *)m_client.actionContextForResultAtPoint_deprecatedForUseWithV1(toAPI(&pageOverlay), WKPointMake(location.x(), location.y()), &apiRange, m_client.base.clientInfo);
+
+            if (apiRange)
+                rangeHandle = toImpl(apiRange)->coreRange();
+
+            return actionContext;
+        }
 
-        return actionContext;
+        return nil;
     }
 
     virtual void dataDetectorsDidPresentUI(WebPageOverlay& pageOverlay) override
index 9e568cc..fcfbb20 100644 (file)
 extern "C" {
 #endif
 
+enum {
+    kWKBundlePageOverlayActionContextForActionMenuRequestType = 0,
+    kWKBundlePageOverlayActionContextForImmediateActionRequestType,
+};
+typedef uint32_t _WKBundlePageOverlayActionContextRequestType;
+
 // Page overlay client.
 typedef void (*WKBundlePageOverlayWillMoveToPageCallback)(WKBundlePageOverlayRef pageOverlay, WKBundlePageRef page, const void* clientInfo);
 typedef void (*WKBundlePageOverlayDidMoveToPageCallback)(WKBundlePageOverlayRef pageOverlay, WKBundlePageRef page, const void* clientInfo);
@@ -49,10 +55,11 @@ typedef bool (*WKBundlePageOverlayMouseUpCallback)(WKBundlePageOverlayRef pageOv
 typedef bool (*WKBundlePageOverlayMouseMovedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
 typedef bool (*WKBundlePageOverlayMouseDraggedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
 
-typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo);
-typedef void (*WKBundlePageOverlayDatadetectorsDidPresentUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
-typedef void (*WKBundlePageOverlayDatadetectorsDidChangeUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
-typedef void (*WKBundlePageOverlayDatadetectorsDidHideUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
+typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback_deprecatedForUseWithV1)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo);
+typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, _WKBundlePageOverlayActionContextRequestType requestType, const void* clientInfo);
+typedef void (*WKBundlePageOverlayDataDetectorsDidPresentUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
+typedef void (*WKBundlePageOverlayDataDetectorsDidChangeUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
+typedef void (*WKBundlePageOverlayDataDetectorsDidHideUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
 
 typedef struct WKBundlePageOverlayClientBase {
     int                                                                 version;
@@ -83,11 +90,30 @@ typedef struct WKBundlePageOverlayClientV1 {
     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
 
     WKBundlePageOverlayActionContextForResultAtPointCallback            actionContextForResultAtPoint;
-    WKBundlePageOverlayDatadetectorsDidPresentUI                         dataDetectorsDidPresentUI;
-    WKBundlePageOverlayDatadetectorsDidChangeUI                           dataDetectorsDidChangeUI;
-    WKBundlePageOverlayDatadetectorsDidHideUI                               dataDetectorsDidHideUI;
+    WKBundlePageOverlayDataDetectorsDidPresentUI                        dataDetectorsDidPresentUI;
+    WKBundlePageOverlayDataDetectorsDidChangeUI                         dataDetectorsDidChangeUI;
+    WKBundlePageOverlayDataDetectorsDidHideUI                           dataDetectorsDidHideUI;
 } WKBundlePageOverlayClientV1;
 
+typedef struct WKBundlePageOverlayClientV2 {
+    WKBundlePageOverlayClientBase                                       base;
+
+    WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
+    WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
+    WKBundlePageOverlayDrawRectCallback                                 drawRect;
+    WKBundlePageOverlayMouseDownCallback                                mouseDown;
+    WKBundlePageOverlayMouseUpCallback                                  mouseUp;
+    WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
+    WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
+
+    WKBundlePageOverlayActionContextForResultAtPointCallback_deprecatedForUseWithV1 actionContextForResultAtPoint_deprecatedForUseWithV1;
+    WKBundlePageOverlayDataDetectorsDidPresentUI                        dataDetectorsDidPresentUI;
+    WKBundlePageOverlayDataDetectorsDidChangeUI                         dataDetectorsDidChangeUI;
+    WKBundlePageOverlayDataDetectorsDidHideUI                           dataDetectorsDidHideUI;
+
+    WKBundlePageOverlayActionContextForResultAtPointCallback            actionContextForResultAtPoint;
+} WKBundlePageOverlayClientV2;
+
 enum { kWKBundlePageOverlayClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
 typedef struct WKBundlePageOverlayClient {
     int                                                                 version;
index 9e4086e..4052030 100644 (file)
@@ -120,9 +120,9 @@ void WebPageOverlay::didScrollFrame(PageOverlay&, Frame& frame)
 }
 
 #if PLATFORM(MAC)
-DDActionContext *WebPageOverlay::actionContextForResultAtPoint(FloatPoint location, RefPtr<WebCore::Range>& rangeHandle)
+DDActionContext *WebPageOverlay::actionContextForResultAtPoint(FloatPoint location, RefPtr<WebCore::Range>& rangeHandle, bool forImmediateAction)
 {
-    return m_client->actionContextForResultAtPoint(*this, location, rangeHandle);
+    return m_client->actionContextForResultAtPoint(*this, location, rangeHandle, forImmediateAction);
 }
 
 void WebPageOverlay::dataDetectorsDidPresentUI()
index fbbe62a..cf76ef0 100644 (file)
@@ -55,7 +55,7 @@ public:
         virtual void didScrollFrame(WebPageOverlay&, WebFrame*) { }
 
 #if PLATFORM(MAC)
-        virtual DDActionContext *actionContextForResultAtPoint(WebPageOverlay&, WebCore::FloatPoint location, RefPtr<WebCore::Range>& rangeHandle) { return nullptr; }
+        virtual DDActionContext *actionContextForResultAtPoint(WebPageOverlay&, WebCore::FloatPoint location, RefPtr<WebCore::Range>& rangeHandle, bool forImmediateAction) { return nullptr; }
         virtual void dataDetectorsDidPresentUI(WebPageOverlay&) { }
         virtual void dataDetectorsDidChangeUI(WebPageOverlay&) { }
         virtual void dataDetectorsDidHideUI(WebPageOverlay&) { }
@@ -79,7 +79,7 @@ public:
     Client& client() const { return *m_client; }
 
 #if PLATFORM(MAC)
-    DDActionContext *actionContextForResultAtPoint(WebCore::FloatPoint, RefPtr<WebCore::Range>&);
+    DDActionContext *actionContextForResultAtPoint(WebCore::FloatPoint, RefPtr<WebCore::Range>&, bool forImmediateAction);
     void dataDetectorsDidPresentUI();
     void dataDetectorsDidChangeUI();
     void dataDetectorsDidHideUI();
index 69a4e5e..0859cb3 100644 (file)
@@ -1133,7 +1133,7 @@ void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInV
             continue;
 
         RefPtr<Range> mainResultRange;
-        DDActionContext *actionContext = webOverlay->actionContextForResultAtPoint(locationInContentCoordinates, mainResultRange);
+        DDActionContext *actionContext = webOverlay->actionContextForResultAtPoint(locationInContentCoordinates, mainResultRange, forImmediateAction);
         if (!actionContext || !mainResultRange)
             continue;
 
index 7c7f27b..d8feee6 100644 (file)
@@ -1,3 +1,14 @@
+2015-05-11  Tim Horton  <timothy_horton@apple.com>
+
+        Page overlay action context override should indicate the source of the request
+        https://bugs.webkit.org/show_bug.cgi?id=144832
+        <rdar://problem/20562594>
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WebKit2ObjC/ActionMenusBundle.mm:
+        (TestWebKitAPI::ActionMenuTest::actionContextForResultAtPoint):
+
 2015-05-10  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] fast/events/page-visibility-transition-test.html is timing out
index 5e8a943..347bf80 100644 (file)
@@ -92,7 +92,7 @@ public:
         *userData = WKDictionaryCreate(keys, values, 1);
     }
 
-    static void* actionContextForResultAtPoint(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo)
+    static void* actionContextForResultAtPoint(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, _WKBundlePageOverlayActionContextRequestType requestType, const void* clientInfo)
     {
         if (position.x > 700) {
             RetainPtr<DDActionContext> actionContext = createActionContextForPhoneNumber();