Title: [217961] trunk/Source/WebKit2
Revision
217961
Author
[email protected]
Date
2017-06-08 22:24:32 -0700 (Thu, 08 Jun 2017)

Log Message

[GTK] Use API::Findclient instead of the C API in WebKitFindController
https://bugs.webkit.org/show_bug.cgi?id=173095

Reviewed by Žan Doberšek.

* UIProcess/API/gtk/WebKitFindController.cpp:
(getPage):
(webkitFindControllerDispose):
(webkitFindControllerConstructed):
(webkit_find_controller_class_init):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (217960 => 217961)


--- trunk/Source/WebKit2/ChangeLog	2017-06-09 05:22:40 UTC (rev 217960)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-09 05:24:32 UTC (rev 217961)
@@ -1,5 +1,18 @@
 2017-06-08  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Use API::Findclient instead of the C API in WebKitFindController
+        https://bugs.webkit.org/show_bug.cgi?id=173095
+
+        Reviewed by Žan Doberšek.
+
+        * UIProcess/API/gtk/WebKitFindController.cpp:
+        (getPage):
+        (webkitFindControllerDispose):
+        (webkitFindControllerConstructed):
+        (webkit_find_controller_class_init):
+
+2017-06-08  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Get rid of custom marshallers of signals
         https://bugs.webkit.org/show_bug.cgi?id=173094
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp (217960 => 217961)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp	2017-06-09 05:22:40 UTC (rev 217960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp	2017-06-09 05:24:32 UTC (rev 217961)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "WebKitFindController.h"
 
+#include "APIFindClient.h"
 #include "WebKitEnumTypes.h"
 #include "WebKitPrivate.h"
 #include "WebKitWebView.h"
@@ -101,40 +102,51 @@
         | (findOptions & FindOptionsWrapAround ? WEBKIT_FIND_OPTIONS_WRAP_AROUND : 0));
 }
 
-static void didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo)
+static inline WebPageProxy* getPage(WebKitFindController* findController)
 {
-    g_signal_emit(WEBKIT_FIND_CONTROLLER(clientInfo), signals[FOUND_TEXT], 0, matchCount);
+    return webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(findController->priv->webView));
 }
 
-static void didFailToFindString(WKPageRef, WKStringRef, const void* clientInfo)
-{
-    g_signal_emit(WEBKIT_FIND_CONTROLLER(clientInfo), signals[FAILED_TO_FIND_TEXT], 0);
-}
+class FindClient final : public API::FindClient {
+public:
+    explicit FindClient(WebKitFindController* findController)
+        : m_findController(findController)
+    {
+    }
 
-static void didCountStringMatches(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo)
+private:
+    void didCountStringMatches(WebPageProxy*, const String&, uint32_t matchCount) override
+    {
+        g_signal_emit(m_findController, signals[COUNTED_MATCHES], 0, matchCount);
+    }
+
+    void didFindString(WebPageProxy*, const String&, const Vector<IntRect>&, uint32_t matchCount, int32_t, bool /*didWrapAround*/) override
+    {
+        g_signal_emit(m_findController, signals[FOUND_TEXT], 0, matchCount);
+    }
+
+    void didFailToFindString(WebPageProxy*, const String&) override
+    {
+        g_signal_emit(m_findController, signals[FAILED_TO_FIND_TEXT], 0);
+    }
+
+    WebKitFindController* m_findController;
+};
+
+static void webkitFindControllerDispose(GObject* object)
 {
-    g_signal_emit(WEBKIT_FIND_CONTROLLER(clientInfo), signals[COUNTED_MATCHES], 0, matchCount);
-}
+    WebKitFindController* findController = WEBKIT_FIND_CONTROLLER(object);
+    getPage(findController)->setFindClient(nullptr);
 
-static inline WebPageProxy* getPage(WebKitFindController* findController)
-{
-    return webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(findController->priv->webView));
+    G_OBJECT_CLASS(webkit_find_controller_parent_class)->dispose(object);
 }
 
 static void webkitFindControllerConstructed(GObject* object)
 {
+    G_OBJECT_CLASS(webkit_find_controller_parent_class)->constructed(object);
+
     WebKitFindController* findController = WEBKIT_FIND_CONTROLLER(object);
-    WKPageFindClientV0 wkFindClient = {
-        {
-            0, // version
-            findController, // clientInfo
-        },
-        didFindString,
-        didFailToFindString,
-        didCountStringMatches
-    };
-
-    WKPageSetPageFindClient(toAPI(getPage(findController)), &wkFindClient.base);
+    getPage(findController)->setFindClient(std::make_unique<FindClient>(findController));
 }
 
 static void webkitFindControllerGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
@@ -175,6 +187,7 @@
 static void webkit_find_controller_class_init(WebKitFindControllerClass* findClass)
 {
     GObjectClass* gObjectClass = G_OBJECT_CLASS(findClass);
+    gObjectClass->dispose = webkitFindControllerDispose;
     gObjectClass->constructed = webkitFindControllerConstructed;
     gObjectClass->get_property = webkitFindControllerGetProperty;
     gObjectClass->set_property = webkitFindControllerSetProperty;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to