<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208025] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208025">208025</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-10-27 20:20:32 -0700 (Thu, 27 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>If an animation's keyframes affect stacking context properties, create stacking context while the animation is running
https://bugs.webkit.org/show_bug.cgi?id=164094

Reviewed by Dean Jackson.

Source/WebCore:

The CSS animations spec &lt;https://drafts.csswg.org/css-animations-1/&gt; now makes it
clear that a keyframe animation animating properties which can affect stacking context
should establish stacking context while it's running, or filling-forwards. This is part
of the &quot;the user agent must act as if the will-change property...includes all the properties
animated by the animation&quot; clause.

Implement by having CompositeAnimation::animate() track whether running animations should
create stacking context, replacing existing code in AnimationController::updateAnimations()
which only looked at opacity and transform. Transitions are also checked to see if they need
to trigger stacking context.

This allows for the removal of a 0.9999 hack when blending opacity.

Tests: animations/stacking-context-fill-forwards.html
       animations/stacking-context-not-fill-forwards.html
       animations/stacking-context-unchanged-while-running.html

* page/animation/AnimationController.cpp:
(WebCore::AnimationController::updateAnimations):
* page/animation/CSSPropertyAnimation.cpp:
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::animate):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::computeStackingContextImpact):
(WebCore::KeyframeAnimation::animate):
* page/animation/KeyframeAnimation.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::currentTransform):
* rendering/style/WillChangeData.cpp:
(WebCore::WillChangeData::propertyCreatesStackingContext):
(WebCore::propertyCreatesStackingContext): Deleted.
* rendering/style/WillChangeData.h:

LayoutTests:

