<!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>[200381] 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/200381">200381</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-05-03 11:00:04 -0700 (Tue, 03 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/198943">r198943</a>): Transitions don't work if they animate display property
https://bugs.webkit.org/show_bug.cgi?id=157244
&lt;rdar://problem/26042189&gt;

Reviewed by Simon Fraser.

Source/WebCore:

Test: transitions/transition-display-property.html

* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement):

    Call the common function for ::before/::after updates.

* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):
(WebCore::Style::TreeResolver::createAnimatedElementUpdate):

    If animation forces render tree reconstruction use the original rather than animated style for update.
    Because animations are tied to renderers we start them during renderer construction in this case.

    Factor to a function.

(WebCore::Style::elementImplicitVisibility):
* style/StyleTreeResolver.h:

LayoutTests:

* transitions/transition-display-property-expected.html: Added.
* transitions/transition-display-property.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="#trunkSourceWebCorestyleRenderTreeUpdatercpp">trunk/Source/WebCore/style/RenderTreeUpdater.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolverh">trunk/Source/WebCore/style/StyleTreeResolver.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTeststransitionstransitiondisplaypropertyexpectedhtml">trunk/LayoutTests/transitions/transition-display-property-expected.html</a></li>
<li><a href="#trunkLayoutTeststransitionstransitiondisplaypropertyhtml">trunk/LayoutTests/transitions/transition-display-property.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (200380 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-03 17:58:23 UTC (rev 200380)
+++ trunk/LayoutTests/ChangeLog        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-05-02  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        REGRESSION (r198943): Transitions don't work if they animate display property
+        https://bugs.webkit.org/show_bug.cgi?id=157244
+        &lt;rdar://problem/26042189&gt;
+
+        Reviewed by Simon Fraser.
+
+        * transitions/transition-display-property-expected.html: Added.
+        * transitions/transition-display-property.html: Added.
+
</ins><span class="cx"> 2016-05-03  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, drop outdated layout test after r200375.
</span></span></pre></div>
<a id="trunkLayoutTeststransitionstransitiondisplaypropertyexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/transitions/transition-display-property-expected.html (0 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/transitions/transition-display-property-expected.html                                (rev 0)
+++ trunk/LayoutTests/transitions/transition-display-property-expected.html        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+&lt;style&gt;
+test { display:inline-block; height:10px; width:10px; border: 2px solid green; }
+&lt;/style&gt;
+&lt;test&gt;&lt;/test&gt;
</ins></span></pre></div>
<a id="trunkLayoutTeststransitionstransitiondisplaypropertyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/transitions/transition-display-property.html (0 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/transitions/transition-display-property.html                                (rev 0)
+++ trunk/LayoutTests/transitions/transition-display-property.html        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;style&gt;
+test { transition:0.1s; display:block; height:100px; border: 2px solid green; }
+.animate { display:inline-block; height:10px; width:10px; }
+&lt;/style&gt;
+&lt;test&gt;&lt;/test&gt;
+&lt;script&gt;
+var test = document.querySelector(&quot;test&quot;);
+var count = 0;
+function testUntilComplete()
+{
+    if (test.offsetWidth == 10 || ++count == 10)
+        testRunner.notifyDone();
+    else
+        setTimeout(testUntilComplete, 0.1);
+}
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testUntilComplete();
+}
+test.offsetWidth;
+test.className = &quot;animate&quot;;
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200380 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-03 17:58:23 UTC (rev 200380)
+++ trunk/Source/WebCore/ChangeLog        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-05-02  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        REGRESSION (r198943): Transitions don't work if they animate display property
+        https://bugs.webkit.org/show_bug.cgi?id=157244
+        &lt;rdar://problem/26042189&gt;
+
+        Reviewed by Simon Fraser.
+
+        Test: transitions/transition-display-property.html
+
+        * style/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement):
+
+            Call the common function for ::before/::after updates.
+
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::resolveElement):
+        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
+
+            If animation forces render tree reconstruction use the original rather than animated style for update.
+            Because animations are tied to renderers we start them during renderer construction in this case.
+
+            Factor to a function.
+
+        (WebCore::Style::elementImplicitVisibility):
+        * style/StyleTreeResolver.h:
+
</ins><span class="cx"> 2016-05-03  Pranjal Jumde  &lt;pjumde@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WorkerGlobalScope's self, location and navigator attributes should not be replaceable
</span></span></pre></div>
<a id="trunkSourceWebCorestyleRenderTreeUpdatercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/RenderTreeUpdater.cpp (200380 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/RenderTreeUpdater.cpp        2016-05-03 17:58:23 UTC (rev 200380)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.cpp        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -480,17 +480,10 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Style::ElementUpdate elementUpdate;
-
</del><span class="cx">     auto newStyle = RenderStyle::clonePtr(*current.renderer()-&gt;getCachedPseudoStyle(pseudoId, &amp;current.renderer()-&gt;style()));
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;RenderStyle&gt; animatedStyle;
-    if (renderer &amp;&amp; m_document.frame()-&gt;animation().updateAnimations(*renderer, *newStyle, animatedStyle))
-        elementUpdate.isSynthetic = true;
</del><ins>+    auto elementUpdate = Style::TreeResolver::createAnimatedElementUpdate(WTFMove(newStyle), renderer, m_document);
</ins><span class="cx"> 
</span><del>-    elementUpdate.style = animatedStyle ? WTFMove(animatedStyle) : WTFMove(newStyle);
-    elementUpdate.change = renderer ? Style::determineChange(renderer-&gt;style(), *elementUpdate.style) : Style::Detach;
-
</del><span class="cx">     if (elementUpdate.change == Style::NoChange)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (200380 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-05-03 17:58:23 UTC (rev 200380)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -185,22 +185,14 @@
</span><span class="cx"> {
</span><span class="cx">     auto newStyle = styleForElement(element, parent().style);
</span><span class="cx"> 
</span><del>-    auto* renderer = element.renderer();
-
</del><span class="cx">     if (!affectsRenderedSubtree(element, *newStyle))
</span><span class="cx">         return { };
</span><span class="cx"> 
</span><del>-    ElementUpdate update;
</del><ins>+    bool shouldReconstructRenderTree = element.styleChangeType() == ReconstructRenderTree || parent().change == Detach;
+    auto* rendererToUpdate = shouldReconstructRenderTree ? nullptr : element.renderer();
</ins><span class="cx"> 
</span><del>-    bool needsNewRenderer = !renderer || element.styleChangeType() == ReconstructRenderTree || parent().change == Detach;
</del><ins>+    auto update = createAnimatedElementUpdate(WTFMove(newStyle), rendererToUpdate, m_document);
</ins><span class="cx"> 
</span><del>-    std::unique_ptr&lt;RenderStyle&gt; animatedStyle;
-    if (!needsNewRenderer &amp;&amp; m_document.frame()-&gt;animation().updateAnimations(*renderer, *newStyle, animatedStyle))
-        update.isSynthetic = true;
-
-    update.style = animatedStyle ? WTFMove(animatedStyle) : WTFMove(newStyle);
-    update.change = needsNewRenderer ? Detach : determineChange(renderer-&gt;style(), *update.style);
-
</del><span class="cx">     if (element.styleChangeType() == SyntheticStyleChange)
</span><span class="cx">         update.isSynthetic = true;
</span><span class="cx"> 
</span><span class="lines">@@ -210,7 +202,7 @@
</span><span class="cx"> 
</span><span class="cx">         // If &quot;rem&quot; units are used anywhere in the document, and if the document element's font size changes, then force font updating
</span><span class="cx">         // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
</span><del>-        if (m_document.authorStyleSheets().usesRemUnits() &amp;&amp; update.change != NoChange &amp;&amp; renderer &amp;&amp; renderer-&gt;style().fontSize() != update.style-&gt;fontSize()) {
</del><ins>+        if (m_document.authorStyleSheets().usesRemUnits() &amp;&amp; update.change != NoChange &amp;&amp; element.renderer() &amp;&amp; element.renderer()-&gt;style().fontSize() != update.style-&gt;fontSize()) {
</ins><span class="cx">             // Cached RenderStyles may depend on the rem units.
</span><span class="cx">             scope().styleResolver.invalidateMatchedPropertiesCache();
</span><span class="cx">             update.change = Force;
</span><span class="lines">@@ -228,6 +220,27 @@
</span><span class="cx">     return update;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr&lt;RenderStyle&gt; newStyle, RenderElement* rendererToUpdate, Document&amp; document)
+{
+    ElementUpdate update;
+
+    std::unique_ptr&lt;RenderStyle&gt; animatedStyle;
+    if (rendererToUpdate &amp;&amp; document.frame()-&gt;animation().updateAnimations(*rendererToUpdate, *newStyle, animatedStyle))
+        update.isSynthetic = true;
+
+    if (animatedStyle) {
+        update.change = determineChange(rendererToUpdate-&gt;style(), *animatedStyle);
+        // If animation forces render tree reconstruction pass the original style. The animation will be applied on renderer construction.
+        // FIXME: We should always use the animated style here.
+        update.style = update.change == Detach ? WTFMove(newStyle) : WTFMove(animatedStyle);
+    } else {
+        update.change = rendererToUpdate ? determineChange(rendererToUpdate-&gt;style(), *newStyle) : Detach;
+        update.style = WTFMove(newStyle);
+    }
+
+    return update;
+}
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> static EVisibility elementImplicitVisibility(const Element* element)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.h (200380 => 200381)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.h        2016-05-03 17:58:23 UTC (rev 200380)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h        2016-05-03 18:00:04 UTC (rev 200381)
</span><span class="lines">@@ -60,6 +60,8 @@
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;Update&gt; resolve(Change);
</span><span class="cx"> 
</span><ins>+    static ElementUpdate createAnimatedElementUpdate(std::unique_ptr&lt;RenderStyle&gt;, RenderElement* existingRenderer, Document&amp;);
+
</ins><span class="cx"> private:
</span><span class="cx">     std::unique_ptr&lt;RenderStyle&gt; styleForElement(Element&amp;, const RenderStyle&amp; inheritedStyle);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>