[GTK] Use API::InjectedBundle::EditorClient in WebKitWebEditor
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jun 2017 10:49:18 +0000 (10:49 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jun 2017 10:49:18 +0000 (10:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173355

Reviewed by Žan Doberšek.

Instead of the C API.

* WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp:
(webkitWebEditorCreate):
(didChangeSelection): Deleted.

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp

index dbb0099..1353d10 100644 (file)
@@ -1,5 +1,18 @@
 2017-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Use API::InjectedBundle::EditorClient in WebKitWebEditor
+        https://bugs.webkit.org/show_bug.cgi?id=173355
+
+        Reviewed by Žan Doberšek.
+
+        Instead of the C API.
+
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp:
+        (webkitWebEditorCreate):
+        (didChangeSelection): Deleted.
+
+2017-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Unreviewed. Fix GTK+ build with GCC 4.9 after r218244.
 
         It seems that GCC 4.9 gets confused by enum named General and value of Print enum named General too. This
index 1105091..86475b2 100644 (file)
@@ -23,7 +23,6 @@
 #include "WebKitPrivate.h"
 #include "WebKitWebEditorPrivate.h"
 #include "WebKitWebPagePrivate.h"
-#include "WKBundleAPICast.h"
 
 using namespace WebKit;
 using namespace WebCore;
@@ -75,35 +74,27 @@ static void webkit_web_editor_class_init(WebKitWebEditorClass* klass)
         G_TYPE_NONE, 0);
 }
 
-static void didChangeSelection(WKBundlePageRef, WKStringRef /* notificationName */, const void* clientInfo)
-{
-    g_signal_emit(WEBKIT_WEB_EDITOR(clientInfo), signals[SELECTION_CHANGED], 0);
-}
+class PageEditorClient final : public API::InjectedBundle::EditorClient {
+public:
+    explicit PageEditorClient(WebKitWebEditor* editor)
+        : m_editor(editor)
+    {
+    }
+
+private:
+    void didChangeSelection(WebPage&, StringImpl*) override
+    {
+        g_signal_emit(m_editor, signals[SELECTION_CHANGED], 0);
+    }
+
+    WebKitWebEditor* m_editor;
+};
 
 WebKitWebEditor* webkitWebEditorCreate(WebKitWebPage* webPage)
 {
     WebKitWebEditor* editor = WEBKIT_WEB_EDITOR(g_object_new(WEBKIT_TYPE_WEB_EDITOR, nullptr));
     editor->priv->webPage = webPage;
-
-    WKBundlePageEditorClientV0 editorClient = {
-        {
-            0, // version
-            editor, // clientInfo
-        },
-        nullptr, // shouldBeginEditing
-        nullptr, // shouldEndEditing
-        nullptr, // shouldInsertNode
-        nullptr, // shouldInsertText
-        nullptr, // shouldDeleteRange
-        nullptr, // shouldChangeSelectedRange
-        nullptr, // shouldApplyStyle
-        nullptr, // didBeginEditing
-        nullptr, // didEndEditing
-        nullptr, // didChange
-        didChangeSelection
-    };
-    WKBundlePageSetEditorClient(toAPI(webkitWebPageGetPage(webPage)), &editorClient.base);
-
+    webkitWebPageGetPage(webPage)->setInjectedBundleEditorClient(std::make_unique<PageEditorClient>(editor));
     return editor;
 }