Title: [159059] trunk
Revision
159059
Author
[email protected]
Date
2013-11-11 11:18:32 -0800 (Mon, 11 Nov 2013)

Log Message

Remove block based APIs from the WebKit2 C API
https://bugs.webkit.org/show_bug.cgi?id=124157

Reviewed by Sam Weinig.

Source/WebKit2:

Remove most of the block based C APIs from WebKit2. We want to discourage people from using
them since any C API "objects" captured by blocks won't be implicitly retained which
can lead to dangling pointer bugs.

* UIProcess/API/C/WKDatabaseManager.cpp:
* UIProcess/API/C/WKDatabaseManager.h:
* UIProcess/API/C/WKFrame.cpp:
* UIProcess/API/C/WKFrame.h:
* UIProcess/API/C/WKPage.cpp:
* UIProcess/API/C/WKPage.h:
* UIProcess/API/C/WKPagePrivate.h:

Tools:

Update for WK2 changes.

* MiniBrowser/mac/WK2BrowserWindowController.m:
(dumpSource):
(-[WK2BrowserWindowController dumpSourceToConsole:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (159058 => 159059)


--- trunk/Source/WebKit2/ChangeLog	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-11 19:18:32 UTC (rev 159059)
@@ -1,3 +1,22 @@
+2013-11-11  Anders Carlsson  <[email protected]>
+
+        Remove block based APIs from the WebKit2 C API
+        https://bugs.webkit.org/show_bug.cgi?id=124157
+
+        Reviewed by Sam Weinig.
+
+        Remove most of the block based C APIs from WebKit2. We want to discourage people from using
+        them since any C API "objects" captured by blocks won't be implicitly retained which
+        can lead to dangling pointer bugs.
+
+        * UIProcess/API/C/WKDatabaseManager.cpp:
+        * UIProcess/API/C/WKDatabaseManager.h:
+        * UIProcess/API/C/WKFrame.cpp:
+        * UIProcess/API/C/WKFrame.h:
+        * UIProcess/API/C/WKPage.cpp:
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/API/C/WKPagePrivate.h:
+
 2013-11-11  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Crash when printing via _javascript_ in WebKit2

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp	2013-11-11 19:18:32 UTC (rev 159059)
@@ -29,10 +29,6 @@
 #include "WebDatabaseManagerProxy.h"
 #include "WKAPICast.h"
 
-#ifdef __BLOCKS__
-#include <Block.h>
-#endif
-
 using namespace WebKit;
 
 WKTypeID WKDatabaseManagerGetTypeID()
@@ -140,24 +136,6 @@
 #endif
 }
 
-#ifdef __BLOCKS__
-static void callGetDatabasesByOriginBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context)
-{
-#if ENABLE(SQL_DATABASE)
-    WKDatabaseManagerGetDatabasesByOriginBlock block = (WKDatabaseManagerGetDatabasesByOriginBlock)context;
-    block(resultValue, errorRef);
-    Block_release(block);
-#endif
-}
-
-void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabasesByOriginBlock block)
-{
-#if ENABLE(SQL_DATABASE)
-    WKDatabaseManagerGetDatabasesByOrigin(databaseManagerRef, Block_copy(block), callGetDatabasesByOriginBlockAndDispose);
-#endif
-}
-#endif // __BLOCKS__
-
 void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction callback)
 {
 #if ENABLE(SQL_DATABASE)
@@ -165,24 +143,6 @@
 #endif
 }
 
-#ifdef __BLOCKS__
-static void callGetDatabaseOriginsBlockBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context)
-{
-#if ENABLE(SQL_DATABASE)
-    WKDatabaseManagerGetDatabaseOriginsBlock block = (WKDatabaseManagerGetDatabaseOriginsBlock)context;
-    block(resultValue, errorRef);
-    Block_release(block);
-#endif
-}
-
-void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabaseOriginsBlock block)
-{
-#if ENABLE(SQL_DATABASE)
-    WKDatabaseManagerGetDatabaseOrigins(databaseManagerRef, Block_copy(block), callGetDatabaseOriginsBlockBlockAndDispose);
-#endif
-}
-#endif // __BLOCKS__
-
 void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManagerRef, WKStringRef databaseNameRef, WKSecurityOriginRef originRef)
 {
 #if ENABLE(SQL_DATABASE)

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h	2013-11-11 19:18:32 UTC (rev 159059)
@@ -83,17 +83,9 @@
 
 typedef void (*WKDatabaseManagerGetDatabasesByOriginFunction)(WKArrayRef, WKErrorRef, void*);
 WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManager, void* context, WKDatabaseManagerGetDatabasesByOriginFunction function);
