[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 11:24:49 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5641bbdbf3170c7b1c1d0a33c7de9f7205cf1d9a
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jul 22 17:02:14 2010 +0000

    2010-07-22  Jamey Hicks  <jamey.hicks at nokia.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Enable binding of QObjects to JavaScript environment for inspector frontend
    
            This patch enables QObjects to be bound to global variables in the
            javascript environment of the inspector frontend. This is useful
            for writing alternate inspector frontends in javascript which need
            additional native functionality. It's a lighter-weight alternative
            than using an NPAPI plugin.
    
            The code which instantiates QWebInspector uses this by setting the
            dynamic property "q_inspectorJavaScriptWindowObjects" on the
            QWebInspector. The value of this property should be a
            QMap<QString,QVariant> mapping global variable name to QObject.
    
            I have used this to add support for eclipse/chrome remote
            debugging in QtTestBrowser.
    
            https://bugs.webkit.org/show_bug.cgi?id=41995
    
            * WebCoreSupport/InspectorClientQt.cpp:
            (WebCore::InspectorClientWebPage::InspectorClientWebPage):
            (WebCore::InspectorClientWebPage::javaScriptWindowObjectCleared):
            (WebCore::InspectorClientQt::openInspectorFrontend):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63899 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index e22ae1b..e5cf357 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,30 @@
+2010-07-22  Jamey Hicks  <jamey.hicks at nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Enable binding of QObjects to JavaScript environment for inspector frontend
+
+        This patch enables QObjects to be bound to global variables in the
+        javascript environment of the inspector frontend. This is useful
+        for writing alternate inspector frontends in javascript which need
+        additional native functionality. It's a lighter-weight alternative
+        than using an NPAPI plugin.
+ 
+        The code which instantiates QWebInspector uses this by setting the
+        dynamic property "q_inspectorJavaScriptWindowObjects" on the
+        QWebInspector. The value of this property should be a
+        QMap<QString,QVariant> mapping global variable name to QObject.
+
+        I have used this to add support for eclipse/chrome remote
+        debugging in QtTestBrowser.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41995
+
+        * WebCoreSupport/InspectorClientQt.cpp:
+        (WebCore::InspectorClientWebPage::InspectorClientWebPage):
+        (WebCore::InspectorClientWebPage::javaScriptWindowObjectCleared):
+        (WebCore::InspectorClientQt::openInspectorFrontend):
+
 2010-07-22  Simon Hausmann  <simon.hausmann at nokia.com>
 
         [Qt] Library versioning.
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index 2cc7e50..e13f6c3 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -44,6 +44,7 @@
 #include "qwebview.h"
 #include <QtCore/QCoreApplication>
 #include <QtCore/QSettings>
+#include <QtCore/QVariant>
 
 namespace WebCore {
 
@@ -60,6 +61,7 @@ public:
     InspectorClientWebPage(QObject* parent = 0)
         : QWebPage(parent)
     {
+        connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(javaScriptWindowObjectCleared()));
     }
 
     QWebPage* createWindow(QWebPage::WebWindowType)
@@ -70,6 +72,25 @@ public:
         view->setAttribute(Qt::WA_DeleteOnClose);
         return page;
     }
+
+public slots:
+    void javaScriptWindowObjectCleared() 
+    {
+#ifndef QT_NO_PROPERTIES
+        QVariant inspectorJavaScriptWindowObjects = property("_q_inspectorJavaScriptWindowObjects");
+        if (!inspectorJavaScriptWindowObjects.isValid())
+            return;
+        QMap<QString, QVariant> javaScriptNameObjectMap = inspectorJavaScriptWindowObjects.toMap();
+        QWebFrame* frame = mainFrame();
+        QMap<QString, QVariant>::const_iterator it = javaScriptNameObjectMap.constBegin();
+        for ( ; it != javaScriptNameObjectMap.constEnd(); ++it) {
+            QString name = it.key();
+            QVariant value = it.value();
+            QObject* obj = value.value<QObject*>();
+            frame->addToJavaScriptWindowObject(name, obj);
+        }
+#endif
+    }
 };
 
 InspectorClientQt::InspectorClientQt(QWebPage* page)
@@ -100,6 +121,12 @@ void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*)
 #endif
     if (!inspectorUrl.isValid())
         inspectorUrl = QUrl("qrc:/webkit/inspector/inspector.html");
+
+#ifndef QT_NO_PROPERTIES
+    QVariant inspectorJavaScriptWindowObjects = inspector->property("_q_inspectorJavaScriptWindowObjects");
+    if (inspectorJavaScriptWindowObjects.isValid())
+        inspectorPage->setProperty("_q_inspectorJavaScriptWindowObjects", inspectorJavaScriptWindowObjects);
+#endif
     inspectorView->page()->mainFrame()->load(inspectorUrl);
     m_inspectedWebPage->d->inspectorFrontend = inspectorView;
     inspector->d->setFrontend(inspectorView);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list