Changeset 68966 in webkit
- Timestamp:
- Oct 1, 2010 6:54:27 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r68963 r68966 1 2010-10-01 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Jon Honeycutt. 4 5 Deploy the new WKString functions to remove most uses of CF from 6 the WebKitTestRunner. 7 8 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 9 (WTR::InjectedBundle::didReceiveMessage): 10 (WTR::InjectedBundle::done): 11 * WebKitTestRunner/StringFunctions.h: 12 (WTR::toWK): 13 (WTR::toJS): 14 (WTR::toSTD): 15 (WTR::operator<<): 16 (WTR::copyURLString): 17 * WebKitTestRunner/TestController.cpp: 18 (WTR::TestController::resetStateToConsistentValues): 19 (WTR::TestController::didFinishLoadForFrame): 20 * WebKitTestRunner/TestInvocation.cpp: 21 (WTR::TestInvocation::invoke): 22 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): 23 1 24 2010-10-01 Mihai Parparita <mihaip@chromium.org> 2 25 -
trunk/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r66548 r68966 33 33 #include <WebKit2/WKBundlePrivate.h> 34 34 #include <WebKit2/WKRetainPtr.h> 35 #include <WebKit2/WKStringCF.h>36 35 #include <WebKit2/WebKit2.h> 37 36 #include <wtf/PassOwnPtr.h> … … 106 105 void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) 107 106 { 108 CFStringRef cfMessage = WKStringCopyCFString(0, messageName); 109 if (CFEqual(cfMessage, CFSTR("BeginTest"))) { 110 WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Ack"))); 111 WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest"))); 107 if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) { 108 ASSERT(!messageBody); 109 110 WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack")); 111 WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest")); 112 112 WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get()); 113 113 … … 116 116 } 117 117 118 WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWith CFString(CFSTR("Error")));119 WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWith CFString(CFSTR("Unknown")));118 WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error")); 119 WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown")); 120 120 WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get()); 121 121 } … … 143 143 m_mainPage->stopLoading(); 144 144 145 WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Done"))); 146 147 std::string output = m_outputStream.str(); 148 RetainPtr<CFStringRef> outputCFString(AdoptCF, CFStringCreateWithCString(0, output.c_str(), kCFStringEncodingUTF8)); 149 WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get())); 145 WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done")); 146 WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithUTF8CString(m_outputStream.str().c_str())); 150 147 151 148 WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get()); -
trunk/WebKitTools/WebKitTestRunner/StringFunctions.h
r65267 r68966 28 28 29 29 #include <JavaScriptCore/JSRetainPtr.h> 30 #include <JavaScriptCore/JavaScript Core.h>30 #include <JavaScriptCore/JavaScript.h> 31 31 #include <WebKit2/WKRetainPtr.h> 32 32 #include <WebKit2/WKString.h> 33 33 #include <WebKit2/WKStringCF.h> 34 #include <WebKit2/WKStringPrivate.h> 34 35 #include <WebKit2/WKURL.h> 35 36 #include <WebKit2/WKURLCF.h> 36 37 #include <sstream> 38 #include <string> 39 #include <wtf/OwnArrayPtr.h> 40 #include <wtf/PassOwnArrayPtr.h> 37 41 #include <wtf/Platform.h> 38 42 #include <wtf/RetainPtr.h> … … 43 47 // Conversion functions 44 48 45 inline RetainPtr<CFStringRef> toCF(JSStringRef string)46 {47 return RetainPtr<CFStringRef>(AdoptCF, JSStringCopyCFString(0, string));48 }49 50 inline RetainPtr<CFStringRef> toCF(WKStringRef string)51 {52 return RetainPtr<CFStringRef>(AdoptCF, WKStringCopyCFString(0, string));53 }54 55 inline RetainPtr<CFURLRef> toCF(WKURLRef url)56 {57 return RetainPtr<CFURLRef>(AdoptCF, WKURLCopyCFURL(0, url));58 }59 60 inline RetainPtr<CFURLRef> toCF(const WKRetainPtr<WKURLRef>& url)61 {62 return toCF(url.get());63 }64 65 49 inline WKRetainPtr<WKStringRef> toWK(JSStringRef string) 66 50 { 67 return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWith CFString(toCF(string).get()));51 return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithJSString(string)); 68 52 } 69 53 70 54 inline WKRetainPtr<WKStringRef> toWK(JSRetainPtr<JSStringRef> string) 71 55 { 72 return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithCFString(toCF(string.get()).get()));56 return toWK(string.get()); 73 57 } 74 58 75 59 inline JSRetainPtr<JSStringRef> toJS(WKStringRef string) 76 60 { 77 return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithCFString(toCF(string).get()));61 return JSRetainPtr<JSStringRef>(Adopt, WKStringCopyJSString(string)); 78 62 } 79 63 … … 83 67 } 84 68 85 // Streaming functions 69 inline std::string toSTD(WKStringRef string) 70 { 71 size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string); 72 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]); 73 WKStringGetUTF8CString(string, buffer.get(), bufferSize); 86 74 87 inline std::ostream& operator<<(std::ostream& out, CFStringRef stringRef) 88 { 89 if (!stringRef) 90 return out; 91 CFIndex bufferLength = CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef), kCFStringEncodingUTF8) + 1; 92 Vector<char> buffer(bufferLength); 93 if (!CFStringGetCString(stringRef, buffer.data(), bufferLength, kCFStringEncodingUTF8)) 94 return out; 95 return out << buffer.data(); 75 return std::string(buffer.get(), bufferSize); 96 76 } 97 77 98 inline std:: ostream& operator<<(std::ostream& out, const RetainPtr<CFStringRef>& stringRef)78 inline std::string toSTD(const WKRetainPtr<WKStringRef>& string) 99 79 { 100 return out << stringRef.get();80 return toSTD(string.get()); 101 81 } 82 83 // Streaming functions 102 84 103 85 inline std::ostream& operator<<(std::ostream& out, WKStringRef stringRef) … … 105 87 if (!stringRef) 106 88 return out; 107 return out << toCF(stringRef); 89 90 return out << toSTD(stringRef); 108 91 } 109 92 … … 113 96 } 114 97 115 // URL creation98 // URL Functions 116 99 117 100 inline WKURLRef createWKURL(const char* pathOrURL) … … 130 113 } 131 114 115 inline WKStringRef copyURLString(WKURLRef url) 116 { 117 RetainPtr<CFURLRef> cfURL(AdoptCF, WKURLCopyCFURL(0, url)); 118 return WKStringCreateWithCFString(CFURLGetString(cfURL.get())); 119 } 132 120 133 121 } // namespace WTR -
trunk/WebKitTools/WebKitTestRunner/TestController.cpp
r68849 r68966 209 209 WKPreferencesSetXSSAuditorEnabled(preferences, false); 210 210 211 static WKStringRef standardFontFamily = WKStringCreateWith CFString(CFSTR("Times"));212 static WKStringRef cursiveFontFamily = WKStringCreateWith CFString(CFSTR("Apple Chancery"));213 static WKStringRef fantasyFontFamily = WKStringCreateWith CFString(CFSTR("Papyrus"));214 static WKStringRef fixedFontFamily = WKStringCreateWith CFString(CFSTR("Courier"));215 static WKStringRef sansSerifFontFamily = WKStringCreateWith CFString(CFSTR("Helvetica"));216 static WKStringRef serifFontFamily = WKStringCreateWith CFString(CFSTR("Times"));211 static WKStringRef standardFontFamily = WKStringCreateWithUTF8CString("Times"); 212 static WKStringRef cursiveFontFamily = WKStringCreateWithUTF8CString("Apple Chancery"); 213 static WKStringRef fantasyFontFamily = WKStringCreateWithUTF8CString("Papyrus"); 214 static WKStringRef fixedFontFamily = WKStringCreateWithUTF8CString("Courier"); 215 static WKStringRef sansSerifFontFamily = WKStringCreateWithUTF8CString("Helvetica"); 216 static WKStringRef serifFontFamily = WKStringCreateWithUTF8CString("Times"); 217 217 218 218 WKPreferencesSetStandardFontFamily(preferences, standardFontFamily); … … 296 296 297 297 WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame)); 298 RetainPtr<CFURLRef> cfURL= toCF(wkURL); 299 CFStringRef cfURLString = CFURLGetString(cfURL.get()); 300 if (!CFEqual(cfURLString, CFSTR("about:blank"))) 298 WKRetainPtr<WKStringRef> wkURLString(AdoptWK, copyURLString(wkURL.get())); 299 if (!WKStringIsEqualToUTF8CString(wkURLString.get(), "about:blank")) 301 300 return; 302 301 -
trunk/WebKitTools/WebKitTestRunner/TestInvocation.cpp
r65294 r68966 31 31 #include <WebKit2/WKContextPrivate.h> 32 32 #include <WebKit2/WKRetainPtr.h> 33 #include <wtf/RetainPtr.h> 33 #include <wtf/OwnArrayPtr.h> 34 #include <wtf/PassOwnArrayPtr.h> 34 35 35 36 using namespace WebKit; … … 71 72 sizeWebViewForCurrentTest(m_pathOrURL); 72 73 73 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest"))); 74 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithCFString(CFSTR(""))); 75 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), messageBody.get()); 74 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("BeginTest")); 75 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); 76 76 77 77 TestController::runUntil(m_gotInitialResponse); … … 105 105 void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody) 106 106 { 107 RetainPtr<CFStringRef> cfMessageName(AdoptCF, WKStringCopyCFString(0, messageName)); 108 if (CFEqual(cfMessageName.get(), CFSTR("Error"))) { 107 if (WKStringIsEqualToUTF8CString(messageName, "Error")) { 109 108 // Set all states to true to stop spinning the runloop. 110 109 m_gotInitialResponse = true; … … 114 113 } 115 114 116 if ( CFEqual(cfMessageName.get(), CFSTR("Ack"))) {115 if (WKStringIsEqualToUTF8CString(messageName, "Ack")) { 117 116 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 118 RetainPtr<CFStringRef> cfMessageBody(AdoptCF, WKStringCopyCFString(0, static_cast<WKStringRef>(messageBody))); 119 120 if (CFEqual(cfMessageBody.get(), CFSTR("BeginTest"))) { 117 WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody); 118 if (WKStringIsEqualToUTF8CString(messageBodyString, "BeginTest")) { 121 119 m_gotInitialResponse = true; 122 120 return; … … 126 124 } 127 125 128 if ( CFEqual(cfMessageName.get(), CFSTR("Done"))) {126 if (WKStringIsEqualToUTF8CString(messageName, "Done")) { 129 127 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 130 ostringstream out; 131 out << static_cast<WKStringRef>(messageBody); 128 WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody); 132 129 133 dump( out.str().c_str());130 dump(toSTD(messageBodyString).c_str()); 134 131 135 132 m_gotFinalMessage = true;
Note: See TracChangeset
for help on using the changeset viewer.