⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 288530 in webkit


Ignore:
Timestamp:
Jan 24, 2022, 5:56:58 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r288429. rdar://problem/86612099

Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
​https://bugs.webkit.org/show_bug.cgi?id=235420
<rdar://86612099>

Patch by Matt Woodrow <Matt Woodrow> on 2022-01-23
Reviewed by Simon Fraser and Darin Adler.

Source/WebCore:

Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
so that we can exclude descendants that definitely won't draw anything into
the compositing layer. Uses a conservative check, which gives up if there are
any transforms in the ancestor chain.

Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html

  • rendering/RenderLayerBacking.cpp: (WebCore::intersectsWithAncestor): (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):

LayoutTests:

Adds a test that has a viewport sized position:fixed element (with compositing
layer), and a single child which is entirely offscreen. Tests that we correctly
determine that we don't need a backing store for the layer.

  • compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
  • compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@288429 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-613-branch
Files:
1 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-613-branch/LayoutTests/ChangeLog

    r288524 r288530  
     12022-01-24  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r288429. rdar://problem/86612099
     4
     5    Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
     6    https://bugs.webkit.org/show_bug.cgi?id=235420
     7    <rdar://86612099>
     8   
     9    Patch by Matt Woodrow <mattwoodrow@apple.com> on 2022-01-23
     10    Reviewed by Simon Fraser and Darin Adler.
     11   
     12    Source/WebCore:
     13   
     14    Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
     15    so that we can exclude descendants that definitely won't draw anything into
     16    the compositing layer. Uses a conservative check, which gives up if there are
     17    any transforms in the ancestor chain.
     18   
     19    Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
     20   
     21    * rendering/RenderLayerBacking.cpp:
     22    (WebCore::intersectsWithAncestor):
     23    (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
     24   
     25    LayoutTests:
     26   
     27    Adds a test that has a viewport sized position:fixed element (with compositing
     28    layer), and a single child which is entirely offscreen. Tests that we correctly
     29    determine that we don't need a backing store for the layer.
     30   
     31    * compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
     32    * compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
     33   
     34    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     35
     36    2022-01-23  Matt Woodrow  <mattwoodrow@apple.com>
     37
     38            Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
     39            https://bugs.webkit.org/show_bug.cgi?id=235420
     40            <rdar://86612099>
     41
     42            Reviewed by Simon Fraser and Darin Adler.
     43
     44            Adds a test that has a viewport sized position:fixed element (with compositing
     45            layer), and a single child which is entirely offscreen. Tests that we correctly
     46            determine that we don't need a backing store for the layer.
     47
     48            * compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
     49            * compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
     50
    1512022-01-24  Alan Coon  <alancoon@apple.com>
    252
  • branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt

    r288529 r288530  
    88      (children 1
    99        (GraphicsLayer
    10           (position 8.00 8.00)
    11           (bounds 100.00 100.00)
    12           (contentsOpaque 1)
    13           (drawsContent 1)
     10          (bounds 200.00 200.00)
    1411        )
    1512      )
  • branches/safari-613-branch/LayoutTests/compositing/clip-child-by-non-stacking-ancestor-expected.txt

    r168244 r288530  
    1111          (bounds 100.00 100.00)
    1212          (contentsOpaque 1)
    13           (drawsContent 1)
    1413        )
    1514      )
  • branches/safari-613-branch/LayoutTests/compositing/geometry/limit-layer-bounds-fixed-expected.txt

    r225897 r288530  
    1616          (position 0.00 3000.00)
    1717          (bounds 300.00 200.00)
    18           (drawsContent 1)
    1918        )
    2019      )
  • branches/safari-613-branch/LayoutTests/platform/ios-wk2/compositing/geometry/limit-layer-bounds-fixed-expected.txt

    r225897 r288530  
    1616          (position 0.00 3000.00)
    1717          (bounds 300.00 200.00)
    18           (drawsContent 1)
    1918        )
    2019      )
  • branches/safari-613-branch/Source/WebCore/ChangeLog

    r288529 r288530  
     12022-01-24  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r288429. rdar://problem/86612099
     4
     5    Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
     6    https://bugs.webkit.org/show_bug.cgi?id=235420
     7    <rdar://86612099>
     8   
     9    Patch by Matt Woodrow <mattwoodrow@apple.com> on 2022-01-23
     10    Reviewed by Simon Fraser and Darin Adler.
     11   
     12    Source/WebCore:
     13   
     14    Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
     15    so that we can exclude descendants that definitely won't draw anything into
     16    the compositing layer. Uses a conservative check, which gives up if there are
     17    any transforms in the ancestor chain.
     18   
     19    Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
     20   
     21    * rendering/RenderLayerBacking.cpp:
     22    (WebCore::intersectsWithAncestor):
     23    (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
     24   
     25    LayoutTests:
     26   
     27    Adds a test that has a viewport sized position:fixed element (with compositing
     28    layer), and a single child which is entirely offscreen. Tests that we correctly
     29    determine that we don't need a backing store for the layer.
     30   
     31    * compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
     32    * compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
     33   
     34    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     35
     36    2022-01-23  Matt Woodrow  <mattwoodrow@apple.com>
     37
     38            Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
     39            https://bugs.webkit.org/show_bug.cgi?id=235420
     40            <rdar://86612099>
     41
     42            Reviewed by Simon Fraser and Darin Adler.
     43
     44            Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
     45            so that we can exclude descendants that definitely won't draw anything into
     46            the compositing layer. Uses a conservative check, which gives up if there are
     47            any transforms in the ancestor chain.
     48
     49            Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
     50
     51            * rendering/RenderLayerBacking.cpp:
     52            (WebCore::intersectsWithAncestor):
     53            (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
     54
    1552022-01-24  Alan Coon  <alancoon@apple.com>
    256
  • branches/safari-613-branch/Source/WebCore/rendering/RenderLayerBacking.cpp

    r287757 r288530  
    27912791}
    27922792
     2793static std::optional<bool> intersectsWithAncestor(const RenderLayer& child, const RenderLayer& ancestor, const LayoutRect& ancestorCompositedBounds)
     2794{
     2795    // If any layers between child and ancestor are transformed, then adjusting the offset is
     2796    // insufficient to convert coordinates into ancestor's coordinate space.
     2797    for (auto* layer = &child; layer != &ancestor; layer = layer->parent()) {
     2798        if (!layer->canUseOffsetFromAncestor())
     2799            return std::nullopt;
     2800    }
     2801
     2802    auto offset = child.convertToLayerCoords(&ancestor, { }, RenderLayer::AdjustForColumns);
     2803    auto overlap = child.overlapBounds();
     2804    overlap.moveBy(offset);
     2805    return overlap.intersects(ancestorCompositedBounds);
     2806}
     2807
    27932808// Conservative test for having no rendered children.
    27942809bool RenderLayerBacking::isPaintDestinationForDescendantLayers(RenderLayer::PaintedContentRequest& request) const
    27952810{
    27962811    bool hasPaintingDescendant = false;
    2797     traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant, &request](const RenderLayer& layer) {
    2798         hasPaintingDescendant |= layer.isVisuallyNonEmpty(&request);
     2812    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant, &request, this](const RenderLayer& layer) {
     2813        RenderLayer::PaintedContentRequest localRequest;
     2814        if (layer.isVisuallyNonEmpty(&localRequest)) {
     2815            bool mayIntersect = intersectsWithAncestor(layer, m_owningLayer, compositedBounds()).value_or(true);
     2816            if (mayIntersect) {
     2817                hasPaintingDescendant = true;
     2818                request.setHasPaintedContent();
     2819            }
     2820        }
    27992821        return (hasPaintingDescendant && request.isSatisfied()) ? LayerTraversal::Stop : LayerTraversal::Continue;
    28002822    });
Note: See TracChangeset for help on using the changeset viewer.