Changeset 149671 in webkit
- Timestamp:
- May 7, 2013 8:33:02 AM (11 years ago)
- Location:
- trunk/Source/WebKit/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/qt/Api/qwebelement.cpp
r149532 r149671 46 46 #include "RenderImage.h" 47 47 #include "ScriptController.h" 48 #include "ScriptSourceCode.h" 48 49 #include "ScriptState.h" 49 50 #include "StaticNodeList.h" … … 711 712 } 712 713 713 static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValue,ScriptState*& state, ScriptController*& scriptController)714 static bool setupScriptContext(WebCore::Element* element, ScriptState*& state, ScriptController*& scriptController) 714 715 { 715 716 if (!element) … … 732 733 return false; 733 734 734 thisValue = toJS(state, deprecatedGlobalObjectForPrototype(state), element);735 if (!thisValue)736 return false;737 738 735 return true; 739 736 } … … 748 745 749 746 ScriptState* state = 0; 750 JSC::JSValue thisValue;751 747 ScriptController* scriptController = 0; 752 748 753 if (!setupScriptContext(m_element, thisValue,state, scriptController))749 if (!setupScriptContext(m_element, state, scriptController)) 754 750 return QVariant(); 755 String script(reinterpret_cast_ptr<const UChar*>(scriptSource.data()), scriptSource.length()); 751 752 JSC::JSLockHolder lock(state); 753 RefPtr<Element> protect = m_element; 754 755 JSC::JSValue thisValue = toJS(state, toJSDOMGlobalObject(m_element->document(), state), m_element); 756 if (!thisValue) 757 return QVariant(); 758 759 ScriptSourceCode sourceCode(scriptSource); 756 760 757 761 JSC::JSValue evaluationException; 758 JSC::JSValue evaluationResult = JSC::evaluate(state, JSC::makeSource(script), thisValue, &evaluationException);762 JSC::JSValue evaluationResult = JSC::evaluate(state, sourceCode.jsSourceCode(), thisValue, &evaluationException); 759 763 if (evaluationException) 760 764 return QVariant(); 765 JSValueRef evaluationResultRef = toRef(state, evaluationResult); 761 766 762 767 int distance = 0; 763 768 JSValueRef* ignoredException = 0; 764 return JSC::Bindings::convertValueToQVariant(toRef(state), toRef(state, evaluationResult), QMetaType::Void, &distance, ignoredException);769 return JSC::Bindings::convertValueToQVariant(toRef(state), evaluationResultRef, QMetaType::Void, &distance, ignoredException); 765 770 } 766 771 -
trunk/Source/WebKit/qt/ChangeLog
r149532 r149671 1 2013-05-07 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 Crash when calling QWebFrame::evaluateJavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=113434 5 6 Reviewed by Simon Hausmann. 7 8 Ensure we hold the JSLock when converting JSValue to JSValueRef. 9 10 * Api/qwebelement.cpp: 11 (setupScriptContext): 12 (QWebElement::evaluateJavaScript): 13 * WebCoreSupport/QWebFrameAdapter.cpp: 14 (QWebFrameAdapter::evaluateJavaScript): 15 1 16 2013-05-03 Andreas Kling <akling@apple.com> 2 17 -
trunk/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
r148696 r149671 198 198 QVariant QWebFrameAdapter::evaluateJavaScript(const QString &scriptSource) 199 199 { 200 ScriptController* proxy= frame->script();200 ScriptController* scriptController = frame->script(); 201 201 QVariant rc; 202 if ( proxy) {202 if (scriptController) { 203 203 int distance = 0; 204 JSC::JSValue v = frame->script()->executeScript(ScriptSourceCode(scriptSource)).jsValue();205 JSC::ExecState* exec = proxy->globalObject(mainThreadNormalWorld())->globalExec();204 ScriptValue value = scriptController->executeScript(ScriptSourceCode(scriptSource)); 205 JSC::ExecState* exec = scriptController->globalObject(mainThreadNormalWorld())->globalExec(); 206 206 JSValueRef* ignoredException = 0; 207 rc = JSC::Bindings::convertValueToQVariant(toRef(exec), toRef(exec, v), QMetaType::Void, &distance, ignoredException); 207 exec->vm().apiLock().lock(); 208 JSValueRef valueRef = toRef(exec, value.jsValue()); 209 exec->vm().apiLock().unlock(); 210 rc = JSC::Bindings::convertValueToQVariant(toRef(exec), valueRef, QMetaType::Void, &distance, ignoredException); 208 211 } 209 212 return rc;
Note: See TracChangeset
for help on using the changeset viewer.