[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 14:03:55 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5f689814fe85f1ba5347a6b81faa25b285fe019c
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Oct 2 01:54:27 2010 +0000

    Deploy the new WKString functions to remove most uses of CF from
    the WebKitTestRunner.
    
    Reviewed by Jon Honeycutt.
    
    * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
    (WTR::InjectedBundle::didReceiveMessage):
    (WTR::InjectedBundle::done):
    * WebKitTestRunner/StringFunctions.h:
    (WTR::toWK):
    (WTR::toJS):
    (WTR::toSTD):
    (WTR::operator<<):
    (WTR::copyURLString):
    * WebKitTestRunner/TestController.cpp:
    (WTR::TestController::resetStateToConsistentValues):
    (WTR::TestController::didFinishLoadForFrame):
    * WebKitTestRunner/TestInvocation.cpp:
    (WTR::TestInvocation::invoke):
    (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68966 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 29ad4c6..bc3fb42 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,26 @@
+2010-10-01  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Jon Honeycutt.
+
+        Deploy the new WKString functions to remove most uses of CF from
+        the WebKitTestRunner.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessage):
+        (WTR::InjectedBundle::done):
+        * WebKitTestRunner/StringFunctions.h:
+        (WTR::toWK):
+        (WTR::toJS):
+        (WTR::toSTD):
+        (WTR::operator<<):
+        (WTR::copyURLString):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::didFinishLoadForFrame):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::invoke):
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
 2010-10-01  Mihai Parparita  <mihaip at chromium.org>
 
         Unreviewed TestResultsServer change.
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index ecc302f..bf8bced 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -32,7 +32,6 @@
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKBundlePrivate.h>
 #include <WebKit2/WKRetainPtr.h>
-#include <WebKit2/WKStringCF.h>
 #include <WebKit2/WebKit2.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RetainPtr.h>
@@ -105,18 +104,19 @@ void InjectedBundle::willDestroyPage(WKBundlePageRef page)
 
 void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 {
-    CFStringRef cfMessage = WKStringCopyCFString(0, messageName);
-    if (CFEqual(cfMessage, CFSTR("BeginTest"))) {
-        WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Ack")));
-        WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
+    if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) {
+        ASSERT(!messageBody);
+
+        WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack"));
+        WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest"));
         WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
 
         beginTesting();
         return;
     }
 
-    WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Error")));
-    WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("Unknown")));
+    WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error"));
+    WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown"));
     WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
 }
 
@@ -142,11 +142,8 @@ void InjectedBundle::done()
 {
     m_mainPage->stopLoading();
 
-    WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Done")));
-
-    std::string output = m_outputStream.str();
-    RetainPtr<CFStringRef> outputCFString(AdoptCF, CFStringCreateWithCString(0, output.c_str(), kCFStringEncodingUTF8));
-    WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
+    WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done"));
+    WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithUTF8CString(m_outputStream.str().c_str()));
 
     WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
 
diff --git a/WebKitTools/WebKitTestRunner/StringFunctions.h b/WebKitTools/WebKitTestRunner/StringFunctions.h
index 8195606..c80e40f 100644
--- a/WebKitTools/WebKitTestRunner/StringFunctions.h
+++ b/WebKitTools/WebKitTestRunner/StringFunctions.h
@@ -27,13 +27,17 @@
 #define StringFunctions_h
 
 #include <JavaScriptCore/JSRetainPtr.h>
-#include <JavaScriptCore/JavaScriptCore.h>
+#include <JavaScriptCore/JavaScript.h>
 #include <WebKit2/WKRetainPtr.h>
 #include <WebKit2/WKString.h>
 #include <WebKit2/WKStringCF.h>
+#include <WebKit2/WKStringPrivate.h>
 #include <WebKit2/WKURL.h>
 #include <WebKit2/WKURLCF.h>
 #include <sstream>
+#include <string>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/PassOwnArrayPtr.h>
 #include <wtf/Platform.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
