<!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>[214435] 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/214435">214435</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2017-03-27 15:56:32 -0700 (Mon, 27 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore:
Allow the page to render before &lt;link&gt; stylesheet tags in body
https://bugs.webkit.org/show_bug.cgi?id=149157
&lt;rdar://problem/24658830&gt;

Reviewed by Simon Fraser.

Currently we block style and renderer building completely if document has any loading
stylesheets. In case a script queries something layout dependent we construct the render
tree with whatever style we have but block painting in it.

This patch changes behavior so that a loading stylesheet in body only blocks rendering for elements
that are after it. The expectation is that such stylesheets rarely affect elements before them
and the elements can be rendered without causing ugly visible styling changes.

The patch replaces the old flash-of-unstyled-content (FOUC) preventation mechanism with a more
fine-grained one. Paint blocking is now done on per-renderer basis with based on isNonFinal flag in
RenderStyle.

For stylesheets in head the behavior should be largely unchanged.

Test: http/tests/incremental/stylesheet-body-incremental-rendering.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::pseudoStyleRulesForElement):
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::resolveStyle):
(WebCore::Document::updateLayoutIgnorePendingStylesheets):

    Remove the old FOUC preventation state tracking.

(WebCore::Document::shouldScheduleLayout):
(WebCore::Document::didRemoveAllPendingStylesheet):

    Repaints will now get triggered by the normal style mechanism.

* dom/Document.h:
(WebCore::Document::hasNodesWithNonFinalStyle):
(WebCore::Document::setHasNodesWithNonFinalStyle):

    Track if we need to recompute the style later because non-final or unstyled elements.

(WebCore::Document::didLayoutWithPendingStylesheets): Deleted.
(WebCore::Document::hasNodesWithPlaceholderStyle): Deleted.
(WebCore::Document::setHasNodesWithPlaceholderStyle): Deleted.
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::rendererIsNeeded):
* page/FrameView.cpp:
(WebCore::FrameView::qualifiesAsVisuallyNonEmpty):

    Don't qualify as visually non-empty if we have loading stylesheets in head (even if there is
    a fouc-prevented render tree).

(WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintContents):

    Instead of a global test, block painting if isNonFinal is set in the renderer's style.

* rendering/RenderLayer.cpp:
(WebCore::shouldSuppressPaintingLayer):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresRepaint):

    The isNonFinal flag prevents painting so we need to trigger repaint when it gets cleared.

* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::isNotFinal):
(WebCore::RenderStyle::setIsNotFinal):
(WebCore::RenderStyle::isPlaceholderStyle): Deleted.
(WebCore::RenderStyle::setIsPlaceholderStyle): Deleted.

    There is no need for placeholder styles anymore. Reuse the bit for isNotFinal.

* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
* rendering/style/StyleRareNonInheritedData.h:
* style/StyleScope.cpp:
(WebCore::Style::Scope::analyzeStyleSheetChange):
(WebCore::Style::Scope::updateActiveStyleSheets):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::styleForElement):
(WebCore::Style::TreeResolver::resolveElement):

    If we have seens a loading stylesheet and don't have a renderer yet don't style the element.
    In case there is a renderer or we are ignoring pending sheets, resolve the style normally
    but mark it as non-final.

(WebCore::Style::makePlaceholderStyle): Deleted.

LayoutTests:
Loading in-body stylesheets should not block rendering of elements before them
https://bugs.webkit.org/show_bug.cgi?id=169345

Reviewed by Simon Fraser.

