<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - No reliable way to get a snapshot of WKWebView (macOS)"
   href="https://bugs.webkit.org/show_bug.cgi?id=161450#c47">Comment # 47</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - No reliable way to get a snapshot of WKWebView (macOS)"
   href="https://bugs.webkit.org/show_bug.cgi?id=161450">bug 161450</a>
              from <span class="vcard"><a class="email" href="mailto:bdakin&#64;apple.com" title="Beth Dakin &lt;bdakin&#64;apple.com&gt;"> <span class="fn">Beth Dakin</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=161450#c45">comment #45</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=300288&amp;action=diff" name="attach_300288" title="Patch">attachment 300288</a> <a href="attachment.cgi?id=300288&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=300288&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=300288&amp;action=review</a>
&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:28
&gt; &gt; +#if WK_API_ENABLED
&gt; 
&gt; Do these tests work with different display colorspaces? We should test with
&gt; a few.
&gt; </span >

They do not. We should. My next patch won't do this yet.

<span class="quote">&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:44
&gt; &gt; +    RetainPtr&lt;CGImageSourceRef&gt; source = adoptCF(CGImageSourceCreateWithData((CFDataRef)[image TIFFRepresentation], NULL));
&gt; &gt; +    return adoptCF(CGImageSourceCreateImageAtIndex(source.get(), 0, NULL));
&gt; 
&gt; Is there any reason this doesn't just use CGImageForProposedRect?</span >

Switched to CGImageForProposedRect.

<span class="quote">&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:54
&gt; &gt; +    CGImageRef cgImage = [image CGImage];
&gt; &gt; +    CFRetain(cgImage);
&gt; &gt; +    return adoptCF(cgImage);
&gt; 
&gt; No need for this dance, just 'return image.CGImage;' will do the right thing
&gt; (it is autoreleased, RetainPtr constructor will retain it).</span >

Fixed.

<span class="quote">&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:73
&gt; &gt; +    WKSnapshotConfiguration *snapshotConfiguration = [[WKSnapshotConfiguration alloc] init];
&gt; 
&gt; Pretty sure this leaks.</span >

RetainPtr'd.

<span class="quote">&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:94
&gt; &gt; +    [webView loadHTMLString:&#64;&quot;&lt;body style='background-color: red;'&gt;&lt;div style='background-color: blue;position: absolute;width: 100px; height: 100px; top: 50px; left: 50px'&gt;&lt;/div&gt;&lt;/body&gt;&quot; baseURL:nil];
&gt; 
&gt; Spaces after semicolons? Kind of inconsistent at the moment.</span >

Fixed.

<span class="quote">&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:97
&gt; &gt; +    WKSnapshotConfiguration *snapshotConfiguration = [[WKSnapshotConfiguration alloc] init];
&gt; 
&gt; Pretty sure this leaks.
&gt; </span >

RetainPtr'd.

<span class="quote">&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:99
&gt; &gt; +    snapshotConfiguration.snapshotWidth = viewWidth;
&gt; 
&gt; Here, viewWidth is being used as points...</span >

Yes.

<span class="quote">&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:108
&gt; &gt; +        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
&gt; 
&gt; Why not a RetainPtr?
&gt; </span >

RetainPtr'd.

<span class="quote">&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:111
&gt; &gt; +        CGContextRef context = CGBitmapContextCreate(rgba, viewWidth, viewHeight, 8, 4 * viewWidth, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
&gt; 
&gt; ... and here as pixels. Does this matter? Does the test succeed on hardware
&gt; of various deviceScaleFactors?
&gt; </span >

Fixed to use real pixels.

<span class="quote">&gt; Also, why not a RetainPtr?
&gt; </span >

RetainPtr'd.

<span class="quote">&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:112
&gt; &gt; +        CGContextDrawImage(context, CGRectMake(0, 0, viewWidth, viewHeight), cgImage.get());
&gt; 
&gt; Or maybe it's OK because it gets scaled into place here?</span >

Fixed, I think.

<span class="quote">&gt; 
&gt; &gt; Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewSnapshot.mm:148
&gt; &gt; +    WKSnapshotConfiguration *snapshotConfiguration = [[WKSnapshotConfiguration alloc] init];
&gt; 
&gt; Pretty sure this leaks.</span >

RetainPtr'd.</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>