2010-10-07 Balazs Kelemen <kbalazs@webkit.org>
authorkbalazs@webkit.org <kbalazs@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Oct 2010 12:23:04 +0000 (12:23 +0000)
committerkbalazs@webkit.org <kbalazs@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Oct 2010 12:23:04 +0000 (12:23 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        WebKitTestRunner should be portable
        https://bugs.webkit.org/show_bug.cgi?id=45393

        Use only the WebKit API for working with urls.
        * WebKitTestRunner/StringFunctions.h:
        (WTR::createWKURL):
        * WebKitTestRunner/TestController.cpp:
        (WTR::blankURL):
        (WTR::TestController::resetStateToConsistentValues):
        (WTR::TestController::didFinishLoadForFrame):
2010-10-07  Balazs Kelemen  <kbalazs@webkit.org>

        Reviewed by Kenneth Rohde Christiansen.

        WebKitTestRunner should be portable
        https://bugs.webkit.org/show_bug.cgi?id=45393

        Introducing additional URL API.
        * Shared/API/c/WKURL.cpp:
        (WKURLCreateWithUTF8CString):
        (WKURLIsEqual):
        * Shared/API/c/WKURL.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69297 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/Shared/API/c/WKURL.cpp
WebKit2/Shared/API/c/WKURL.h
WebKitTools/ChangeLog
WebKitTools/WebKitTestRunner/StringFunctions.h
WebKitTools/WebKitTestRunner/TestController.cpp

index 63e1c24..7b05fe3 100644 (file)
@@ -1,3 +1,16 @@
+2010-10-07  Balazs Kelemen  <kbalazs@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        WebKitTestRunner should be portable
+        https://bugs.webkit.org/show_bug.cgi?id=45393
+
+        Introducing additional URL API.
+        * Shared/API/c/WKURL.cpp:
+        (WKURLCreateWithUTF8CString):
+        (WKURLIsEqual):
+        * Shared/API/c/WKURL.h:
+
 2010-10-06  Balazs Kelemen  <kbalazs@webkit.org>
 
         Reviewed by Kenneth Rohde Christiansen.
index 0176223..dbce7d0 100644 (file)
@@ -33,3 +33,13 @@ WKTypeID WKURLGetTypeID()
 {
     return toAPI(WebURL::APIType);
 }
+
+WKURLRef WKURLCreateWithUTF8CString(const char* string)
+{
+    return toAPI(WebURL::create(String::fromUTF8(string)).leakRef());
+}
+
+bool WKURLIsEqual(WKURLRef a, WKURLRef b)
+{
+    return toImpl(a)->string() == toImpl(b)->string();
+}
index e12f55c..6eb46a1 100644 (file)
@@ -34,6 +34,10 @@ extern "C" {
 
 WK_EXPORT WKTypeID WKURLGetTypeID();
 
+WK_EXPORT WKURLRef WKURLCreateWithUTF8CString(const char* string);
+
+WK_EXPORT bool WKURLIsEqual(WKURLRef a, WKURLRef b);
+
 #ifdef __cplusplus
 }
 #endif
index db0cba0..bd69255 100644 (file)
@@ -1,3 +1,18 @@
+2010-10-07  Balazs Kelemen  <kbalazs@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        WebKitTestRunner should be portable
+        https://bugs.webkit.org/show_bug.cgi?id=45393
+
+        Use only the WebKit API for working with urls.
+        * WebKitTestRunner/StringFunctions.h:
+        (WTR::createWKURL):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::blankURL):
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::didFinishLoadForFrame):
+
 2010-10-07  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Reviewed by Xan Lopez.
index ba048ea..862ddee 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 University of Szeged. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <JavaScriptCore/JavaScript.h>
+#include <sstream>
+#include <string>
 #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>
 
 namespace WTR {
@@ -94,27 +92,20 @@ inline std::ostream& operator<<(std::ostream& out, const WKRetainPtr<WKStringRef
     return out << stringRef.get();
 }
 
-// URL Functions
+// URL creation
 
 inline WKURLRef createWKURL(const char* pathOrURL)
 {
-    RetainPtr<CFStringRef> pathOrURLCFString(AdoptCF, CFStringCreateWithCString(0, pathOrURL, kCFStringEncodingUTF8));
-    RetainPtr<CFURLRef> cfURL;
-    if (CFStringHasPrefix(pathOrURLCFString.get(), CFSTR("http://")) || CFStringHasPrefix(pathOrURLCFString.get(), CFSTR("https://")))
-        cfURL.adoptCF(CFURLCreateWithString(0, pathOrURLCFString.get(), 0));
-    else
-#if PLATFORM(WIN)
-        cfURL.adoptCF(CFURLCreateWithFileSystemPath(0, pathOrURLCFString.get(), kCFURLWindowsPathStyle, false));
-#else
-        cfURL.adoptCF(CFURLCreateWithFileSystemPath(0, pathOrURLCFString.get(), kCFURLPOSIXPathStyle, false));
-#endif
-    return WKURLCreateWithCFURL(cfURL.get());
-}
-
-inline WKStringRef copyURLString(WKURLRef url)
-{
-    RetainPtr<CFURLRef> cfURL(AdoptCF, WKURLCopyCFURL(0, url));
-    return WKStringCreateWithCFString(CFURLGetString(cfURL.get()));
+    if (strstr(pathOrURL, "http://") || strstr(pathOrURL, "https") || strstr(pathOrURL, "file://"))
+        return WKURLCreateWithUTF8CString(pathOrURL);
+
+    const char* filePrefix = "file://";
+    static const size_t prefixLength = strlen(filePrefix);
+    size_t length = strlen(pathOrURL);
+    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length + prefixLength + 1]);
+    strcpy(buffer.get(), filePrefix);
+    strcat(buffer.get(), pathOrURL);
+    return WKURLCreateWithUTF8CString(buffer.get());
 }
 
 } // namespace WTR
index 739d405..9608235 100644 (file)
 
 namespace WTR {
 
+static WKURLRef blankURL()
+{
+    static staticBlankURL = WKURLCreateWithUTF8CString("about:blank");
+    retun staticBlankURL;
+}
+
 static TestController* controller;
 
 TestController& TestController::shared()
@@ -227,8 +233,7 @@ void TestController::resetStateToConsistentValues()
     // Reset main page back to about:blank
     m_doneResetting = false;
 
-    WKRetainPtr<WKURLRef> url(AdoptWK, createWKURL("about:blank"));
-    WKPageLoadURL(m_mainWebView->page(), url.get());
+    WKPageLoadURL(m_mainWebView->page(), blankURL());
     TestController::runUntil(m_doneResetting);
 }
 
@@ -295,8 +300,7 @@ void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame)
         return;
 
     WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame));
-    WKRetainPtr<WKStringRef> wkURLString(AdoptWK, copyURLString(wkURL.get()));
-    if (!WKStringIsEqualToUTF8CString(wkURLString.get(), "about:blank"))
+    if (!WKURLIsEqual(wkURL.get(), blankURL()))
         return;
 
     m_doneResetting = true;