<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - When WKWebView prepares the session state blob, we should be able to filter it."
   href="https://bugs.webkit.org/show_bug.cgi?id=159410#c10">Comment # 10</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - When WKWebView prepares the session state blob, we should be able to filter it."
   href="https://bugs.webkit.org/show_bug.cgi?id=159410">bug 159410</a>
              from <span class="vcard"><a class="email" href="mailto:beidson&#64;apple.com" title="Brady Eidson &lt;beidson&#64;apple.com&gt;"> <span class="fn">Brady Eidson</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=282914&amp;action=diff" name="attach_282914" title="Add a SPI to WKWebView so that we can filter the session state.">attachment 282914</a> <a href="attachment.cgi?id=282914&amp;action=edit" title="Add a SPI to WKWebView so that we can filter the session state.">[details]</a></span>
Add a SPI to WKWebView so that we can filter the session state.

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=282914&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=282914&amp;action=review</a>

<span class="quote">&gt; Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3378
&gt; +    auto handler = adoptNS([filter copy]);
&gt; +    WebKit::SessionState sessionState = _page-&gt;sessionState([handler](WebKit::WebBackForwardListItem&amp; item) {</span >

Can put the filter copy inside the lambda:
[handler = adoptNS([filter copy])]

<span class="quote">&gt; Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3384
&gt; +        BOOL (^filterBlock)(WKBackForwardListItem *item) = (BOOL (^)(WKBackForwardListItem *item))handler.get();
&gt; +        if (filterBlock) {
&gt; +            if (!filterBlock(wrapper(item)))
&gt; +                return false;
&gt; +        }
&gt; +        return true;</span >

This should be able to be simpler:

if (!handler)
   return true;

BOOL (^filterBlock)(WKBackForwardListItem *item) = (BOOL (^)(WKBackForwardListItem *item))handler.get();
return filterBlock(wrapper(item));</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>