2011-04-01 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Apr 2011 22:35:39 +0000 (22:35 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Apr 2011 22:35:39 +0000 (22:35 +0000)
        Reviewed by Adam Roben.

        Add adoptWK to WKRetainPtr.h
        https://bugs.webkit.org/show_bug.cgi?id=57670

        * UIProcess/API/cpp/WKRetainPtr.h:
        (WebKit::adoptWK):
        Add shared implementation of adoptWK. Previously both WebKitTestRunner
        and TestWebKitAPI had separate versions of it.
2011-04-01  Sam Weinig  <sam@webkit.org>

        Reviewed by Adam Roben.

        Add adoptWK to WKRetainPtr.h
        https://bugs.webkit.org/show_bug.cgi?id=57670

        * TestWebKitAPI/PlatformUtilities.h:
        * TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp:
        * TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp:
        * TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp:
        * TestWebKitAPI/Tests/WebKit2/CookieManager.cpp:
        * TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp:
        * TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp:
        * TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp:
        * TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp:
        (TestWebKitAPI::createSessionStateContainingFormData):
        * WebKitTestRunner/StringFunctions.h:
        Replace custom versions of adoptWK with the API on in WebKit2/WKRetainPtr.h.

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

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformUtilities.h
Tools/TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp
Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp
Tools/TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp
Tools/TestWebKitAPI/Tests/WebKit2/CookieManager.cpp
Tools/TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp
Tools/TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp
Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp
Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp
Tools/WebKitTestRunner/StringFunctions.h

index 706f0d5..9d9754d 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-01  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Adam Roben.
+
+        Add adoptWK to WKRetainPtr.h
+        https://bugs.webkit.org/show_bug.cgi?id=57670
+
+        * UIProcess/API/cpp/WKRetainPtr.h:
+        (WebKit::adoptWK):
+        Add shared implementation of adoptWK. Previously both WebKitTestRunner
+        and TestWebKitAPI had separate versions of it.
+
 2011-04-01  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index cb2a63e..21c15bc 100644 (file)
@@ -204,9 +204,15 @@ template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr<
     return a != b.get(); 
 }
 
+template<typename T> static inline WKRetainPtr<T> adoptWK(T o)
+{
+    return WKRetainPtr<T>(AdoptWK, o);
+}
+
 } // namespace WebKit
 
 using WebKit::WKRetainPtr;
 using WebKit::AdoptWK;
+using WebKit::adoptWK;
 
 #endif // WKRetainPtr_h
index 059914f..e7339c4 100644 (file)
@@ -2,6 +2,26 @@
 
         Reviewed by Adam Roben.
 
+        Add adoptWK to WKRetainPtr.h
+        https://bugs.webkit.org/show_bug.cgi?id=57670
+
+        * TestWebKitAPI/PlatformUtilities.h:
+        * TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp:
+        * TestWebKitAPI/Tests/WebKit2/CanHandleRequest.cpp:
+        * TestWebKitAPI/Tests/WebKit2/CanHandleRequest_Bundle.cpp:
+        * TestWebKitAPI/Tests/WebKit2/CookieManager.cpp:
+        * TestWebKitAPI/Tests/WebKit2/HitTestResultNodeHandle.cpp:
+        * TestWebKitAPI/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp:
+        * TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp:
+        * TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp:
+        (TestWebKitAPI::createSessionStateContainingFormData):
+        * WebKitTestRunner/StringFunctions.h:
+        Replace custom versions of adoptWK with the API on in WebKit2/WKRetainPtr.h.
+
+2011-04-01  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Adam Roben.
+
         Fix leak noticed by Adam Roben in LayoutTestController::shadowRoot.
 
         * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
index a682545..4de1398 100644 (file)
@@ -50,11 +50,6 @@ bool isKeyDown(WKNativeEventPtr);
 std::string toSTD(WKStringRef string);
 WKRetainPtr<WKStringRef> toWK(const char* utf8String);
 
-template<typename T> static inline WKRetainPtr<T> adoptWK(T item)
-{
-    return WKRetainPtr<T>(AdoptWK, item);
-}
-
 } // namespace Util
 } // namespace TestWebKitAPI
 
index 27180e3..cb00276 100644 (file)
@@ -43,7 +43,7 @@ static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef resp
 
 TEST(WebKit2, AboutBlankLoad)
 {
-    WKRetainPtr<WKContextRef> context = Util::adoptWK(WKContextCreate());
+    WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
     PlatformWebView webView(context.get());
 
     WKPagePolicyClient policyClient;
@@ -52,7 +52,7 @@ TEST(WebKit2, AboutBlankLoad)
     policyClient.decidePolicyForResponse = decidePolicyForResponse;
     WKPageSetPagePolicyClient(webView.page(), &policyClient);
 
-    WKPageLoadURL(webView.page(), Util::adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
+    WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
 
     Util::run(&done);
 }
index 8460847..dffac9b 100644 (file)
@@ -55,14 +55,14 @@ static void setInjectedBundleClient(WKContextRef context)
 
 TEST(WebKit2, CanHandleRequest)
 {
-    WKRetainPtr<WKContextRef> context = Util::adoptWK(Util::createContextForInjectedBundleTest("CanHandleRequestTest"));
+    WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("CanHandleRequestTest"));
     setInjectedBundleClient(context.get());
 
     _WKContextRegisterURLSchemeAsEmptyDocument(context.get(), Util::toWK("emptyscheme").get());
 
     PlatformWebView webView(context.get());
 
-    WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple", "html")).get());
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
 
     WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("CheckCanHandleRequest").get(), 0);
     Util::run(&didReceiveMessage);
