Title: [285570] trunk
Revision
285570
Author
[email protected]
Date
2021-11-10 01:42:52 -0800 (Wed, 10 Nov 2021)

Log Message

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285569 => 285570)


--- trunk/LayoutTests/ChangeLog	2021-11-10 09:30:27 UTC (rev 285569)
+++ trunk/LayoutTests/ChangeLog	2021-11-10 09:42:52 UTC (rev 285570)
@@ -1,5 +1,15 @@
 2021-11-10  Tim Nguyen  <[email protected]>
 
+        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-11-10  Tim Nguyen  <[email protected]>
+
         Enable dialog tests on Windows
         https://bugs.webkit.org/show_bug.cgi?id=232911
 

Added: trunk/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt (0 => 285570)


--- trunk/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash-expected.txt	2021-11-10 09:42:52 UTC (rev 285570)
@@ -0,0 +1 @@
+PASS if this doesn't crash

Added: trunk/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash.html (0 => 285570)


--- trunk/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layers/top-layer-ancestor-opacity-and-transform-crash.html	2021-11-10 09:42:52 UTC (rev 285570)
@@ -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: trunk/Source/WebCore/ChangeLog (285569 => 285570)


--- trunk/Source/WebCore/ChangeLog	2021-11-10 09:30:27 UTC (rev 285569)
+++ trunk/Source/WebCore/ChangeLog	2021-11-10 09:42:52 UTC (rev 285570)
@@ -1,5 +1,27 @@
 2021-11-10  Tim Nguyen  <[email protected]>
 
+        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-11-10  Tim Nguyen  <[email protected]>
+
         Enable dialog tests on Windows
         https://bugs.webkit.org/show_bug.cgi?id=232911
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (285569 => 285570)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2021-11-10 09:30:27 UTC (rev 285569)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2021-11-10 09:42:52 UTC (rev 285570)
@@ -2078,9 +2078,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;
     }
@@ -3050,7 +3050,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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to