summaryrefslogtreecommitdiff
path: root/Source/WebKit/qt/Api/qwebframe.cpp
diff options
context:
space:
mode:
authorhausmann@webkit.org <hausmann@webkit.org>2012-06-13 13:37:54 +0000
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-13 16:11:58 +0200
commit0001dcd3a2d67fe8832562746a293754a9a8d7a0 (patch)
tree115a06aa0f07dfefa0d5bc34f1465c8b16139143 /Source/WebKit/qt/Api/qwebframe.cpp
parent0bb233d1f7c4317bb772d72cc3f92cbcdb4027de (diff)
downloadqtwebkit-0001dcd3a2d67fe8832562746a293754a9a8d7a0.tar.gz
Remove dependency to QtScript for the Qt 5 build https://bugs.webkit.org/show_bug.cgi?id=88993
Reviewed by Kenneth Rohde Christiansen. Source/WebCore: 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): Source/WebKit/qt: 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Diffstat (limited to 'Source/WebKit/qt/Api/qwebframe.cpp')
-rw-r--r--Source/WebKit/qt/Api/qwebframe.cpp36
1 files changed, 9 insertions, 27 deletions
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);