Changeset 169987 in webkit


Ignore:
Timestamp:
Jun 14, 2014, 7:10:26 PM (11 years ago)
Author:
mitz@apple.com
Message:

Replace StringImpl* callback parameters with const String&
https://bugs.webkit.org/show_bug.cgi?id=133922

Reviewed by Sam Weinig.

  • UIProcess/API/C/WKPage.cpp:

(toGenericCallbackFunction): Added this helper function to wrap a WKStringRef-returning
API callback in a generic const String&-returning callback.
(WKPageRenderTreeExternalRepresentation):
(WKPageGetSourceForFrame):
(WKPageGetContentsAsString):
(WKPageGetBytecodeProfile):
(WKPageValidateCommand):

  • UIProcess/API/mac/WKView.mm:

(-[WKView validateUserInterfaceItem:]):
(-[WKView startSpeaking:]):

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _define:]):
(-[WKContentView applyAutocorrection:toString:withCompletionHandler:]):

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r169986 r169987  
     12014-06-14  Dan Bernstein  <mitz@apple.com>
     2
     3        Replace StringImpl* callback parameters with const String&
     4        https://bugs.webkit.org/show_bug.cgi?id=133922
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/API/C/WKPage.cpp:
     9        (toGenericCallbackFunction): Added this helper function to wrap a WKStringRef-returning
     10        API callback in a generic const String&-returning callback.
     11        (WKPageRenderTreeExternalRepresentation):
     12        (WKPageGetSourceForFrame):
     13        (WKPageGetContentsAsString):
     14        (WKPageGetBytecodeProfile):
     15        (WKPageValidateCommand):
     16        * UIProcess/API/mac/WKView.mm:
     17        (-[WKView validateUserInterfaceItem:]):
     18        (-[WKView startSpeaking:]):
     19        * UIProcess/WebPageProxy.h:
     20        * UIProcess/ios/WKContentViewInteraction.mm:
     21        (-[WKContentView _define:]):
     22        (-[WKContentView applyAutocorrection:toString:withCompletionHandler:]):
     23
    1242014-06-14  Dan Bernstein  <mitz@apple.com>
    225
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r169984 r169987  
    15801580#endif
    15811581
     1582static std::function<void (const String&, CallbackBase::Error)> toGenericCallbackFunction(void* context, void (*callback)(WKStringRef, WKErrorRef, void*))
     1583{
     1584    return [context, callback](const String& returnValue, CallbackBase::Error error) {
     1585        callback(toAPI(API::String::create(returnValue).get()), error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
     1586    };
     1587}
     1588
    15821589void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
    15831590{
    1584     toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
     1591    toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(toGenericCallbackFunction(context, callback)));
    15851592}
    15861593
    15871594void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
    15881595{
    1589     toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
     1596    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(toGenericCallbackFunction(context, callback)));
    15901597}
    15911598
    15921599void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
    15931600{
    1594     toImpl(pageRef)->getContentsAsString(StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
     1601    toImpl(pageRef)->getContentsAsString(StringCallback::create(toGenericCallbackFunction(context, callback)));
    15951602}
    15961603
    15971604void WKPageGetBytecodeProfile(WKPageRef pageRef, void* context, WKPageGetBytecodeProfileFunction callback)
    15981605{
    1599     toImpl(pageRef)->getBytecodeProfile(StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
     1606    toImpl(pageRef)->getBytecodeProfile(StringCallback::create(toGenericCallbackFunction(context, callback)));
    16001607}
    16011608
     
    16541661void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
    16551662{
    1656     toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](StringImpl* commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
    1657         callback(toAPI(commandName), isEnabled, state, error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
     1663    toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](const String& commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
     1664        callback(toAPI(API::String::create(commandName).get()), isEnabled, state, error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
    16581665    }));
    16591666}
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r169971 r169987  
    836836        // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
    837837        // we asked for the same command; there is no guarantee the answer is still valid.
    838         _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](StringImpl* commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
     838        _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](const String& commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
    839839            // If the process exits before the command can be validated, we'll be called back with an error.
    840840            if (error != CallbackBase::Error::None)
    841841                return;
    842842           
    843             [self _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:state];
     843            [self _setUserInterfaceItemState:commandName enabled:isEnabled state:state];
    844844        }));
    845845    }
     
    853853- (IBAction)startSpeaking:(id)sender
    854854{
    855     _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
     855    _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](const String& string, CallbackBase::Error error) {
    856856        if (error != CallbackBase::Error::None)
    857857            return;
     
    859859            return;
    860860
    861         [NSApp speakString:*string];
     861        [NSApp speakString:string];
    862862    }));
    863863}
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r169962 r169987  
    187187typedef GenericCallback<uint64_t> UnsignedCallback;
    188188typedef GenericCallback<EditingRange> EditingRangeCallback;
    189 typedef GenericCallback<StringImpl*> StringCallback;
     189typedef GenericCallback<const String&> StringCallback;
    190190typedef GenericCallback<WebSerializedScriptValue*> ScriptValueCallback;
    191191
     
    205205#endif
    206206
    207 typedef GenericCallback<StringImpl*, bool, int32_t> ValidateCommandCallback;
     207typedef GenericCallback<const String&, bool, int32_t> ValidateCommandCallback;
    208208typedef GenericCallback<const WebCore::IntRect&, const EditingRange&> RectForCharacterRangeCallback;
    209209
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r169986 r169987  
    12111211- (void)_define:(id)sender
    12121212{
    1213     _page->getSelectionOrContentsAsString(StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
     1213    _page->getSelectionOrContentsAsString(StringCallback::create([self](const String& string, CallbackBase::Error error) {
    12141214        if (error != CallbackBase::Error::None)
    12151215            return;
     
    12171217            return;
    12181218
    1219         NSString *convertedString = *string;
    1220         [self _showDictionary:convertedString];
     1219        [self _showDictionary:string];
    12211220    }));
    12221221}
     
    15581557    }
    15591558    _autocorrectionData.autocorrectionHandler = [completionHandler copy];
    1560     _page->applyAutocorrection(correction, input, StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
    1561         _autocorrectionData.autocorrectionHandler(string ? [WKAutocorrectionRects autocorrectionRectsWithRects:_autocorrectionData.textFirstRect lastRect:_autocorrectionData.textLastRect] : nil);
     1559    _page->applyAutocorrection(correction, input, StringCallback::create([self](const String& string, CallbackBase::Error error) {
     1560        _autocorrectionData.autocorrectionHandler(!string.isNull() ? [WKAutocorrectionRects autocorrectionRectsWithRects:_autocorrectionData.textFirstRect lastRect:_autocorrectionData.textLastRect] : nil);
    15621561        [_autocorrectionData.autocorrectionHandler release];
    15631562        _autocorrectionData.autocorrectionHandler = nil;
Note: See TracChangeset for help on using the changeset viewer.