[EFL] Add Web Inspector to WebKit-EFL
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2012 07:17:22 +0000 (07:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2012 07:17:22 +0000 (07:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83865

Patch by Seokju Kwon <seokju.kwon@samsung.com> on 2012-07-06
Reviewed by Pavel Feldman.

Source/WebKit:

EFL port implementation for Web Inspector.
Prepare Web Inspector resources.

* PlatformEfl.cmake:

Source/WebKit/efl:

EFL port implementation for Web Inspector.
Implementation of InspectorClientEfl and InspectorFrontendClientEfl
for using the Web Inspector in WebKit-EFL with new EWK APIs.

* WebCoreSupport/InspectorClientEfl.cpp:
(WebCore::notifyWebInspectorDestroy):
(WebCore):
(InspectorFrontendSettingsEfl):
(WebCore::InspectorFrontendSettingsEfl::getProperty):
(WebCore::InspectorFrontendSettingsEfl::setProperty):
(WebCore::InspectorClientEfl::InspectorClientEfl):
(WebCore::InspectorClientEfl::~InspectorClientEfl):
(WebCore::InspectorClientEfl::inspectorDestroyed):
(WebCore::InspectorClientEfl::openInspectorFrontend):
(WebCore::InspectorClientEfl::closeInspectorFrontend):
(WebCore::InspectorClientEfl::bringFrontendToFront):
(WebCore::InspectorClientEfl::sendMessageToFrontend):
(WebCore::InspectorClientEfl::releaseFrontendPage):
(WebCore::InspectorClientEfl::inspectorFilesPath):
(WebCore::InspectorFrontendClientEfl::InspectorFrontendClientEfl):
(WebCore::InspectorFrontendClientEfl::~InspectorFrontendClientEfl):
(WebCore::InspectorFrontendClientEfl::localizedStringsURL):
(WebCore::InspectorFrontendClientEfl::hiddenPanels):
(WebCore::InspectorFrontendClientEfl::bringToFront):
(WebCore::InspectorFrontendClientEfl::closeWindow):
(WebCore::InspectorFrontendClientEfl::inspectedURLChanged):
(WebCore::InspectorFrontendClientEfl::attachWindow):
(WebCore::InspectorFrontendClientEfl::detachWindow):
(WebCore::InspectorFrontendClientEfl::setAttachedWindowHeight):
(WebCore::InspectorFrontendClientEfl::destroyInspectorWindow):
* WebCoreSupport/InspectorClientEfl.h:
(WebCore):
(InspectorClientEfl):
(InspectorFrontendClientEfl):
(WebCore::InspectorFrontendClientEfl::disconnectInspectorClient):
* ewk/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_ewk_view_priv_new):
(ewk_view_web_inspector_show):
(ewk_view_web_inspector_close):
(ewk_view_web_inspector_view_get):
(ewk_view_web_inspector_view_set):
* ewk/ewk_view.h:

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

Source/WebKit/ChangeLog
Source/WebKit/PlatformEfl.cmake
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/InspectorClientEfl.cpp
Source/WebKit/efl/WebCoreSupport/InspectorClientEfl.h
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/efl/ewk/ewk_view.h

index fa4d58f..6708cc4 100644 (file)
@@ -1,3 +1,15 @@
+2012-07-06  Seokju Kwon  <seokju.kwon@samsung.com>
+
+        [EFL] Add Web Inspector to WebKit-EFL
+        https://bugs.webkit.org/show_bug.cgi?id=83865
+
+        Reviewed by Pavel Feldman.
+
+        EFL port implementation for Web Inspector.
+        Prepare Web Inspector resources.
+
+        * PlatformEfl.cmake:
+
 2012-07-05  Kihong Kwon  <kihong.kwon@samsung.com>
 
         [EFL] Change class name from NotificationClientEfl to NotificationPresenterClientEfl.
index b8c8bd2..368383a 100644 (file)
@@ -371,3 +371,23 @@ FOREACH(testName ${EWKUnitTests_BINARIES})
     ADD_TARGET_PROPERTIES(${testName} LINK_FLAGS "${EWKUnitTests_LINK_FLAGS}")
     SET_TARGET_PROPERTIES(${testName} PROPERTIES FOLDER "WebKit")
 ENDFOREACH()
+
+IF (ENABLE_INSPECTOR)
+    SET(WEB_INSPECTOR_DIR ${CMAKE_BINARY_DIR}/WebKit/efl/webinspector)
+    ADD_DEFINITIONS(-DWEB_INSPECTOR_DIR="${WEB_INSPECTOR_DIR}")
+    ADD_DEFINITIONS(-DWEB_INSPECTOR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/webinspector")
+    ADD_CUSTOM_TARGET(
+        web-inspector-resources ALL
+        COMMAND ${CMAKE_COMMAND} -E copy_directory ${WEBCORE_DIR}/inspector/front-end ${WEB_INSPECTOR_DIR}
+        COMMAND ${CMAKE_COMMAND} -E copy ${WEBCORE_DIR}/English.lproj/localizedStrings.js ${WEB_INSPECTOR_DIR}
+        COMMAND ${CMAKE_COMMAND} -E copy ${DERIVED_SOURCES_WEBCORE_DIR}/InspectorBackendCommands.js ${WEB_INSPECTOR_DIR}/InspectorBackendCommands.js
+        DEPENDS ${WebCore_LIBRARY_NAME}
+    )
+    INSTALL(DIRECTORY ${WEB_INSPECTOR_DIR}
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}
+        FILES_MATCHING PATTERN "*.js"
+                       PATTERN "*.html"
+                       PATTERN "*.css"
+                       PATTERN "*.gif"
+                       PATTERN "*.png")
+ENDIF ()
index 751713c..b80323b 100644 (file)
@@ -1,3 +1,54 @@
+2012-07-06  Seokju Kwon  <seokju.kwon@samsung.com>
+
+        [EFL] Add Web Inspector to WebKit-EFL
+        https://bugs.webkit.org/show_bug.cgi?id=83865
+
+        Reviewed by Pavel Feldman.
+
+        EFL port implementation for Web Inspector.
+        Implementation of InspectorClientEfl and InspectorFrontendClientEfl
+        for using the Web Inspector in WebKit-EFL with new EWK APIs.
+
+        * WebCoreSupport/InspectorClientEfl.cpp:
+        (WebCore::notifyWebInspectorDestroy):
+        (WebCore):
+        (InspectorFrontendSettingsEfl):
+        (WebCore::InspectorFrontendSettingsEfl::getProperty):
+        (WebCore::InspectorFrontendSettingsEfl::setProperty):
+        (WebCore::InspectorClientEfl::InspectorClientEfl):
+        (WebCore::InspectorClientEfl::~InspectorClientEfl):
+        (WebCore::InspectorClientEfl::inspectorDestroyed):
+        (WebCore::InspectorClientEfl::openInspectorFrontend):
+        (WebCore::InspectorClientEfl::closeInspectorFrontend):
+        (WebCore::InspectorClientEfl::bringFrontendToFront):
+        (WebCore::InspectorClientEfl::sendMessageToFrontend):
+        (WebCore::InspectorClientEfl::releaseFrontendPage):
+        (WebCore::InspectorClientEfl::inspectorFilesPath):
+        (WebCore::InspectorFrontendClientEfl::InspectorFrontendClientEfl):
+        (WebCore::InspectorFrontendClientEfl::~InspectorFrontendClientEfl):
+        (WebCore::InspectorFrontendClientEfl::localizedStringsURL):
+        (WebCore::InspectorFrontendClientEfl::hiddenPanels):
+        (WebCore::InspectorFrontendClientEfl::bringToFront):
+        (WebCore::InspectorFrontendClientEfl::closeWindow):
+        (WebCore::InspectorFrontendClientEfl::inspectedURLChanged):
+        (WebCore::InspectorFrontendClientEfl::attachWindow):
+        (WebCore::InspectorFrontendClientEfl::detachWindow):
+        (WebCore::InspectorFrontendClientEfl::setAttachedWindowHeight):
+        (WebCore::InspectorFrontendClientEfl::destroyInspectorWindow):
+        * WebCoreSupport/InspectorClientEfl.h:
+        (WebCore):
+        (InspectorClientEfl):
+        (InspectorFrontendClientEfl):
+        (WebCore::InspectorFrontendClientEfl::disconnectInspectorClient):
+        * ewk/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_ewk_view_priv_new):
+        (ewk_view_web_inspector_show):
+        (ewk_view_web_inspector_close):
+        (ewk_view_web_inspector_view_get):
+        (ewk_view_web_inspector_view_set):
+        * ewk/ewk_view.h:
+
 2012-07-05  Kihong Kwon  <kihong.kwon@samsung.com>
 
         [EFL] Change class name from NotificationClientEfl to NotificationPresenterClientEfl.
