Changeset 271430 in webkit


Ignore:
Timestamp:
Jan 12, 2021 9:48:23 PM (3 years ago)
Author:
timothy_horton@apple.com
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.

Location:
trunk/Source/WebKitLegacy/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r271378 r271430  
     12021-01-12  Tim Horton  <timothy_horton@apple.com>
     2
     3        QuickLook snapshots are missing some image content
     4        https://bugs.webkit.org/show_bug.cgi?id=220571
     5        <rdar://problem/72184373>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebView/WebFrame.mm:
     10        (-[WebFrame _paintBehaviorForDestinationContext:]):
     11        Quick Look snapshots use WebView, and call displayRectIgnoringOpacity:inContext:
     12        in order to paint it into a bitmap context. However, if the WebView is layer-backed,
     13        including for reasons outside of WebKit or Quick Look's control, it currently
     14        does a "normal" paint (as opposed to a snapshotting + flattening paint).
     15        This results in async image decoding kicking in, which is undesirable
     16        for a snapshot, since there is no opportunity to repaint when the decode
     17        is complete.
     18
     19        It is difficult to detect all cases in which WebView is being painted into
     20        an offscreen context, but one case that we can easily detect, and which
     21        fixes Quick Look, is if the WebView itself is not hosted in a window.
     22
     23        So, if not hosted in a window, do a snapshotting+flattening paint.
     24
    1252021-01-11  Alex Christensen  <achristensen@webkit.org>
    226
  • trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm

    r271011 r271430  
    604604#endif
    605605#if PLATFORM(MAC)
    606         if ([documentView _web_isDrawingIntoLayer])
     606        // Even if we are layer-backed, we may be painting into an offscreen context.
     607        // We can be sure it's an offscreen context if we are not parented in a window, so exclude that case.
     608        // This does not cover all cases, such as a parented view being painted into an offscreen context.
     609        if ([documentView _web_isDrawingIntoLayer] && documentView.window)
    607610            return WebCore::PaintBehavior::Normal;
    608611#endif
    609612    }
    610    
     613
    611614    return OptionSet<WebCore::PaintBehavior>(WebCore::PaintBehavior::FlattenCompositingLayers) | WebCore::PaintBehavior::Snapshotting;
    612615}
Note: See TracChangeset for help on using the changeset viewer.