@@ -42,39 +46,19 @@ namespace WTR {
 
 // Conversion functions
 
-inline RetainPtr<CFStringRef> toCF(JSStringRef string)
-{
-    return RetainPtr<CFStringRef>(AdoptCF, JSStringCopyCFString(0, string));
-}
-
-inline RetainPtr<CFStringRef> toCF(WKStringRef string)
-{
-    return RetainPtr<CFStringRef>(AdoptCF, WKStringCopyCFString(0, string));
-}
-
-inline RetainPtr<CFURLRef> toCF(WKURLRef url)
-{
-    return RetainPtr<CFURLRef>(AdoptCF, WKURLCopyCFURL(0, url));
-}
-
-inline RetainPtr<CFURLRef> toCF(const WKRetainPtr<WKURLRef>& url)
-{
-    return toCF(url.get());
-}
-
 inline WKRetainPtr<WKStringRef> toWK(JSStringRef string)
 {
-    return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithCFString(toCF(string).get()));
+    return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithJSString(string));
 }
 
 inline WKRetainPtr<WKStringRef> toWK(JSRetainPtr<JSStringRef> string)
 {
-    return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithCFString(toCF(string.get()).get()));
+    return toWK(string.get());
 }
 
 inline JSRetainPtr<JSStringRef> toJS(WKStringRef string)
 {
-    return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithCFString(toCF(string).get()));
+    return JSRetainPtr<JSStringRef>(Adopt, WKStringCopyJSString(string));
 }
 
 inline JSRetainPtr<JSStringRef> toJS(const WKRetainPtr<WKStringRef>& string)
@@ -82,29 +66,28 @@ inline JSRetainPtr<JSStringRef> toJS(const WKRetainPtr<WKStringRef>& string)
     return toJS(string.get());
 }
 
-// Streaming functions
-
-inline std::ostream& operator<<(std::ostream& out, CFStringRef stringRef)
+inline std::string toSTD(WKStringRef string)
 {
-    if (!stringRef)
-        return out;
-    CFIndex bufferLength = CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef), kCFStringEncodingUTF8) + 1;
-    Vector<char> buffer(bufferLength);
-    if (!CFStringGetCString(stringRef, buffer.data(), bufferLength, kCFStringEncodingUTF8))
-        return out;
-    return out << buffer.data();
+    size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
+    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
+    WKStringGetUTF8CString(string, buffer.get(), bufferSize);
+
+    return std::string(buffer.get(), bufferSize);
 }
 
-inline std::ostream& operator<<(std::ostream& out, const RetainPtr<CFStringRef>& stringRef)
+inline std::string toSTD(const WKRetainPtr<WKStringRef>& string)
 {
-    return out << stringRef.get();
+    return toSTD(string.get());
 }
 
+// Streaming functions
+
 inline std::ostream& operator<<(std::ostream& out, WKStringRef stringRef)
 {
     if (!stringRef)
         return out;
-    return out << toCF(stringRef);
+
+    return out << toSTD(stringRef);
 }
 
 inline std::ostream& operator<<(std::ostream& out, const WKRetainPtr<WKStringRef>& stringRef)
@@ -112,7 +95,7 @@ inline std::ostream& operator<<(std::ostream& out, const WKRetainPtr<WKStringRef
     return out << stringRef.get();
 }
 
-// URL creation
+// URL Functions
 
 inline WKURLRef createWKURL(const char* pathOrURL)
 {
@@ -129,6 +112,11 @@ inline WKURLRef createWKURL(const char* pathOrURL)
     return WKURLCreateWithCFURL(cfURL.get());
 }
 
+inline WKStringRef copyURLString(WKURLRef url)
+{
+    RetainPtr<CFURLRef> cfURL(AdoptCF, WKURLCopyCFURL(0, url));
+    return WKStringCreateWithCFString(CFURLGetString(cfURL.get()));
+}
 
 } // namespace WTR
 
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index efd893d..739d405 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -208,12 +208,12 @@ void TestController::resetStateToConsistentValues()
     WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
     WKPreferencesSetXSSAuditorEnabled(preferences, false);
 