* animations/stacking-context-fill-forwards-expected.html: Added.
* animations/stacking-context-fill-forwards.html: Added.
* animations/stacking-context-not-fill-forwards-expected.html: Added.
* animations/stacking-context-not-fill-forwards.html: Added.
* animations/stacking-context-unchanged-while-running-expected.html: Added.
* animations/stacking-context-unchanged-while-running.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageanimationAnimationControllercpp">trunk/Source/WebCore/page/animation/AnimationController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageanimationCSSPropertyAnimationcpp">trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp</a></li>
<li><a href="#trunkSourceWebCorepageanimationCompositeAnimationcpp">trunk/Source/WebCore/page/animation/CompositeAnimation.cpp</a></li>
<li><a href="#trunkSourceWebCorepageanimationKeyframeAnimationcpp">trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp</a></li>
<li><a href="#trunkSourceWebCorepageanimationKeyframeAnimationh">trunk/Source/WebCore/page/animation/KeyframeAnimation.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleWillChangeDatacpp">trunk/Source/WebCore/rendering/style/WillChangeData.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleWillChangeDatah">trunk/Source/WebCore/rendering/style/WillChangeData.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsanimationsstackingcontextfillforwardsexpectedhtml">trunk/LayoutTests/animations/stacking-context-fill-forwards-expected.html</a></li>
<li><a href="#trunkLayoutTestsanimationsstackingcontextfillforwardshtml">trunk/LayoutTests/animations/stacking-context-fill-forwards.html</a></li>
<li><a href="#trunkLayoutTestsanimationsstackingcontextnotfillforwardsexpectedhtml">trunk/LayoutTests/animations/stacking-context-not-fill-forwards-expected.html</a></li>
<li><a href="#trunkLayoutTestsanimationsstackingcontextnotfillforwardshtml">trunk/LayoutTests/animations/stacking-context-not-fill-forwards.html</a></li>
<li><a href="#trunkLayoutTestsanimationsstackingcontextunchangedwhilerunningexpectedhtml">trunk/LayoutTests/animations/stacking-context-unchanged-while-running-expected.html</a></li>
<li><a href="#trunkLayoutTestsanimationsstackingcontextunchangedwhilerunninghtml">trunk/LayoutTests/animations/stacking-context-unchanged-while-running.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/LayoutTests/ChangeLog        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-10-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        If an animation's keyframes affect stacking context properties, create stacking context while the animation is running
+        https://bugs.webkit.org/show_bug.cgi?id=164094
+
+        Reviewed by Dean Jackson.
+
+        * animations/stacking-context-fill-forwards-expected.html: Added.
+        * animations/stacking-context-fill-forwards.html: Added.
+        * animations/stacking-context-not-fill-forwards-expected.html: Added.
+        * animations/stacking-context-not-fill-forwards.html: Added.
+        * animations/stacking-context-unchanged-while-running-expected.html: Added.
+        * animations/stacking-context-unchanged-while-running.html: Added.
+
</ins><span class="cx"> 2016-10-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [macOS] [WebGL2] Temporarily upgrade WebGL 2's internal OpenGL context from version 2.1 to 3.2
</span></span></pre></div>
<a id="trunkLayoutTestsanimationsstackingcontextfillforwardsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/animations/stacking-context-fill-forwards-expected.html (0 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/stacking-context-fill-forwards-expected.html                                (rev 0)
+++ trunk/LayoutTests/animations/stacking-context-fill-forwards-expected.html        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .box {
+            position: absolute;
+            top: 0;
+            left: 0;
+            height: 100px;
+            width: 100px;
+        }
+
+        #animating {
+            background-color: orange;
+            z-index: 0;
+        }
+
+        .behind {
+            background-color: blue;
+            top: 50px;
+            left: 50px;
+            z-index: 1;
+        }
+
+        .front {
+            top: 25px;
+            left: 25px;
+            background-color: green;
+            z-index: 2;
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;behind box&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;animating&quot; class=&quot;box&quot;&gt;
+    &lt;div class=&quot;front box&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsanimationsstackingcontextfillforwardshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/animations/stacking-context-fill-forwards.html (0 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/stacking-context-fill-forwards.html                                (rev 0)
+++ trunk/LayoutTests/animations/stacking-context-fill-forwards.html        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Tests that a fill-forwards animation causes stacking context when finished.&lt;/title&gt;
+    &lt;style&gt;
+        .box {
+            position: absolute;
+            top: 0;
+            left: 0;
+            height: 100px;
+            width: 100px;
+        }
+
+        #animating {
+            animation: move 0.1s 1 forwards;
+            background-color: orange;
+        }
+
+        @keyframes move {
+            from { transform: translateX(400px); }
+            to   { transform: none }
+        }
+
+        .behind {
+            background-color: blue;
+            top: 50px;
+            left: 50px;
+            z-index: 1;
+        }
+
+        .front {
+            top: 25px;
+            left: 25px;
+            background-color: green;
+            z-index: 2;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+        
+        window.addEventListener('load', function() {
+            document.getElementById('animating').addEventListener('animationend', function() {
+                // Wait until filling forwards.
+                window.setTimeout(function() {
+                    if (window.testRunner)
+                        testRunner.notifyDone();
+                }, 0);
+            })
+        }, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;behind box&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;animating&quot; class=&quot;box&quot;&gt;
+    &lt;div class=&quot;front box&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsanimationsstackingcontextnotfillforwardsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/animations/stacking-context-not-fill-forwards-expected.html (0 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/stacking-context-not-fill-forwards-expected.html                                (rev 0)
+++ trunk/LayoutTests/animations/stacking-context-not-fill-forwards-expected.html        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .box {
+            position: absolute;
+            top: 0;
+            left: 0;
+            height: 100px;
+            width: 100px;
+        }
+
+        #animating {
+            background-color: orange;
+        }
+
+        .behind {
+            background-color: blue;
+            top: 50px;
+            left: 50px;
+            z-index: 1;
+        }
+
+        .front {
+            top: 25px;
+            left: 25px;
+            background-color: green;
+            z-index: 2;
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;behind box&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;animating&quot; class=&quot;box&quot;&gt;
+    &lt;div class=&quot;front box&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsanimationsstackingcontextnotfillforwardshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/animations/stacking-context-not-fill-forwards.html (0 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/stacking-context-not-fill-forwards.html                                (rev 0)
+++ trunk/LayoutTests/animations/stacking-context-not-fill-forwards.html        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Tests that a non-fill-forwards animation doesn't cause stacking context once finished.&lt;/title&gt;
+    &lt;style&gt;
+        .box {
+            position: absolute;
+            top: 0;
+            left: 0;
+            height: 100px;
+            width: 100px;
+        }
+        
+        #animating {
+            animation: move 0.1s 1;
+            background-color: orange;
+        }
+
+        @keyframes move {
+            from { transform: translateX(400px); }
+            to   { transform: none }
+        }
+
+        .behind {
+            background-color: blue;
+            top: 50px;
+            left: 50px;
+            z-index: 1;
+        }
+
+        .front {
+            top: 25px;
+            left: 25px;
+            background-color: green;
+            z-index: 2;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+        
+        window.addEventListener('load', function() {
+            document.getElementById('animating').addEventListener('animationend', function() {
+                // Wait until filling forwards.
+                window.setTimeout(function() {
+                    if (window.testRunner)
+                        testRunner.notifyDone();
+                }, 0);
+            })
+        }, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;behind box&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;animating&quot; class=&quot;box&quot;&gt;
+    &lt;div class=&quot;front box&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsanimationsstackingcontextunchangedwhilerunningexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/animations/stacking-context-unchanged-while-running-expected.html (0 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/stacking-context-unchanged-while-running-expected.html                                (rev 0)
+++ trunk/LayoutTests/animations/stacking-context-unchanged-while-running-expected.html        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .box {
+            position: absolute;
+            top: 0;
+            left: 0;
+            height: 100px;
+            width: 100px;
+        }
+        
+        #animating {
+            background-color: orange;
+             z-index: 0;
+        }
+
+        .behind {
+            background-color: blue;
+            top: 25px;
+            left: 50px;
+            z-index: 1;
+        }
+
+        .front {
+            top: 50px;
+            left: 25px;
+            background-color: green;
+            z-index: 2;
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;behind box&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;animating&quot; class=&quot;box&quot;&gt;
+    &lt;div class=&quot;front box&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsanimationsstackingcontextunchangedwhilerunninghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/animations/stacking-context-unchanged-while-running.html (0 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/animations/stacking-context-unchanged-while-running.html                                (rev 0)
+++ trunk/LayoutTests/animations/stacking-context-unchanged-while-running.html        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Tests that an element with an animation whose keyframes affect stacking context creates stacking context throughout the animation.&lt;/title&gt;
+    &lt;style&gt;
+        .box {
+            position: absolute;
+            top: 0;
+            left: 0;
+            height: 100px;
+            width: 100px;
+        }
+
+        #animating {
+            animation: move 2s 1;
+            background-color: orange;
+        }
+
+        @keyframes move {
+            from { z-index: 1; }
+            10%  { z-index: auto; }
+            90%  { z-index: auto; }
+            to   { z-index: 2; }
+        }
+
+        .behind {
+            background-color: blue;
+            top: 25px;
+            left: 50px;
+            z-index: 1;
+        }
+
+        .front {
+            top: 50px;
+            left: 25px;
+            background-color: green;
+            z-index: 2;
+        }
+        
+        #result {
+            opacity: 0;
+        }
+    &lt;/style&gt;
+    &lt;script src=&quot;resources/animation-test-helpers.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        const expectedValues = [
+            // [animation-name, time, element-id, property, expected-value, tolerance]
+            [&quot;move&quot;, 0.5, &quot;animating&quot;, &quot;z-index&quot;, 0, 0],
+        ];
+
+        var doPixelTest = true;
+        var disablePauseAPI = false;
+        runAnimationTest(expectedValues, null, undefined, disablePauseAPI, doPixelTest);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;behind box&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;animating&quot; class=&quot;box&quot;&gt;
+    &lt;div class=&quot;front box&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/ChangeLog        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-10-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        If an animation's keyframes affect stacking context properties, create stacking context while the animation is running
+        https://bugs.webkit.org/show_bug.cgi?id=164094
+
+        Reviewed by Dean Jackson.
+
+        The CSS animations spec &lt;https://drafts.csswg.org/css-animations-1/&gt; now makes it
+        clear that a keyframe animation animating properties which can affect stacking context
+        should establish stacking context while it's running, or filling-forwards. This is part
+        of the &quot;the user agent must act as if the will-change property...includes all the properties
+        animated by the animation&quot; clause.
+
+        Implement by having CompositeAnimation::animate() track whether running animations should
+        create stacking context, replacing existing code in AnimationController::updateAnimations()
+        which only looked at opacity and transform. Transitions are also checked to see if they need
+        to trigger stacking context.
+
+        This allows for the removal of a 0.9999 hack when blending opacity.
+
+        Tests: animations/stacking-context-fill-forwards.html
+               animations/stacking-context-not-fill-forwards.html
+               animations/stacking-context-unchanged-while-running.html
+
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationController::updateAnimations):
+        * page/animation/CSSPropertyAnimation.cpp:
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimation::animate):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::KeyframeAnimation):
+        (WebCore::KeyframeAnimation::computeStackingContextImpact):
+        (WebCore::KeyframeAnimation::animate):
+        * page/animation/KeyframeAnimation.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::currentTransform):
+        * rendering/style/WillChangeData.cpp:
+        (WebCore::WillChangeData::propertyCreatesStackingContext):
+        (WebCore::propertyCreatesStackingContext): Deleted.
+        * rendering/style/WillChangeData.h:
+
</ins><span class="cx"> 2016-10-27  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Move code generators off of domSignature::type and onto domSignature::idlType
</span></span></pre></div>
<a id="trunkSourceWebCorepageanimationAnimationControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/animation/AnimationController.cpp (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/animation/AnimationController.cpp        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/page/animation/AnimationController.cpp        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -624,13 +624,6 @@
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (animatedStyle) {
-        // If the animations/transitions change opacity or transform, we need to update
-        // the style to impose the stacking rules. Note that this is also
-        // done in StyleResolver::adjustRenderStyle().
-        if (animatedStyle-&gt;hasAutoZIndex() &amp;&amp; (animatedStyle-&gt;opacity() &lt; 1.0f || animatedStyle-&gt;hasTransform()))
-            animatedStyle-&gt;setZIndex(0);
-    }
</del><span class="cx">     return animationStateChanged;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageanimationCSSPropertyAnimationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -638,10 +638,7 @@
</span><span class="cx"> 
</span><span class="cx">     void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override
</span><span class="cx">     {
</span><del>-        float fromOpacity = a-&gt;opacity();
-
-        // This makes sure we put the object being animated into a RenderLayer during the animation
-        dst-&gt;setOpacity(blendFunc(anim, (fromOpacity == 1) ? 0.999999f : fromOpacity, b-&gt;opacity(), progress));
</del><ins>+        dst-&gt;setOpacity(blendFunc(anim, a-&gt;opacity(), b-&gt;opacity(), progress));
</ins><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageanimationCompositeAnimationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.cpp (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/animation/CompositeAnimation.cpp        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.cpp        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -292,14 +292,34 @@
</span><span class="cx">     m_keyframeAnimations.checkConsistency();
</span><span class="cx"> 
</span><span class="cx">     bool animationStateChanged = false;
</span><ins>+    bool forceStackingContext = false;
</ins><span class="cx"> 
</span><span class="cx">     if (currentStyle) {
</span><span class="cx">         // Now that we have transition objects ready, let them know about the new goal state.  We want them
</span><span class="cx">         // to fill in a RenderStyle*&amp; only if needed.
</span><ins>+        bool checkForStackingContext = false;
</ins><span class="cx">         for (auto&amp; transition : m_transitions.values()) {
</span><span class="cx">             if (transition-&gt;animate(this, &amp;renderer, currentStyle, &amp;targetStyle, blendedStyle))
</span><span class="cx">                 animationStateChanged = true;
</span><ins>+
+            checkForStackingContext |= WillChangeData::propertyCreatesStackingContext(transition-&gt;animatingProperty());
</ins><span class="cx">         }
</span><ins>+
+        if (blendedStyle &amp;&amp; checkForStackingContext) {
+            // Note that this is similar to code in StyleResolver::adjustRenderStyle() but only needs to consult
+            // animatable properties that can trigger stacking context.
+            if (blendedStyle-&gt;opacity() &lt; 1.0f
+                || blendedStyle-&gt;hasTransformRelatedProperty()
+                || blendedStyle-&gt;hasMask()
+                || blendedStyle-&gt;clipPath()
+                || blendedStyle-&gt;boxReflect()
+                || blendedStyle-&gt;hasFilter()
+#if ENABLE(FILTERS_LEVEL_2)
+                || blendedStyle-&gt;hasBackdropFilter()
+#endif
+                )
+            forceStackingContext = true;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Now that we have animation objects ready, let them know about the new goal state.  We want them
</span><span class="lines">@@ -306,10 +326,24 @@
</span><span class="cx">     // to fill in a RenderStyle*&amp; only if needed.
</span><span class="cx">     for (auto&amp; name : m_keyframeAnimationOrderMap) {
</span><span class="cx">         RefPtr&lt;KeyframeAnimation&gt; keyframeAnim = m_keyframeAnimations.get(name);
</span><del>-        if (keyframeAnim &amp;&amp; keyframeAnim-&gt;animate(this, &amp;renderer, currentStyle, &amp;targetStyle, blendedStyle))
-            animationStateChanged = true;
</del><ins>+        if (keyframeAnim) {
+            if (keyframeAnim-&gt;animate(this, &amp;renderer, currentStyle, &amp;targetStyle, blendedStyle))
+                animationStateChanged = true;
+
+            bool runningOrFillingForwards = !keyframeAnim-&gt;waitingToStart() &amp;&amp; !keyframeAnim-&gt;postActive();
+            forceStackingContext |= runningOrFillingForwards &amp;&amp; keyframeAnim-&gt;triggersStackingContext();
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // https://drafts.csswg.org/css-animations-1/
+    // While an animation is applied but has not finished, or has finished but has an animation-fill-mode of forwards or both,
+    // the user agent must act as if the will-change property ([css-will-change-1]) on the element additionally
+    // includes all the properties animated by the animation.
+    if (forceStackingContext &amp;&amp; blendedStyle) {
+        if (blendedStyle-&gt;hasAutoZIndex())
+            blendedStyle-&gt;setZIndex(0);
+    }
+
</ins><span class="cx">     return animationStateChanged;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageanimationKeyframeAnimationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;RenderStyle.h&quot;
</span><span class="cx"> #include &quot;StylePendingResources.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;WillChangeData.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -55,6 +56,7 @@
</span><span class="cx"> #if ENABLE(FILTERS_LEVEL_2)
</span><span class="cx">     checkForMatchingBackdropFilterFunctionLists();
</span><span class="cx"> #endif
</span><ins>+    computeStackingContextImpact();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> KeyframeAnimation::~KeyframeAnimation()
</span><span class="lines">@@ -64,6 +66,16 @@
</span><span class="cx">         endAnimation();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void KeyframeAnimation::computeStackingContextImpact()
+{
+    for (auto propertyID : m_keyframes.properties()) {
+        if (WillChangeData::propertyCreatesStackingContext(propertyID)) {
+            m_triggersStackingContext = true;
+            break;
+        }
+    }
+}
+
</ins><span class="cx"> void KeyframeAnimation::fetchIntervalEndpointsForProperty(CSSPropertyID property, const RenderStyle*&amp; fromStyle, const RenderStyle*&amp; toStyle, double&amp; prog) const
</span><span class="cx"> {
</span><span class="cx">     size_t numKeyframes = m_keyframes.size();
</span><span class="lines">@@ -147,6 +159,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // FIXME: the code below never changes the state, so this function always returns false.
</ins><span class="cx">     AnimationState oldState = state();
</span><span class="cx"> 
</span><span class="cx">     // Run a cycle of animation.
</span></span></pre></div>
<a id="trunkSourceWebCorepageanimationKeyframeAnimationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.h (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/animation/KeyframeAnimation.h        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.h        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     const AtomicString&amp; name() const { return m_keyframes.animationName(); }
</span><span class="cx"> 
</span><span class="cx">     bool hasAnimationForProperty(CSSPropertyID) const;
</span><ins>+
+    bool triggersStackingContext() const { return m_triggersStackingContext; }
</ins><span class="cx">     
</span><span class="cx">     void setUnanimatedStyle(std::unique_ptr&lt;RenderStyle&gt; style) { m_unanimatedStyle = WTFMove(style); }
</span><span class="cx">     RenderStyle* unanimatedStyle() const { return m_unanimatedStyle.get(); }
</span><span class="lines">@@ -81,6 +83,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool computeExtentOfAnimationForMatchingTransformLists(const FloatRect&amp; rendererBox, LayoutRect&amp;) const;
</span><span class="cx"> 
</span><ins>+    void computeStackingContextImpact();
</ins><span class="cx">     void resolveKeyframeStyles();
</span><span class="cx">     void validateTransformFunctionList();
</span><span class="cx">     void checkForMatchingFilterFunctionLists();
</span><span class="lines">@@ -99,6 +102,7 @@
</span><span class="cx">     std::unique_ptr&lt;RenderStyle&gt; m_unanimatedStyle; // The style just before we started animation
</span><span class="cx"> 
</span><span class="cx">     bool m_startEventDispatched { false };
</span><ins>+    bool m_triggersStackingContext { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -996,6 +996,7 @@
</span><span class="cx">     
</span><span class="cx">     RenderBox* box = renderBox();
</span><span class="cx">     ASSERT(box);
</span><ins>+    // FIXME: replace with call to AnimationController::isRunningAcceleratedAnimationOnRenderer() and remove RenderStyle::isRunningAcceleratedAnimation().
</ins><span class="cx">     if (renderer().style().isRunningAcceleratedAnimation()) {
</span><span class="cx">         TransformationMatrix currTransform;
</span><span class="cx">         FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box-&gt;borderBoxRect(), box-&gt;document().deviceScaleFactor());
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleWillChangeDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/WillChangeData.cpp (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/WillChangeData.cpp        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/rendering/style/WillChangeData.cpp        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> 
</span><span class="cx"> // &quot;If any non-initial value of a property would create a stacking context on the element,
</span><span class="cx"> // specifying that property in will-change must create a stacking context on the element.&quot;
</span><del>-static bool propertyCreatesStackingContext(CSSPropertyID property)
</del><ins>+bool WillChangeData::propertyCreatesStackingContext(CSSPropertyID property)
</ins><span class="cx"> {
</span><span class="cx">     switch (property) {
</span><span class="cx">     case CSSPropertyPerspective:
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleWillChangeDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/WillChangeData.h (208024 => 208025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/WillChangeData.h        2016-10-28 02:26:55 UTC (rev 208024)
+++ trunk/Source/WebCore/rendering/style/WillChangeData.h        2016-10-28 03:20:32 UTC (rev 208025)
</span><span class="lines">@@ -70,6 +70,8 @@
</span><span class="cx">     typedef std::pair&lt;Feature, CSSPropertyID&gt; FeaturePropertyPair;
</span><span class="cx">     FeaturePropertyPair featureAt(size_t) const;
</span><span class="cx"> 
</span><ins>+    static bool propertyCreatesStackingContext(CSSPropertyID);
+
</ins><span class="cx"> private:
</span><span class="cx">     WillChangeData()
</span><span class="cx">     {
</span></span></pre>
</div>
</div>

</body>
</html>