Changeset 259005 in webkit


Ignore:
Timestamp:
Mar 25, 2020 1:02:59 PM (4 years ago)
Author:
beidson@apple.com
Message:

Some WKWebView.h header doc cleanup.
https://bugs.webkit.org/show_bug.cgi?id=209549

Reviewed by Simon Fraser.

  • UIProcess/API/Cocoa/WKWebView.h:
Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r258995 r259005  
     12020-03-25  Brady Eidson  <beidson@apple.com>
     2
     3        Some WKWebView.h header doc cleanup.
     4        https://bugs.webkit.org/show_bug.cgi?id=209549
     5
     6        Reviewed by Simon Fraser.
     7
     8        * UIProcess/API/Cocoa/WKWebView.h:
     9
    1102020-03-25  Daniel Bates  <dabates@apple.com>
    211
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h

    r257819 r259005  
    234234 Those changes will only be visibile to scripts executed in the same WKContentWorld.
    235235 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)
    236  Once your global state is set up, consider using callAsyncJavaScriptFunction: for more flexible interaction with the JavaScript programming model.
     236 Once your global state is set up, consider using callAsyncJavaScript: for more flexible interaction with the JavaScript programming model.
    237237*/
    238238- (void)evaluateJavaScript:(NSString *)javaScriptString 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));
     
    244244 @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.
    245245 @discussion The functionBody string is treated as an anonymous JavaScript function body that can be called with named arguments.
    246  Do not format your string as one of the variants of function call available in JavaScript.
    247  Instead pass in a JavaScript string representing the function body, formatted for evaluation.
     246 Do not format your functionBody string as a function-like callable object as you would in pure JavaScript.
     247 Your functionBody string should contain only the function body you want executed.
     248
    248249 For example do not pass in the string:
    249      function(x, y, z) { return x ? y : z; }
     250 @textblock
     251     function(x, y, z)
     252     {
     253         return x ? y : z;
     254     }
     255 @/textblock
     256
    250257 Instead pass in the string:
     258 @textblock
    251259     return x ? y : z;
     260 @/textblock
    252261
    253262 The arguments dictionary supplies the values for those arguments which are serialized into JavaScript equivalents.
    254263 For example:
     264 @textblock
    255265     @{ @"x" : @YES, @"y" : @1, @"z" : @"hello world" };
    256 
    257  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.
     266 @/textblock
     267
     268 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.
    258269
    259270 Allowed argument types are:
     
    280291 Since the function is a JavaScript "async" function you can use JavaScript "await" on thenable objects inside your function body.
    281292 For example:
     293 @textblock
    282294     var p = new Promise(function (f) {
    283295         window.setTimeout("f(42)", 1000);
     
    285297     await p;
    286298     return p;
     299 @/textblock
    287300
    288301 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.
Note: See TracChangeset for help on using the changeset viewer.