-#ifdef __BLOCKS__
-typedef void (^WKDatabaseManagerGetDatabasesByOriginBlock)(WKArrayRef, WKErrorRef);
-WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabasesByOriginBlock block);
-#endif
 
 typedef void (*WKDatabaseManagerGetDatabaseOriginsFunction)(WKArrayRef, WKErrorRef, void*);
 WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef contextRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction function);
-#ifdef __BLOCKS__
-typedef void (^WKDatabaseManagerGetDatabaseOriginsBlock)(WKArrayRef, WKErrorRef);
-WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabaseOriginsBlock block);
-#endif
 
 WK_EXPORT void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManager, WKStringRef databaseName, WKSecurityOriginRef origin);
 WK_EXPORT void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin);

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKFrame.cpp (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKFrame.cpp	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKFrame.cpp	2013-11-11 19:18:32 UTC (rev 159059)
@@ -29,10 +29,6 @@
 #include "WKAPICast.h"
 #include "WebFrameProxy.h"
 
-#ifdef __BLOCKS__
-#include <Block.h>
-#endif
-
 using namespace WebKit;
 
 WKTypeID WKFrameGetTypeID()
@@ -136,45 +132,11 @@
     toImpl(frameRef)->getResourceData(toImpl(resourceURL), DataCallback::create(context, callback));
 }
 
-#ifdef __BLOCKS__
-static void callGetResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context)
-{
-    WKFrameGetResourceDataBlock block = (WKFrameGetResourceDataBlock)context;
-    block(data, error);
-    Block_release(block);
-}
-
-void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetResourceDataBlock block)
-{
-    WKFrameGetMainResourceData(frameRef, callGetResourceDataBlockAndDispose, Block_copy(block));
-}
-
-void WKFrameGetResourceData_b(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataBlock block)
-{
-    WKFrameGetResourceData(frameRef, resourceURL, callGetResourceDataBlockAndDispose, Block_copy(block));
-}
-#endif
-
 void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context)
 {
     toImpl(frameRef)->getWebArchive(DataCallback::create(context, callback));
 }
 
-#ifdef __BLOCKS__
-static void callGetWebArchiveBlockAndDispose(WKDataRef archiveData, WKErrorRef error, void* context)
-{
-    WKFrameGetWebArchiveBlock block = (WKFrameGetWebArchiveBlock)context;
-    block(archiveData, error);
-    Block_release(block);
-}
-
-void WKFrameGetWebArchive_b(WKFrameRef frameRef, WKFrameGetWebArchiveBlock block)
-{
-    WKFrameGetWebArchive(frameRef, callGetWebArchiveBlockAndDispose, Block_copy(block));
-}
-#endif
-
-
 // NOTE: These are deprecated and should be removed. They currently do nothing.
 
 WKArrayRef WKFrameCopyChildFrames(WKFrameRef)

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKFrame.h (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKFrame.h	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKFrame.h	2013-11-11 19:18:32 UTC (rev 159059)
@@ -71,20 +71,10 @@
 typedef void (*WKFrameGetResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
 WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetResourceDataFunction function, void* functionContext);
 WK_EXPORT void WKFrameGetResourceData(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataFunction function, void* functionContext);
-#ifdef __BLOCKS__
-typedef void (^WKFrameGetResourceDataBlock)(WKDataRef data, WKErrorRef error);
-WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetResourceDataBlock block);
-WK_EXPORT void WKFrameGetResourceData_b(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataBlock block);
-#endif
 
 typedef void (*WKFrameGetWebArchiveFunction)(WKDataRef archiveData, WKErrorRef error, void* functionContext);
 WK_EXPORT void WKFrameGetWebArchive(WKFrameRef frame, WKFrameGetWebArchiveFunction function, void* functionContext);
-#ifdef __BLOCKS__
-typedef void (^WKFrameGetWebArchiveBlock)(WKDataRef archiveData, WKErrorRef error);
-WK_EXPORT void WKFrameGetWebArchive_b(WKFrameRef frame, WKFrameGetWebArchiveBlock block);
-#endif
 
-
 // NOTE: These are deprecated and should be removed. They currently do nothing.
 
 WK_EXPORT WKArrayRef WKFrameCopyChildFrames(WKFrameRef frame);

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2013-11-11 19:18:32 UTC (rev 159059)
@@ -689,58 +689,16 @@
     toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(context, callback));
 }
 
-#ifdef __BLOCKS__
-static void callRenderTreeExternalRepresentationBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
-{
-    WKPageRenderTreeExternalRepresentationBlock block = (WKPageRenderTreeExternalRepresentationBlock)context;
-    block(resultValue, error);
-    Block_release(block);
-}
-
-void WKPageRenderTreeExternalRepresentation_b(WKPageRef pageRef, WKPageRenderTreeExternalRepresentationBlock block)
-{
-    WKPageRenderTreeExternalRepresentation(pageRef, Block_copy(block), callRenderTreeExternalRepresentationBlockAndDispose);
-}
-#endif
-
 void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
 {
     toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(context, callback));
 }
 
