Changeset 218089 in webkit


Ignore:
Timestamp:
Jun 11, 2017 11:05:05 PM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Remove WKInspectorClientGtk
https://bugs.webkit.org/show_bug.cgi?id=173142

Reviewed by Michael Catanzaro.

It's only used internally in GTk+ API, we can simplify it by using a C++ client instead.

  • PlatformGTK.cmake:
  • UIProcess/API/C/gtk/WKInspectorClientGtk.cpp: Removed.
  • UIProcess/API/C/gtk/WKInspectorClientGtk.h: Removed.
  • UIProcess/API/gtk/WebKitPrivate.h:
  • UIProcess/API/gtk/WebKitWebInspector.cpp:

(_WebKitWebInspectorPrivate::~_WebKitWebInspectorPrivate):
(webkitWebInspectorCreate):

  • UIProcess/WebInspectorProxy.cpp:
  • UIProcess/WebInspectorProxy.h:
  • UIProcess/gtk/WebInspectorClientGtk.cpp: Removed.
  • UIProcess/gtk/WebInspectorProxyClient.h: Renamed from Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.h.
  • UIProcess/gtk/WebInspectorProxyGtk.cpp:

(WebKit::WebInspectorProxy::setClient):
(WebKit::WebInspectorProxy::createInspectorWindow):
(WebKit::WebInspectorProxy::platformDidClose):
(WebKit::WebInspectorProxy::platformBringToFront):
(WebKit::WebInspectorProxy::platformInspectedURLChanged):
(WebKit::WebInspectorProxy::platformAttach):
(WebKit::WebInspectorProxy::platformDetach):
(WebKit::WebInspectorProxy::platformSetAttachedWindowHeight):
(WebKit::WebInspectorProxy::platformSetAttachedWindowWidth):
(WebKit::WebInspectorProxy::platformAttachAvailabilityChanged):

