Title: [286395] branches/safari-612-branch
Revision
286395
Author
repst...@apple.com
Date
2021-12-01 16:18:00 -0800 (Wed, 01 Dec 2021)

Log Message

Cherry-pick r285570. rdar://problem/83070565

    Fix crash in GraphicsContextCG::endTransparencyLayer
    https://bugs.webkit.org/show_bug.cgi?id=230230

    Reviewed by Myles C. Maxfield.

    Source/WebCore:

    The crash was due to unbalanced calls to begin and end transparency layers.

    A branch handling ancestors of transparent layers that are transform root needed to be
    aware of the top layer. Opacity on ancestors don't affect top layer elements so calling
    `beginTransparencyLayers` on `parent()` is incorrect.

    Also fix `transparentPaintingAncestor()` to be top layer aware to avoid flickering layers
    while scrolling.

    Test: fast/layers/top-layer-ancestor-opacity-and-transform-crash.html

    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::transparentPaintingAncestor):
    (WebCore::RenderLayer::paintLayerWithEffects):

    LayoutTests:

    * fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt: Added.
    * fast/layers/top-layer-ancestor-opacity-and-transform-crash.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/ChangeLog (286394 => 286395)


--- branches/safari-612-branch/LayoutTests/ChangeLog	2021-12-02 00:17:56 UTC (rev 286394)
+++ branches/safari-612-branch/LayoutTests/ChangeLog	2021-12-02 00:18:00 UTC (rev 286395)
@@ -1,5 +1,49 @@
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r285570. rdar://problem/83070565
+
+    Fix crash in GraphicsContextCG::endTransparencyLayer
+    https://bugs.webkit.org/show_bug.cgi?id=230230
+    
+    Reviewed by Myles C. Maxfield.
+    
+    Source/WebCore:
+    
+    The crash was due to unbalanced calls to begin and end transparency layers.
+    
+    A branch handling ancestors of transparent layers that are transform root needed to be
+    aware of the top layer. Opacity on ancestors don't affect top layer elements so calling
+    `beginTransparencyLayers` on `parent()` is incorrect.
+    
+    Also fix `transparentPaintingAncestor()` to be top layer aware to avoid flickering layers
+    while scrolling.
+    
+    Test: fast/layers/top-layer-ancestor-opacity-and-transform-crash.html
+    
+    * rendering/RenderLayer.cpp:
+    (WebCore::RenderLayer::transparentPaintingAncestor):
+    (WebCore::RenderLayer::paintLayerWithEffects):
+    
+    LayoutTests:
+    
+    * fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt: Added.
+    * fast/layers/top-layer-ancestor-opacity-and-transform-crash.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285570 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-10  Tim Nguyen  <n...@apple.com>
+
+            Fix crash in GraphicsContextCG::endTransparencyLayer
+            https://bugs.webkit.org/show_bug.cgi?id=230230
+
+            Reviewed by Myles C. Maxfield.
+
+            * fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt: Added.
+            * fast/layers/top-layer-ancestor-opacity-and-transform-crash.html: Added.
+
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r285569. rdar://problem/83070565
 
     Enable dialog tests on Windows

Added: branches/safari-612-branch/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt (0 => 286395)


--- branches/safari-612-branch/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt	2021-12-02 00:18:00 UTC (rev 286395)
@@ -0,0 +1 @@
+PASS if this doesn't crash

Added: branches/safari-612-branch/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash.html (0 => 286395)


--- branches/safari-612-branch/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash.html	2021-12-02 00:18:00 UTC (rev 286395)
@@ -0,0 +1,9 @@
+<style>
+* { opacity: 0.1; translate: 1px; }
+</style>
+<dialog>PASS if this doesn't crash</dialog>
+<script>
+    document.querySelector("dialog").showModal();
+    if (testRunner)
+        testRunner.dumpAsText();
+</script>

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (286394 => 286395)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-12-02 00:17:56 UTC (rev 286394)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-12-02 00:18:00 UTC (rev 286395)
@@ -1,5 +1,61 @@
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r285570. rdar://problem/83070565
+
+    Fix crash in GraphicsContextCG::endTransparencyLayer
+    https://bugs.webkit.org/show_bug.cgi?id=230230
+    
+    Reviewed by Myles C. Maxfield.
+    
+    Source/WebCore:
+    
+    The crash was due to unbalanced calls to begin and end transparency layers.
+    
+    A branch handling ancestors of transparent layers that are transform root needed to be
+    aware of the top layer. Opacity on ancestors don't affect top layer elements so calling
+    `beginTransparencyLayers` on `parent()` is incorrect.
+    
+    Also fix `transparentPaintingAncestor()` to be top layer aware to avoid flickering layers
+    while scrolling.
+    
+    Test: fast/layers/top-layer-ancestor-opacity-and-transform-crash.html
+    
+    * rendering/RenderLayer.cpp:
+    (WebCore::RenderLayer::transparentPaintingAncestor):
+    (WebCore::RenderLayer::paintLayerWithEffects):
+    
+    LayoutTests:
+    
+    * fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt: Added.
+    * fast/layers/top-layer-ancestor-opacity-and-transform-crash.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285570 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-10  Tim Nguyen  <n...@apple.com>
+
+            Fix crash in GraphicsContextCG::endTransparencyLayer
+            https://bugs.webkit.org/show_bug.cgi?id=230230
+
+            Reviewed by Myles C. Maxfield.
+
+            The crash was due to unbalanced calls to begin and end transparency layers.
+
+            A branch handling ancestors of transparent layers that are transform root needed to be
+            aware of the top layer. Opacity on ancestors don't affect top layer elements so calling
+            `beginTransparencyLayers` on `parent()` is incorrect.
+
+            Also fix `transparentPaintingAncestor()` to be top layer aware to avoid flickering layers
+            while scrolling.
+
+            Test: fast/layers/top-layer-ancestor-opacity-and-transform-crash.html
+
+            * rendering/RenderLayer.cpp:
+            (WebCore::RenderLayer::transparentPaintingAncestor):
+            (WebCore::RenderLayer::paintLayerWithEffects):
+
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r285569. rdar://problem/83070565
 
     Enable dialog tests on Windows

Modified: branches/safari-612-branch/Source/WebCore/rendering/RenderLayer.cpp (286394 => 286395)


--- branches/safari-612-branch/Source/WebCore/rendering/RenderLayer.cpp	2021-12-02 00:17:56 UTC (rev 286394)
+++ branches/safari-612-branch/Source/WebCore/rendering/RenderLayer.cpp	2021-12-02 00:18:00 UTC (rev 286395)
@@ -2017,9 +2017,9 @@
     if (isComposited())
         return nullptr;
 
-    for (RenderLayer* curr = parent(); curr; curr = curr->parent()) {
+    for (RenderLayer* curr = stackingContext(); curr; curr = curr->stackingContext()) {
         if (curr->isComposited())
-            return nullptr;
+            break;
         if (curr->isTransparent())
             return curr;
     }
@@ -3001,7 +3001,8 @@
         // If we have a transparency layer enclosing us and we are the root of a transform, then we need to establish the transparency
         // layer from the parent now, assuming there is a parent
         if (paintFlags & PaintLayerFlag::HaveTransparency) {
-            if (parent())
+            // Top layer elements are not affected by ancestor opacities
+            if (!establishesTopLayer() && parent())
                 parent()->beginTransparencyLayers(context, paintingInfo, paintingInfo.paintDirtyRect);
             else
                 beginTransparencyLayers(context, paintingInfo, paintingInfo.paintDirtyRect);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to