-#ifdef __BLOCKS__
-static void callGetSourceForFrameBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
-{
-    WKPageGetSourceForFrameBlock block = (WKPageGetSourceForFrameBlock)context;
-    block(resultValue, error);
-    Block_release(block);
-}
-
-void WKPageGetSourceForFrame_b(WKPageRef pageRef, WKFrameRef frameRef, WKPageGetSourceForFrameBlock block)
-{
-    WKPageGetSourceForFrame(pageRef, frameRef, Block_copy(block), callGetSourceForFrameBlockBlockAndDispose);
-}
-#endif
-
 void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
 {
     toImpl(pageRef)->getContentsAsString(StringCallback::create(context, callback));
 }
 
-#ifdef __BLOCKS__
-static void callContentsAsStringBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
-{
-    WKPageGetContentsAsStringBlock block = (WKPageGetContentsAsStringBlock)context;
-    block(resultValue, error);
-    Block_release(block);
-}
-
-void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock block)
-{
-    WKPageGetContentsAsString(pageRef, Block_copy(block), callContentsAsStringBlockBlockAndDispose);
-}
-#endif
-
 void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
 {
     toImpl(pageRef)->getSelectionAsWebArchiveData(DataCallback::create(context, callback));

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.h (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.h	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.h	2013-11-11 19:18:32 UTC (rev 159059)
@@ -510,17 +510,9 @@
 
 typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
 WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
-#ifdef __BLOCKS__
-typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
-WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
-#endif
 
 typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
 WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
-#ifdef __BLOCKS__
-typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
-WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
-#endif
 
 typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*);
 WK_EXPORT void WKPageGetContentsAsMHTMLData(WKPageRef page, bool useBinaryEncoding, void* context, WKPageGetContentsAsMHTMLDataFunction function);

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (159058 => 159059)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2013-11-11 19:18:32 UTC (rev 159059)
@@ -36,11 +36,6 @@
 typedef void (*WKPageRenderTreeExternalRepresentationFunction)(WKStringRef, WKErrorRef, void*);
 WK_EXPORT void WKPageRenderTreeExternalRepresentation(WKPageRef page, void *context, WKPageRenderTreeExternalRepresentationFunction function);
 
-#ifdef __BLOCKS__
-typedef void (^WKPageRenderTreeExternalRepresentationBlock)(WKStringRef, WKErrorRef);
-WK_EXPORT void WKPageRenderTreeExternalRepresentation_b(WKPageRef page, WKPageRenderTreeExternalRepresentationBlock block);
-#endif
-
 enum {
     kWKDebugFlashViewUpdates = 1 << 0,
     kWKDebugFlashBackingStoreUpdates = 1 << 1

Modified: trunk/Tools/ChangeLog (159058 => 159059)


--- trunk/Tools/ChangeLog	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Tools/ChangeLog	2013-11-11 19:18:32 UTC (rev 159059)
@@ -1,3 +1,16 @@
+2013-11-11  Anders Carlsson  <[email protected]>
+
+        Remove block based APIs from the WebKit2 C API
+        https://bugs.webkit.org/show_bug.cgi?id=124157
+
+        Reviewed by Sam Weinig.
+
+        Update for WK2 changes.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (dumpSource):
+        (-[WK2BrowserWindowController dumpSourceToConsole:]):
+
 2013-11-11  Tamas Gergely  <[email protected]>
 
         The feeder queue will not feed patches older than one week.

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (159058 => 159059)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2013-11-11 18:21:21 UTC (rev 159058)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2013-11-11 19:18:32 UTC (rev 159059)
@@ -281,18 +281,19 @@
     [[self window] display];    
 }
 
-- (IBAction)dumpSourceToConsole:(id)sender
+static void dumpSource(WKStringRef source, WKErrorRef error, void* context)
 {
-    WKPageGetSourceForFrame_b(_webView.pageRef, WKPageGetMainFrame(_webView.pageRef), ^(WKStringRef result, WKErrorRef error) {
-        if (!result)
-            return;
+    if (!source)
+        return;
 
-        CFStringRef cfResult = WKStringCopyCFString(0, result);
-        LOG(@"Main frame source\n \"%@\"", (NSString *)cfResult);
-        CFRelease(cfResult);
-    });
+    LOG(@"Main frame source\n \"%@\"", CFBridgingRelease(WKStringCopyCFString(0, source)));
 }
 
+- (IBAction)dumpSourceToConsole:(id)sender
+{
+    WKPageGetSourceForFrame(_webView.pageRef, WKPageGetMainFrame(_webView.pageRef), NULL, dumpSource);
+}
+
 // MARK: Loader Client Callbacks
 
 static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to