Changeset 80188 in webkit
- Timestamp:
- Mar 2, 2011 5:17:45 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80185 r80188 1 2011-03-02 Timothy Hatcher <timothy@apple.com> 2 3 Export SerializedScriptValue::create(JSC::ExecState* exec, JSC::JSValue value). 4 5 Reviewed by Darin Adler. 6 7 * WebCore.exp.in: Added __ZN7WebCore21SerializedScriptValue6createEPN3JSC9ExecStateENS1_7JSValueE. 8 1 9 2011-03-02 Daniel Cheng <dcheng@chromium.org> 2 10 -
trunk/Source/WebCore/WebCore.exp.in
r80180 r80188 529 529 __ZN7WebCore21SerializedScriptValue11deserializeEPK15OpaqueJSContextPPK13OpaqueJSValue 530 530 __ZN7WebCore21SerializedScriptValue6createEPK15OpaqueJSContextPK13OpaqueJSValuePS6_ 531 __ZN7WebCore21SerializedScriptValue6createEPN3JSC9ExecStateENS1_7JSValueE 531 532 __ZN7WebCore21SerializedScriptValueC1ERN3WTF6VectorIhLm0EEE 532 533 __ZN7WebCore21SerializedScriptValueD1Ev -
trunk/Source/WebKit2/ChangeLog
r80180 r80188 1 2011-03-02 Timothy Hatcher <timothy@apple.com> 2 3 Make the runJavaScriptInMainFrame callback send a WKSerializedScriptValueRef. 4 5 https://webkit.org/b/55623 6 7 Reviewed by Darin Adler. 8 9 * UIProcess/API/C/WKPage.cpp: 10 (WKPageRunJavaScriptInMainFrame): Use ScriptValueCallback. 11 (callRunJavaScriptBlockAndRelease): Use WKSerializedScriptValueRef. 12 * UIProcess/API/C/WKPage.h: Use WKSerializedScriptValueRef. 13 * UIProcess/WebPageProxy.cpp: 14 (WebKit::WebPageProxy::close): Call invalidateCallbackMap for m_scriptValueCallbacks. 15 (WebKit::WebPageProxy::runJavaScriptInMainFrame): Take a ScriptValueCallback. 16 (WebKit::WebPageProxy::scriptValueCallback): Added. Create a WebSerializedScriptValue 17 from the DataReference before calling the callback. 18 (WebKit::WebPageProxy::processDidCrash): Call invalidateCallbackMap for m_scriptValueCallbacks. 19 * UIProcess/WebPageProxy.h: Added ScriptValueCallback and m_scriptValueCallbacks. 20 * UIProcess/WebPageProxy.messages.in: Added ScriptValueCallback. 21 * WebProcess/WebPage/WebPage.cpp: 22 (WebKit::WebPage::runJavaScriptInMainFrame): Create a DataReference from a WebCore::SerializedScriptValue. 23 And use ScriptValueCallback to send the message back. 24 1 25 2011-03-02 Jessie Berlin <jberlin@apple.com> 2 26 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r80125 r80188 398 398 void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback) 399 399 { 400 toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), S tringCallback::create(context, callback));400 toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), ScriptValueCallback::create(context, callback)); 401 401 } 402 402 403 403 #ifdef __BLOCKS__ 404 static void callRunJavaScriptBlockAndRelease(WKS tringRef resultValue, WKErrorRef error, void* context)404 static void callRunJavaScriptBlockAndRelease(WKSerializedScriptValueRef resultValue, WKErrorRef error, void* context) 405 405 { 406 406 WKPageRunJavaScriptBlock block = (WKPageRunJavaScriptBlock)context; -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.h
r80125 r80188 340 340 WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client); 341 341 342 typedef void (*WKPageRunJavaScriptFunction)(WKS tringRef, WKErrorRef, void*);342 typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*); 343 343 WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function); 344 344 #ifdef __BLOCKS__ 345 typedef void (^WKPageRunJavaScriptBlock)(WKS tringRef, WKErrorRef);345 typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef); 346 346 WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block); 347 347 #endif -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r79886 r80188 312 312 invalidateCallbackMap(m_dataCallbacks); 313 313 invalidateCallbackMap(m_stringCallbacks); 314 invalidateCallbackMap(m_scriptValueCallbacks); 314 315 invalidateCallbackMap(m_computedPagesCallbacks); 315 316 … … 1113 1114 process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID); 1114 1115 } 1115 1116 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<S tringCallback> prpCallback)1117 { 1118 RefPtr<S tringCallback> callback = prpCallback;1116 1117 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback) 1118 { 1119 RefPtr<ScriptValueCallback> callback = prpCallback; 1119 1120 uint64_t callbackID = callback->callbackID(); 1120 m_s tringCallbacks.set(callbackID, callback.get());1121 m_scriptValueCallbacks.set(callbackID, callback.get()); 1121 1122 process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID); 1122 1123 } … … 2443 2444 } 2444 2445 2446 void WebPageProxy::scriptValueCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID) 2447 { 2448 RefPtr<ScriptValueCallback> callback = m_scriptValueCallbacks.take(callbackID); 2449 if (!callback) { 2450 // FIXME: Log error or assert. 2451 return; 2452 } 2453 2454 Vector<uint8_t> data; 2455 data.reserveInitialCapacity(dataReference.size()); 2456 data.append(dataReference.data(), dataReference.size()); 2457 2458 callback->performCallbackWithReturnValue(WebSerializedScriptValue::adopt(data).get()); 2459 } 2460 2445 2461 void WebPageProxy::computedPagesCallback(const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, uint64_t callbackID) 2446 2462 { … … 2548 2564 invalidateCallbackMap(m_dataCallbacks); 2549 2565 invalidateCallbackMap(m_stringCallbacks); 2566 invalidateCallbackMap(m_scriptValueCallbacks); 2550 2567 invalidateCallbackMap(m_computedPagesCallbacks); 2551 2568 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r80125 r80188 114 114 115 115 typedef GenericCallback<WKStringRef, StringImpl*> StringCallback; 116 typedef GenericCallback<WKSerializedScriptValueRef, WebSerializedScriptValue*> ScriptValueCallback; 116 117 117 118 class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client { … … 304 305 void getSourceForFrame(WebFrameProxy*, PassRefPtr<StringCallback>); 305 306 void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>); 306 void runJavaScriptInMainFrame(const String&, PassRefPtr<S tringCallback>);307 void runJavaScriptInMainFrame(const String&, PassRefPtr<ScriptValueCallback>); 307 308 void forceRepaint(PassRefPtr<VoidCallback>); 308 309 … … 575 576 void dataCallback(const CoreIPC::DataReference&, uint64_t); 576 577 void stringCallback(const String&, uint64_t); 578 void scriptValueCallback(const CoreIPC::DataReference&, uint64_t); 577 579 void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, uint64_t); 578 580 … … 624 626 HashMap<uint64_t, RefPtr<DataCallback> > m_dataCallbacks; 625 627 HashMap<uint64_t, RefPtr<StringCallback> > m_stringCallbacks; 628 HashMap<uint64_t, RefPtr<ScriptValueCallback> > m_scriptValueCallbacks; 626 629 HashMap<uint64_t, RefPtr<ComputedPagesCallback> > m_computedPagesCallbacks; 627 630 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r79886 r80188 120 120 DataCallback(CoreIPC::DataReference resultData, uint64_t callbackID) 121 121 StringCallback(WTF::String resultString, uint64_t callbackID) 122 ScriptValueCallback(CoreIPC::DataReference resultData, uint64_t callbackID) 122 123 ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, uint64_t callbackID) 123 124 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r79965 r80188 92 92 #include <WebCore/ReplaceSelectionCommand.h> 93 93 #include <WebCore/ResourceRequest.h> 94 #include <WebCore/SerializedScriptValue.h> 94 95 #include <WebCore/Settings.h> 95 96 #include <WebCore/SharedBuffer.h> … … 1195 1196 // disappear during script execution. 1196 1197 1198 CoreIPC::DataReference dataReference; 1199 1197 1200 JSLock lock(SilenceAssertionsOnly); 1198 JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue();1199 String resultString;1200 if (resultValue)1201 resultString = ustringToString(resultValue.toString(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec()));1202 1203 send(Messages::WebPageProxy::S tringCallback(resultString, callbackID));1201 if (JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue()) { 1202 if (RefPtr<SerializedScriptValue> serializedResultValue = SerializedScriptValue::create(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec(), resultValue)) 1203 dataReference = CoreIPC::DataReference(serializedResultValue->data().data(), serializedResultValue->data().size()); 1204 } 1205 1206 send(Messages::WebPageProxy::ScriptValueCallback(dataReference, callbackID)); 1204 1207 } 1205 1208
Note: See TracChangeset
for help on using the changeset viewer.