index 7e29758..a0f1aac 100644 (file)
 #include "config.h"
 #include "InspectorClientEfl.h"
 
+#if ENABLE(INSPECTOR)
+#include "InspectorController.h"
 #include "NotImplemented.h"
 #include "PlatformString.h"
-
-using namespace WebCore;
+#include "ewk_view_private.h"
+#include <unistd.h>
 
 namespace WebCore {
 
+static void notifyWebInspectorDestroy(void* userData, Evas_Object* webview, void* eventInfo)
+{
+    InspectorFrontendClientEfl* inspectorFrontendClient = static_cast<InspectorFrontendClientEfl*>(userData);
+    if (inspectorFrontendClient)
+        inspectorFrontendClient->destroyInspectorWindow(true);
+}
+
+class InspectorFrontendSettingsEfl : public InspectorFrontendClientLocal::Settings {
+public:
+    virtual String getProperty(const String& name)
+    {
+        notImplemented();
+        return String();
+    }
+
+    virtual void setProperty(const String& name, const String& value)
+    {
+        notImplemented();
+    }
+};
+
+InspectorClientEfl::InspectorClientEfl(Evas_Object* webView)
+    : m_inspectedView(webView)
+    , m_inspectorView(0)
+    , m_frontendClient(0)
+{
+}
+
+InspectorClientEfl::~InspectorClientEfl()
+{
+    if (m_frontendClient) {
+        m_frontendClient->disconnectInspectorClient();
+        m_frontendClient = 0;
+    }
+}
+
 void InspectorClientEfl::inspectorDestroyed()
 {
+    closeInspectorFrontend();
     delete this;
 }
 
 void InspectorClientEfl::openInspectorFrontend(InspectorController*)
 {
-    notImplemented();
+    evas_object_smart_callback_call(m_inspectedView, "inspector,view,create", 0);
+
+    Evas_Object* inspectorView = ewk_view_web_inspector_view_get(m_inspectedView);
+    if (!inspectorView)
+        return;
+
+    m_inspectorView = inspectorView;
+
+    String inspectorUri = inspectorFilesPath();
+    ewk_view_uri_set(m_inspectorView, inspectorUri.utf8().data());
+
+    OwnPtr<InspectorFrontendClientEfl> frontendClient = adoptPtr(new InspectorFrontendClientEfl(m_inspectedView, m_inspectorView, this));
+    m_frontendClient = frontendClient.get();
+
+    InspectorController* controller = EWKPrivate::corePage(m_inspectorView)->inspectorController();
+    controller->setInspectorFrontendClient(frontendClient.release());
 }
 
 void InspectorClientEfl::closeInspectorFrontend()
 {
-    notImplemented();
+    if (m_frontendClient)
+        m_frontendClient->destroyInspectorWindow(false);
 }
 
 void InspectorClientEfl::bringFrontendToFront()
 {
-    notImplemented();
+    m_frontendClient->bringToFront();
 }
 
 void InspectorClientEfl::highlight()
@@ -58,21 +113,98 @@ void InspectorClientEfl::hideHighlight()
     notImplemented();
 }
 
