diff options
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/WebCore/ChangeLog | 25 | ||||
| -rw-r--r-- | Source/WebCore/Target.pri | 6 | ||||
| -rw-r--r-- | Source/WebCore/bindings/js/ScriptControllerQt.cpp | 2 | ||||
| -rw-r--r-- | Source/WebCore/bridge/qt/qt_instance.cpp | 10 | ||||
| -rw-r--r-- | Source/WebCore/bridge/qt/qt_instance.h | 15 | ||||
| -rw-r--r-- | Source/WebCore/bridge/qt/qt_runtime.cpp | 2 | ||||
| -rw-r--r-- | Source/WebCore/bridge/qt/qt_runtime_qt4.cpp | 2 | ||||
| -rw-r--r-- | Source/WebKit/qt/Api/qwebframe.cpp | 36 | ||||
| -rw-r--r-- | Source/WebKit/qt/Api/qwebframe.h | 20 | ||||
| -rw-r--r-- | Source/WebKit/qt/ChangeLog | 19 | ||||
| -rw-r--r-- | Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp | 20 |
11 files changed, 102 insertions, 55 deletions
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index bfe50e01a..c52bf1a6c 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2012-06-13 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Remove dependency to QtScript for the Qt 5 build + https://bugs.webkit.org/show_bug.cgi?id=88993 + + Reviewed by Kenneth Rohde Christiansen. + + Replace the use of QScriptEngine::ValueOwnership with an enum local + to the class where it is used (QtInstance). + + * Target.pri: + * bindings/js/ScriptControllerQt.cpp: + (WebCore::ScriptController::createScriptInstanceForWidget): + * bridge/qt/qt_instance.cpp: + (JSC::Bindings::QtInstance::QtInstance): + (JSC::Bindings::QtInstance::~QtInstance): + (JSC::Bindings::QtInstance::getQtInstance): + * bridge/qt/qt_instance.h: + (QtInstance): + (JSC::Bindings::QtInstance::create): + * bridge/qt/qt_runtime.cpp: + (JSC::Bindings::convertQVariantToValue): + * bridge/qt/qt_runtime_qt4.cpp: + (JSC::Bindings::convertQVariantToValue): + 2012-06-01 Joe Thomas <joethomas@motorola.com> getComputedStyle for background shorthand property does not return background-origin and background-clip. diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index 3ee85e793..8d9457568 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -16,11 +16,7 @@ CONFIG += staticlib DEFINES += QT_MAKEDLL -haveQt(5) { - # Add a QtScript dependency for the time being, in order to pull in the include - # path for QtScript when it's built as a standalone module - QT += script -} else { +!haveQt(5) { INCLUDEPATH += $$PWD/../WTF/wtf/qt/compat } diff --git a/Source/WebCore/bindings/js/ScriptControllerQt.cpp b/Source/WebCore/bindings/js/ScriptControllerQt.cpp index 979a4f658..14e894256 100644 --- a/Source/WebCore/bindings/js/ScriptControllerQt.cpp +++ b/Source/WebCore/bindings/js/ScriptControllerQt.cpp @@ -59,7 +59,7 @@ PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWid if (!object) return 0; - return JSC::Bindings::QtInstance::getQtInstance(object, bindingRootObject(), QScriptEngine::QtOwnership); + return JSC::Bindings::QtInstance::getQtInstance(object, bindingRootObject(), JSC::Bindings::QtInstance::QtOwnership); } } diff --git a/Source/WebCore/bridge/qt/qt_instance.cpp b/Source/WebCore/bridge/qt/qt_instance.cpp index c79096d5a..14cec8036 100644 --- a/Source/WebCore/bridge/qt/qt_instance.cpp +++ b/Source/WebCore/bridge/qt/qt_instance.cpp @@ -90,7 +90,7 @@ QtRuntimeObject::QtRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, } // QtInstance -QtInstance::QtInstance(QObject* o, PassRefPtr<RootObject> rootObject, QScriptEngine::ValueOwnership ownership) +QtInstance::QtInstance(QObject* o, PassRefPtr<RootObject> rootObject, ValueOwnership ownership) : Instance(rootObject) , m_class(0) , m_object(o) @@ -113,20 +113,20 @@ QtInstance::~QtInstance() if (m_object) { switch (m_ownership) { - case QScriptEngine::QtOwnership: + case QtOwnership: break; - case QScriptEngine::AutoOwnership: + case AutoOwnership: if (m_object.data()->parent()) break; // fall through! - case QScriptEngine::ScriptOwnership: + case ScriptOwnership: delete m_object.data(); break; } } } -PassRefPtr<QtInstance> QtInstance::getQtInstance(QObject* o, PassRefPtr<RootObject> rootObject, QScriptEngine::ValueOwnership ownership) +PassRefPtr<QtInstance> QtInstance::getQtInstance(QObject* o, PassRefPtr<RootObject> rootObject, ValueOwnership ownership) { JSLock lock(SilenceAssertionsOnly); diff --git a/Source/WebCore/bridge/qt/qt_instance.h b/Source/WebCore/bridge/qt/qt_instance.h index 055623bfd..5502ca4f5 100644 --- a/Source/WebCore/bridge/qt/qt_instance.h +++ b/Source/WebCore/bridge/qt/qt_instance.h @@ -24,7 +24,6 @@ #include "runtime_root.h" #include <QStack> #include <QWeakPointer> -#include <QtScript/qscriptengine.h> #include <qhash.h> #include <qset.h> @@ -38,6 +37,12 @@ class QtRuntimeMetaMethod; class QtInstance : public Instance { public: + enum ValueOwnership { + QtOwnership, + ScriptOwnership, + AutoOwnership + }; + ~QtInstance(); virtual Class* getClass() const; @@ -63,7 +68,7 @@ public: QObject* getObject() const { return m_object.data(); } QObject* hashKey() const { return m_hashkey; } - static PassRefPtr<QtInstance> getQtInstance(QObject*, PassRefPtr<RootObject>, QScriptEngine::ValueOwnership ownership); + static PassRefPtr<QtInstance> getQtInstance(QObject*, PassRefPtr<RootObject>, ValueOwnership); virtual bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); virtual void put(JSObject*, ExecState*, PropertyName, JSValue, PutPropertySlot&); @@ -85,20 +90,20 @@ public: static QtSenderStack* qtSenderStack(); private: - static PassRefPtr<QtInstance> create(QObject *instance, PassRefPtr<RootObject> rootObject, QScriptEngine::ValueOwnership ownership) + static PassRefPtr<QtInstance> create(QObject *instance, PassRefPtr<RootObject> rootObject, ValueOwnership ownership) { return adoptRef(new QtInstance(instance, rootObject, ownership)); } friend class QtClass; friend class QtField; - QtInstance(QObject*, PassRefPtr<RootObject>, QScriptEngine::ValueOwnership ownership); // Factory produced only.. + QtInstance(QObject*, PassRefPtr<RootObject>, ValueOwnership); // Factory produced only.. mutable QtClass* m_class; QWeakPointer<QObject> m_object; QObject* m_hashkey; mutable QHash<QByteArray, WriteBarrier<JSObject> > m_methods; mutable QHash<QString, QtField*> m_fields; - QScriptEngine::ValueOwnership m_ownership; + ValueOwnership m_ownership; }; } // namespace Bindings diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index c403115bb..0b6fa681b 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -896,7 +896,7 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con QObject* obj = variant.value<QObject*>(); if (!obj) return jsNull(); - return QtInstance::getQtInstance(obj, root, QScriptEngine::QtOwnership)->createRuntimeObject(exec); + return QtInstance::getQtInstance(obj, root, QtInstance::QtOwnership)->createRuntimeObject(exec); } if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(variant.type()))) diff --git a/Source/WebCore/bridge/qt/qt_runtime_qt4.cpp b/Source/WebCore/bridge/qt/qt_runtime_qt4.cpp index 477df71b6..a079e455d 100644 --- a/Source/WebCore/bridge/qt/qt_runtime_qt4.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime_qt4.cpp @@ -896,7 +896,7 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con QObject* obj = variant.value<QObject*>(); if (!obj) return jsNull(); - return QtInstance::getQtInstance(obj, root, QScriptEngine::QtOwnership)->createRuntimeObject(exec); + return QtInstance::getQtInstance(obj, root, QtInstance::QtOwnership)->createRuntimeObject(exec); } if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(variant.type()))) diff --git a/Source/WebKit/qt/Api/qwebframe.cpp b/Source/WebKit/qt/Api/qwebframe.cpp index aba58db0c..a3a6ca9ce 100644 --- a/Source/WebKit/qt/Api/qwebframe.cpp +++ b/Source/WebKit/qt/Api/qwebframe.cpp @@ -499,7 +499,7 @@ static JSValueRef qtSenderCallback(JSContextRef context, JSObjectRef, JSObjectRe JSC::ExecState* exec = ::toJS(context); RefPtr<JSC::Bindings::RootObject> rootObject = JSC::Bindings::findRootObject(exec->dynamicGlobalObject()); - JSC::JSObject* jsSender = JSC::Bindings::QtInstance::getQtInstance(sender, rootObject, QScriptEngine::QtOwnership)->createRuntimeObject(exec); + JSC::JSObject* jsSender = JSC::Bindings::QtInstance::getQtInstance(sender, rootObject, JSC::Bindings::QtInstance::QtOwnership)->createRuntimeObject(exec); return ::toRef(jsSender); } @@ -628,30 +628,7 @@ QWebFrame::~QWebFrame() } /*! - Make \a object available under \a name from within the frame's JavaScript - context. The \a object will be inserted as a child of the frame's window - object. - - Qt properties will be exposed as JavaScript properties and slots as - JavaScript methods. - The interaction between C++ and JavaScript is explained in the documentation of the \l{The QtWebKit Bridge}{QtWebKit bridge}. - - If you want to ensure that your QObjects remain accessible after loading a - new URL, you should add them in a slot connected to the - javaScriptWindowObjectCleared() signal. - - If Javascript is not enabled for this page, then this method does nothing. - - The \a object will never be explicitly deleted by QtWebKit. -*/ -void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object) -{ - addToJavaScriptWindowObject(name, object, QScriptEngine::QtOwnership); -} - -/*! - \fn void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership own) - \overload + \fn void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, ValueOwnership own) Make \a object available under \a name from within the frame's JavaScript context. The \a object will be inserted as a child of the frame's window @@ -669,15 +646,20 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object The ownership of \a object is specified using \a own. */ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, ValueOwnership ownership) +#else void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership) +#endif { if (!page()->settings()->testAttribute(QWebSettings::JavascriptEnabled)) return; #if USE(JSC) + JSC::Bindings::QtInstance::ValueOwnership valueOwnership = static_cast<JSC::Bindings::QtInstance::ValueOwnership>(ownership); JSC::JSLock lock(JSC::SilenceAssertionsOnly); JSDOMWindow* window = toJSDOMWindow(d->frame, mainThreadNormalWorld()); JSC::Bindings::RootObject* root; - if (ownership == QScriptEngine::QtOwnership) + if (valueOwnership == JSC::Bindings::QtInstance::QtOwnership) root = d->frame->script()->cacheableBindingRootObject(); else root = d->frame->script()->bindingRootObject(); @@ -694,7 +676,7 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object JSC::ExecState* exec = window->globalExec(); JSC::JSObject* runtimeObject = - JSC::Bindings::QtInstance::getQtInstance(object, root, ownership)->createRuntimeObject(exec); + JSC::Bindings::QtInstance::getQtInstance(object, root, valueOwnership)->createRuntimeObject(exec); JSC::PutPropertySlot slot; window->methodTable()->put(window, exec, JSC::Identifier(&exec->globalData(), reinterpret_cast_ptr<const UChar*>(name.constData()), name.length()), runtimeObject, slot); diff --git a/Source/WebKit/qt/Api/qwebframe.h b/Source/WebKit/qt/Api/qwebframe.h index 0a8e6fc65..6d486d50e 100644 --- a/Source/WebKit/qt/Api/qwebframe.h +++ b/Source/WebKit/qt/Api/qwebframe.h @@ -25,10 +25,13 @@ #include <QtCore/qurl.h> #include <QtCore/qvariant.h> #include <QtGui/qicon.h> -#include <QtScript/qscriptengine.h> #include <QtNetwork/qnetworkaccessmanager.h> #include "qwebkitglobal.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include <QtScript/qscriptengine.h> +#endif + QT_BEGIN_NAMESPACE class QRect; class QPoint; @@ -121,6 +124,14 @@ private: ~QWebFrame(); public: +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + enum ValueOwnership { + QtOwnership, + ScriptOwnership, + AutoOwnership + }; +#endif + QWebPage *page() const; void load(const QUrl &url); @@ -128,8 +139,11 @@ public: void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); - void addToJavaScriptWindowObject(const QString &name, QObject *object); - void addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership); +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + void addToJavaScriptWindowObject(const QString &name, QObject *object, ValueOwnership ownership = QtOwnership); +#else + void addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership = QScriptEngine::QtOwnership); +#endif QString toHtml() const; QString toPlainText() const; QString renderTreeDump() const; diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog index 7fef898b3..417953d1f 100644 --- a/Source/WebKit/qt/ChangeLog +++ b/Source/WebKit/qt/ChangeLog @@ -1,3 +1,22 @@ +2012-06-13 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Remove dependency to QtScript for the Qt 5 build + https://bugs.webkit.org/show_bug.cgi?id=88993 + + Reviewed by Kenneth Rohde Christiansen. + + When building against Qt 5, replace the use of QScriptEngine::ValueOwnership with + a (compatible) QWebFrame::ValueOwnership enum. + + * Api/qwebframe.cpp: + (qtSenderCallback): + (QWebFrame::addToJavaScriptWindowObject): + * Api/qwebframe.h: + * tests/qobjectbridge/tst_qobjectbridge.cpp: + (tst_QObjectBridge::arrayObjectEnumerable): + (tst_QObjectBridge::ownership): + (tst_QObjectBridge::qObjectWrapperWithSameIdentity): + 2012-06-01 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> [Qt] Move QObject bridge related tests from tst_qwebframe to tst_qobjectbridge diff --git a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp index 32e8233ea..8b7eb4af8 100644 --- a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp +++ b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp @@ -37,6 +37,12 @@ Q_DECLARE_METATYPE(Qt::BrushStyle) Q_DECLARE_METATYPE(QVariantList) Q_DECLARE_METATYPE(QVariantMap) +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#define OwnershipClass QWebFrame +#else +#define OwnershipClass QScriptEngine +#endif + class MyQObject : public QObject { Q_OBJECT @@ -1996,7 +2002,7 @@ void tst_QObjectBridge::arrayObjectEnumerable() QWebPage page; QWebFrame* frame = page.mainFrame(); QObject* qobject = new StringListTestObject(); - frame->addToJavaScriptWindowObject("test", qobject, QScriptEngine::ScriptOwnership); + frame->addToJavaScriptWindowObject("test", qobject, OwnershipClass::ScriptOwnership); const QString script("var stringArray = test.stringList();" "var result = '';" @@ -2037,7 +2043,7 @@ void tst_QObjectBridge::ownership() { QWebPage page; QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", ptr.data(), QScriptEngine::ScriptOwnership); + frame->addToJavaScriptWindowObject("test", ptr.data(), OwnershipClass::ScriptOwnership); } QVERIFY(!ptr); } @@ -2048,7 +2054,7 @@ void tst_QObjectBridge::ownership() { QWebPage page; QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", ptr.data(), QScriptEngine::QtOwnership); + frame->addToJavaScriptWindowObject("test", ptr.data(), OwnershipClass::QtOwnership); } QVERIFY(ptr.data() == before); delete ptr.data(); @@ -2058,7 +2064,7 @@ void tst_QObjectBridge::ownership() QObject* child = new QObject(parent); QWebPage page; QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", child, QScriptEngine::QtOwnership); + frame->addToJavaScriptWindowObject("test", child, OwnershipClass::QtOwnership); QVariant v = frame->evaluateJavaScript("test"); QCOMPARE(qvariant_cast<QObject*>(v), child); delete parent; @@ -2071,7 +2077,7 @@ void tst_QObjectBridge::ownership() { QWebPage page; QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", ptr.data(), QScriptEngine::AutoOwnership); + frame->addToJavaScriptWindowObject("test", ptr.data(), OwnershipClass::AutoOwnership); } // no parent, so it should be like ScriptOwnership QVERIFY(!ptr); @@ -2083,7 +2089,7 @@ void tst_QObjectBridge::ownership() { QWebPage page; QWebFrame* frame = page.mainFrame(); - frame->addToJavaScriptWindowObject("test", child.data(), QScriptEngine::AutoOwnership); + frame->addToJavaScriptWindowObject("test", child.data(), OwnershipClass::AutoOwnership); } // has parent, so it should be like QtOwnership QVERIFY(child); @@ -2125,7 +2131,7 @@ void tst_QObjectBridge::qObjectWrapperWithSameIdentity() QWebFrame* mainFrame = m_view->page()->mainFrame(); QCOMPARE(mainFrame->toPlainText(), QString("test")); - mainFrame->addToJavaScriptWindowObject("test", new TestFactory, QScriptEngine::ScriptOwnership); + mainFrame->addToJavaScriptWindowObject("test", new TestFactory, OwnershipClass::ScriptOwnership); mainFrame->evaluateJavaScript("triggerBug();"); QCOMPARE(mainFrame->toPlainText(), QString("test1")); |
