Modified: trunk/Source/WebKit/ChangeLog (259004 => 259005)
--- trunk/Source/WebKit/ChangeLog 2020-03-25 19:49:39 UTC (rev 259004)
+++ trunk/Source/WebKit/ChangeLog 2020-03-25 20:02:59 UTC (rev 259005)
@@ -1,3 +1,12 @@
+2020-03-25 Brady Eidson <beid...@apple.com>
+
+ Some WKWebView.h header doc cleanup.
+ https://bugs.webkit.org/show_bug.cgi?id=209549
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/Cocoa/WKWebView.h:
+
2020-03-25 Daniel Bates <daba...@apple.com>
Remove newline that I accidentally added in r258989.
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h (259004 => 259005)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h 2020-03-25 19:49:39 UTC (rev 259004)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h 2020-03-25 20:02:59 UTC (rev 259005)
@@ -233,7 +233,7 @@
Evaluating your _javascript_ string can leave behind other changes to global state visibile to _javascript_. (e.g. `window.myVariable = 1;`)
Those changes will only be visibile to scripts executed in the same WKContentWorld.
evaluateJavaScript: is a great way to set up global state for future _javascript_ execution in a given world. (e.g. Importing libraries/utilities that future _javascript_ execution will rely on)
- Once your global state is set up, consider using callAsyncJavaScriptFunction: for more flexible interaction with the _javascript_ programming model.
+ Once your global state is set up, consider using callAsyncJavaScript: for more flexible interaction with the _javascript_ programming model.
*/
- (void)evaluateJavaScript:(NSString *)_javascript_String inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^ _Nullable)(_Nullable id, NSError * _Nullable error))completionHandler NS_REFINED_FOR_SWIFT WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@@ -243,18 +243,29 @@
@param contentWorld The WKContentWorld in which to call the _javascript_ function.
@param completionHandler A block to invoke with the return value of the function call, or with the asynchronous resolution of the function's return value.
@discussion The functionBody string is treated as an anonymous _javascript_ function body that can be called with named arguments.
- Do not format your string as one of the variants of function call available in _javascript_.
- Instead pass in a _javascript_ string representing the function body, formatted for evaluation.
+ Do not format your functionBody string as a function-like callable object as you would in pure _javascript_.
+ Your functionBody string should contain only the function body you want executed.
+
For example do not pass in the string:
- function(x, y, z) { return x ? y : z; }
+ @textblock
+ function(x, y, z)
+ {
+ return x ? y : z;
+ }
+ @/textblock
+
Instead pass in the string:
+ @textblock
return x ? y : z;
+ @/textblock
The arguments dictionary supplies the values for those arguments which are serialized into _javascript_ equivalents.
For example:
+ @textblock
@{ @"x" : @YES, @"y" : @1, @"z" : @"hello world" };
+ @/textblock
- Combining the above arguments dictionary with the above functionBody string, a function with the arguments named "x", "y", and "z" is called with values YES, 1, and "hello world" respectively.
+ Combining the above arguments dictionary with the above functionBody string, a function with the arguments named "x", "y", and "z" is called with values true, 1, and "hello world" respectively.
Allowed argument types are:
NSNumber, NSString, NSDate, NSArray, NSDictionary, and NSNull.
@@ -279,11 +290,13 @@
Since the function is a _javascript_ "async" function you can use _javascript_ "await" on thenable objects inside your function body.
For example:
+ @textblock
var p = new Promise(function (f) {
window.setTimeout("f(42)", 1000);
});
await p;
return p;
+ @/textblock
The above function text will create a promise that will fulfull with the value 42 after a one second delay, wait for it to resolve, then return the fulfillment value of 42.
*/