* http/tests/incremental/resources/delayed-css.php: Added.
* http/tests/incremental/stylesheet-body-incremental-rendering-expected.html: Added.
* http/tests/incremental/stylesheet-body-incremental-rendering.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="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFrameSetElementcpp">trunk/Source/WebCore/html/HTMLFrameSetElement.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStylecpp">trunk/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStyleh">trunk/Source/WebCore/rendering/style/RenderStyle.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleStyleRareNonInheritedDatacpp">trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleStyleRareNonInheritedDatah">trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleScopecpp">trunk/Source/WebCore/style/StyleScope.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderingexpectedhtml">trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html</a></li>
<li><a href="#trunkLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderinghtml">trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/LayoutTests/ChangeLog        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-03-27  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Loading in-body stylesheets should not block rendering of elements before them
+        https://bugs.webkit.org/show_bug.cgi?id=169345
+
+        Reviewed by Simon Fraser.
+
+        * http/tests/incremental/resources/delayed-css.php: Added.
+        * http/tests/incremental/stylesheet-body-incremental-rendering-expected.html: Added.
+        * http/tests/incremental/stylesheet-body-incremental-rendering.html: Added.
+
</ins><span class="cx"> 2017-03-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Test variation font ranges in the CSS Font Loading API
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderingexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html (0 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+&lt;div style=&quot;width:100px; height:100px; background-color:green&quot;&gt;&lt;/div&gt;
+&lt;div style=&quot;width:100px; height:100px; background-color:green&quot;&gt;&lt;/div&gt;
+&lt;p&gt;
+Before stylesheet load: (repaint rects (rect 8 8 100 100) )&lt;br&gt;
+After stylesheet load: (repaint rects (rect 8 108 100 100) )&lt;br&gt;
+&lt;/p&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html (0 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;body&gt;
+&lt;script&gt;
+document.body.offsetWidth;
+
+internals.startTrackingRepaints();
+let initialRects;
+setTimeout(() =&gt; {
+   initialRects = internals.repaintRectsAsText();
+   internals.stopTrackingRepaints();
+   internals.startTrackingRepaints();
+}, 0);
+
+document.body.onload = () =&gt; {
+    let finalRects = internals.repaintRectsAsText();
+    internals.stopTrackingRepaints();
+    document.body.innerHTML += `&lt;p&gt;
+        Before stylesheet load: ${initialRects}&lt;br&gt;
+        After stylesheet load: ${finalRects}&lt;br&gt;
+    &lt;/p&gt;`;
+};
+&lt;/script&gt;
+&lt;div style=&quot;width:100px; height:100px; background-color:green&quot;&gt;&lt;/div&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;resources/delayed-css.php?delay=300&quot;&gt;
+&lt;div class=delayed style=&quot;width:100px; height:100px; background-color:red&quot;&gt;&lt;/div&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/ChangeLog        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -1,3 +1,96 @@
</span><ins>+2017-03-27  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Allow the page to render before &lt;link&gt; stylesheet tags in body
+        https://bugs.webkit.org/show_bug.cgi?id=149157
+        &lt;rdar://problem/24658830&gt;
+
+        Reviewed by Simon Fraser.
+
+        Currently we block style and renderer building completely if document has any loading
+        stylesheets. In case a script queries something layout dependent we construct the render
+        tree with whatever style we have but block painting in it.
+
+        This patch changes behavior so that a loading stylesheet in body only blocks rendering for elements
+        that are after it. The expectation is that such stylesheets rarely affect elements before them
+        and the elements can be rendered without causing ugly visible styling changes.
+
+        The patch replaces the old flash-of-unstyled-content (FOUC) preventation mechanism with a more
+        fine-grained one. Paint blocking is now done on per-renderer basis with based on isNonFinal flag in
+        RenderStyle.
+
+        For stylesheets in head the behavior should be largely unchanged.
+
+        Test: http/tests/incremental/stylesheet-body-incremental-rendering.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::pseudoStyleRulesForElement):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::resolveStyle):
+        (WebCore::Document::updateLayoutIgnorePendingStylesheets):
+
+            Remove the old FOUC preventation state tracking.
+
+        (WebCore::Document::shouldScheduleLayout):
+        (WebCore::Document::didRemoveAllPendingStylesheet):
+
+            Repaints will now get triggered by the normal style mechanism.
+
+        * dom/Document.h:
+        (WebCore::Document::hasNodesWithNonFinalStyle):
+        (WebCore::Document::setHasNodesWithNonFinalStyle):
+
+            Track if we need to recompute the style later because non-final or unstyled elements.
+
+        (WebCore::Document::didLayoutWithPendingStylesheets): Deleted.
+        (WebCore::Document::hasNodesWithPlaceholderStyle): Deleted.
+        (WebCore::Document::setHasNodesWithPlaceholderStyle): Deleted.
+        * html/HTMLFrameSetElement.cpp:
+        (WebCore::HTMLFrameSetElement::rendererIsNeeded):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
+
+            Don't qualify as visually non-empty if we have loading stylesheets in head (even if there is
+            a fouc-prevented render tree).
+
+        (WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintContents):
+
+            Instead of a global test, block painting if isNonFinal is set in the renderer's style.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::shouldSuppressPaintingLayer):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::changeRequiresRepaint):
+
+            The isNonFinal flag prevents painting so we need to trigger repaint when it gets cleared.
+
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::isNotFinal):
+        (WebCore::RenderStyle::setIsNotFinal):
+        (WebCore::RenderStyle::isPlaceholderStyle): Deleted.
+        (WebCore::RenderStyle::setIsPlaceholderStyle): Deleted.
+
+            There is no need for placeholder styles anymore. Reuse the bit for isNotFinal.
+
+        * rendering/style/StyleRareNonInheritedData.cpp:
+        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+        (WebCore::StyleRareNonInheritedData::operator==):
+        * rendering/style/StyleRareNonInheritedData.h:
+        * style/StyleScope.cpp:
+        (WebCore::Style::Scope::analyzeStyleSheetChange):
+        (WebCore::Style::Scope::updateActiveStyleSheets):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::styleForElement):
+        (WebCore::Style::TreeResolver::resolveElement):
+
+            If we have seens a loading stylesheet and don't have a renderer yet don't style the element.
+            In case there is a renderer or we are ignoring pending sheets, resolve the style normally
+            but mark it as non-final.
+
+        (WebCore::Style::makePlaceholderStyle): Deleted.
+
</ins><span class="cx"> 2017-03-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Test variation font ranges in the CSS Font Loading API
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -1123,8 +1123,8 @@
</span><span class="cx"> 
</span><span class="cx"> Vector&lt;RefPtr&lt;StyleRule&gt;&gt; StyleResolver::pseudoStyleRulesForElement(const Element* element, PseudoId pseudoId, unsigned rulesToInclude)
</span><span class="cx"> {
</span><del>-    if (!element || !element-&gt;document().haveStylesheetsLoaded())
-        return Vector&lt;RefPtr&lt;StyleRule&gt;&gt;();
</del><ins>+    if (!element)
+        return { };
</ins><span class="cx"> 
</span><span class="cx">     m_state = State(*element, nullptr);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/dom/Document.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -1725,7 +1725,8 @@
</span><span class="cx"> 
</span><span class="cx">         if (type == ResolveStyleType::Rebuild) {
</span><span class="cx">             // This may get set again during style resolve.
</span><del>-            m_hasNodesWithPlaceholderStyle = false;
</del><ins>+            m_hasNodesWithNonFinalStyle = false;
+            m_hasNodesWithMissingStyle = false;
</ins><span class="cx"> 
</span><span class="cx">             auto documentStyle = Style::resolveForDocument(*this);
</span><span class="cx"> 
</span><span class="lines">@@ -1761,6 +1762,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         updatedCompositingLayers = frameView.updateCompositingLayersAfterStyleChange();
</span><ins>+
+        if (m_renderView-&gt;needsLayout())
+            frameView.scheduleRelayout();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If we wanted to call implicitClose() during recalcStyle, do so now that we're finished.
</span><span class="lines">@@ -1854,12 +1858,6 @@
</span><span class="cx">         frameView-&gt;layout();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// FIXME: This is a bad idea and needs to be removed eventually.
-// Other browsers load stylesheets before they continue parsing the web page.
-// Since we don't, we can run JavaScript code that needs answers before the
-// stylesheets are loaded. Doing a layout ignoring the pending stylesheets
-// lets us get reasonable answers. The long term solution to this problem is
-// to instead suspend JavaScript execution.
</del><span class="cx"> void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks)
</span><span class="cx"> {
</span><span class="cx">     bool oldIgnore = m_ignorePendingStylesheets;
</span><span class="lines">@@ -1866,22 +1864,9 @@
</span><span class="cx"> 
</span><span class="cx">     if (!haveStylesheetsLoaded()) {
</span><span class="cx">         m_ignorePendingStylesheets = true;
</span><del>-        // FIXME: We are willing to attempt to suppress painting with outdated style info only once.  Our assumption is that it would be
-        // dangerous to try to stop it a second time, after page content has already been loaded and displayed
-        // with accurate style information.  (Our suppression involves blanking the whole page at the
-        // moment.  If it were more refined, we might be able to do something better.)
-        // It's worth noting though that this entire method is a hack, since what we really want to do is
-        // suspend JS instead of doing a layout with inaccurate information.
-        HTMLElement* bodyElement = bodyOrFrameset();
-        if (bodyElement &amp;&amp; !bodyElement-&gt;renderer() &amp;&amp; m_pendingSheetLayout == NoLayoutWithPendingSheets) {
-            m_pendingSheetLayout = DidLayoutWithPendingSheets;
-            styleScope().didChangeActiveStyleSheetCandidates();
-            resolveStyle(ResolveStyleType::Rebuild);
-        } else if (m_hasNodesWithPlaceholderStyle)
-            // If new nodes have been added or style recalc has been done with style sheets still pending, some nodes 
-            // may not have had their real style calculated yet. Normally this gets cleaned when style sheets arrive 
-            // but here we need up-to-date style immediately.
-            resolveStyle(ResolveStyleType::Rebuild);
</del><ins>+        // FIXME: This should just invalidate elements with missing styles.
+        if (m_hasNodesWithMissingStyle)
+            scheduleForcedStyleRecalc();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     updateLayout();
</span><span class="lines">@@ -2723,14 +2708,16 @@
</span><span class="cx"> 
</span><span class="cx"> bool Document::shouldScheduleLayout()
</span><span class="cx"> {
</span><del>-    // This function will only be called when FrameView thinks a layout is needed.
-    // This enforces a couple extra rules.
-    //
-    //    (a) Only schedule a layout once the stylesheets are loaded.
-    //    (b) Only schedule layout once we have a body element.
</del><ins>+    if (!documentElement())
+        return false;
+    if (!is&lt;HTMLHtmlElement&gt;(*documentElement()))
+        return true;
+    if (!bodyOrFrameset())
+        return false;
+    if (styleScope().hasPendingSheetsBeforeBody())
+        return false;
</ins><span class="cx"> 
</span><del>-    return (haveStylesheetsLoaded() &amp;&amp; bodyOrFrameset())
-        || (documentElement() &amp;&amp; !is&lt;HTMLHtmlElement&gt;(*documentElement()));
</del><ins>+    return true;
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> bool Document::isLayoutTimerActive()
</span><span class="lines">@@ -3034,15 +3021,6 @@
</span><span class="cx"> 
</span><span class="cx"> void Document::didRemoveAllPendingStylesheet()
</span><span class="cx"> {
</span><del>-    if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
-        // Painting is disabled when doing layouts with pending sheets to avoid FOUC.
-        // We need to force paint when coming out from this state.
-        // FIXME: This is not very elegant.
-        m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
-        if (renderView())
-            renderView()-&gt;repaintViewAndCompositedLayers();
-    }
-
</del><span class="cx">     if (auto* parser = scriptableDocumentParser())
</span><span class="cx">         parser-&gt;executeScriptsWaitingForStylesheetsSoon();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/dom/Document.h        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -936,13 +936,11 @@
</span><span class="cx">     WEBCORE_EXPORT Ref&lt;XPathNSResolver&gt; createNSResolver(Node* nodeResolver);
</span><span class="cx">     WEBCORE_EXPORT ExceptionOr&lt;Ref&lt;XPathResult&gt;&gt; evaluate(const String&amp; expression, Node* contextNode, RefPtr&lt;XPathNSResolver&gt;&amp;&amp;, unsigned short type, XPathResult*);
</span><span class="cx"> 
</span><del>-    enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
</del><ins>+    bool hasNodesWithNonFinalStyle() const { return m_hasNodesWithNonFinalStyle; }
+    void setHasNodesWithNonFinalStyle() { m_hasNodesWithNonFinalStyle = true; }
+    bool hasNodesWithMissingStyle() const { return m_hasNodesWithMissingStyle; }
+    void setHasNodesWithMissingStyle() { m_hasNodesWithMissingStyle = true; }
</ins><span class="cx"> 
</span><del>-    bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
-
-    bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
-    void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
-
</del><span class="cx">     void updateFocusAppearanceSoon(SelectionRestorationMode);
</span><span class="cx">     void cancelFocusAppearanceUpdate();
</span><span class="cx"> 
</span><span class="lines">@@ -1678,16 +1676,12 @@
</span><span class="cx">     bool m_wellFormed { false };
</span><span class="cx">     bool m_createRenderers { true };
</span><span class="cx"> 
</span><del>-    bool m_hasNodesWithPlaceholderStyle { false };
</del><ins>+    bool m_hasNodesWithNonFinalStyle { false };
+    bool m_hasNodesWithMissingStyle { false };
</ins><span class="cx">     // But sometimes you need to ignore pending stylesheet count to
</span><span class="cx">     // force an immediate layout when requested by JS.
</span><span class="cx">     bool m_ignorePendingStylesheets { false };
</span><span class="cx"> 
</span><del>-    // If we do ignore the pending stylesheet count, then we need to add a boolean
-    // to track that this happened so that we can do a full repaint when the stylesheets
-    // do eventually load.
-    PendingSheetLayout m_pendingSheetLayout { NoLayoutWithPendingSheets };
-
</del><span class="cx">     bool m_hasElementUsingStyleBasedEditability { false };
</span><span class="cx">     bool m_focusNavigationStartingNodeIsRemoved { false };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFrameSetElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFrameSetElement.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFrameSetElement.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/html/HTMLFrameSetElement.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -153,7 +153,7 @@
</span><span class="cx"> {
</span><span class="cx">     // For compatibility, frames render even when display: none is set.
</span><span class="cx">     // However, we delay creating a renderer until stylesheets have loaded. 
</span><del>-    return !style.isPlaceholderStyle();
</del><ins>+    return !style.isNotFinal();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderPtr&lt;RenderElement&gt; HTMLFrameSetElement::createElementRenderer(RenderStyle&amp;&amp; style, const RenderTreePosition&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/page/FrameView.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -4586,6 +4586,10 @@
</span><span class="cx">     if (!frame().document()-&gt;parsing() &amp;&amp; frame().loader().stateMachine().committedFirstRealDocumentLoad())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    // FIXME: We should also ignore renderers with non-final style.
+    if (frame().document()-&gt;styleScope().hasPendingSheetsBeforeBody())
+        return false;
+
</ins><span class="cx">     // Require the document to grow a bit.
</span><span class="cx">     // Using a value of 48 allows the header on Google's search page to render immediately before search results populate later.
</span><span class="cx">     static const int documentHeightThreshold = 48;
</span><span class="lines">@@ -5128,7 +5132,7 @@
</span><span class="cx">     updateIsVisuallyNonEmpty();
</span><span class="cx"> 
</span><span class="cx">     // If the layout was done with pending sheets, we are not in fact visually non-empty yet.
</span><del>-    if (m_isVisuallyNonEmpty &amp;&amp; !frame().document()-&gt;didLayoutWithPendingStylesheets() &amp;&amp; m_firstVisuallyNonEmptyLayoutCallbackPending) {
</del><ins>+    if (m_isVisuallyNonEmpty &amp;&amp;m_firstVisuallyNonEmptyLayoutCallbackPending) {
</ins><span class="cx">         m_firstVisuallyNonEmptyLayoutCallbackPending = false;
</span><span class="cx">         if (requestedMilestones &amp; DidFirstVisuallyNonEmptyLayout)
</span><span class="cx">             milestonesAchieved |= DidFirstVisuallyNonEmptyLayout;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -1579,10 +1579,10 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderBlock::paintContents(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
</span><span class="cx"> {
</span><del>-    // Avoid painting descendants of the root element when stylesheets haven't loaded.  This eliminates FOUC.
-    // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document
-    // will do a full repaint.
-    if (document().didLayoutWithPendingStylesheets() &amp;&amp; !isRenderView())
</del><ins>+    // Style is non-final if the element has a pending stylesheet before it. We end up with renderers with such styles if a script
+    // forces renderer construction by querying something layout dependent.
+    // Avoid FOUC by not painting. Switching to final style triggers repaint.
+    if (style().isNotFinal())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (childrenInline())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -3939,10 +3939,7 @@
</span><span class="cx">     
</span><span class="cx"> static inline bool shouldSuppressPaintingLayer(RenderLayer* layer)
</span><span class="cx"> {
</span><del>-    // Avoid painting descendants of the root layer when stylesheets haven't loaded. This eliminates FOUC.
-    // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
-    // will do a full repaint().
-    if (layer-&gt;renderer().document().didLayoutWithPendingStylesheets() &amp;&amp; !layer-&gt;isRootLayer() &amp;&amp; !layer-&gt;renderer().isDocumentElementRenderer())
</del><ins>+    if (layer-&gt;renderer().style().isNotFinal() &amp;&amp; !layer-&gt;isRootLayer() &amp;&amp; !layer-&gt;renderer().isDocumentElementRenderer())
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     // Avoid painting all layers if the document is in a state where visual updates aren't allowed.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -853,6 +853,9 @@
</span><span class="cx">         || m_rareInheritedData-&gt;imageRendering != other.m_rareInheritedData-&gt;imageRendering)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    if (m_rareNonInheritedData-&gt;isNotFinal != other.m_rareNonInheritedData-&gt;isNotFinal)
+        return true;
+
</ins><span class="cx">     if (m_rareNonInheritedData-&gt;shapeOutside != other.m_rareNonInheritedData-&gt;shapeOutside)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.h        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -1659,8 +1659,9 @@
</span><span class="cx">     static Isolation initialIsolation() { return IsolationAuto; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    bool isPlaceholderStyle() const { return m_rareNonInheritedData-&gt;isPlaceholderStyle; }
-    void setIsPlaceholderStyle() { SET_VAR(m_rareNonInheritedData, isPlaceholderStyle, true); }
</del><ins>+    // Indicates the style is likely to change due to a pending stylesheet load.
+    bool isNotFinal() const { return m_rareNonInheritedData-&gt;isNotFinal; }
+    void setIsNotFinal() { SET_VAR(m_rareNonInheritedData, isNotFinal, true); }
</ins><span class="cx"> 
</span><span class="cx">     void setVisitedLinkColor(const Color&amp;);
</span><span class="cx">     void setVisitedLinkBackgroundColor(const Color&amp; v) { SET_VAR(m_rareNonInheritedData, visitedLinkBackgroundColor, v); }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleStyleRareNonInheritedDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">     , breakInside(RenderStyle::initialBreakInside())
</span><span class="cx">     , resize(RenderStyle::initialResize())
</span><span class="cx">     , hasAttrContent(false)
</span><del>-    , isPlaceholderStyle(false)
</del><ins>+    , isNotFinal(false)
</ins><span class="cx"> {
</span><span class="cx">     maskBoxImage.setMaskDefaults();
</span><span class="cx"> }
</span><span class="lines">@@ -200,7 +200,7 @@
</span><span class="cx">     , breakInside(o.breakInside)
</span><span class="cx">     , resize(o.resize)
</span><span class="cx">     , hasAttrContent(o.hasAttrContent)
</span><del>-    , isPlaceholderStyle(o.isPlaceholderStyle)
</del><ins>+    , isNotFinal(o.isNotFinal)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -304,7 +304,7 @@
</span><span class="cx">         &amp;&amp; breakInside == o.breakInside
</span><span class="cx">         &amp;&amp; resize == o.resize
</span><span class="cx">         &amp;&amp; hasAttrContent == o.hasAttrContent
</span><del>-        &amp;&amp; isPlaceholderStyle == o.isPlaceholderStyle;
</del><ins>+        &amp;&amp; isNotFinal == o.isNotFinal;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData&amp; other) const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleStyleRareNonInheritedDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -220,7 +220,7 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned hasAttrContent : 1;
</span><span class="cx"> 
</span><del>-    unsigned isPlaceholderStyle : 1;
</del><ins>+    unsigned isNotFinal : 1;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     StyleRareNonInheritedData();
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleScope.cpp (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/style/StyleScope.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -394,7 +394,7 @@
</span><span class="cx">     auto styleResolverUpdateType = hasInsertions ? Reset : Additive;
</span><span class="cx"> 
</span><span class="cx">     // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
</span><del>-    if (!m_document.bodyOrFrameset() || m_document.hasNodesWithPlaceholderStyle())
</del><ins>+    if (!m_document.bodyOrFrameset() || m_document.hasNodesWithNonFinalStyle() || m_document.hasNodesWithMissingStyle())
</ins><span class="cx">         return styleResolverUpdateType;
</span><span class="cx"> 
</span><span class="cx">     StyleInvalidationAnalysis invalidationAnalysis(addedSheets, styleResolver.mediaQueryEvaluator());
</span><span class="lines">@@ -445,7 +445,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Don't bother updating, since we haven't loaded all our style info yet
</span><span class="cx">     // and haven't calculated the style resolver for the first time.
</span><del>-    if (!m_shadowRoot &amp;&amp; !m_didUpdateActiveStyleSheets &amp;&amp; hasPendingSheets()) {
</del><ins>+    if (!m_shadowRoot &amp;&amp; !m_didUpdateActiveStyleSheets &amp;&amp; hasPendingSheetsBeforeBody()) {
</ins><span class="cx">         clearResolver();
</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 (214434 => 214435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2017-03-27 22:22:40 UTC (rev 214434)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2017-03-27 22:56:32 UTC (rev 214435)
</span><span class="lines">@@ -51,24 +51,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace Style {
</span><span class="cx"> 
</span><del>-static std::unique_ptr&lt;RenderStyle&gt; makePlaceholderStyle(Document&amp; document)
-{
-    auto placeholderStyle = RenderStyle::createPtr();
-    placeholderStyle-&gt;setDisplay(NONE);
-    placeholderStyle-&gt;setIsPlaceholderStyle();
-
-    FontCascadeDescription fontDescription;
-    fontDescription.setOneFamily(standardFamily);
-    fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
-    float size = Style::fontSizeForKeyword(CSSValueMedium, false, document);
-    fontDescription.setSpecifiedSize(size);
-    fontDescription.setComputedSize(size);
-    placeholderStyle-&gt;setFontDescription(fontDescription);
-
-    placeholderStyle-&gt;fontCascade().update(&amp;document.fontSelector());
-    return placeholderStyle;
-}
-
</del><span class="cx"> TreeResolver::TreeResolver(Document&amp; document)
</span><span class="cx">     : m_document(document)
</span><span class="cx"> {
</span><span class="lines">@@ -126,11 +108,6 @@
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;RenderStyle&gt; TreeResolver::styleForElement(Element&amp; element, const RenderStyle&amp; inheritedStyle)
</span><span class="cx"> {
</span><del>-    if (m_didSeePendingStylesheet &amp;&amp; !element.renderer() &amp;&amp; !m_document.isIgnoringPendingStylesheets()) {
-        m_document.setHasNodesWithPlaceholderStyle();
-        return makePlaceholderStyle(m_document);
-    }
-
</del><span class="cx">     if (element.hasCustomStyleResolveCallbacks()) {
</span><span class="cx">         RenderStyle* shadowHostStyle = scope().shadowRoot ? m_update-&gt;elementStyle(*scope().shadowRoot-&gt;host()) : nullptr;
</span><span class="cx">         if (auto customStyle = element.resolveCustomStyle(inheritedStyle, shadowHostStyle)) {
</span><span class="lines">@@ -191,15 +168,25 @@
</span><span class="cx"> 
</span><span class="cx"> ElementUpdate TreeResolver::resolveElement(Element&amp; element)
</span><span class="cx"> {
</span><ins>+    if (m_didSeePendingStylesheet &amp;&amp; !element.renderer() &amp;&amp; !m_document.isIgnoringPendingStylesheets()) {
+        m_document.setHasNodesWithMissingStyle();
+        return { };
+    }
+
</ins><span class="cx">     auto newStyle = styleForElement(element, parent().style);
</span><span class="cx"> 
</span><span class="cx">     if (!affectsRenderedSubtree(element, *newStyle))
</span><span class="cx">         return { };
</span><span class="cx"> 
</span><ins>+    auto* existingStyle = element.renderStyle();
+
+    if (m_didSeePendingStylesheet &amp;&amp; (!existingStyle || existingStyle-&gt;isNotFinal())) {
+        newStyle-&gt;setIsNotFinal();
+        m_document.setHasNodesWithNonFinalStyle();
+    }
+
</ins><span class="cx">     auto update = createAnimatedElementUpdate(WTFMove(newStyle), element, parent().change);
</span><span class="cx"> 
</span><del>-    auto* existingStyle = element.renderStyle();
-
</del><span class="cx">     if (&amp;element == m_document.documentElement()) {
</span><span class="cx">         m_documentElementStyle = RenderStyle::clonePtr(*update.style);
</span><span class="cx">         scope().styleResolver.setOverrideDocumentElementStyle(m_documentElementStyle.get());
</span></span></pre>
</div>
</div>

</body>
</html>