<!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>[214583] branches/safari-604.1.14-branch</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/214583">214583</a></dd>
<dt>Author</dt> <dd>jmarcell@apple.com</dd>
<dt>Date</dt> <dd>2017-03-29 16:42:20 -0700 (Wed, 29 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/214435">r214435</a>. rdar://problem/31303823</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari604114branchLayoutTestsChangeLog">branches/safari-604.1.14-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari604114branchSourceJavaScriptCoreChangeLog">branches/safari-604.1.14-branch/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchessafari604114branchSourceWebCoreChangeLog">branches/safari-604.1.14-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari604114branchSourceWebCorecssStyleResolvercpp">branches/safari-604.1.14-branch/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCoredomDocumentcpp">branches/safari-604.1.14-branch/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCoredomDocumenth">branches/safari-604.1.14-branch/Source/WebCore/dom/Document.h</a></li>
<li><a href="#branchessafari604114branchSourceWebCorehtmlHTMLFrameSetElementcpp">branches/safari-604.1.14-branch/Source/WebCore/html/HTMLFrameSetElement.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorepageFrameViewcpp">branches/safari-604.1.14-branch/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorerenderingRenderBlockcpp">branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorerenderingRenderLayercpp">branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorerenderingstyleRenderStylecpp">branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorerenderingstyleRenderStyleh">branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.h</a></li>
<li><a href="#branchessafari604114branchSourceWebCorerenderingstyleStyleRareNonInheritedDatacpp">branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorerenderingstyleStyleRareNonInheritedDatah">branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h</a></li>
<li><a href="#branchessafari604114branchSourceWebCorestyleStyleScopecpp">branches/safari-604.1.14-branch/Source/WebCore/style/StyleScope.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebCorestyleStyleTreeResolvercpp">branches/safari-604.1.14-branch/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
<li><a href="#branchessafari604114branchSourceWebKit2ChangeLog">branches/safari-604.1.14-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari604114branchToolsChangeLog">branches/safari-604.1.14-branch/Tools/ChangeLog</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari604114branchLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderingexpectedhtml">branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html</a></li>
<li><a href="#branchessafari604114branchLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderinghtml">branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari604114branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/LayoutTests/ChangeLog (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/LayoutTests/ChangeLog        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/LayoutTests/ChangeLog        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
+
+        Cherry-pick r214435. rdar://problem/31303823
+
+    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-23  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Revert r213712, caused iPad PLT regression
</span></span></pre></div>
<a id="branchessafari604114branchLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderingexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html (0 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html                                (rev 0)
+++ branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering-expected.html        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchLayoutTestshttptestsincrementalstylesheetbodyincrementalrenderinghtml"></a>
<div class="addfile"><h4>Added: branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html (0 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html                                (rev 0)
+++ branches/safari-604.1.14-branch/LayoutTests/http/tests/incremental/stylesheet-body-incremental-rendering.html        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/JavaScriptCore/ChangeLog (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/JavaScriptCore/ChangeLog        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/JavaScriptCore/ChangeLog        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -1,33 +1,37 @@
</span><span class="cx"> 2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-        Cherry-pick r214333. rdar://problem/31303823
</del><ins>+        Cherry-pick r214435. rdar://problem/31303823
</ins><span class="cx"> 
</span><span class="cx">     2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-            Cherry-pick r214511. rdar://problem/31260325
</del><ins>+            Cherry-pick r214333. rdar://problem/31303823
</ins><span class="cx"> 
</span><span class="cx">         2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-                Cherry-pick r214509. rdar://problem/30755345
</del><ins>+                Cherry-pick r214511. rdar://problem/31260325
</ins><span class="cx"> 
</span><del>-            2017-03-28  Mark Lam  &lt;mark.lam@apple.com&gt;
</del><ins>+            2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</ins><span class="cx"> 
</span><del>-                    The Mutator should not be able to steal the conn if the Collector hasn't reached the NotRunning phase yet.
-                    https://bugs.webkit.org/show_bug.cgi?id=170213
-                    &lt;rdar://problem/30755345&gt;
</del><ins>+                    Cherry-pick r214509. rdar://problem/30755345
</ins><span class="cx"> 
</span><del>-                    Reviewed by Filip Pizlo.
</del><ins>+                2017-03-28  Mark Lam  &lt;mark.lam@apple.com&gt;
</ins><span class="cx"> 
</span><del>-                    The current condition for stealing the conn isn't tight enough.  Restricting the
-                    stealing to when m_currentPhase == NotRunning ensures that the Collector is
-                    really done running.
</del><ins>+                        The Mutator should not be able to steal the conn if the Collector hasn't reached the NotRunning phase yet.
+                        https://bugs.webkit.org/show_bug.cgi?id=170213
+                        &lt;rdar://problem/30755345&gt;
</ins><span class="cx"> 
</span><del>-                    No test because this issue only manifests with a race condition that is difficult
-                    to reproduce on demand.
</del><ins>+                        Reviewed by Filip Pizlo.
</ins><span class="cx"> 
</span><del>-                    * heap/Heap.cpp:
-                    (JSC::Heap::requestCollection):
</del><ins>+                        The current condition for stealing the conn isn't tight enough.  Restricting the
+                        stealing to when m_currentPhase == NotRunning ensures that the Collector is
+                        really done running.
</ins><span class="cx"> 
</span><ins>+                        No test because this issue only manifests with a race condition that is difficult
+                        to reproduce on demand.
+
+                        * heap/Heap.cpp:
+                        (JSC::Heap::requestCollection):
+
</ins><span class="cx"> 2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r214495. rdar://problem/31242019
</span></span></pre></div>
<a id="branchessafari604114branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/ChangeLog (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/ChangeLog        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/ChangeLog        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -1,3 +1,100 @@
</span><ins>+2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
+
+        Cherry-pick r214435. rdar://problem/31303823
+
+    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-23  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Revert r213712, caused iPad PLT regression
</span></span></pre></div>
<a id="branchessafari604114branchSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/css/StyleResolver.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/css/StyleResolver.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/css/StyleResolver.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/dom/Document.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/dom/Document.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/dom/Document.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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">@@ -2714,14 +2699,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">@@ -3025,15 +3012,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="branchessafari604114branchSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/dom/Document.h (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/dom/Document.h        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/dom/Document.h        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorehtmlHTMLFrameSetElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/html/HTMLFrameSetElement.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/html/HTMLFrameSetElement.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/html/HTMLFrameSetElement.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/page/FrameView.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/page/FrameView.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/page/FrameView.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderBlock.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderBlock.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderBlock.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderLayer.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderLayer.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/rendering/RenderLayer.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorerenderingstyleRenderStyleh"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.h (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.h        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/rendering/style/RenderStyle.h        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -1653,8 +1653,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="branchessafari604114branchSourceWebCorerenderingstyleStyleRareNonInheritedDatacpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorerenderingstyleStyleRareNonInheritedDatah"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h        2017-03-29 23:42:20 UTC (rev 214583)
</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="branchessafari604114branchSourceWebCorestyleStyleScopecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/style/StyleScope.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/style/StyleScope.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/style/StyleScope.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -389,7 +389,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">@@ -440,7 +440,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="branchessafari604114branchSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebCore/style/StyleTreeResolver.cpp (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebCore/style/StyleTreeResolver.cpp        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebCore/style/StyleTreeResolver.cpp        2017-03-29 23:42:20 UTC (rev 214583)
</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>
<a id="branchessafari604114branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Source/WebKit2/ChangeLog (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Source/WebKit2/ChangeLog        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Source/WebKit2/ChangeLog        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -1,24 +1,28 @@
</span><span class="cx"> 2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-        Cherry-pick r214333. rdar://problem/31303823
</del><ins>+        Cherry-pick r214435. rdar://problem/31303823
</ins><span class="cx"> 
</span><span class="cx">     2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-            Cherry-pick r214511. rdar://problem/31260325
</del><ins>+            Cherry-pick r214333. rdar://problem/31303823
</ins><span class="cx"> 
</span><del>-        2017-03-28  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</del><ins>+        2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</ins><span class="cx"> 
</span><del>-                Stop overriding scroll view inset defaults
-                https://bugs.webkit.org/show_bug.cgi?id=170221
-                &lt;rdar://problem/31260325&gt;
</del><ins>+                Cherry-pick r214511. rdar://problem/31260325
</ins><span class="cx"> 
</span><del>-                Reviewed by Simon Fraser.
</del><ins>+            2017-03-28  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</ins><span class="cx"> 
</span><del>-                * Platform/spi/ios/UIKitSPI.h:
-                * UIProcess/API/Cocoa/WKWebView.mm:
-                (-[WKWebView _initializeWithConfiguration:]):
-                The default behavior is sufficient for us.
</del><ins>+                    Stop overriding scroll view inset defaults
+                    https://bugs.webkit.org/show_bug.cgi?id=170221
+                    &lt;rdar://problem/31260325&gt;
</ins><span class="cx"> 
</span><ins>+                    Reviewed by Simon Fraser.
+
+                    * Platform/spi/ios/UIKitSPI.h:
+                    * UIProcess/API/Cocoa/WKWebView.mm:
+                    (-[WKWebView _initializeWithConfiguration:]):
+                    The default behavior is sufficient for us.
+
</ins><span class="cx"> 2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r214509. rdar://problem/30755345
</span></span></pre></div>
<a id="branchessafari604114branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-604.1.14-branch/Tools/ChangeLog (214582 => 214583)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-604.1.14-branch/Tools/ChangeLog        2017-03-29 23:42:12 UTC (rev 214582)
+++ branches/safari-604.1.14-branch/Tools/ChangeLog        2017-03-29 23:42:20 UTC (rev 214583)
</span><span class="lines">@@ -1,28 +1,32 @@
</span><span class="cx"> 2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-        Cherry-pick r214333. rdar://problem/31303823
</del><ins>+        Cherry-pick r214435. rdar://problem/31303823
</ins><span class="cx"> 
</span><span class="cx">     2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-            Cherry-pick r214511. rdar://problem/31260325
</del><ins>+            Cherry-pick r214333. rdar://problem/31303823
</ins><span class="cx"> 
</span><span class="cx">         2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</span><span class="cx"> 
</span><del>-                Cherry-pick r214509. rdar://problem/30755345
</del><ins>+                Cherry-pick r214511. rdar://problem/31260325
</ins><span class="cx"> 
</span><del>-            2017-03-28  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</del><ins>+            2017-03-29  Jason Marcell  &lt;jmarcell@apple.com&gt;
</ins><span class="cx"> 
</span><del>-                    Safari crashes when attempting to close tab that is displaying PDF
-                    https://bugs.webkit.org/show_bug.cgi?id=170201
-                    &lt;rdar://problem/31242019&gt;
</del><ins>+                    Cherry-pick r214509. rdar://problem/30755345
</ins><span class="cx"> 
</span><del>-                    Reviewed by Wenson Hsieh.
</del><ins>+                2017-03-28  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</ins><span class="cx"> 
</span><del>-                    * TestWebKitAPI/Tests/WebKit2Cocoa/DoAfterNextPresentationUpdateAfterCrash.mm:
-                    (TEST):
-                    Add a test for doAfterNextStablePresentationUpdate just like the existing
-                    non-stable one.
</del><ins>+                        Safari crashes when attempting to close tab that is displaying PDF
+                        https://bugs.webkit.org/show_bug.cgi?id=170201
+                        &lt;rdar://problem/31242019&gt;
</ins><span class="cx"> 
</span><ins>+                        Reviewed by Wenson Hsieh.
+
+                        * TestWebKitAPI/Tests/WebKit2Cocoa/DoAfterNextPresentationUpdateAfterCrash.mm:
+                        (TEST):
+                        Add a test for doAfterNextStablePresentationUpdate just like the existing
+                        non-stable one.
+
</ins><span class="cx"> 2017-03-22  Matt Rajca  &lt;mrajca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Only run volume-related autoplay policy tests on Mac.
</span></span></pre>
</div>
</div>

</body>
</html>