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

andreas.kling at nokia.com andreas.kling at nokia.com
Wed Dec 22 13:20:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d2ffdf2ab52cab51a72f1859f98b08ff69151066
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 11 17:06:57 2010 +0000

    2010-09-11  Vlad Burlik  <volodimir.burlik at nokia.com>
    
            Reviewed by Andreas Kling.
    
            [Qt] V8 port for QT platform: QT API implementation changes
            https://bugs.webkit.org/show_bug.cgi?id=45148
    
            V8 Implementation of QWebFrame::addToJavaScriptWindowObject()
            and QWebFrame::evaluateJavaScript()
    
            * Api/qwebelement.cpp:
            (setupScriptContext): JSC and V8 variations
            (QWebElement::evaluateJavaScript):
            * Api/qwebelement.h:
            * Api/qwebframe.cpp: QObject injection to V8 world
            (QWebFrame::addToJavaScriptWindowObject):
            (QWebFrame::evaluateJavaScript):
            * Api/qwebpage.cpp: Use ScriptController type definitions instead of direct references to JSC or V8
            (QWebPagePrivate::QWebPagePrivate):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67301 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp
index f7b1188..4a8beea 100644
--- a/WebKit/qt/Api/qwebelement.cpp
+++ b/WebKit/qt/Api/qwebelement.cpp
@@ -31,23 +31,33 @@
 #include "FrameView.h"
 #include "GraphicsContext.h"
 #include "HTMLElement.h"
+#if USE(JSC)
 #include "JSGlobalObject.h"
 #include "JSHTMLElement.h"
 #include "JSObject.h"
-#include "NodeList.h"
 #include "PropertyNameArray.h"
+#include <parser/SourceCode.h>
+#include "qt_runtime.h"
+#elif USE(V8)
+#include "V8DOMWindow.h"
+#include "V8Binding.h"
+#include "qt_instancev8.h"
+#endif
+#include "NodeList.h"
 #include "RenderImage.h"
 #include "StaticNodeList.h"
-#include "qt_runtime.h"
 #include "qwebframe.h"
 #include "qwebframe_p.h"
 #include "runtime_root.h"
-#include <parser/SourceCode.h>
 #include <wtf/Vector.h>
 #include <wtf/text/CString.h>
 
 #include <QPainter>
 
+#if USE(V8)
+using namespace V8::Bindings;
+#endif
+
 using namespace WebCore;
 
 class QWebElementPrivate {
@@ -694,6 +704,7 @@ QWebFrame *QWebElement::webFrame() const
     return QWebFramePrivate::kit(frame);
 }
 
+#if USE(JSC)
 static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValue, ScriptState*& state, ScriptController*& scriptController)
 {
     if (!element)
@@ -721,6 +732,26 @@ static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValu
 
     return true;
 }