Location:
trunk/Source/WebKit2
Files:
3 deleted
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r218068 r218089  
     12017-06-11  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Remove WKInspectorClientGtk
     4        https://bugs.webkit.org/show_bug.cgi?id=173142
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        It's only used internally in GTk+ API, we can simplify it by using a C++ client instead.
     9
     10        * PlatformGTK.cmake:
     11        * UIProcess/API/C/gtk/WKInspectorClientGtk.cpp: Removed.
     12        * UIProcess/API/C/gtk/WKInspectorClientGtk.h: Removed.
     13        * UIProcess/API/gtk/WebKitPrivate.h:
     14        * UIProcess/API/gtk/WebKitWebInspector.cpp:
     15        (_WebKitWebInspectorPrivate::~_WebKitWebInspectorPrivate):
     16        (webkitWebInspectorCreate):
     17        * UIProcess/WebInspectorProxy.cpp:
     18        * UIProcess/WebInspectorProxy.h:
     19        * UIProcess/gtk/WebInspectorClientGtk.cpp: Removed.
     20        * UIProcess/gtk/WebInspectorProxyClient.h: Renamed from Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.h.
     21        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
     22        (WebKit::WebInspectorProxy::setClient):
     23        (WebKit::WebInspectorProxy::createInspectorWindow):
     24        (WebKit::WebInspectorProxy::platformDidClose):
     25        (WebKit::WebInspectorProxy::platformBringToFront):
     26        (WebKit::WebInspectorProxy::platformInspectedURLChanged):
     27        (WebKit::WebInspectorProxy::platformAttach):
     28        (WebKit::WebInspectorProxy::platformDetach):
     29        (WebKit::WebInspectorProxy::platformSetAttachedWindowHeight):
     30        (WebKit::WebInspectorProxy::platformSetAttachedWindowWidth):
     31        (WebKit::WebInspectorProxy::platformAttachAvailabilityChanged):
     32
    1332017-06-11  Tim Horton  <timothy_horton@apple.com>
    234
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r218064 r218089  
    110110    UIProcess/API/C/cairo/WKIconDatabaseCairo.cpp
    111111
    112     UIProcess/API/C/gtk/WKInspectorClientGtk.cpp
    113112    UIProcess/API/C/gtk/WKTextCheckerGtk.cpp
    114113    UIProcess/API/C/gtk/WKView.cpp
     
    337336    UIProcess/gtk/WebColorPickerGtk.cpp
    338337    UIProcess/gtk/WebContextMenuProxyGtk.cpp
    339     UIProcess/gtk/WebInspectorClientGtk.cpp
    340338    UIProcess/gtk/WebInspectorProxyGtk.cpp
    341339    UIProcess/gtk/WebKitInspectorWindow.cpp
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h

    r218064 r218089  
    3636#include <WebKit/WKIconDatabase.h>
    3737#include <WebKit/WKInspector.h>
    38 #include <WebKit/WKInspectorClientGtk.h>
    3938#include <WebKit/WKRetainPtr.h>
    4039#include <WebKit/WKSerializedScriptValue.h>
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.cpp

    r217960 r218089  
    2222
    2323#include "WebInspectorProxy.h"
     24#include "WebInspectorProxyClient.h"
    2425#include "WebKitWebInspectorPrivate.h"
    2526#include <glib/gi18n-lib.h>
     
    7980    ~_WebKitWebInspectorPrivate()
    8081    {
    81         WKInspectorSetInspectorClientGtk(toAPI(webInspector.get()), 0);
     82        webInspector->setClient(nullptr);
    8283    }
    8384
     
    282283}
    283284
    284 static bool openWindow(WKInspectorRef, const void* clientInfo)
    285 {
    286     gboolean returnValue;
    287     g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[OPEN_WINDOW], 0, &returnValue);
    288     return returnValue;
    289 }
    290 
    291 static void didClose(WKInspectorRef, const void* clientInfo)
    292 {
    293     g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[CLOSED], 0);
    294 }
    295 
    296 static bool bringToFront(WKInspectorRef, const void* clientInfo)
    297 {
    298     gboolean returnValue;
    299     g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[BRING_TO_FRONT], 0, &returnValue);
    300     return returnValue;
    301 }
    302 
    303 static void inspectedURLChanged(WKInspectorRef, WKStringRef url, const void* clientInfo)
    304 {
    305     WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(clientInfo);
    306     CString uri = toImpl(url)->string().utf8();
    307     if (uri == inspector->priv->inspectedURI)
    308         return;
    309     inspector->priv->inspectedURI = uri;
    310     g_object_notify(G_OBJECT(inspector), "inspected-uri");
    311 }
    312 
    313 static bool attach(WKInspectorRef, const void* clientInfo)
    314 {
    315     gboolean returnValue;
    316     g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[ATTACH], 0, &returnValue);
    317     return returnValue;
    318 }
    319 
    320 static bool detach(WKInspectorRef, const void* clientInfo)
    321 {
    322     gboolean returnValue;
    323     g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[DETACH], 0, &returnValue);
    324     return returnValue;
    325 }
    326 
    327 static void didChangeAttachedHeight(WKInspectorRef, unsigned height, const void* clientInfo)
    328 {
    329     WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(clientInfo);
    330     if (inspector->priv->attachedHeight == height)
    331         return;
    332     inspector->priv->attachedHeight = height;
    333     g_object_notify(G_OBJECT(inspector), "attached-height");
    334 }
    335 
    336 static void didChangeAttachAvailability(WKInspectorRef, bool available, const void* clientInfo)
    337 {
    338     WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(clientInfo);
    339     if (inspector->priv->canAttach == available)
    340         return;
    341     inspector->priv->canAttach = available;
    342     g_object_notify(G_OBJECT(clientInfo), "can-attach");
    343 }
     285class WebKitInspectorClient final : public WebInspectorProxyClient {
     286public:
     287    explicit WebKitInspectorClient(WebKitWebInspector* inspector)
     288        : m_inspector(inspector)
     289    {
     290    }
     291
     292private:
     293    bool openWindow(WebInspectorProxy&) override
     294    {
     295        gboolean returnValue;
     296        g_signal_emit(m_inspector, signals[OPEN_WINDOW], 0, &returnValue);
     297        return returnValue;
     298    }
     299
     300    void didClose(WebInspectorProxy&) override
     301    {
     302        g_signal_emit(m_inspector, signals[CLOSED], 0);
     303    }
     304
     305    bool bringToFront(WebInspectorProxy&) override
     306    {
     307        gboolean returnValue;
     308        g_signal_emit(m_inspector, signals[BRING_TO_FRONT], 0, &returnValue);
     309        return returnValue;
     310    }
     311
     312    void inspectedURLChanged(WebInspectorProxy&, const String& url) override
     313    {
     314        CString uri = url.utf8();
     315        if (uri == m_inspector->priv->inspectedURI)
     316            return;
     317        m_inspector->priv->inspectedURI = uri;
     318        g_object_notify(G_OBJECT(m_inspector), "inspected-uri");
     319    }
     320
     321    bool attach(WebInspectorProxy&) override
     322    {
     323        gboolean returnValue;
     324        g_signal_emit(m_inspector, signals[ATTACH], 0, &returnValue);
     325        return returnValue;
     326    }
     327
     328    bool detach(WebInspectorProxy&) override
     329    {
     330        gboolean returnValue;
     331        g_signal_emit(m_inspector, signals[DETACH], 0, &returnValue);
     332        return returnValue;
     333    }
     334
     335    void didChangeAttachedHeight(WebInspectorProxy&, unsigned height) override
     336    {
     337        if (m_inspector->priv->attachedHeight == height)
     338            return;
     339        m_inspector->priv->attachedHeight = height;
     340        g_object_notify(G_OBJECT(m_inspector), "attached-height");
     341    }
     342
     343    void didChangeAttachedWidth(WebInspectorProxy&, unsigned width) override
     344    {
     345    }
     346
     347    void didChangeAttachAvailability(WebInspectorProxy&, bool available) override
     348    {
     349        if (m_inspector->priv->canAttach == available)
     350            return;
     351        m_inspector->priv->canAttach = available;
     352        g_object_notify(G_OBJECT(m_inspector), "can-attach");
     353    }
     354
     355    WebKitWebInspector* m_inspector;
     356};
    344357
    345358WebKitWebInspector* webkitWebInspectorCreate(WebInspectorProxy* webInspector)
     
    347360    WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL));
    348361    inspector->priv->webInspector = webInspector;
    349 
    350     WKInspectorClientGtkV0 wkInspectorClientGtk = {
    351         {
    352             0, // version
    353             inspector, // clientInfo
    354         },
    355         openWindow,
    356         didClose,
    357         bringToFront,
    358         inspectedURLChanged,
    359         attach,
    360         detach,
    361         didChangeAttachedHeight,
    362         nullptr, // didChangeAttachedWidth
    363         didChangeAttachAvailability
    364     };
    365     WKInspectorSetInspectorClientGtk(toAPI(webInspector), &wkInspectorClientGtk.base);
    366 
     362    webInspector->setClient(std::make_unique<WebKitInspectorClient>(inspector));
    367363    return inspector;
    368364}
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp

    r217924 r218089  
    4848#include <wtf/NeverDestroyed.h>
    4949
     50#if PLATFORM(GTK)
     51#include "WebInspectorProxyClient.h"
     52#endif
     53
    5054using namespace WebCore;
    5155
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h

    r217924 r218089  
    5050#endif
    5151
    52 #if PLATFORM(GTK)
    53 #include "WebInspectorClientGtk.h"
    54 #endif
    55 
    5652namespace WebCore {
    5753class URL;
     
    6157
    6258class WebFrameProxy;
     59class WebInspectorProxyClient;
    6360class WebPageProxy;
    6461class WebPreferences;
     
    116113#if PLATFORM(GTK)
    117114    GtkWidget* inspectorView() const { return m_inspectorView; };
    118     void initializeInspectorClientGtk(const WKInspectorClientGtkBase*);
     115    void setClient(std::unique_ptr<WebInspectorProxyClient>&&);
    119116#endif
    120117
     
    243240    String m_urlString;
    244241#elif PLATFORM(GTK)
    245     WebInspectorClientGtk m_client;
     242    std::unique_ptr<WebInspectorProxyClient> m_client;
    246243    GtkWidget* m_inspectorView { nullptr };
    247244    GtkWidget* m_inspectorWindow { nullptr };
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyClient.h

    r218086 r218089  
    2626#pragma once
    2727
    28 #include "APIClient.h"
    29 #include "WKInspectorClientGtk.h"
    3028#include <wtf/text/WTFString.h>
    31 
    32 namespace API {
    33 class Object;
    34 
    35 template<> struct ClientTraits<WKInspectorClientGtkBase> {
    36     typedef std::tuple<WKInspectorClientGtkV0> Versions;
    37 };
    38 }
    3929
    4030namespace WebKit {
     
    4232class WebInspectorProxy;
    4333
    44 class WebInspectorClientGtk : public API::Client<WKInspectorClientGtkBase> {
     34class WebInspectorProxyClient {
    4535public:
    46     bool openWindow(WebInspectorProxy*);
    47     void didClose(WebInspectorProxy*);
    48     bool bringToFront(WebInspectorProxy*);
    49     void inspectedURLChanged(WebInspectorProxy*, const String& url);
    50     bool attach(WebInspectorProxy*);
    51     bool detach(WebInspectorProxy*);
    52     void didChangeAttachedHeight(WebInspectorProxy*, unsigned height);
    53     void didChangeAttachedWidth(WebInspectorProxy*, unsigned width);
    54     void didChangeAttachAvailability(WebInspectorProxy*, bool available);
     36    virtual bool openWindow(WebInspectorProxy&) = 0;
     37    virtual void didClose(WebInspectorProxy&) = 0;
     38    virtual bool bringToFront(WebInspectorProxy&) = 0;
     39    virtual void inspectedURLChanged(WebInspectorProxy&, const String& url) = 0;
     40    virtual bool attach(WebInspectorProxy&) = 0;
     41    virtual bool detach(WebInspectorProxy&) = 0;
     42    virtual void didChangeAttachedHeight(WebInspectorProxy&, unsigned height) = 0;
     43    virtual void didChangeAttachedWidth(WebInspectorProxy&, unsigned width) = 0;
     44    virtual void didChangeAttachAvailability(WebInspectorProxy&, bool available) = 0;
    5545};
    5646
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp

    r215732 r218089  
    3030#include "WebInspectorProxy.h"
    3131
     32#include "WebInspectorProxyClient.h"
    3233#include "WebKitInspectorWindow.h"
    3334#include "WebKitWebViewBasePrivate.h"
     
    5758}
    5859
    59 void WebInspectorProxy::initializeInspectorClientGtk(const WKInspectorClientGtkBase* inspectorClient)
    60 {
    61     m_client.initialize(inspectorClient);
     60void WebInspectorProxy::setClient(std::unique_ptr<WebInspectorProxyClient>&& client)
     61{
     62    m_client = WTFMove(client);
    6263}
    6364
     
    143144void WebInspectorProxy::createInspectorWindow()
    144145{
    145     if (m_client.openWindow(this))
     146    if (m_client && m_client->openWindow(*this))
    146147        return;
    147148
     
    185186        g_signal_handlers_disconnect_by_func(m_inspectorView, reinterpret_cast<void*>(inspectorViewDestroyed), this);
    186187
    187     m_client.didClose(this);
     188    if (m_client)
     189        m_client->didClose(*this);
    188190
    189191    if (m_inspectorWindow) {
     
    209211void WebInspectorProxy::platformBringToFront()
    210212{
    211     if (m_client.bringToFront(this))
     213    if (m_client && m_client->bringToFront(*this))
    212214        return;
    213215
     
    233235{
    234236    m_inspectedURLString = url;
    235     m_client.inspectedURLChanged(this, url);
     237    if (m_client)
     238        m_client->inspectedURLChanged(*this, url);
    236239
    237240    if (m_inspectorWindow)
     
    286289    }
    287290
    288     if (m_client.attach(this))
     291    if (m_client && m_client->attach(*this))
    289292        return;
    290293
     
    299302
    300303    GRefPtr<GtkWidget> inspectorView = m_inspectorView;
    301     if (!m_client.detach(this)) {
     304    if (m_client && !m_client->detach(*this)) {
    302305        // Detach is called when m_isAttached is true, but it could called before
    303306        // the inspector is opened if the inspector is shown/closed quickly. So,
     
    325328        return;
    326329
    327     m_client.didChangeAttachedHeight(this, height);
     330    if (m_client)
     331        m_client->didChangeAttachedHeight(*this, height);
    328332    webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), height);
    329333}
     
    334338        return;
    335339
    336     m_client.didChangeAttachedWidth(this, width);
     340    if (m_client)
     341        m_client->didChangeAttachedWidth(*this, width);
    337342    webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), width);
    338343}
     
    355360void WebInspectorProxy::platformAttachAvailabilityChanged(bool available)
    356361{
    357     m_client.didChangeAttachAvailability(this, available);
     362    if (m_client)
     363        m_client->didChangeAttachAvailability(*this, available);
    358364}
    359365
Note: See TracChangeset for help on using the changeset viewer.