-    static WKStringRef standardFontFamily = WKStringCreateWithCFString(CFSTR("Times"));
-    static WKStringRef cursiveFontFamily = WKStringCreateWithCFString(CFSTR("Apple Chancery"));
-    static WKStringRef fantasyFontFamily = WKStringCreateWithCFString(CFSTR("Papyrus"));
-    static WKStringRef fixedFontFamily = WKStringCreateWithCFString(CFSTR("Courier"));
-    static WKStringRef sansSerifFontFamily = WKStringCreateWithCFString(CFSTR("Helvetica"));
-    static WKStringRef serifFontFamily = WKStringCreateWithCFString(CFSTR("Times"));
+    static WKStringRef standardFontFamily = WKStringCreateWithUTF8CString("Times");
+    static WKStringRef cursiveFontFamily = WKStringCreateWithUTF8CString("Apple Chancery");
+    static WKStringRef fantasyFontFamily = WKStringCreateWithUTF8CString("Papyrus");
+    static WKStringRef fixedFontFamily = WKStringCreateWithUTF8CString("Courier");
+    static WKStringRef sansSerifFontFamily = WKStringCreateWithUTF8CString("Helvetica");
+    static WKStringRef serifFontFamily = WKStringCreateWithUTF8CString("Times");
 
     WKPreferencesSetStandardFontFamily(preferences, standardFontFamily);
     WKPreferencesSetCursiveFontFamily(preferences, cursiveFontFamily);
@@ -295,9 +295,8 @@ void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame)
         return;
 
     WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame));
-    RetainPtr<CFURLRef> cfURL= toCF(wkURL);
-    CFStringRef cfURLString = CFURLGetString(cfURL.get());
-    if (!CFEqual(cfURLString, CFSTR("about:blank")))
+    WKRetainPtr<WKStringRef> wkURLString(AdoptWK, copyURLString(wkURL.get()));
+    if (!WKStringIsEqualToUTF8CString(wkURLString.get(), "about:blank"))
         return;
 
     m_doneResetting = true;
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.cpp b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
index 47df66b..9b5bc1a 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.cpp
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
@@ -30,7 +30,8 @@
 #include "TestController.h"
 #include <WebKit2/WKContextPrivate.h>
 #include <WebKit2/WKRetainPtr.h>
-#include <wtf/RetainPtr.h>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/PassOwnArrayPtr.h>
 
 using namespace WebKit;
 using namespace std;
@@ -70,9 +71,8 @@ void TestInvocation::invoke()
 {
     sizeWebViewForCurrentTest(m_pathOrURL);
 
-    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
-    WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("")));
-    WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), messageBody.get());
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("BeginTest"));
+    WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 
     TestController::runUntil(m_gotInitialResponse);
     if (m_error) {
@@ -104,8 +104,7 @@ void TestInvocation::dump(const char* stringToDump)
 
 void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
 {
-    RetainPtr<CFStringRef> cfMessageName(AdoptCF, WKStringCopyCFString(0, messageName));
-    if (CFEqual(cfMessageName.get(), CFSTR("Error"))) {
+    if (WKStringIsEqualToUTF8CString(messageName, "Error")) {
         // Set all states to true to stop spinning the runloop.
         m_gotInitialResponse = true;
         m_gotFinalMessage = true;
@@ -113,11 +112,10 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         return;
     }
 
-    if (CFEqual(cfMessageName.get(), CFSTR("Ack"))) {
+    if (WKStringIsEqualToUTF8CString(messageName, "Ack")) {
         ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
-        RetainPtr<CFStringRef> cfMessageBody(AdoptCF, WKStringCopyCFString(0, static_cast<WKStringRef>(messageBody)));
-
-        if (CFEqual(cfMessageBody.get(), CFSTR("BeginTest"))) {
+        WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody);
+        if (WKStringIsEqualToUTF8CString(messageBodyString, "BeginTest")) {
             m_gotInitialResponse = true;
             return;
         }
@@ -125,12 +123,11 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         ASSERT_NOT_REACHED();
     }
 
-    if (CFEqual(cfMessageName.get(), CFSTR("Done"))) {
+    if (WKStringIsEqualToUTF8CString(messageName, "Done")) {
         ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
-        ostringstream out;
-        out << static_cast<WKStringRef>(messageBody);
+        WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody);
 
-        dump(out.str().c_str());
+        dump(toSTD(messageBodyString).c_str());
 
         m_gotFinalMessage = true;
         return;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list