-void InspectorClientEfl::populateSetting(const String&, String*)
+bool InspectorClientEfl::sendMessageToFrontend(const String& message)
+{
+    Page* frontendPage = EWKPrivate::corePage(m_inspectorView);
+    return doDispatchMessageOnFrontendPage(frontendPage, message);
+}
+
+void InspectorClientEfl::releaseFrontendPage()
+{
+    m_inspectorView = 0;
+    m_frontendClient = 0;
+}
+
+String InspectorClientEfl::inspectorFilesPath()
+{
+    String inspectorFilesPath = makeString("file://", WEB_INSPECTOR_INSTALL_DIR, "/inspector.html");
+    if (access(inspectorFilesPath.utf8().data(), R_OK)) // On success, zero is returned
+        inspectorFilesPath = makeString("file://", WEB_INSPECTOR_DIR, "/inspector.html");
+
+    return inspectorFilesPath;
+}
+
+InspectorFrontendClientEfl::InspectorFrontendClientEfl(Evas_Object* inspectedView, Evas_Object* inspectorView, InspectorClientEfl* inspectorClient)
+    : InspectorFrontendClientLocal(EWKPrivate::corePage(inspectedView)->inspectorController(), EWKPrivate::corePage(inspectorView), adoptPtr(new InspectorFrontendSettingsEfl()))
+    , m_inspectedView(inspectedView)
+    , m_inspectorView(inspectorView)
+    , m_inspectorClient(inspectorClient)
+{
+    evas_object_smart_callback_add(m_inspectorView, "inspector,view,destroy", notifyWebInspectorDestroy, this);
+}
+
+InspectorFrontendClientEfl::~InspectorFrontendClientEfl()
+{
+    evas_object_smart_callback_del(m_inspectorView, "inspector,view,destroy", notifyWebInspectorDestroy);
+
+    if (m_inspectorClient) {
+        m_inspectorClient->releaseFrontendPage();
+        m_inspectorClient = 0;
+    }
+}
+
+String InspectorFrontendClientEfl::localizedStringsURL()
+{
+    notImplemented();
+    return String();
+}
+
+String InspectorFrontendClientEfl::hiddenPanels()
+{
+    notImplemented();
+    return String();
+}
+
+void InspectorFrontendClientEfl::bringToFront()
 {
     notImplemented();
 }
 
