Changeset 125324 in webkit
- Timestamp:
- Aug 10, 2012 1:40:11 PM (12 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r125300 r125324 1 2012-08-10 Benjamin C Meyer <bmeyer@rim.com> 2 3 Introduce JavaScriptVariant object. 4 https://bugs.webkit.org/show_bug.cgi?id=93644 5 6 The JavaScriptVariant can be used for functions that return results from 7 JavaScript such as executeJavaScript or functions that take arguments 8 to pass a variable to JavaScript and they want to make sure the type 9 is correct. 10 11 Convert executeJavaScriptFunction() to use this data type as the 12 example, other functions will be converted in the future. 13 14 PR 14929 15 16 Internally reviewed by Joe Mason 17 Reviewed by Adam Treat 18 19 * PlatformBlackBerry.cmake: 20 1 21 2012-08-10 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 22 -
trunk/Source/WebKit/PlatformBlackBerry.cmake
r125300 r125324 70 70 blackberry/Api/WebString.cpp 71 71 blackberry/Api/WebViewportArguments.cpp 72 blackberry/Api/JavaScriptVariant.cpp 72 73 blackberry/WebCoreSupport/AutofillManager.cpp 73 74 blackberry/WebCoreSupport/CacheClientBlackBerry.cpp -
trunk/Source/WebKit/blackberry/Api/WebPage.cpp
r125071 r125324 79 79 #include "InspectorOverlay.h" 80 80 #include "JavaScriptDebuggerBlackBerry.h" 81 #include "JavaScriptVariant_p.h" 81 82 #include "LayerWebKitThread.h" 82 83 #include "NetworkManager.h" … … 847 848 } 848 849 849 bool WebPage::executeJavaScriptFunction(const std::vector<std::string> &function, const std::vector<std::string> &args, JavaScriptDataType& returnType, WebString& returnValue) 850 { 851 if (!d->m_mainFrame) 852 return false; 850 void WebPage::executeJavaScriptFunction(const std::vector<std::string> &function, const std::vector<JavaScriptVariant> &args, JavaScriptVariant& returnValue) 851 { 852 if (!d->m_mainFrame) { 853 returnValue.setType(JavaScriptVariant::Exception); 854 return; 855 } 856 853 857 JSC::Bindings::RootObject* root = d->m_mainFrame->script()->bindingRootObject(); 854 if (!root) 855 return false; 858 if (!root) { 859 returnValue.setType(JavaScriptVariant::Exception); 860 return; 861 } 862 856 863 JSC::ExecState* exec = root->globalObject()->globalExec(); 857 864 JSGlobalContextRef ctx = toGlobalRef(exec); 858 865 859 WTF::Vector<JSStringRef> argList(args.size());860 866 WTF::Vector<JSValueRef> argListRef(args.size()); 861 for (unsigned i = 0; i < args.size(); ++i) { 862 JSStringRef str = JSStringCreateWithUTF8CString(args[i].c_str()); 863 argList[i] = str; 864 JSValueRef strRef = JSValueMakeString(ctx, str); 865 argListRef[i] = strRef; 866 } 867 for (unsigned i = 0; i < args.size(); ++i) 868 argListRef[i] = BlackBerryJavaScriptVariantToJSValueRef(ctx, args[i]); 867 869 868 870 JSValueRef windowObjectValue = windowObject(); … … 883 885 result = JSObjectCallAsFunction(ctx, functionObject, thisObject, args.size(), argListRef.data(), 0); 884 886 885 for (unsigned i = 0; i < args.size(); ++i)886 JSStringRelease(argList[i]);887 888 887 JSC::JSValue value = toJS(exec, result); 889 890 888 if (!value) { 891 returnType = JSException; 892 return false; 893 } 894 895 JSType type = JSValueGetType(ctx, result); 896 897 switch (type) { 898 case kJSTypeNull: 899 returnType = JSNull; 900 break; 901 case kJSTypeBoolean: 902 returnType = JSBoolean; 903 break; 904 case kJSTypeNumber: 905 returnType = JSNumber; 906 break; 907 case kJSTypeString: 908 returnType = JSString; 909 break; 910 case kJSTypeObject: 911 returnType = JSObject; 912 break; 913 case kJSTypeUndefined: 914 default: 915 returnType = JSUndefined; 916 break; 917 } 918 919 if (returnType == JSBoolean || returnType == JSNumber || returnType == JSString || returnType == JSObject) { 920 JSStringRef stringRef = JSValueToStringCopy(ctx, result, 0); 921 size_t bufferSize = JSStringGetMaximumUTF8CStringSize(stringRef); 922 WTF::Vector<char> buffer(bufferSize); 923 JSStringGetUTF8CString(stringRef, buffer.data(), bufferSize); 924 returnValue = WebString::fromUtf8(buffer.data()); 925 } 926 927 return true; 889 returnValue.setType(JavaScriptVariant::Exception); 890 return; 891 } 892 893 returnValue = JSValueRefToBlackBerryJavaScriptVariant(ctx, result); 928 894 } 929 895 -
trunk/Source/WebKit/blackberry/Api/WebPage.h
r125071 r125324 21 21 22 22 #include "BlackBerryGlobal.h" 23 #include "JavaScriptVariant.h" 23 24 #include "WebString.h" 24 25 … … 107 108 bool executeJavaScriptInIsolatedWorld(const std::wstring& script, JavaScriptDataType& returnType, WebString& returnValue); 108 109 109 bool executeJavaScriptFunction(const std::vector<std::string> &script, const std::vector<std::string> &args, JavaScriptDataType& returnType, WebString& returnValue);110 void executeJavaScriptFunction(const std::vector<std::string> &function, const std::vector<JavaScriptVariant> &args, JavaScriptVariant& returnValue); 110 111 111 112 void initializeIconDataBase(); -
trunk/Source/WebKit/blackberry/ChangeLog
r125207 r125324 1 2012-08-10 Benjamin C Meyer <bmeyer@rim.com> 2 3 Introduce JavaScriptVariant object. 4 https://bugs.webkit.org/show_bug.cgi?id=93644 5 6 The JavaScriptVariant can be used for functions that return results from 7 JavaScript such as executeJavaScript or functions that take arguments 8 to pass a variable to JavaScript and they want to make sure the type 9 is correct. 10 11 Convert executeJavaScriptFunction() to use this data type as the 12 example, other functions will be converted in the future. 13 14 PR 14929 15 16 Internally reviewed by Joe Mason 17 Reviewed by Adam Treat 18 19 * Api/JavaScriptVariant.cpp: Added. 20 (WebKit): 21 (BlackBerry::WebKit::JSValueRefToBlackBerryJavaScriptVariant): 22 (BlackBerry::WebKit::BlackBerryJavaScriptVariantToJSValueRef): 23 (BlackBerry::WebKit::JavaScriptVariant::JavaScriptVariant): 24 (BlackBerry::WebKit::JavaScriptVariant::~JavaScriptVariant): 25 (BlackBerry::WebKit::JavaScriptVariant::operator=): 26 (BlackBerry::WebKit::JavaScriptVariant::setType): 27 (BlackBerry::WebKit::JavaScriptVariant::type): 28 (BlackBerry::WebKit::JavaScriptVariant::setDouble): 29 (BlackBerry::WebKit::JavaScriptVariant::doubleValue): 30 (BlackBerry::WebKit::JavaScriptVariant::setString): 31 (BlackBerry::WebKit::JavaScriptVariant::stringValue): 32 (BlackBerry::WebKit::JavaScriptVariant::setBoolean): 33 (BlackBerry::WebKit::JavaScriptVariant::booleanValue): 34 * Api/JavaScriptVariant.h: Added. 35 (WebKit): 36 * Api/JavaScriptVariant_p.h: Added. 37 (WebKit): 38 * Api/WebPage.cpp: 39 (BlackBerry::WebKit::WebPage::executeJavaScriptFunction): 40 * Api/WebPage.h: 41 1 42 2012-08-09 Leo Yang <leoyang@rim.com> 2 43
Note: See TracChangeset
for help on using the changeset viewer.