[Qt] Add a way to have experimental features in WebKit2
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2011 13:19:06 +0000 (13:19 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2011 13:19:06 +0000 (13:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67707

Reviewed by Kenneth Rohde Christiansen.

.:

Add the new private QML module in the build.

* Source/QtWebKit.pro:

Source/WebKit/qt:

This patch is adding a new module for accessing private
method and property from the view. It requires an import
QtWebKit.private in QML to be used.

* declarative/private/plugin.cpp: Added.
(WebKitQmlPluginPrivate::registerTypes):
* declarative/private/private.pro: Added.
* declarative/private/qmldir: Added.

Source/WebKit2:

Add new QML extensions for our public view. This extension
returns the private object of the view so that the user could
use unstable/unreleased APIs. This requires our private class
to be exported and QObject subclass.

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebviewprivateextension.cpp: Added.
(QQuickWebViewPrivateExtension::QQuickWebViewPrivateExtension):
(QQuickWebViewPrivateExtension::viewPrivate):
* UIProcess/API/qt/qquickwebviewprivateextension_p.h: Added.

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

12 files changed:
ChangeLog
Source/QtWebKit.pro
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/declarative/private/plugin.cpp [new file with mode: 0644]
Source/WebKit/qt/declarative/private/private.pro [new file with mode: 0644]
Source/WebKit/qt/declarative/private/qmldir [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
Source/WebKit2/UIProcess/API/qt/qquickwebviewprivateextension.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/qquickwebviewprivateextension_p.h [new file with mode: 0644]

index 36ea36c..32c4f3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-11-11  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Add a way to have experimental features in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=67707
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add the new private QML module in the build.
+
+        * Source/QtWebKit.pro:
+
 2011-11-10  Balazs Kelemen  <kbalazs@webkit.org>
 
         [Qt] X11 plugins need to be reworked for Qt5
index cf12785..710cfd3 100644 (file)
@@ -18,6 +18,9 @@ SUBDIRS += api
 include(WebKit/qt/docs/docs.pri)
 
 SUBDIRS += WebKit/qt/declarative
+haveQt(5) {
+    SUBDIRS += WebKit/qt/declarative/private
+}
 
 tests.file = tests.pri
 SUBDIRS += tests
index e8386af..d55029f 100644 (file)
@@ -1,3 +1,19 @@
+2011-11-11  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Add a way to have experimental features in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=67707
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch is adding a new module for accessing private
+        method and property from the view. It requires an import
+        QtWebKit.private in QML to be used.
+
+        * declarative/private/plugin.cpp: Added.
+        (WebKitQmlPluginPrivate::registerTypes):
+        * declarative/private/private.pro: Added.
+        * declarative/private/qmldir: Added.
+
 2011-11-11  Simon Hausmann  <simon.hausmann@nokia.com>
 
         [Qt][WK2] Remove QWebNavigationController
diff --git a/Source/WebKit/qt/declarative/private/plugin.cpp b/Source/WebKit/qt/declarative/private/plugin.cpp
new file mode 100644 (file)
index 0000000..6b11344
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#include "qquickwebpage.h"
+#include "qquickwebview.h"
+#include "qquickwebview_p.h"
+#include "qquickwebviewprivateextension_p.h"
+
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+
+QT_BEGIN_NAMESPACE
+
+class WebKitQmlPluginPrivate : public QDeclarativeExtensionPlugin {
+    Q_OBJECT
+public:
+    virtual void registerTypes(const char* uri)
+    {
+        Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit.private"));
+        qmlRegisterExtendedType<QQuickWebView, QQuickWebViewPrivateExtension>(uri, 3, 0, "WebView");
+        qmlRegisterUncreatableType<QQuickWebViewPrivate>(uri, 3, 0, "WebViewPrivate", QObject::tr("Cannot create separate instance of WebViewPrivate"));
+    }
+};
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qmlwebkitpluginprivate, QT_PREPEND_NAMESPACE(WebKitQmlPluginPrivate));
diff --git a/Source/WebKit/qt/declarative/private/private.pro b/Source/WebKit/qt/declarative/private/private.pro
new file mode 100644 (file)
index 0000000..886b73b
--- /dev/null
@@ -0,0 +1,54 @@
+# -------------------------------------------------------------------
+# Project file for the QtWebKit QML private plugin
+#
+# See 'Tools/qmake/README' for an overview of the build system
+# -------------------------------------------------------------------
+
+TEMPLATE = lib
+TARGET  = qmlwebkitprivateplugin
+
+TARGET.module_name = QtWebKit/private
+
+CONFIG += qt plugin
+
+win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release
+
+QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir
+copy2build.input = QMLDIRFILE
+copy2build.output = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name}/qmldir
+!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS
+copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+copy2build.name = COPY ${QMAKE_FILE_IN}
+copy2build.CONFIG += no_link
+QMAKE_EXTRA_COMPILERS += copy2build
+
+TARGET = $$qtLibraryTarget($$TARGET)
+contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
+
+wince*:LIBS += $$QMAKE_LIBS_GUI
+
+load(javascriptcore)
+load(webcore)
+load(webkit2)
+CONFIG += qtwebkit
+
+QT += declarative widgets network
+
+DESTDIR = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name}
+
+CONFIG += rpath
+RPATHDIR_RELATIVE_TO_DESTDIR = ../../lib
+
+SOURCES += plugin.cpp
+
+DEFINES += HAVE_WEBKIT2
+INCLUDEPATH += ../../../../WebKit2/UIProcess/API/qt
+
+target.path = $$[QT_INSTALL_IMPORTS]/$${TARGET.module_name}
+
+
+qmldir.files += $$PWD/qmldir
+qmldir.path +=  $$[QT_INSTALL_IMPORTS]/$${TARGET.module_name}
+
+INSTALLS += target qmldir
+
diff --git a/Source/WebKit/qt/declarative/private/qmldir b/Source/WebKit/qt/declarative/private/qmldir
new file mode 100644 (file)
index 0000000..9dc8b0e
--- /dev/null
@@ -0,0 +1 @@
+plugin qmlwebkitprivateplugin
index c5a386d..c6ea6b4 100644 (file)
@@ -1,3 +1,23 @@
+2011-11-11  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Add a way to have experimental features in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=67707
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add new QML extensions for our public view. This extension
+        returns the private object of the view so that the user could
+        use unstable/unreleased APIs. This requires our private class
+        to be exported and QObject subclass.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qquickwebviewprivateextension.cpp: Added.
+        (QQuickWebViewPrivateExtension::QQuickWebViewPrivateExtension):
+        (QQuickWebViewPrivateExtension::viewPrivate):
+        * UIProcess/API/qt/qquickwebviewprivateextension_p.h: Added.
+
 2011-11-11  Simon Hausmann  <simon.hausmann@nokia.com>
 
         [Qt][WK2] Remove QWebNavigationController