-void InspectorClientEfl::storeSetting(const String&, const String&)
+void InspectorFrontendClientEfl::closeWindow()
+{
+    destroyInspectorWindow(true);
+}
+
+void InspectorFrontendClientEfl::inspectedURLChanged(const String&)
+{
+    notImplemented();
+}
+
+void InspectorFrontendClientEfl::attachWindow()
 {
     notImplemented();
 }
 
-bool InspectorClientEfl::sendMessageToFrontend(const String&)
+void InspectorFrontendClientEfl::detachWindow()
 {
     notImplemented();
-    return false;
 }
 
+void InspectorFrontendClientEfl::setAttachedWindowHeight(unsigned)
+{
+    notImplemented();
+}
+
+void InspectorFrontendClientEfl::destroyInspectorWindow(bool notifyInspectorController)
+{
+    if (notifyInspectorController)
+        EWKPrivate::corePage(m_inspectedView)->inspectorController()->disconnectFrontend();
+
+    if (m_inspectorClient)
+        m_inspectorClient->releaseFrontendPage();
+
+    evas_object_smart_callback_call(m_inspectedView, "inspector,view,close", m_inspectorView);
+}
 
 }
+#endif
index f92e94d..b6a078e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2007 Apple Inc.  All rights reserved.
  * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
  * Copyright (C) 2009-2010 ProFUSION embedded systems
