diff options
Diffstat (limited to 'WebKit/qt/Api/qwebelement.cpp')
-rw-r--r-- | WebKit/qt/Api/qwebelement.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index f7b1188..261631c 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 "NotImplemented.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,10 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource) int distance = 0; return JSC::Bindings::convertValueToQVariant(state, result, QMetaType::Void, &distance); +#elif USE(V8) + notImplemented(); + return QVariant(); +#endif } /*! |