Changeset 159059 in webkit


Ignore:
Timestamp:
Nov 11, 2013 11:18:32 AM (10 years ago)
Author:
andersca@apple.com
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:]):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r159042 r159059  
     12013-11-11  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove block based APIs from the WebKit2 C API
     4        https://bugs.webkit.org/show_bug.cgi?id=124157
     5
     6        Reviewed by Sam Weinig.
     7
     8        Remove most of the block based C APIs from WebKit2. We want to discourage people from using
     9        them since any C API "objects" captured by blocks won't be implicitly retained which
     10        can lead to dangling pointer bugs.
     11
     12        * UIProcess/API/C/WKDatabaseManager.cpp:
     13        * UIProcess/API/C/WKDatabaseManager.h:
     14        * UIProcess/API/C/WKFrame.cpp:
     15        * UIProcess/API/C/WKFrame.h:
     16        * UIProcess/API/C/WKPage.cpp:
     17        * UIProcess/API/C/WKPage.h:
     18        * UIProcess/API/C/WKPagePrivate.h:
     19
    1202013-11-11  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp

    r123315 r159059  
    2929#include "WebDatabaseManagerProxy.h"
    3030#include "WKAPICast.h"
    31 
    32 #ifdef __BLOCKS__
    33 #include <Block.h>
    34 #endif
    3531
    3632using namespace WebKit;
     
    141137}
    142138
    143 #ifdef __BLOCKS__
    144 static void callGetDatabasesByOriginBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context)
    145 {
    146 #if ENABLE(SQL_DATABASE)
    147     WKDatabaseManagerGetDatabasesByOriginBlock block = (WKDatabaseManagerGetDatabasesByOriginBlock)context;
    148     block(resultValue, errorRef);
    149     Block_release(block);
    150 #endif
    151 }
    152 
    153 void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabasesByOriginBlock block)
    154 {
    155 #if ENABLE(SQL_DATABASE)
    156     WKDatabaseManagerGetDatabasesByOrigin(databaseManagerRef, Block_copy(block), callGetDatabasesByOriginBlockAndDispose);
    157 #endif
    158 }
    159 #endif // __BLOCKS__
    160 
    161139void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction callback)
    162140{
     
    165143#endif
    166144}
    167 
    168 #ifdef __BLOCKS__
    169 static void callGetDatabaseOriginsBlockBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context)
    170 {
    171 #if ENABLE(SQL_DATABASE)
    172     WKDatabaseManagerGetDatabaseOriginsBlock block = (WKDatabaseManagerGetDatabaseOriginsBlock)context;
    173     block(resultValue, errorRef);
    174     Block_release(block);
    175 #endif
    176 }
    177 
    178 void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabaseOriginsBlock block)
    179 {
    180 #if ENABLE(SQL_DATABASE)
    181     WKDatabaseManagerGetDatabaseOrigins(databaseManagerRef, Block_copy(block), callGetDatabaseOriginsBlockBlockAndDispose);
    182 #endif
    183 }
    184 #endif // __BLOCKS__
    185145
    186146void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManagerRef, WKStringRef databaseNameRef, WKSecurityOriginRef originRef)
  • trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h

    r95901 r159059  
    8484typedef void (*WKDatabaseManagerGetDatabasesByOriginFunction)(WKArrayRef, WKErrorRef, void*);
    8585WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManager, void* context, WKDatabaseManagerGetDatabasesByOriginFunction function);
    86 #ifdef __BLOCKS__
    87 typedef void (^WKDatabaseManagerGetDatabasesByOriginBlock)(WKArrayRef, WKErrorRef);
    88 WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabasesByOriginBlock block);
    89 #endif
    9086
    9187typedef void (*WKDatabaseManagerGetDatabaseOriginsFunction)(WKArrayRef, WKErrorRef, void*);
    9288WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef contextRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction function);
    93 #ifdef __BLOCKS__
    94 typedef void (^WKDatabaseManagerGetDatabaseOriginsBlock)(WKArrayRef, WKErrorRef);
    95 WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabaseOriginsBlock block);
    96 #endif
    9789
    9890WK_EXPORT void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManager, WKStringRef databaseName, WKSecurityOriginRef origin);
  • trunk/Source/WebKit2/UIProcess/API/C/WKFrame.cpp

    r141708 r159059  
    2929#include "WKAPICast.h"
    3030#include "WebFrameProxy.h"
    31 
    32 #ifdef __BLOCKS__
    33 #include <Block.h>
    34 #endif
    3531
    3632using namespace WebKit;
     
    137133}
    138134
    139 #ifdef __BLOCKS__
    140 static void callGetResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context)
    141 {
    142     WKFrameGetResourceDataBlock block = (WKFrameGetResourceDataBlock)context;
    143     block(data, error);
    144     Block_release(block);
    145 }
    146 
    147 void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetResourceDataBlock block)
    148 {
    149     WKFrameGetMainResourceData(frameRef, callGetResourceDataBlockAndDispose, Block_copy(block));
    150 }
    151 
    152 void WKFrameGetResourceData_b(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataBlock block)
    153 {
    154     WKFrameGetResourceData(frameRef, resourceURL, callGetResourceDataBlockAndDispose, Block_copy(block));
    155 }
    156 #endif
    157 
    158135void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context)
    159136{
    160137    toImpl(frameRef)->getWebArchive(DataCallback::create(context, callback));
    161138}
    162 
    163 #ifdef __BLOCKS__
    164 static void callGetWebArchiveBlockAndDispose(WKDataRef archiveData, WKErrorRef error, void* context)
    165 {
    166     WKFrameGetWebArchiveBlock block = (WKFrameGetWebArchiveBlock)context;
    167     block(archiveData, error);
    168     Block_release(block);
    169 }
    170 
    171 void WKFrameGetWebArchive_b(WKFrameRef frameRef, WKFrameGetWebArchiveBlock block)
    172 {
    173     WKFrameGetWebArchive(frameRef, callGetWebArchiveBlockAndDispose, Block_copy(block));
    174 }
    175 #endif
    176 
    177139
    178140// NOTE: These are deprecated and should be removed. They currently do nothing.
  • trunk/Source/WebKit2/UIProcess/API/C/WKFrame.h

    r141708 r159059  
    7272WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetResourceDataFunction function, void* functionContext);
    7373WK_EXPORT void WKFrameGetResourceData(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataFunction function, void* functionContext);
    74 #ifdef __BLOCKS__
    75 typedef void (^WKFrameGetResourceDataBlock)(WKDataRef data, WKErrorRef error);
    76 WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetResourceDataBlock block);
    77 WK_EXPORT void WKFrameGetResourceData_b(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataBlock block);
    78 #endif
    7974
    8075typedef void (*WKFrameGetWebArchiveFunction)(WKDataRef archiveData, WKErrorRef error, void* functionContext);
    8176WK_EXPORT void WKFrameGetWebArchive(WKFrameRef frame, WKFrameGetWebArchiveFunction function, void* functionContext);
    82 #ifdef __BLOCKS__
    83 typedef void (^WKFrameGetWebArchiveBlock)(WKDataRef archiveData, WKErrorRef error);
    84 WK_EXPORT void WKFrameGetWebArchive_b(WKFrameRef frame, WKFrameGetWebArchiveBlock block);
    85 #endif
    86 
    8777
    8878// NOTE: These are deprecated and should be removed. They currently do nothing.
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r158759 r159059  
    690690}
    691691
    692 #ifdef __BLOCKS__
    693 static void callRenderTreeExternalRepresentationBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
    694 {
    695     WKPageRenderTreeExternalRepresentationBlock block = (WKPageRenderTreeExternalRepresentationBlock)context;
    696     block(resultValue, error);
    697     Block_release(block);
    698 }
    699 
    700 void WKPageRenderTreeExternalRepresentation_b(WKPageRef pageRef, WKPageRenderTreeExternalRepresentationBlock block)
    701 {
    702     WKPageRenderTreeExternalRepresentation(pageRef, Block_copy(block), callRenderTreeExternalRepresentationBlockAndDispose);
    703 }
    704 #endif
    705 
    706692void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
    707693{
     
    709695}
    710696
    711 #ifdef __BLOCKS__
    712 static void callGetSourceForFrameBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
    713 {
    714     WKPageGetSourceForFrameBlock block = (WKPageGetSourceForFrameBlock)context;
    715     block(resultValue, error);
    716     Block_release(block);
    717 }
    718 
    719 void WKPageGetSourceForFrame_b(WKPageRef pageRef, WKFrameRef frameRef, WKPageGetSourceForFrameBlock block)
    720 {
    721     WKPageGetSourceForFrame(pageRef, frameRef, Block_copy(block), callGetSourceForFrameBlockBlockAndDispose);
    722 }
    723 #endif
    724 
    725697void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
    726698{
    727699    toImpl(pageRef)->getContentsAsString(StringCallback::create(context, callback));
    728700}
    729 
    730 #ifdef __BLOCKS__
    731 static void callContentsAsStringBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
    732 {
    733     WKPageGetContentsAsStringBlock block = (WKPageGetContentsAsStringBlock)context;
    734     block(resultValue, error);
    735     Block_release(block);
    736 }
    737 
    738 void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock block)
    739 {
    740     WKPageGetContentsAsString(pageRef, Block_copy(block), callContentsAsStringBlockBlockAndDispose);
    741 }
    742 #endif
    743701
    744702void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.h

    r156924 r159059  
    511511typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
    512512WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
    513 #ifdef __BLOCKS__
    514 typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
    515 WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
    516 #endif
    517513
    518514typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
    519515WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
    520 #ifdef __BLOCKS__
    521 typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
    522 WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
    523 #endif
    524516
    525517typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*);
  • trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h

    r152425 r159059  
    3636typedef void (*WKPageRenderTreeExternalRepresentationFunction)(WKStringRef, WKErrorRef, void*);
    3737WK_EXPORT void WKPageRenderTreeExternalRepresentation(WKPageRef page, void *context, WKPageRenderTreeExternalRepresentationFunction function);
    38 
    39 #ifdef __BLOCKS__
    40 typedef void (^WKPageRenderTreeExternalRepresentationBlock)(WKStringRef, WKErrorRef);
    41 WK_EXPORT void WKPageRenderTreeExternalRepresentation_b(WKPageRef page, WKPageRenderTreeExternalRepresentationBlock block);
    42 #endif
    4338
    4439enum {
  • trunk/Tools/ChangeLog

    r159052 r159059  
     12013-11-11  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove block based APIs from the WebKit2 C API
     4        https://bugs.webkit.org/show_bug.cgi?id=124157
     5
     6        Reviewed by Sam Weinig.
     7
     8        Update for WK2 changes.
     9
     10        * MiniBrowser/mac/WK2BrowserWindowController.m:
     11        (dumpSource):
     12        (-[WK2BrowserWindowController dumpSourceToConsole:]):
     13
    1142013-11-11  Tamas Gergely  <gertom@inf.u-szeged.hu>
    215
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r153956 r159059  
    282282}
    283283
     284static void dumpSource(WKStringRef source, WKErrorRef error, void* context)
     285{
     286    if (!source)
     287        return;
     288
     289    LOG(@"Main frame source\n \"%@\"", CFBridgingRelease(WKStringCopyCFString(0, source)));
     290}
     291
    284292- (IBAction)dumpSourceToConsole:(id)sender
    285293{
    286     WKPageGetSourceForFrame_b(_webView.pageRef, WKPageGetMainFrame(_webView.pageRef), ^(WKStringRef result, WKErrorRef error) {
    287         if (!result)
    288             return;
    289 
    290         CFStringRef cfResult = WKStringCopyCFString(0, result);
    291         LOG(@"Main frame source\n \"%@\"", (NSString *)cfResult);
    292         CFRelease(cfResult);
    293     });
     294    WKPageGetSourceForFrame(_webView.pageRef, WKPageGetMainFrame(_webView.pageRef), NULL, dumpSource);
    294295}
    295296
Note: See TracChangeset for help on using the changeset viewer.