ASSERTION FAILED: accumulation == TransformState::FlattenTransform in WebCore::Graphi...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 00:08:28 +0000 (00:08 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 00:08:28 +0000 (00:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155362

Reviewed by Zalan Bujtas.

Source/WebCore:

A particular configuration of composited RenderLayers with preserve-3d and clipping
caused assertions because an ancestor clipping layer had masksToBounds() set, but
a preserves3D() parent, triggering an assertion in GraphicsLayerCA::computeVisibleAndCoverageRect().
Make two changes to address this:

First, CSS clip: and clip-path: should force flattening and override preserve-3d in
the RenderStyle.

Second, don't accumulate transforms in GraphicsLayerCA through layers with masksToBounds().

Tests: compositing/clipping/preserve3d-flatten-assertion-nested.html
       compositing/clipping/preserve3d-flatten-assertion.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::accumulatesTransform):

LayoutTests:

Test cases that should not assert in debug builds.

* compositing/clipping/preserve3d-flatten-assertion-nested.html: Added.
* compositing/clipping/preserve3d-flatten-assertion.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/clipping/preserve3d-flatten-assertion-expected.txt [new file with mode: 0644]
LayoutTests/compositing/clipping/preserve3d-flatten-assertion-nested-expected.txt [new file with mode: 0644]
LayoutTests/compositing/clipping/preserve3d-flatten-assertion-nested.html [new file with mode: 0644]
LayoutTests/compositing/clipping/preserve3d-flatten-assertion.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

index df48560..6eb773b 100644 (file)
@@ -1,3 +1,15 @@
+2016-04-21  Simon Fraser  <simon.fraser@apple.com>
+
+        ASSERTION FAILED: accumulation == TransformState::FlattenTransform in WebCore::GraphicsLayerCA::computeVisibleAndCoverageRect
+        https://bugs.webkit.org/show_bug.cgi?id=155362
+
+        Reviewed by Zalan Bujtas.
+
+        Test cases that should not assert in debug builds.
+
+        * compositing/clipping/preserve3d-flatten-assertion-nested.html: Added.
+        * compositing/clipping/preserve3d-flatten-assertion.html: Added.
+
 2016-04-21  Jiewen Tan  <jiewen_tan@apple.com>
 
         [iOS] DumpRenderTree crashed in com.apple.WebCore: WebCore::ResourceLoadNotifier::didFailToLoad
diff --git a/LayoutTests/compositing/clipping/preserve3d-flatten-assertion-expected.txt b/LayoutTests/compositing/clipping/preserve3d-flatten-assertion-expected.txt
new file mode 100644 (file)
index 0000000..a80f130
--- /dev/null
@@ -0,0 +1 @@
+This test should not assert in debug builds.
diff --git a/LayoutTests/compositing/clipping/preserve3d-flatten-assertion-nested-expected.txt b/LayoutTests/compositing/clipping/preserve3d-flatten-assertion-nested-expected.txt
new file mode 100644 (file)
index 0000000..a80f130
--- /dev/null
@@ -0,0 +1 @@
+This test should not assert in debug builds.
diff --git a/LayoutTests/compositing/clipping/preserve3d-flatten-assertion-nested.html b/LayoutTests/compositing/clipping/preserve3d-flatten-assertion-nested.html
new file mode 100644 (file)
index 0000000..9b47dac
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+    .box {
+        height: 200px;
+        width: 200px;
+        margin: 10px;
+        border: 1px solid black;
+    }
+    .middle {
+        position: absolute;
+        transform: translateZ(0);
+        transform-style: preserve-3d;
+    }
+    
+    .clipping {
+        position: absolute;
+        overflow: hidden;
+    }
+    
+    .composited {
+        transform: translateZ(0);
+    }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+    </script>
+</head>
+<body>
+    <div class="middle box">
+        <div class="clipping box">
+            <div class="composited box">
+                This test should not assert in debug builds.
+            </div>
+        </div>
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/compositing/clipping/preserve3d-flatten-assertion.html b/LayoutTests/compositing/clipping/preserve3d-flatten-assertion.html
new file mode 100644 (file)
index 0000000..2555fcb
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+    .box {
+        height: 300px;
+        width: 300px;
+        padding: 10px;
+        position: absolute;
+        border: 1px solid black;
+        transform: translateZ(0);
+        transform-style: preserve-3d;
+        clip: rect(10px, 200px, 200px, 10px);
+    }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+    </script>
+</head>
+<body>
+<div class="box">
+    <div class="box">
+        This test should not assert in debug builds.
+    </div>
+</div>
+</body>
+</html>
index b366eef..2a12e6d 100644 (file)
@@ -1,3 +1,28 @@
+2016-04-21  Simon Fraser  <simon.fraser@apple.com>
+
+        ASSERTION FAILED: accumulation == TransformState::FlattenTransform in WebCore::GraphicsLayerCA::computeVisibleAndCoverageRect
+        https://bugs.webkit.org/show_bug.cgi?id=155362
+
+        Reviewed by Zalan Bujtas.
+
+        A particular configuration of composited RenderLayers with preserve-3d and clipping
+        caused assertions because an ancestor clipping layer had masksToBounds() set, but
+        a preserves3D() parent, triggering an assertion in GraphicsLayerCA::computeVisibleAndCoverageRect().
+        Make two changes to address this:
+
+        First, CSS clip: and clip-path: should force flattening and override preserve-3d in
+        the RenderStyle.
+
+        Second, don't accumulate transforms in GraphicsLayerCA through layers with masksToBounds().
+
+        Tests: compositing/clipping/preserve3d-flatten-assertion-nested.html
+               compositing/clipping/preserve3d-flatten-assertion.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::adjustRenderStyle):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::accumulatesTransform):
+
 2016-04-21  Chris Dumez  <cdumez@apple.com>
 
         Element::idForStyleResolution() is a foot-gun
index 608ff36..3814e46 100644 (file)
@@ -975,6 +975,8 @@ void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& par
     // FIXME: when dropping the -webkit prefix on transform-style, we should also have opacity < 1 cause flattening.
     if (style.preserves3D() && (style.overflowX() != OVISIBLE
         || style.overflowY() != OVISIBLE
+        || style.hasClip()
+        || style.clipPath()
         || style.hasFilter()
 #if ENABLE(FILTERS_LEVEL_2)
         || style.hasBackdropFilter()
index 2af851b..43a6dea 100644 (file)
@@ -1131,7 +1131,7 @@ void GraphicsLayerCA::flushCompositingStateForThisLayerOnly(bool viewportIsStabl
 
 static inline bool accumulatesTransform(const GraphicsLayerCA& layer)
 {
-    return layer.preserves3D() || (layer.parent() && layer.parent()->preserves3D());
+    return !layer.masksToBounds() && (layer.preserves3D() || (layer.parent() && layer.parent()->preserves3D()));
 }
 
 bool GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush(const TransformState& state) const