+#elif USE(V8)
+static bool setupScriptContext(WebCore::Element* element, v8::Handle<v8::Value>& thisValue, ScriptState*& state, ScriptController*& scriptController)
+{
+    if (!element)
+        return false;
+
+    Document* document = element->document();
+    if (!document)
+        return false;
+
+    Frame* frame = document->frame();
+    if (!frame)
+        return false;
+
+    state = mainWorldScriptState(frame);
+    // Get V8 wrapper for DOM element
+    thisValue = toV8(frame->domWindow());
+    return true;
+}
+#endif
 
 
 /*!
@@ -732,12 +763,16 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
         return QVariant();
 
     ScriptState* state = 0;
+#if USE(JSC)
     JSC::JSValue thisValue;
+#elif USE(V8)
+    v8::Handle<v8::Value> thisValue;
+#endif
     ScriptController* scriptController = 0;
 
     if (!setupScriptContext(m_element, thisValue, state, scriptController))
         return QVariant();
-
+#if USE(JSC)
     JSC::ScopeChain& scopeChain = state->dynamicGlobalObject()->globalScopeChain();
     JSC::UString script(reinterpret_cast_ptr<const UChar*>(scriptSource.data()), scriptSource.length());
     JSC::Completion completion = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue);
@@ -750,6 +785,26 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
 
     int distance = 0;
     return JSC::Bindings::convertValueToQVariant(state, result, QMetaType::Void, &distance);
+#elif USE(V8)
+    // Create scope handler
+    v8::HandleScope hs;
+    // Get proxy from scriptcontroller
+    V8Proxy* proxy = scriptController->proxy();
+    // Ask the context from proxy
+    v8::Handle<v8::Context> context = proxy->context();
+    if (context.IsEmpty())
+        return QVariant();
+
+    // Create scope for the context
+    v8::Context::Scope scope(context);
+    v8::Local<v8::Value> object = proxy->evaluate(ScriptSourceCode(scriptSource), static_cast<Node*>(m_element));
+
+    if (object.IsEmpty())
+        return QVariant();
+    String result = v8ValueToWebCoreString(object);
+    int distance = 0;
+    return V8::Bindings::convertValueToQVariant(object, QMetaType::Void, &distance);
+#endif
 }
 
 /*!
diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h
index c488d12..b94c372 100644
--- a/WebKit/qt/Api/qwebelement.h
+++ b/WebKit/qt/Api/qwebelement.h
@@ -32,11 +32,20 @@ namespace WebCore {
     class Node;
 }
 
-namespace JSC {
-namespace Bindings {
+
+#if defined(WTF_USE_V8) && WTF_USE_V8
+namespace V8 {
+    namespace Bindings {
     class QtWebElementRuntime;
+    }
 }
+#else
+namespace JSC {
+    namespace Bindings {
+    class QtWebElementRuntime;
+    }
 }
+#endif
 
 QT_BEGIN_NAMESPACE
 class QPainter;
@@ -160,7 +169,12 @@ private:
     friend class QWebHitTestResult;
     friend class QWebHitTestResultPrivate;
     friend class QWebPage;
+
+#if defined(WTF_USE_V8) && WTF_USE_V8
+    friend class V8::Bindings::QtWebElementRuntime;
+#else
     friend class JSC::Bindings::QtWebElementRuntime;
+#endif
 
     QWebElementPrivate* d;
     WebCore::Element* m_element;
diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp
index ef24666..bc8afdf 100644
--- a/WebKit/qt/Api/qwebframe.cpp
+++ b/WebKit/qt/Api/qwebframe.cpp
@@ -21,8 +21,12 @@
 #include "config.h"
 #include "qwebframe.h"
 
+#if USE(JSC)
 #include "Bridge.h"
 #include "CallFrame.h"
+#elif USE(V8)
+#include "V8Binding.h"
+#endif
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "DragData.h"
@@ -32,23 +36,34 @@
 #include "FrameLoaderClientQt.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#if USE(JSC)
 #include "GCController.h"
+#elif USE(V8)
+#include "V8GCController.h"
+#endif
 #include "GraphicsContext.h"
 #include "HTMLMetaElement.h"
 #include "HitTestResult.h"
 #include "HTTPParsers.h"
 #include "IconDatabase.h"
 #include "InspectorController.h"
+#if USE(JSC)
 #include "JSDOMBinding.h"
 #include "JSDOMWindowBase.h"
 #include "JSLock.h"
 #include "JSObject.h"
+#elif USE(V8)
+#include "V8DOMWrapper.h"
+#include "V8DOMWindowShell.h"
+#endif
 #include "NodeList.h"
 #include "Page.h"
 #include "PlatformMouseEvent.h"
 #include "PlatformWheelEvent.h"
 #include "PrintContext.h"
+#if USE(JSC)
 #include "PutPropertySlot.h"
+#endif
 #include "RenderLayer.h"
 #include "RenderTreeAsText.h"
 #include "RenderView.h"
@@ -64,8 +79,13 @@
 #include "TiledBackingStore.h"
 #include "htmlediting.h"
 #include "markup.h"
+#if USE(JSC)
 #include "qt_instance.h"
 #include "qt_runtime.h"
+#elif USE(V8)
+#include "qt_instancev8.h"
+#include "qt_runtimev8.h"
+#endif
 #include "qwebelement.h"
 #include "qwebframe_p.h"
 #include "qwebpage.h"
@@ -74,8 +94,10 @@
 #include "qwebsecurityorigin_p.h"
 #include "qwebscriptworld.h"
 #include "qwebscriptworld_p.h"
+#if USE(JSC)
 #include "runtime_object.h"
 #include "runtime_root.h"
+#endif
 #include "wtf/HashMap.h"
 #include <QMultiMap>
 #include <qdebug.h>
@@ -476,7 +498,7 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object
 {
     if (!page()->settings()->testAttribute(QWebSettings::JavascriptEnabled))
         return;
-
+#if USE(JSC)
     JSC::JSLock lock(JSC::SilenceAssertionsOnly);
     JSDOMWindow* window = toJSDOMWindow(d->frame, mainThreadNormalWorld());
     JSC::Bindings::RootObject* root;
@@ -497,6 +519,24 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object
 
     JSC::PutPropertySlot slot;
     window->put(exec, JSC::Identifier(exec, reinterpret_cast_ptr<const UChar*>(name.constData()), name.length()), runtimeObject, slot);
+#elif USE(V8)
+    // Publish QObject in v8 isolated context
+    v8::HandleScope handlescope;
+    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(d->frame);
+    if (v8Context.IsEmpty())
+        return;
+    v8::Context::Scope conxtextscope(v8Context);
+    v8::Handle<v8::Value> windowValue = v8Context->Global()->Get(v8::String::New("window"));
+    v8::Handle<v8::Object> dest = 
+        (windowValue.IsEmpty() || !windowValue->IsObject()) ? v8Context->Global() : windowValue->ToObject();
+    dest->Set(v8::String::New(
+        name.toLatin1().constData()), 
+        V8::Bindings::QtInstance::getQtInstance(
+                object, 
+                v8Context, 
+                name, // have to pass name for v8::FunctionTemplate
+                ownership)->getV8Object());
+#endif
 }
 
 /*!
@@ -1393,9 +1433,22 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource)
     ScriptController *proxy = d->frame->script();
     QVariant rc;
     if (proxy) {
-        JSC::JSValue v = d->frame->script()->executeScript(ScriptSourceCode(scriptSource)).jsValue();
         int distance = 0;
+#if USE(JSC)
+        JSC::JSValue v = d->frame->script()->executeScript(ScriptSourceCode(scriptSource)).jsValue();
+
         rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject(mainThreadNormalWorld())->globalExec(), v, QMetaType::Void, &distance);
+#elif USE(V8)
+        v8::HandleScope handlescope;
+        // Get context from the frame
+        v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(d->frame);
+        if (v8Context.IsEmpty())
+            return rc;
+        // Get root object for the context
+        v8::Context::Scope conxtextscope(v8Context);
+        v8::Handle<v8::Value> v = v8::Script::Compile(v8::String::New(scriptSource.toLatin1().constData()))->Run();
+        rc = V8::Bindings::convertValueToQVariant(v, QMetaType::Void, &distance);
+#endif
     }
     return rc;
 }
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index a81ff56..75850fa 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -263,7 +263,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     , inspectorIsInternalOnly(false)
 {
     WebCore::InitializeLoggingChannelsIfNecessary();
-    JSC::initializeThreading();
+    ScriptController::initializeThreading();
     WTF::initializeMainThread();
     WebCore::SecurityOrigin::setLocalLoadPolicy(WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData);
 #if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index ec15703..66e8fd7 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-11  Vlad Burlik  <volodimir.burlik at nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        [Qt] V8 port for QT platform: QT API implementation changes
+        https://bugs.webkit.org/show_bug.cgi?id=45148
+
+        V8 Implementation of QWebFrame::addToJavaScriptWindowObject()
+        and QWebFrame::evaluateJavaScript()
+
+        * Api/qwebelement.cpp:
+        (setupScriptContext): JSC and V8 variations
+        (QWebElement::evaluateJavaScript):
+        * Api/qwebelement.h:
+        * Api/qwebframe.cpp: QObject injection to V8 world
+        (QWebFrame::addToJavaScriptWindowObject):
+        (QWebFrame::evaluateJavaScript):
+        * Api/qwebpage.cpp: Use ScriptController type definitions instead of direct references to JSC or V8
+        (QWebPagePrivate::QWebPagePrivate):
+
 2010-09-10  yi shen  <yi.4.shen at nokia.com>
 
         Reviewed by Antonio Gomes.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list