Title: [169987] trunk/Source/WebKit2
Revision
169987
Author
[email protected]
Date
2014-06-14 19:10:26 -0700 (Sat, 14 Jun 2014)

Log 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:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (169986 => 169987)


--- trunk/Source/WebKit2/ChangeLog	2014-06-15 00:07:42 UTC (rev 169986)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-15 02:10:26 UTC (rev 169987)
@@ -1,5 +1,28 @@
 2014-06-14  Dan Bernstein  <[email protected]>
 
+        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:]):
+
+2014-06-14  Dan Bernstein  <[email protected]>
+
         Additional iOS build fix.
 
         * UIProcess/ios/WKContentViewInteraction.mm:

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


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-06-15 00:07:42 UTC (rev 169986)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-06-15 02:10:26 UTC (rev 169987)
@@ -1579,24 +1579,31 @@
 }
 #endif
 
+static std::function<void (const String&, CallbackBase::Error)> toGenericCallbackFunction(void* context, void (*callback)(WKStringRef, WKErrorRef, void*))
+{
+    return [context, callback](const String& returnValue, CallbackBase::Error error) {
+        callback(toAPI(API::String::create(returnValue).get()), error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
+    };
+}
+
 void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
 {
-    toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
+    toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(toGenericCallbackFunction(context, callback)));
 }
 
 void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
 {
-    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
+    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(toGenericCallbackFunction(context, callback)));
 }
 
 void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
 {
-    toImpl(pageRef)->getContentsAsString(StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
+    toImpl(pageRef)->getContentsAsString(StringCallback::create(toGenericCallbackFunction(context, callback)));
 }
 
 void WKPageGetBytecodeProfile(WKPageRef pageRef, void* context, WKPageGetBytecodeProfileFunction callback)
 {
-    toImpl(pageRef)->getBytecodeProfile(StringCallback::create(toGenericCallbackFunction<WKStringRef, StringImpl*>(context, callback)));
+    toImpl(pageRef)->getBytecodeProfile(StringCallback::create(toGenericCallbackFunction(context, callback)));
 }
 
 void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
@@ -1653,8 +1660,8 @@
 
 void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
 {
-    toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](StringImpl* commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
-        callback(toAPI(commandName), isEnabled, state, error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
+    toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](const String& commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
+        callback(toAPI(API::String::create(commandName).get()), isEnabled, state, error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
     }));
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (169986 => 169987)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-06-15 00:07:42 UTC (rev 169986)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-06-15 02:10:26 UTC (rev 169987)
@@ -835,12 +835,12 @@
         // If we are not already awaiting validation for this command, start the asynchronous validation process.
         // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
         // we asked for the same command; there is no guarantee the answer is still valid.
-        _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](StringImpl* commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
+        _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](const String& commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
             // If the process exits before the command can be validated, we'll be called back with an error.
             if (error != CallbackBase::Error::None)
                 return;
             
-            [self _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:state];
+            [self _setUserInterfaceItemState:commandName enabled:isEnabled state:state];
         }));
     }
 
@@ -852,13 +852,13 @@
 
 - (IBAction)startSpeaking:(id)sender
 {
-    _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
+    _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](const String& string, CallbackBase::Error error) {
         if (error != CallbackBase::Error::None)
             return;
         if (!string)
             return;
 
-        [NSApp speakString:*string];
+        [NSApp speakString:string];
     }));
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (169986 => 169987)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-06-15 00:07:42 UTC (rev 169986)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-06-15 02:10:26 UTC (rev 169987)
@@ -186,7 +186,7 @@
 
 typedef GenericCallback<uint64_t> UnsignedCallback;
 typedef GenericCallback<EditingRange> EditingRangeCallback;
-typedef GenericCallback<StringImpl*> StringCallback;
+typedef GenericCallback<const String&> StringCallback;
 typedef GenericCallback<WebSerializedScriptValue*> ScriptValueCallback;
 
 #if PLATFORM(GTK)
@@ -204,7 +204,7 @@
 };
 #endif
 
-typedef GenericCallback<StringImpl*, bool, int32_t> ValidateCommandCallback;
+typedef GenericCallback<const String&, bool, int32_t> ValidateCommandCallback;
 typedef GenericCallback<const WebCore::IntRect&, const EditingRange&> RectForCharacterRangeCallback;
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (169986 => 169987)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-06-15 00:07:42 UTC (rev 169986)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-06-15 02:10:26 UTC (rev 169987)
@@ -1210,14 +1210,13 @@
 
 - (void)_define:(id)sender
 {
-    _page->getSelectionOrContentsAsString(StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
+    _page->getSelectionOrContentsAsString(StringCallback::create([self](const String& string, CallbackBase::Error error) {
         if (error != CallbackBase::Error::None)
             return;
         if (!string)
             return;
 
-        NSString *convertedString = *string;
-        [self _showDictionary:convertedString];
+        [self _showDictionary:string];
     }));
 }
 
@@ -1557,8 +1556,8 @@
         return;
     }
     _autocorrectionData.autocorrectionHandler = [completionHandler copy];
-    _page->applyAutocorrection(correction, input, StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
-        _autocorrectionData.autocorrectionHandler(string ? [WKAutocorrectionRects autocorrectionRectsWithRects:_autocorrectionData.textFirstRect lastRect:_autocorrectionData.textLastRect] : nil);
+    _page->applyAutocorrection(correction, input, StringCallback::create([self](const String& string, CallbackBase::Error error) {
+        _autocorrectionData.autocorrectionHandler(!string.isNull() ? [WKAutocorrectionRects autocorrectionRectsWithRects:_autocorrectionData.textFirstRect lastRect:_autocorrectionData.textLastRect] : nil);
         [_autocorrectionData.autocorrectionHandler release];
         _autocorrectionData.autocorrectionHandler = nil;
     }));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to