Title: [271430] trunk/Source/WebKitLegacy/mac
Revision
271430
Author
[email protected]
Date
2021-01-12 21:48:23 -0800 (Tue, 12 Jan 2021)

Log Message

QuickLook snapshots are missing some image content
https://bugs.webkit.org/show_bug.cgi?id=220571
<rdar://problem/72184373>

Reviewed by Simon Fraser.

* WebView/WebFrame.mm:
(-[WebFrame _paintBehaviorForDestinationContext:]):
Quick Look snapshots use WebView, and call displayRectIgnoringOpacity:inContext:
in order to paint it into a bitmap context. However, if the WebView is layer-backed,
including for reasons outside of WebKit or Quick Look's control, it currently
does a "normal" paint (as opposed to a snapshotting + flattening paint).
This results in async image decoding kicking in, which is undesirable
for a snapshot, since there is no opportunity to repaint when the decode
is complete.

It is difficult to detect all cases in which WebView is being painted into
an offscreen context, but one case that we can easily detect, and which
fixes Quick Look, is if the WebView itself is not hosted in a window.

So, if not hosted in a window, do a snapshotting+flattening paint.

Modified Paths

Diff

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (271429 => 271430)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-01-13 05:11:55 UTC (rev 271429)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-01-13 05:48:23 UTC (rev 271430)
@@ -1,3 +1,27 @@
+2021-01-12  Tim Horton  <[email protected]>
+
+        QuickLook snapshots are missing some image content
+        https://bugs.webkit.org/show_bug.cgi?id=220571
+        <rdar://problem/72184373>
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _paintBehaviorForDestinationContext:]):
+        Quick Look snapshots use WebView, and call displayRectIgnoringOpacity:inContext:
+        in order to paint it into a bitmap context. However, if the WebView is layer-backed,
+        including for reasons outside of WebKit or Quick Look's control, it currently
+        does a "normal" paint (as opposed to a snapshotting + flattening paint).
+        This results in async image decoding kicking in, which is undesirable
+        for a snapshot, since there is no opportunity to repaint when the decode
+        is complete.
+
+        It is difficult to detect all cases in which WebView is being painted into
+        an offscreen context, but one case that we can easily detect, and which
+        fixes Quick Look, is if the WebView itself is not hosted in a window.
+
+        So, if not hosted in a window, do a snapshotting+flattening paint.
+
 2021-01-11  Alex Christensen  <[email protected]>
 
         Use sendWithAsyncReply instead of dataCallback for icon loading

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (271429 => 271430)


--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2021-01-13 05:11:55 UTC (rev 271429)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2021-01-13 05:48:23 UTC (rev 271430)
@@ -603,11 +603,14 @@
         return [[documentView window] isInSnapshottingPaint] ? WebCore::PaintBehavior::Snapshotting : WebCore::PaintBehavior::Normal;
 #endif
 #if PLATFORM(MAC)
-        if ([documentView _web_isDrawingIntoLayer])
+        // Even if we are layer-backed, we may be painting into an offscreen context.
+        // We can be sure it's an offscreen context if we are not parented in a window, so exclude that case.
+        // This does not cover all cases, such as a parented view being painted into an offscreen context.
+        if ([documentView _web_isDrawingIntoLayer] && documentView.window)
             return WebCore::PaintBehavior::Normal;
 #endif
     }
-    
+
     return OptionSet<WebCore::PaintBehavior>(WebCore::PaintBehavior::FlattenCompositingLayers) | WebCore::PaintBehavior::Snapshotting;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to