- * Copyright (C) 2009-2010 Samsung Electronics
+ * Copyright (C) 2009-2012 Samsung Electronics
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #define InspectorClientEfl_h
 
 #include "InspectorClient.h"
+#include "InspectorFrontendClientLocal.h"
+#include <Evas.h>
 #include <wtf/Forward.h>
 
 namespace WebCore {
+class InspectorFrontendClientEfl;
 class Page;
 
-class InspectorClientEfl : public WebCore::InspectorClient {
+class InspectorClientEfl : public InspectorClient {
 public:
+    InspectorClientEfl(Evas_Object*);
+    ~InspectorClientEfl();
+
     virtual void inspectorDestroyed();
 
     virtual void openInspectorFrontend(InspectorController*);
@@ -49,10 +55,43 @@ public:
     virtual void highlight();
     virtual void hideHighlight();
 
-    virtual void populateSetting(const String& key, String* value);
-    virtual void storeSetting(const String& key, const String& value);
-
     virtual bool sendMessageToFrontend(const String&);
+
+    void releaseFrontendPage();
+    String inspectorFilesPath();
+
+private:
+    Evas_Object* m_inspectedView;
+    Evas_Object* m_inspectorView;
+    InspectorFrontendClientEfl* m_frontendClient;
+};
+
+class InspectorFrontendClientEfl : public InspectorFrontendClientLocal {
+public:
+    InspectorFrontendClientEfl(Evas_Object*, Evas_Object*, InspectorClientEfl*);
+    ~InspectorFrontendClientEfl();
+
+    virtual String localizedStringsURL();
+    virtual String hiddenPanels();
+
+    virtual void bringToFront();
+    virtual void closeWindow();
+
+    virtual void inspectedURLChanged(const String&);
+
+    virtual void attachWindow();
+    virtual void detachWindow();
+
+    virtual void setAttachedWindowHeight(unsigned);
+
+    void disconnectInspectorClient() { m_inspectorClient = 0; }
+    void destroyInspectorWindow(bool notifyInspectorController);
+
+private:
+    Evas_Object* m_inspectedView;
+    Evas_Object* m_inspectorView;
+    InspectorClientEfl* m_inspectorClient;
+
 };
 }
 
index 5f94a3c..a98769a 100644 (file)
@@ -41,6 +41,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InspectorClientEfl.h"
+#include "InspectorController.h"
 #include "IntSize.h"
 #include "JSDOMBinding.h"
 #include "JSDOMWindow.h"
@@ -344,6 +345,9 @@ struct _Ewk_View_Private_Data {
     SoupSession* soupSession;
     const char* cursorGroup;
     Evas_Object* cursorObject;
+#if ENABLE(INSPECTOR)
+    Evas_Object* inspectorView;
+#endif
 #ifdef HAVE_ECORE_X
     bool isUsingEcoreX;
 #endif
@@ -730,8 +734,9 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
     pageClients.chromeClient = new WebCore::ChromeClientEfl(smartData->self);
     pageClients.editorClient = new WebCore::EditorClientEfl(smartData->self);
     pageClients.dragClient = new WebCore::DragClientEfl;
-    pageClients.inspectorClient = new WebCore::InspectorClientEfl;
-
+#if ENABLE(INSPECTOR)
+    pageClients.inspectorClient = new WebCore::InspectorClientEfl(smartData->self);
+#endif
     priv->page = adoptPtr(new WebCore::Page(pageClients));
 
 #if ENABLE(DEVICE_ORIENTATION)
@@ -4362,6 +4367,48 @@ void ewk_view_setting_should_display_text_descriptions_set(Evas_Object *ewkView,
 #endif
 }
 
+void ewk_view_web_inspector_show(const Evas_Object* ewkView)
+{
+#if ENABLE(INSPECTOR)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    priv->page->inspectorController()->show();
+#endif
+}
+
+void ewk_view_web_inspector_close(const Evas_Object* ewkView)
+{
+#if ENABLE(INSPECTOR)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+    priv->page->inspectorController()->close();
+#endif
+}
+
+Evas_Object* ewk_view_web_inspector_view_get(const Evas_Object* ewkView)
+{
+#if ENABLE(INSPECTOR)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
+
+    return priv->inspectorView;
+#else
+    return 0;
+#endif
+}
+
+void ewk_view_web_inspector_view_set(Evas_Object* ewkView, Evas_Object* inspectorView)
+{
+#if ENABLE(INSPECTOR)
+    EWK_VIEW_SD_GET(ewkView, smartData);
+    EWK_VIEW_PRIV_GET(smartData, priv);
+
+    priv->inspectorView = inspectorView;
+#endif
+}
+
 #if USE(ACCELERATED_COMPOSITING)
 bool ewk_view_accelerated_compositing_object_create(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface, const WebCore::IntRect& rect)
 {
index f645f72..d5feb36 100644 (file)
@@ -46,6 +46,8 @@
  *  - "icon,received", void: main frame received an icon.
  *  - "inputmethod,changed", Eina_Bool: reports that input method was changed and
  *    it gives a boolean value whether it's enabled or not as an argument.
+ *  - "inspector,view,close", Evas_Object*: request to close the view for web inspector.
+ *  - "inspector,view,create", void: request to create the new view for web inspector.
  *  - "js,windowobject,clear", void: Report that the JS window object has been cleared.
  *  - "link,hover,in", const char *link[2]: reports mouse is over a link.
  *    It gives the url in link[0] and link's title in link[1] as an argument.
@@ -2644,6 +2646,53 @@ EAPI Eina_Bool    ewk_view_setting_web_audio_get(const Evas_Object *o);
  */
 EAPI Eina_Bool    ewk_view_setting_web_audio_set(Evas_Object *o, Eina_Bool enable);
 
+/**
+ * Show the web inspector to debug a web page.
+ *
+ * The following signals are emiited.
+ * "inspector,view,create" and "inspector,view,close"
+ * The first one will be called to request the view for web inspector on view that will be inspected.
+ * This callback should create the view for web inspector and set the view with ewk_view_web_inspector_view_set().
+ * The second one will be called to close the view for web inspector on view having the web inspector after disconnecting frontend
+ * This callback should remove the view for web inspector.
+ *
+ * When the view having the web inspector is removed,
+ * please emit the "inspector,view,destroy" signal on view for web inspector.
+ *
+ * @param o The view to show the web inspector.
+ *
+ * @see ewk_view_web_inspector_close()
+ * @see ewk_view_web_inspector_view_set()
+ */
+EAPI void ewk_view_web_inspector_show(const Evas_Object *o);
+
+/**
+ * Close the web inspector view
+ *
+ * @param o The view to close the web inspector.
+ *
+ * @see ewk_view_web_inspector_show()
+ * @see ewk_view_web_inspector_view_get()
+ */
+EAPI void ewk_view_web_inspector_close(const Evas_Object *o);
+
+/**
+ * Get the view of web inspector.
+ *
+ * @param o The view that is inspected.
+ *
+ * @return view object on success or @c 0 on failure
+ */
+EAPI Evas_Object* ewk_view_web_inspector_view_get(const Evas_Object *o);
+
+/**
+ * Set the view of web inspector.
+ *
+ * @param o The view that is inspected.
+ * @param inspector_view The view of web inspector.
+ */
+EAPI void ewk_view_web_inspector_view_set(Evas_Object *o, Evas_Object *inspector_view);
+
 #ifdef __cplusplus
 }
 #endif