index a253362..b5d644d 100644 (file)
@@ -47,7 +47,7 @@ CanHandleRequestTest::CanHandleRequestTest(const std::string& identifier)
 
 static bool canHandleURL(const char* url)
 {
-    return WKBundlePageCanHandleRequest(Util::adoptWK(WKURLRequestCreateWithWKURL(Util::adoptWK(WKURLCreateWithUTF8CString(url)).get())).get());
+    return WKBundlePageCanHandleRequest(adoptWK(WKURLRequestCreateWithWKURL(adoptWK(WKURLCreateWithUTF8CString(url)).get())).get());
 }
 
 static bool runTest()
@@ -60,7 +60,7 @@ void CanHandleRequestTest::didReceiveMessage(WKBundleRef bundle, WKStringRef mes
     if (!WKStringIsEqualToUTF8CString(messageName, "CheckCanHandleRequest"))
         return;
 
-    WKBundlePostMessage(bundle, Util::toWK("DidCheckCanHandleRequest").get(), Util::adoptWK(WKBooleanCreate(runTest())).get());
+    WKBundlePostMessage(bundle, Util::toWK("DidCheckCanHandleRequest").get(), adoptWK(WKBooleanCreate(runTest())).get());
 }
 
 } // namespace TestWebKitAPI
index cc4fc43..a1c366c 100644 (file)
@@ -80,7 +80,7 @@ TEST(WebKit2, CookieManager)
     loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
     WKPageSetPageLoaderClient(webView.page(), &loaderClient);
 
-    WKPageLoadURL(webView.page(), Util::adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
+    WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
 
     Util::run(&testDone);
 }
index 5000a47..3f15c15 100644 (file)
@@ -77,7 +77,7 @@ TEST(WebKit2, HitTestResultNodeHandle)
     PlatformWebView webView(context.get());
     setPageLoaderClient(webView.page());
 
-    WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple", "html")).get());
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
     Util::run(&didFinishLoad);
     didFinishLoad = false;
 
index a492a67..ce7324b 100644 (file)
@@ -72,12 +72,12 @@ TEST(WebKit2, PageLoadDidChangeLocationWithinPageForFrame)
     WKPageLoadURL(webView.page(), url.get());
     Util::run(&didFinishLoad);
 
-    WKRetainPtr<WKURLRef> initialURL = Util::adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page())));
+    WKRetainPtr<WKURLRef> initialURL = adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page())));
 
     WKPageRunJavaScriptInMainFrame(webView.page(), Util::toWK("clickLink()").get(), 0, nullJavaScriptCallback);
     Util::run(&didChangeLocationWithinPage);
 
-    WKRetainPtr<WKURLRef> urlAfterAnchorClick = Util::adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page())));
+    WKRetainPtr<WKURLRef> urlAfterAnchorClick = adoptWK(WKFrameCopyURL(WKPageGetMainFrame(webView.page())));
 
     TEST_ASSERT(!WKURLIsEqual(initialURL.get(), urlAfterAnchorClick.get()));
 }
index ea1013a..d8273a1 100644 (file)
@@ -75,13 +75,13 @@ static void setPageLoaderClient(WKPageRef page)
 
 TEST(WebKit2, ResponsivenessTimerDoesntFireEarly)
 {
-    WKRetainPtr<WKContextRef> context = Util::adoptWK(Util::createContextForInjectedBundleTest("ResponsivenessTimerDoesntFireEarlyTest"));
+    WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("ResponsivenessTimerDoesntFireEarlyTest"));
     setInjectedBundleClient(context.get());
 
     PlatformWebView webView(context.get());
     setPageLoaderClient(webView.page());
 
-    WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple", "html")).get());
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
     Util::run(&didFinishLoad);
 
     WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("BrieflyPause").get(), 0);
index 7c08735..0970bd2 100644 (file)
@@ -53,7 +53,7 @@ static WKRetainPtr<WKDataRef> createSessionStateContainingFormData(WKContextRef
     PlatformWebView webView(context);
     setPageLoaderClient(webView.page());
 
-    WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple-form", "html")).get());
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple-form", "html")).get());
     Util::run(&didFinishLoad);
     didFinishLoad = false;
 
@@ -61,7 +61,7 @@ static WKRetainPtr<WKDataRef> createSessionStateContainingFormData(WKContextRef
     Util::run(&didFinishLoad);
     didFinishLoad = false;
 
-    return Util::adoptWK(WKPageCopySessionState(webView.page(), 0, 0));
+    return adoptWK(WKPageCopySessionState(webView.page(), 0, 0));
 }
 
 TEST(WebKit2, RestoreSessionStateContainingFormData)
index 33e391d..28c6f85 100644 (file)
@@ -44,11 +44,6 @@ namespace WTR {
 
 // Conversion functions
 
-template<typename T> static inline WKRetainPtr<T> adoptWK(const T item)
-{
-    return WKRetainPtr<T>(AdoptWK, item);
-}
-
 inline WKRetainPtr<WKStringRef> toWK(JSStringRef string)
 {
     return adoptWK(WKStringCreateWithJSString(string));