index 9c5911e..ad13b3f 100644 (file)
@@ -247,6 +247,7 @@ HEADERS += \
     UIProcess/API/qt/qquickwebpage_p.h \
     UIProcess/API/qt/qquickwebview.h \
     UIProcess/API/qt/qquickwebview_p.h \
+    UIProcess/API/qt/qquickwebviewprivateextension_p.h \
     UIProcess/Authentication/AuthenticationChallengeProxy.h \
     UIProcess/Authentication/AuthenticationDecisionListener.h \
     UIProcess/Authentication/WebCredential.h \
@@ -546,6 +547,7 @@ SOURCES += \
     UIProcess/API/qt/qquickwebpage.cpp \
     UIProcess/API/qt/qquickwebview.cpp \
     UIProcess/API/qt/qwebpreferences.cpp \
+    UIProcess/API/qt/qquickwebviewprivateextension.cpp \
     UIProcess/Authentication/AuthenticationChallengeProxy.cpp \
     UIProcess/Authentication/AuthenticationDecisionListener.cpp \
     UIProcess/Authentication/WebCredential.cpp \
index b0a85c1..12307b2 100644 (file)
@@ -495,3 +495,4 @@ WKPageRef QQuickWebView::pageRef() const
 }
 
 #include "moc_qquickwebview.cpp"
+#include "moc_qquickwebview_p.cpp"
index defb36a..a33fc68 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "qquickwebview.h"
 
+#include <QtCore/QObject>
 #include <QtCore/QScopedPointer>
 
 class QWebNavigationController;
@@ -37,7 +38,8 @@ QT_BEGIN_NAMESPACE
 class QFileDialog;
 QT_END_NAMESPACE
 
-class QWEBKIT_EXPORT QQuickWebViewPrivate : public WebKit::QtPolicyInterface {
+class QWEBKIT_EXPORT QQuickWebViewPrivate : public QObject, public WebKit::QtPolicyInterface {
+    Q_OBJECT
     Q_DECLARE_PUBLIC(QQuickWebView)
 public:
     QQuickWebViewPrivate();
@@ -54,7 +56,6 @@ public:
     void scrollPositionRequested(const QPoint& pos);
     void updateViewportSize();
     void updateViewportConstraints();
-    void setUseTraditionalDesktopBehaviour(bool enable);
 
     static QQuickWebViewPrivate* get(QQuickWebView* view)
     {
@@ -76,6 +77,10 @@ public:
     QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
     void didChangeViewportProperties(const WebCore::ViewportArguments& args);
 
+public slots:
+    void setUseTraditionalDesktopBehaviour(bool enable);
+
+private:
     QScopedPointer<QQuickWebPage> pageView;
     QScopedPointer<WebKit::QtViewInterface> viewInterface;
     QScopedPointer<QtViewportInteractionEngine> interactionEngine;
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebviewprivateextension.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebviewprivateextension.cpp
new file mode 100644 (file)
index 0000000..7ac4395
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qquickwebviewprivateextension_p.h"
+
+#include "qquickwebpage.h"
+#include "qquickwebview.h"
+#include "qquickwebview_p.h"
+
+QQuickWebViewPrivateExtension::QQuickWebViewPrivateExtension(QObject* parent)
+    : QObject(parent)
+{
+}
+
+QQuickWebViewPrivate* QQuickWebViewPrivateExtension::viewPrivate()
+{
+    return QQuickWebViewPrivate::get(static_cast<QQuickWebView*>(parent()));
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebviewprivateextension_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebviewprivateextension_p.h
new file mode 100644 (file)
index 0000000..1066552
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickwebviewprivateextension_p_h
+#define qquickwebviewprivateextension_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QObject>
+
+class QQuickWebViewPrivate;
+
+class QWEBKIT_EXPORT QQuickWebViewPrivateExtension : public QObject {
+    Q_OBJECT
+    Q_PROPERTY(QQuickWebViewPrivate* privateObject READ viewPrivate CONSTANT FINAL)
+public:
+    QQuickWebViewPrivateExtension(QObject *parent = 0);
+    QQuickWebViewPrivate* viewPrivate();
+};
+
+#endif // qquickwebviewprivateextension_p_h