<!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>[194691] trunk/Source/WebCore</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/194691">194691</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-01-07 00:16:49 -0800 (Thu, 07 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Factor free standing tree style resolve functions into a class
https://bugs.webkit.org/show_bug.cgi?id=152786

Reviewed by Simon Fraser.

Factor the free standing tree style resolve functions into a class that can keep state.
Style::TreeResolver instances resolve a single tree scope. It is instantiated for resolving
the document style and then recursively for each encountered shadow tree.

This will enable new features and optimizations later.

* dom/Document.cpp:
(WebCore::Document::recalcStyle):

    Move the root style computation code back to Document. It fits better here and avoid some
    awkwardness with style resolver construction order.

* style/StyleResolveTree.cpp:
(WebCore::Style::TreeResolver::TreeResolver):

    TreeResolver knows the current tree context and the StyleResolver to use for it.
    Switch the functions to use these instead of recomputing them repeatedly.

(WebCore::Style::shouldCreateRenderer):
(WebCore::Style::TreeResolver::styleForElement):
(WebCore::Style::moveToFlowThreadIfNeeded):
(WebCore::Style::TreeResolver::createRenderer):
(WebCore::Style::updateTextRendererAfterContentChange):
(WebCore::Style::TreeResolver::createRenderTreeForChildren):
(WebCore::Style::TreeResolver::createRenderTreeForShadowRoot):
(WebCore::Style::needsPseudoElement):
(WebCore::Style::TreeResolver::createRenderTreeForBeforeOrAfterPseudoElement):
(WebCore::Style::TreeResolver::createRenderTreeForSlotAssignees):
(WebCore::Style::TreeResolver::createRenderTreeRecursively):

    Rename to reduce the use of confusing &quot;attach&quot; terminology.

(WebCore::Style::pseudoStyleCacheIsInvalid):
(WebCore::Style::TreeResolver::resolveLocally):
(WebCore::Style::resolveTextNode):
(WebCore::Style::TreeResolver::resolveChildAtShadowBoundary):
(WebCore::Style::TreeResolver::resolveShadowTree):
(WebCore::Style::TreeResolver::resolveBeforeOrAfterPseudoElement):
(WebCore::Style::TreeResolver::resolveChildren):
(WebCore::Style::TreeResolver::resolveSlotAssignees):
(WebCore::Style::TreeResolver::resolveRecursively):
(WebCore::Style::TreeResolver::resolve):
(WebCore::Style::detachRenderTree):
(WebCore::Style::styleForElement): Deleted.
(WebCore::Style::createRendererIfNeeded): Deleted.
(WebCore::Style::attachChildren): Deleted.
(WebCore::Style::attachShadowRoot): Deleted.
(WebCore::Style::attachBeforeOrAfterPseudoElementIfNeeded): Deleted.
(WebCore::Style::attachSlotAssignees): Deleted.
(WebCore::Style::attachRenderTree): Deleted.
(WebCore::Style::resolveLocal): Deleted.
(WebCore::Style::resolveChildAtShadowBoundary): Deleted.
(WebCore::Style::resolveShadowTree): Deleted.
(WebCore::Style::updateBeforeOrAfterPseudoElement): Deleted.
(WebCore::Style::resolveChildren): Deleted.
(WebCore::Style::resolveSlotAssignees): Deleted.
(WebCore::Style::resolveTree): Deleted.
* style/StyleResolveTree.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomCharacterDatacpp">trunk/Source/WebCore/dom/CharacterData.cpp</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodecpp">trunk/Source/WebCore/dom/ContainerNode.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlElementcpp">trunk/Source/WebCore/html/HTMLFormControlElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFrameOwnerElementcpp">trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLPlugInImageElementcpp">trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLSelectElementcpp">trunk/Source/WebCore/mathml/MathMLSelectElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolverh">trunk/Source/WebCore/style/StyleTreeResolver.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorestyleStyleResolveTreecpp">trunk/Source/WebCore/style/StyleResolveTree.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleResolveTreeh">trunk/Source/WebCore/style/StyleResolveTree.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -2605,7 +2605,7 @@
</span><span class="cx">     style/StyleChange.cpp
</span><span class="cx">     style/StyleFontSizeFunctions.cpp
</span><span class="cx">     style/StyleResolveForDocument.cpp
</span><del>-    style/StyleResolveTree.cpp
</del><ins>+    style/StyleTreeResolver.cpp
</ins><span class="cx"> 
</span><span class="cx">     svg/SVGAElement.cpp
</span><span class="cx">     svg/SVGAltGlyphDefElement.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/ChangeLog        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -1,3 +1,69 @@
</span><ins>+2016-01-06  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Factor free standing tree style resolve functions into a class
+        https://bugs.webkit.org/show_bug.cgi?id=152786
+
+        Reviewed by Simon Fraser.
+
+        Factor the free standing tree style resolve functions into a class that can keep state.
+        Style::TreeResolver instances resolve a single tree scope. It is instantiated for resolving
+        the document style and then recursively for each encountered shadow tree.
+
+        This will enable new features and optimizations later.
+
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyle):
+
+            Move the root style computation code back to Document. It fits better here and avoid some
+            awkwardness with style resolver construction order.
+
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::TreeResolver::TreeResolver):
+
+            TreeResolver knows the current tree context and the StyleResolver to use for it.
+            Switch the functions to use these instead of recomputing them repeatedly.
+
+        (WebCore::Style::shouldCreateRenderer):
+        (WebCore::Style::TreeResolver::styleForElement):
+        (WebCore::Style::moveToFlowThreadIfNeeded):
+        (WebCore::Style::TreeResolver::createRenderer):
+        (WebCore::Style::updateTextRendererAfterContentChange):
+        (WebCore::Style::TreeResolver::createRenderTreeForChildren):
+        (WebCore::Style::TreeResolver::createRenderTreeForShadowRoot):
+        (WebCore::Style::needsPseudoElement):
+        (WebCore::Style::TreeResolver::createRenderTreeForBeforeOrAfterPseudoElement):
+        (WebCore::Style::TreeResolver::createRenderTreeForSlotAssignees):
+        (WebCore::Style::TreeResolver::createRenderTreeRecursively):
+
+            Rename to reduce the use of confusing &quot;attach&quot; terminology.
+
+        (WebCore::Style::pseudoStyleCacheIsInvalid):
+        (WebCore::Style::TreeResolver::resolveLocally):
+        (WebCore::Style::resolveTextNode):
+        (WebCore::Style::TreeResolver::resolveChildAtShadowBoundary):
+        (WebCore::Style::TreeResolver::resolveShadowTree):
+        (WebCore::Style::TreeResolver::resolveBeforeOrAfterPseudoElement):
+        (WebCore::Style::TreeResolver::resolveChildren):
+        (WebCore::Style::TreeResolver::resolveSlotAssignees):
+        (WebCore::Style::TreeResolver::resolveRecursively):
+        (WebCore::Style::TreeResolver::resolve):
+        (WebCore::Style::detachRenderTree):
+        (WebCore::Style::styleForElement): Deleted.
+        (WebCore::Style::createRendererIfNeeded): Deleted.
+        (WebCore::Style::attachChildren): Deleted.
+        (WebCore::Style::attachShadowRoot): Deleted.
+        (WebCore::Style::attachBeforeOrAfterPseudoElementIfNeeded): Deleted.
+        (WebCore::Style::attachSlotAssignees): Deleted.
+        (WebCore::Style::attachRenderTree): Deleted.
+        (WebCore::Style::resolveLocal): Deleted.
+        (WebCore::Style::resolveChildAtShadowBoundary): Deleted.
+        (WebCore::Style::resolveShadowTree): Deleted.
+        (WebCore::Style::updateBeforeOrAfterPseudoElement): Deleted.
+        (WebCore::Style::resolveChildren): Deleted.
+        (WebCore::Style::resolveSlotAssignees): Deleted.
+        (WebCore::Style::resolveTree): Deleted.
+        * style/StyleResolveTree.h:
+
</ins><span class="cx"> 2016-01-07  Doug Russell  &lt;d_russell@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         AX: AXObjectCacheMac is passing WebCore enum values directly to VoiceOver
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -19202,7 +19202,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\style\StyleChange.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\style\StyleFontSizeFunctions.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\style\StyleResolveForDocument.cpp&quot; /&gt;
</span><del>-    &lt;ClCompile Include=&quot;..\style\StyleResolveTree.cpp&quot; /&gt;
</del><ins>+    &lt;ClCompile Include=&quot;..\style\StyleTreeResolver.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\jsc\BridgeJSC.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\c\c_class.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\c\c_instance.cpp&quot; /&gt;
</span><span class="lines">@@ -22766,7 +22766,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\style\StyleChange.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\style\StyleFontSizeFunctions.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\style\StyleResolveForDocument.h&quot; /&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\style\StyleResolveTree.h&quot; /&gt;
</del><ins>+    &lt;ClInclude Include=&quot;..\style\StyleTreeResolver.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\bridge\Bridge.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\bridge\jsc\BridgeJSC.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\bridge\c\c_class.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -6579,8 +6579,8 @@
</span><span class="cx">                 E4D58EBB17B8F12800CBDCA8 /* ElementTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4D988B417BFD1F60084FB88 /* TextNodeTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D988B317BFD1F60084FB88 /* TextNodeTraversal.h */; };
</span><span class="cx">                 E4D988B617BFEB210084FB88 /* TextNodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */; };
</span><del>-                E4DEAA1717A93DC3000E0430 /* StyleResolveTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */; };
-                E4DEAA1817A93DC3000E0430 /* StyleResolveTree.h in Headers */ = {isa = PBXBuildFile; fileRef = E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><ins>+                E4DEAA1717A93DC3000E0430 /* StyleTreeResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4DEAA1517A93DC3000E0430 /* StyleTreeResolver.cpp */; };
+                E4DEAA1817A93DC3000E0430 /* StyleTreeResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E4DEAA1617A93DC3000E0430 /* StyleTreeResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 E4E39AFB1330EFA8003AB274 /* LegacyTileLayerPool.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */; };
</span><span class="cx">                 E4E39AFD1330EFC6003AB274 /* LegacyTileLayerPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */; };
</span><span class="cx">                 E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */; };
</span><span class="lines">@@ -14496,8 +14496,8 @@
</span><span class="cx">                 E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementTraversal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4D988B317BFD1F60084FB88 /* TextNodeTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextNodeTraversal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextNodeTraversal.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleResolveTree.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolveTree.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                E4DEAA1517A93DC3000E0430 /* StyleTreeResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleTreeResolver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E4DEAA1617A93DC3000E0430 /* StyleTreeResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleTreeResolver.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyTileLayerPool.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyTileLayerPool.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutResolver.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -23120,8 +23120,8 @@
</span><span class="cx">                                 E4D58EB717B4ED8900CBDCA8 /* StyleFontSizeFunctions.h */,
</span><span class="cx">                                 E4D58EB217B4DBDC00CBDCA8 /* StyleResolveForDocument.cpp */,
</span><span class="cx">                                 E4D58EB317B4DBDC00CBDCA8 /* StyleResolveForDocument.h */,
</span><del>-                                E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */,
-                                E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */,
</del><ins>+                                E4DEAA1517A93DC3000E0430 /* StyleTreeResolver.cpp */,
+                                E4DEAA1617A93DC3000E0430 /* StyleTreeResolver.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = style;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -27508,7 +27508,7 @@
</span><span class="cx">                                 BC2272870E82E70700E7F975 /* StyleReflection.h in Headers */,
</span><span class="cx">                                 E4D58EB517B4DBDC00CBDCA8 /* StyleResolveForDocument.h in Headers */,
</span><span class="cx">                                 E139866415478474001E3F65 /* StyleResolver.h in Headers */,
</span><del>-                                E4DEAA1817A93DC3000E0430 /* StyleResolveTree.h in Headers */,
</del><ins>+                                E4DEAA1817A93DC3000E0430 /* StyleTreeResolver.h in Headers */,
</ins><span class="cx">                                 E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */,
</span><span class="cx">                                 E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */,
</span><span class="cx">                                 F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */,
</span><span class="lines">@@ -31039,7 +31039,7 @@
</span><span class="cx">                                 BC2272BC0E82EAAE00E7F975 /* StyleRareNonInheritedData.cpp in Sources */,
</span><span class="cx">                                 E4D58EB417B4DBDC00CBDCA8 /* StyleResolveForDocument.cpp in Sources */,
</span><span class="cx">                                 E139866315478474001E3F65 /* StyleResolver.cpp in Sources */,
</span><del>-                                E4DEAA1717A93DC3000E0430 /* StyleResolveTree.cpp in Sources */,
</del><ins>+                                E4DEAA1717A93DC3000E0430 /* StyleTreeResolver.cpp in Sources */,
</ins><span class="cx">                                 E4BBED4C14FCDBA1003F0B98 /* StyleRule.cpp in Sources */,
</span><span class="cx">                                 E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */,
</span><span class="cx">                                 F47A5E3F195B8E4800483100 /* StyleScrollSnapPoints.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomCharacterDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CharacterData.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CharacterData.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/dom/CharacterData.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> #include &quot;ProcessingInstruction.h&quot;
</span><span class="cx"> #include &quot;RenderText.h&quot;
</span><span class="cx"> #include &quot;StyleInheritedData.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &quot;TextBreakIterator.h&quot;
</span><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx"> #include &quot;SVGElement.h&quot;
</span><span class="cx"> #include &quot;SVGNames.h&quot;
</span><span class="cx"> #include &quot;SelectorQuery.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &quot;TemplateContentDocumentFragment.h&quot;
</span><span class="cx"> #include &lt;algorithm&gt;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -154,10 +154,11 @@
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;StorageEvent.h&quot;
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><ins>+#include &quot;StyleResolveForDocument.h&quot;
</ins><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> #include &quot;StyleSheetList.h&quot;
</span><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &quot;SubresourceLoader.h&quot;
</span><span class="cx"> #include &quot;TextEvent.h&quot;
</span><span class="cx"> #include &quot;TextNodeTraversal.h&quot;
</span><span class="lines">@@ -1851,9 +1852,23 @@
</span><span class="cx">         if (change == Style::Force) {
</span><span class="cx">             // This may get set again during style resolve.
</span><span class="cx">             m_hasNodesWithPlaceholderStyle = false;
</span><ins>+
+            auto documentStyle = Style::resolveForDocument(*this);
+
+            // Inserting the pictograph font at the end of the font fallback list is done by the
+            // font selector, so set a font selector if needed.
+            if (Settings* settings = this-&gt;settings()) {
+                if (settings-&gt;fontFallbackPrefersPictographs())
+                    documentStyle.get().fontCascade().update(&amp;fontSelector());
+            }
+
+            auto documentChange = Style::determineChange(documentStyle.get(), m_renderView-&gt;style());
+            if (documentChange != Style::NoChange)
+                renderView()-&gt;setStyle(WTFMove(documentStyle));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        Style::resolveTree(*this, change);
</del><ins>+        Style::TreeResolver resolver(*this);
+        resolver.resolve(change);
</ins><span class="cx"> 
</span><span class="cx">         updatedCompositingLayers = frameView.updateCompositingLayersAfterStyleChange();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/dom/Element.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -77,8 +77,8 @@
</span><span class="cx"> #include &quot;SelectorQuery.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;VoidCallback.h&quot;
</span><span class="cx"> #include &quot;WheelEvent.h&quot;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> #include &quot;HTMLTextAreaElement.h&quot;
</span><span class="cx"> #include &quot;RenderBox.h&quot;
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &quot;ValidationMessage.h&quot;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFrameOwnerElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> #include &quot;RenderWidget.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;SVGDocument.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLPlugInImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -48,8 +48,8 @@
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> #include &quot;SubframeLoader.h&quot;
</span><span class="cx"> #include &quot;TypedElementDescendantIterator.h&quot;
</span><span class="cx"> #include &lt;JavaScriptCore/APICast.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLSelectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLSelectElement.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #include &quot;RenderMathMLRow.h&quot;
</span><span class="cx"> #include &quot;SVGElement.h&quot;
</span><span class="cx"> #include &quot;SVGNames.h&quot;
</span><del>-#include &quot;StyleResolveTree.h&quot;
</del><ins>+#include &quot;StyleTreeResolver.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleResolveTreecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/style/StyleResolveTree.cpp (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleResolveTree.cpp        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -1,920 +0,0 @@
</span><del>-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- *           (C) 2001 Peter Kelly (pmk@post.com)
- *           (C) 2001 Dirk Mueller (mueller@kde.org)
- *           (C) 2007 David Smith (catfish.man@gmail.com)
- * Copyright (C) 2004-2010, 2012-2014 Apple Inc. All rights reserved.
- *           (C) 2007 Eric Seidel (eric@webkit.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include &quot;config.h&quot;
-#include &quot;StyleResolveTree.h&quot;
-
-#include &quot;AXObjectCache.h&quot;
-#include &quot;AnimationController.h&quot;
-#include &quot;AuthorStyleSheets.h&quot;
-#include &quot;CSSFontSelector.h&quot;
-#include &quot;ComposedTreeAncestorIterator.h&quot;
-#include &quot;ComposedTreeIterator.h&quot;
-#include &quot;ElementIterator.h&quot;
-#include &quot;ElementRareData.h&quot;
-#include &quot;FlowThreadController.h&quot;
-#include &quot;HTMLSlotElement.h&quot;
-#include &quot;InspectorInstrumentation.h&quot;
-#include &quot;LoaderStrategy.h&quot;
-#include &quot;MainFrame.h&quot;
-#include &quot;NodeRenderStyle.h&quot;
-#include &quot;NodeTraversal.h&quot;
-#include &quot;PlatformStrategies.h&quot;
-#include &quot;RenderFullScreen.h&quot;
-#include &quot;RenderNamedFlowThread.h&quot;
-#include &quot;RenderText.h&quot;
-#include &quot;RenderTreePosition.h&quot;
-#include &quot;RenderWidget.h&quot;
-#include &quot;Settings.h&quot;
-#include &quot;ShadowRoot.h&quot;
-#include &quot;StyleResolveForDocument.h&quot;
-#include &quot;StyleResolver.h&quot;
-#include &quot;Text.h&quot;
-
-#if PLATFORM(IOS)
-#include &quot;CSSFontSelector.h&quot;
-#include &quot;WKContentObservation.h&quot;
-#endif
-
-namespace WebCore {
-
-namespace Style {
-
-enum DetachType { NormalDetach, ReattachDetach };
-
-static void attachRenderTree(Element&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, PassRefPtr&lt;RenderStyle&gt;);
-static void attachTextRenderer(Text&amp;, RenderTreePosition&amp;);
-static void detachRenderTree(Element&amp;, DetachType);
-static void resolveTextNode(Text&amp;, RenderTreePosition&amp;);
-static void resolveTree(Element&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, Change);
-
-static bool shouldCreateRenderer(const Element&amp; element, const RenderElement&amp; parentRenderer)
-{
-    if (!element.document().shouldCreateRenderers())
-        return false;
-    if (!parentRenderer.canHaveChildren() &amp;&amp; !(element.isPseudoElement() &amp;&amp; parentRenderer.canHaveGeneratedChildren()))
-        return false;
-    if (parentRenderer.element() &amp;&amp; !parentRenderer.element()-&gt;childShouldCreateRenderer(element))
-        return false;
-    return true;
-}
-
-static Ref&lt;RenderStyle&gt; styleForElement(Element&amp; element, RenderStyle&amp; inheritedStyle)
-{
-    if (element.hasCustomStyleResolveCallbacks()) {
-        if (RefPtr&lt;RenderStyle&gt; style = element.customStyleForRenderer(inheritedStyle))
-            return style.releaseNonNull();
-    }
-    return element.resolveStyle(&amp;inheritedStyle);
-}
-
-#if ENABLE(CSS_REGIONS)
-static RenderNamedFlowThread* moveToFlowThreadIfNeeded(Element&amp; element, const RenderStyle&amp; style)
-{
-    if (!element.shouldMoveToFlowThread(style))
-        return 0;
-
-    FlowThreadController&amp; flowThreadController = element.document().renderView()-&gt;flowThreadController();
-    RenderNamedFlowThread&amp; parentFlowRenderer = flowThreadController.ensureRenderFlowThreadWithName(style.flowThread());
-    flowThreadController.registerNamedFlowContentElement(element, parentFlowRenderer);
-    return &amp;parentFlowRenderer;
-}
-#endif
-
-static void createRendererIfNeeded(Element&amp; element, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, PassRefPtr&lt;RenderStyle&gt; resolvedStyle)
-{
-    ASSERT(!element.renderer());
-
-    RefPtr&lt;RenderStyle&gt; style = resolvedStyle;
-
-    if (!shouldCreateRenderer(element, renderTreePosition.parent()))
-        return;
-
-    if (!style)
-        style = styleForElement(element, inheritedStyle);
-
-    RenderNamedFlowThread* parentFlowRenderer = 0;
-#if ENABLE(CSS_REGIONS)
-    parentFlowRenderer = moveToFlowThreadIfNeeded(element, *style);
-#endif
-
-    if (!element.rendererIsNeeded(*style))
-        return;
-
-    renderTreePosition.computeNextSibling(element);
-
-    RenderTreePosition insertionPosition = parentFlowRenderer
-        ? RenderTreePosition(*parentFlowRenderer, parentFlowRenderer-&gt;nextRendererForElement(element))
-        : renderTreePosition;
-
-    RenderElement* newRenderer = element.createElementRenderer(style.releaseNonNull(), insertionPosition).leakPtr();
-    if (!newRenderer)
-        return;
-    if (!insertionPosition.canInsert(*newRenderer)) {
-        newRenderer-&gt;destroy();
-        return;
-    }
-
-    // Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
-    // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
-    newRenderer-&gt;setFlowThreadState(insertionPosition.parent().flowThreadState());
-
-    // Code below updateAnimations() can depend on Element::renderer() already being set.
-    element.setRenderer(newRenderer);
-
-    // FIXME: There's probably a better way to factor this.
-    // This just does what setAnimatedStyle() does, except with setStyleInternal() instead of setStyle().
-    Ref&lt;RenderStyle&gt; animatedStyle = newRenderer-&gt;style();
-    newRenderer-&gt;animation().updateAnimations(*newRenderer, animatedStyle, animatedStyle);
-    newRenderer-&gt;setStyleInternal(WTFMove(animatedStyle));
-
-    newRenderer-&gt;initializeStyle();
-
-#if ENABLE(FULLSCREEN_API)
-    Document&amp; document = element.document();
-    if (document.webkitIsFullScreen() &amp;&amp; document.webkitCurrentFullScreenElement() == &amp;element) {
-        newRenderer = RenderFullScreen::wrapRenderer(newRenderer, &amp;insertionPosition.parent(), document);
-        if (!newRenderer)
-            return;
-    }
-#endif
-    // Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
-    insertionPosition.insert(*newRenderer);
-}
-
-static void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node&amp; current)
-{
-    // FIXME: This needs to traverse in composed tree order.
-
-    // This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of
-    // the current node gaining or losing the renderer. This can only affect white space text nodes.
-    for (Node* sibling = current.nextSibling(); sibling; sibling = sibling-&gt;nextSibling()) {
-        if (sibling-&gt;needsStyleRecalc())
-            return;
-        if (is&lt;Element&gt;(*sibling)) {
-            // Text renderers beyond rendered elements can't be affected.
-            if (!sibling-&gt;renderer() || RenderTreePosition::isRendererReparented(*sibling-&gt;renderer()))
-                continue;
-            return;
-        }
-        if (!is&lt;Text&gt;(*sibling))
-            continue;
-        Text&amp; textSibling = downcast&lt;Text&gt;(*sibling);
-        if (!textSibling.containsOnlyWhitespace())
-            continue;
-        textSibling.setNeedsStyleRecalc();
-    }
-}
-
-static bool textRendererIsNeeded(const Text&amp; textNode, const RenderTreePosition&amp; renderTreePosition)
-{
-    const RenderElement&amp; parentRenderer = renderTreePosition.parent();
-    if (!parentRenderer.canHaveChildren())
-        return false;
-    if (parentRenderer.element() &amp;&amp; !parentRenderer.element()-&gt;childShouldCreateRenderer(textNode))
-        return false;
-    if (textNode.isEditingText())
-        return true;
-    if (!textNode.length())
-        return false;
-    if (!textNode.containsOnlyWhitespace())
-        return true;
-    // This text node has nothing but white space. We may still need a renderer in some cases.
-    if (parentRenderer.isTable() || parentRenderer.isTableRow() || parentRenderer.isTableSection() || parentRenderer.isRenderTableCol() || parentRenderer.isFrameSet())
-        return false;
-    if (parentRenderer.style().preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
-        return true;
-
-    RenderObject* previousRenderer = renderTreePosition.previousSiblingRenderer(textNode);
-    if (previousRenderer &amp;&amp; previousRenderer-&gt;isBR()) // &lt;span&gt;&lt;br/&gt; &lt;br/&gt;&lt;/span&gt;
-        return false;
-        
-    if (parentRenderer.isRenderInline()) {
-        // &lt;span&gt;&lt;div/&gt; &lt;div/&gt;&lt;/span&gt;
-        if (previousRenderer &amp;&amp; !previousRenderer-&gt;isInline())
-            return false;
-    } else {
-        if (parentRenderer.isRenderBlock() &amp;&amp; !parentRenderer.childrenInline() &amp;&amp; (!previousRenderer || !previousRenderer-&gt;isInline()))
-            return false;
-        
-        RenderObject* first = parentRenderer.firstChild();
-        while (first &amp;&amp; first-&gt;isFloatingOrOutOfFlowPositioned())
-            first = first-&gt;nextSibling();
-        RenderObject* nextRenderer = renderTreePosition.nextSiblingRenderer(textNode);
-        if (!first || nextRenderer == first) {
-            // Whitespace at the start of a block just goes away. Don't even make a render object for this text.
-            return false;
-        }
-    }
-    return true;
-}
-
-static void createTextRendererIfNeeded(Text&amp; textNode, RenderTreePosition&amp; renderTreePosition)
-{
-    ASSERT(!textNode.renderer());
-
-    if (!textRendererIsNeeded(textNode, renderTreePosition))
-        return;
-
-    auto newRenderer = textNode.createTextRenderer(renderTreePosition.parent().style());
-    ASSERT(newRenderer);
-
-    renderTreePosition.computeNextSibling(textNode);
-
-    if (!renderTreePosition.canInsert(*newRenderer))
-        return;
-
-    // Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
-    // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
-    newRenderer-&gt;setFlowThreadState(renderTreePosition.parent().flowThreadState());
-
-    textNode.setRenderer(newRenderer.get());
-    // Parent takes care of the animations, no need to call setAnimatableStyle.
-    renderTreePosition.insert(*newRenderer.leakPtr());
-}
-
-void attachTextRenderer(Text&amp; textNode, RenderTreePosition&amp; renderTreePosition)
-{
-    createTextRendererIfNeeded(textNode, renderTreePosition);
-
-    textNode.clearNeedsStyleRecalc();
-}
-
-void detachTextRenderer(Text&amp; textNode)
-{
-    if (textNode.renderer())
-        textNode.renderer()-&gt;destroyAndCleanupAnonymousWrappers();
-    textNode.setRenderer(0);
-}
-
-void updateTextRendererAfterContentChange(Text&amp; textNode, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData)
-{
-    auto* renderingParentNode = composedTreeAncestors(textNode).first();
-    if (!renderingParentNode || !renderingParentNode-&gt;renderer())
-        return;
-
-    bool hadRenderer = textNode.renderer();
-
-    RenderTreePosition renderTreePosition(*renderingParentNode-&gt;renderer());
-    resolveTextNode(textNode, renderTreePosition);
-
-    if (hadRenderer &amp;&amp; textNode.renderer())
-        textNode.renderer()-&gt;setTextWithOffset(textNode.data(), offsetOfReplacedData, lengthOfReplacedData);
-}
-
-static void attachChildren(ContainerNode&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition)
-{
-    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
-        ASSERT((!child-&gt;renderer() || child-&gt;isNamedFlowContentNode()) || current.shadowRoot());
-        if (child-&gt;renderer()) {
-            renderTreePosition.invalidateNextSibling(*child-&gt;renderer());
-            continue;
-        }
-        if (is&lt;Text&gt;(*child)) {
-            attachTextRenderer(downcast&lt;Text&gt;(*child), renderTreePosition);
-            continue;
-        }
-        if (is&lt;Element&gt;(*child))
-            attachRenderTree(downcast&lt;Element&gt;(*child), inheritedStyle, renderTreePosition, nullptr);
-    }
-}
-
-static void attachShadowRoot(ShadowRoot&amp; shadowRoot)
-{
-    ASSERT(shadowRoot.host());
-    ASSERT(shadowRoot.host()-&gt;renderer());
-
-    auto&amp; renderer = *shadowRoot.host()-&gt;renderer();
-    RenderTreePosition renderTreePosition(renderer);
-    attachChildren(shadowRoot, renderer.style(), renderTreePosition);
-
-    shadowRoot.clearNeedsStyleRecalc();
-    shadowRoot.clearChildNeedsStyleRecalc();
-}
-
-static PseudoElement* beforeOrAfterPseudoElement(Element&amp; current, PseudoId pseudoId)
-{
-    ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
-    if (pseudoId == BEFORE)
-        return current.beforePseudoElement();
-    return current.afterPseudoElement();
-}
-
-static void setBeforeOrAfterPseudoElement(Element&amp; current, Ref&lt;PseudoElement&gt;&amp;&amp; pseudoElement, PseudoId pseudoId)
-{
-    ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
-    if (pseudoId == BEFORE) {
-        current.setBeforePseudoElement(WTFMove(pseudoElement));
-        return;
-    }
-    current.setAfterPseudoElement(WTFMove(pseudoElement));
-}
-
-static void clearBeforeOrAfterPseudoElement(Element&amp; current, PseudoId pseudoId)
-{
-    ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
-    if (pseudoId == BEFORE) {
-        current.clearBeforePseudoElement();
-        return;
-    }
-    current.clearAfterPseudoElement();
-}
-
-static void resetStyleForNonRenderedDescendants(Element&amp; current)
-{
-    ASSERT(!current.renderer());
-    bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
-    for (auto&amp; child : childrenOfType&lt;Element&gt;(current)) {
-        ASSERT(!child.renderer());
-        if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
-            if (child.styleIsAffectedByPreviousSibling())
-                child.setNeedsStyleRecalc();
-            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = child.affectsNextSiblingElementStyle();
-        }
-
-        if (child.needsStyleRecalc()) {
-            child.resetComputedStyle();
-            child.clearNeedsStyleRecalc();
-            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = child.affectsNextSiblingElementStyle();
-        }
-
-        if (child.childNeedsStyleRecalc()) {
-            resetStyleForNonRenderedDescendants(child);
-            child.clearChildNeedsStyleRecalc();
-        }
-    }
-}
-
-static bool needsPseudoElement(Element&amp; current, PseudoId pseudoId)
-{
-    if (!current.renderer() || !current.renderer()-&gt;canHaveGeneratedChildren())
-        return false;
-    if (current.isPseudoElement())
-        return false;
-    if (!pseudoElementRendererIsNeeded(current.renderer()-&gt;getCachedPseudoStyle(pseudoId)))
-        return false;
-    return true;
-}
-
-static void attachBeforeOrAfterPseudoElementIfNeeded(Element&amp; current, PseudoId pseudoId, RenderTreePosition&amp; renderTreePosition)
-{
-    if (!needsPseudoElement(current, pseudoId))
-        return;
-    Ref&lt;PseudoElement&gt; pseudoElement = PseudoElement::create(current, pseudoId);
-    InspectorInstrumentation::pseudoElementCreated(pseudoElement-&gt;document().page(), pseudoElement.get());
-    setBeforeOrAfterPseudoElement(current, pseudoElement.copyRef(), pseudoId);
-    attachRenderTree(pseudoElement.get(), *current.renderStyle(), renderTreePosition, nullptr);
-}
-
-#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-static void attachSlotAssignees(HTMLSlotElement&amp; slot, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition)
-{
-    if (auto* assignedNodes = slot.assignedNodes()) {
-        for (auto* child : *assignedNodes) {
-            if (is&lt;Text&gt;(*child))
-                attachTextRenderer(downcast&lt;Text&gt;(*child), renderTreePosition);
-            else if (is&lt;Element&gt;(*child))
-                attachRenderTree(downcast&lt;Element&gt;(*child), inheritedStyle, renderTreePosition, nullptr);
-        }
-    } else
-        attachChildren(slot, inheritedStyle, renderTreePosition);
-
-    slot.clearNeedsStyleRecalc();
-    slot.clearChildNeedsStyleRecalc();
-}
-#endif
-
-static void attachRenderTree(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, PassRefPtr&lt;RenderStyle&gt; resolvedStyle)
-{
-    PostResolutionCallbackDisabler callbackDisabler(current.document());
-    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
-
-#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-    if (is&lt;HTMLSlotElement&gt;(current)) {
-        attachSlotAssignees(downcast&lt;HTMLSlotElement&gt;(current), inheritedStyle, renderTreePosition);
-        return;
-    }
-#endif
-
-    if (current.hasCustomStyleResolveCallbacks())
-        current.willAttachRenderers();
-
-    createRendererIfNeeded(current, inheritedStyle, renderTreePosition, resolvedStyle);
-
-    if (auto* renderer = current.renderer()) {
-        StyleResolverParentPusher parentPusher(&amp;current);
-
-        RenderTreePosition childRenderTreePosition(*renderer);
-        attachBeforeOrAfterPseudoElementIfNeeded(current, BEFORE, childRenderTreePosition);
-
-        auto* shadowRoot = current.shadowRoot();
-        if (shadowRoot) {
-            parentPusher.push();
-            attachShadowRoot(*shadowRoot);
-        } else if (current.firstChild())
-            parentPusher.push();
-
-        bool skipChildren = shadowRoot;
-        if (!skipChildren)
-            attachChildren(current, renderer-&gt;style(), childRenderTreePosition);
-
-        if (AXObjectCache* cache = current.document().axObjectCache())
-            cache-&gt;updateCacheAfterNodeIsAttached(&amp;current);
-
-        attachBeforeOrAfterPseudoElementIfNeeded(current, AFTER, childRenderTreePosition);
-
-        current.updateFocusAppearanceAfterAttachIfNeeded();
-    } else
-        resetStyleForNonRenderedDescendants(current);
-
-    current.clearNeedsStyleRecalc();
-    current.clearChildNeedsStyleRecalc();
-
-    if (current.hasCustomStyleResolveCallbacks())
-        current.didAttachRenderers();
-}
-
-static void detachChildren(ContainerNode&amp; current, DetachType detachType)
-{
-    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
-        if (is&lt;Text&gt;(*child))
-            detachTextRenderer(downcast&lt;Text&gt;(*child));
-        else if (is&lt;Element&gt;(*child))
-            detachRenderTree(downcast&lt;Element&gt;(*child), detachType);
-    }
-    current.clearChildNeedsStyleRecalc();
-}
-
-static void detachShadowRoot(ShadowRoot&amp; shadowRoot, DetachType detachType)
-{
-    detachChildren(shadowRoot, detachType);
-}
-
-#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-static void detachSlotAssignees(HTMLSlotElement&amp; slot, DetachType detachType)
-{
-    ASSERT(!slot.renderer());
-    if (auto* assignedNodes = slot.assignedNodes()) {
-        for (auto* child : *assignedNodes) {
-            if (is&lt;Text&gt;(*child))
-                detachTextRenderer(downcast&lt;Text&gt;(*child));
-            else if (is&lt;Element&gt;(*child))
-                detachRenderTree(downcast&lt;Element&gt;(*child), detachType);
-        }
-    } else
-        detachChildren(slot, detachType);
-
-    slot.clearNeedsStyleRecalc();
-    slot.clearChildNeedsStyleRecalc();
-}
-#endif
-
-static void detachRenderTree(Element&amp; current, DetachType detachType)
-{
-    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
-
-    if (current.hasCustomStyleResolveCallbacks())
-        current.willDetachRenderers();
-
-    current.clearStyleDerivedDataBeforeDetachingRenderer();
-
-    // Do not remove the element's hovered and active status
-    // if performing a reattach.
-    if (detachType != ReattachDetach)
-        current.clearHoverAndActiveStatusBeforeDetachingRenderer();
-
-#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-    if (is&lt;HTMLSlotElement&gt;(current))
-        detachSlotAssignees(downcast&lt;HTMLSlotElement&gt;(current), detachType);
-#endif
-    else if (ShadowRoot* shadowRoot = current.shadowRoot())
-        detachShadowRoot(*shadowRoot, detachType);
-
-    detachChildren(current, detachType);
-
-    if (current.renderer())
-        current.renderer()-&gt;destroyAndCleanupAnonymousWrappers();
-    current.setRenderer(0);
-
-    if (current.hasCustomStyleResolveCallbacks())
-        current.didDetachRenderers();
-}
-
-static bool pseudoStyleCacheIsInvalid(RenderElement* renderer, RenderStyle* newStyle)
-{
-    const RenderStyle&amp; currentStyle = renderer-&gt;style();
-
-    const PseudoStyleCache* pseudoStyleCache = currentStyle.cachedPseudoStyles();
-    if (!pseudoStyleCache)
-        return false;
-
-    for (auto&amp; cache : *pseudoStyleCache) {
-        RefPtr&lt;RenderStyle&gt; newPseudoStyle;
-        PseudoId pseudoId = cache-&gt;styleType();
-        if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED)
-            newPseudoStyle = renderer-&gt;uncachedFirstLineStyle(newStyle);
-        else
-            newPseudoStyle = renderer-&gt;getUncachedPseudoStyle(PseudoStyleRequest(pseudoId), newStyle, newStyle);
-        if (!newPseudoStyle)
-            return true;
-        if (*newPseudoStyle != *cache) {
-            if (pseudoId &lt; FIRST_INTERNAL_PSEUDOID)
-                newStyle-&gt;setHasPseudoStyle(pseudoId);
-            newStyle-&gt;addCachedPseudoStyle(newPseudoStyle);
-            if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) {
-                // FIXME: We should do an actual diff to determine whether a repaint vs. layout
-                // is needed, but for now just assume a layout will be required. The diff code
-                // in RenderObject::setStyle would need to be factored out so that it could be reused.
-                renderer-&gt;setNeedsLayoutAndPrefWidthsRecalc();
-            }
-            return true;
-        }
-    }
-    return false;
-}
-
-static Change resolveLocal(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change inheritedChange)
-{
-    Change localChange = Detach;
-    RefPtr&lt;RenderStyle&gt; newStyle;
-    RefPtr&lt;RenderStyle&gt; currentStyle = current.renderStyle();
-
-    Document&amp; document = current.document();
-    if (currentStyle &amp;&amp; current.styleChangeType() != ReconstructRenderTree) {
-        Ref&lt;RenderStyle&gt; style(styleForElement(current, inheritedStyle));
-        newStyle = style.ptr();
-        localChange = determineChange(*currentStyle, style);
-    }
-    if (localChange == Detach) {
-        if (current.renderer() || current.isNamedFlowContentNode())
-            detachRenderTree(current, ReattachDetach);
-        attachRenderTree(current, inheritedStyle, renderTreePosition, newStyle.release());
-        invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(current);
-
-        return Detach;
-    }
-
-    if (RenderElement* renderer = current.renderer()) {
-        if (localChange != NoChange || pseudoStyleCacheIsInvalid(renderer, newStyle.get()) || (inheritedChange == Force &amp;&amp; renderer-&gt;requiresForcedStyleRecalcPropagation()) || current.styleChangeType() == SyntheticStyleChange)
-            renderer-&gt;setAnimatableStyle(*newStyle, current.styleChangeType() == SyntheticStyleChange ? StyleDifferenceRecompositeLayer : StyleDifferenceEqual);
-        else if (current.needsStyleRecalc()) {
-            // Although no change occurred, we use the new style so that the cousin style sharing code won't get
-            // fooled into believing this style is the same.
-            renderer-&gt;setStyleInternal(*newStyle);
-        }
-    }
-
-    // If &quot;rem&quot; units are used anywhere in the document, and if the document element's font size changes, then force font updating
-    // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
-    if (document.authorStyleSheets().usesRemUnits() &amp;&amp; document.documentElement() == &amp;current &amp;&amp; localChange != NoChange &amp;&amp; currentStyle &amp;&amp; newStyle &amp;&amp; currentStyle-&gt;fontSize() != newStyle-&gt;fontSize()) {
-        // Cached RenderStyles may depend on the re units.
-        if (StyleResolver* styleResolver = document.styleResolverIfExists())
-            styleResolver-&gt;invalidateMatchedPropertiesCache();
-        return Force;
-    }
-    if (inheritedChange == Force)
-        return Force;
-    if (current.styleChangeType() &gt;= FullStyleChange)
-        return Force;
-
-    return localChange;
-}
-
-void resolveTextNode(Text&amp; text, RenderTreePosition&amp; renderTreePosition)
-{
-    text.clearNeedsStyleRecalc();
-
-    bool hasRenderer = text.renderer();
-    bool needsRenderer = textRendererIsNeeded(text, renderTreePosition);
-    if (hasRenderer) {
-        if (needsRenderer)
-            return;
-        detachTextRenderer(text);
-        invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);
-        return;
-    }
-    if (!needsRenderer)
-        return;
-    attachTextRenderer(text, renderTreePosition);
-    invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);
-}
-
-static void resolveChildAtShadowBoundary(Node&amp; child, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Style::Change change)
-{
-    if (auto* renderer = child.renderer())
-        renderTreePosition.invalidateNextSibling(*renderer);
-
-    if (is&lt;Text&gt;(child) &amp;&amp; child.needsStyleRecalc()) {
-        resolveTextNode(downcast&lt;Text&gt;(child), renderTreePosition);
-        return;
-    }
-    if (is&lt;Element&gt;(child))
-        resolveTree(downcast&lt;Element&gt;(child), inheritedStyle, renderTreePosition, change);
-}
-
-static void resolveShadowTree(ShadowRoot&amp; shadowRoot, Element&amp; host, Style::Change change)
-{
-    ASSERT(shadowRoot.host() == &amp;host);
-    ASSERT(host.renderer());
-    auto&amp; inheritedStyle = host.renderer()-&gt;style();
-    if (shadowRoot.styleChangeType() &gt;= FullStyleChange)
-        change = Force;
-    RenderTreePosition renderTreePosition(*host.renderer());
-    for (auto* child = shadowRoot.firstChild(); child; child = child-&gt;nextSibling())
-        resolveChildAtShadowBoundary(*child, inheritedStyle, renderTreePosition, change);
-
-    shadowRoot.clearNeedsStyleRecalc();
-    shadowRoot.clearChildNeedsStyleRecalc();
-}
-
-static void updateBeforeOrAfterPseudoElement(Element&amp; current, Change change, PseudoId pseudoId, RenderTreePosition&amp; renderTreePosition)
-{
-    ASSERT(current.renderer());
-    if (PseudoElement* existingPseudoElement = beforeOrAfterPseudoElement(current, pseudoId)) {
-        if (existingPseudoElement-&gt;renderer())
-            renderTreePosition.invalidateNextSibling(*existingPseudoElement-&gt;renderer());
-
-        if (needsPseudoElement(current, pseudoId))
-            resolveTree(*existingPseudoElement, current.renderer()-&gt;style(), renderTreePosition, current.needsStyleRecalc() ? Force : change);
-        else
-            clearBeforeOrAfterPseudoElement(current, pseudoId);
-        return;
-    }
-    attachBeforeOrAfterPseudoElementIfNeeded(current, pseudoId, renderTreePosition);
-}
-
-#if PLATFORM(IOS)
-static EVisibility elementImplicitVisibility(const Element* element)
-{
-    RenderObject* renderer = element-&gt;renderer();
-    if (!renderer)
-        return VISIBLE;
-
-    RenderStyle&amp; style = renderer-&gt;style();
-
-    Length width(style.width());
-    Length height(style.height());
-    if ((width.isFixed() &amp;&amp; width.value() &lt;= 0) || (height.isFixed() &amp;&amp; height.value() &lt;= 0))
-        return HIDDEN;
-
-    Length top(style.top());
-    Length left(style.left());
-    if (left.isFixed() &amp;&amp; width.isFixed() &amp;&amp; -left.value() &gt;= width.value())
-        return HIDDEN;
-
-    if (top.isFixed() &amp;&amp; height.isFixed() &amp;&amp; -top.value() &gt;= height.value())
-        return HIDDEN;
-    return VISIBLE;
-}
-
-class CheckForVisibilityChangeOnRecalcStyle {
-public:
-    CheckForVisibilityChangeOnRecalcStyle(Element* element, RenderStyle* currentStyle)
-        : m_element(element)
-        , m_previousDisplay(currentStyle ? currentStyle-&gt;display() : NONE)
-        , m_previousVisibility(currentStyle ? currentStyle-&gt;visibility() : HIDDEN)
-        , m_previousImplicitVisibility(WKObservingContentChanges() &amp;&amp; WKContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : VISIBLE)
-    {
-    }
-    ~CheckForVisibilityChangeOnRecalcStyle()
-    {
-        if (!WKObservingContentChanges())
-            return;
-        if (m_element-&gt;isInUserAgentShadowTree())
-            return;
-        RenderStyle* style = m_element-&gt;renderStyle();
-        if (!style)
-            return;
-        if ((m_previousDisplay == NONE &amp;&amp; style-&gt;display() != NONE) || (m_previousVisibility == HIDDEN &amp;&amp; style-&gt;visibility() != HIDDEN)
-            || (m_previousImplicitVisibility == HIDDEN &amp;&amp; elementImplicitVisibility(m_element.get()) == VISIBLE))
-            WKSetObservedContentChange(WKContentVisibilityChange);
-    }
-private:
-    RefPtr&lt;Element&gt; m_element;
-    EDisplay m_previousDisplay;
-    EVisibility m_previousVisibility;
-    EVisibility m_previousImplicitVisibility;
-};
-#endif // PLATFORM(IOS)
-
-static void resolveChildren(Element&amp; current, RenderStyle&amp; inheritedStyle, Change change, RenderTreePosition&amp; childRenderTreePosition)
-{
-    StyleResolverParentPusher parentPusher(&amp;current);
-
-    bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
-    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
-        if (RenderObject* childRenderer = child-&gt;renderer())
-            childRenderTreePosition.invalidateNextSibling(*childRenderer);
-        if (is&lt;Text&gt;(*child) &amp;&amp; child-&gt;needsStyleRecalc()) {
-            resolveTextNode(downcast&lt;Text&gt;(*child), childRenderTreePosition);
-            continue;
-        }
-        if (!is&lt;Element&gt;(*child))
-            continue;
-
-        Element&amp; childElement = downcast&lt;Element&gt;(*child);
-        if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
-            if (childElement.styleIsAffectedByPreviousSibling())
-                childElement.setNeedsStyleRecalc();
-            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
-        } else if (childElement.needsStyleRecalc())
-            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
-        if (change &gt;= Inherit || childElement.childNeedsStyleRecalc() || childElement.needsStyleRecalc()) {
-            parentPusher.push();
-            resolveTree(childElement, inheritedStyle, childRenderTreePosition, change);
-        }
-    }
-}
-
-#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-static void resolveSlotAssignees(HTMLSlotElement&amp; slot, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change change)
-{
-    if (auto* assignedNodes = slot.assignedNodes()) {
-        for (auto* child : *assignedNodes)
-            resolveChildAtShadowBoundary(*child, inheritedStyle, renderTreePosition, change);
-    } else
-        resolveChildren(slot, inheritedStyle, change, renderTreePosition);
-
-    slot.clearNeedsStyleRecalc();
-    slot.clearChildNeedsStyleRecalc();
-}
-#endif
-
-void resolveTree(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change change)
-{
-    ASSERT(change != Detach);
-
-#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-    if (is&lt;HTMLSlotElement&gt;(current)) {
-        resolveSlotAssignees(downcast&lt;HTMLSlotElement&gt;(current), inheritedStyle, renderTreePosition, change);
-        return;
-    }
-#endif
-
-    if (current.hasCustomStyleResolveCallbacks()) {
-        if (!current.willRecalcStyle(change))
-            return;
-    }
-
-#if PLATFORM(IOS)
-    CheckForVisibilityChangeOnRecalcStyle checkForVisibilityChange(&amp;current, current.renderStyle());
-#endif
-
-    if (change &gt; NoChange || current.needsStyleRecalc())
-        current.resetComputedStyle();
-
-    if (change &gt;= Inherit || current.needsStyleRecalc())
-        change = resolveLocal(current, inheritedStyle, renderTreePosition, change);
-
-    auto* renderer = current.renderer();
-
-    if (change != Detach &amp;&amp; renderer) {
-        auto* shadowRoot = current.shadowRoot();
-        if (shadowRoot &amp;&amp; (change &gt;= Inherit || shadowRoot-&gt;childNeedsStyleRecalc() || shadowRoot-&gt;needsStyleRecalc()))
-            resolveShadowTree(*shadowRoot, current, change);
-
-        RenderTreePosition childRenderTreePosition(*renderer);
-        updateBeforeOrAfterPseudoElement(current, change, BEFORE, childRenderTreePosition);
-
-        bool skipChildren = shadowRoot;
-        if (!skipChildren)
-            resolveChildren(current, renderer-&gt;style(), change, childRenderTreePosition);
-
-        updateBeforeOrAfterPseudoElement(current, change, AFTER, childRenderTreePosition);
-    }
-    if (change != Detach &amp;&amp; !renderer)
-        resetStyleForNonRenderedDescendants(current);
-
-    current.clearNeedsStyleRecalc();
-    current.clearChildNeedsStyleRecalc();
-    
-    if (current.hasCustomStyleResolveCallbacks())
-        current.didRecalcStyle(change);
-}
-
-void resolveTree(Document&amp; document, Change change)
-{
-    auto&amp; renderView = *document.renderView();
-
-    if (change == Force) {
-        auto documentStyle = resolveForDocument(document);
-
-        // Inserting the pictograph font at the end of the font fallback list is done by the
-        // font selector, so set a font selector if needed.
-        if (Settings* settings = document.settings()) {
-            if (settings-&gt;fontFallbackPrefersPictographs())
-                documentStyle.get().fontCascade().update(&amp;document.fontSelector());
-        }
-
-        Style::Change documentChange = determineChange(documentStyle.get(), renderView.style());
-        if (documentChange != NoChange)
-            renderView.setStyle(WTFMove(documentStyle));
-    }
-
-    Element* documentElement = document.documentElement();
-    if (!documentElement)
-        return;
-    if (change &lt; Inherit &amp;&amp; !documentElement-&gt;childNeedsStyleRecalc() &amp;&amp; !documentElement-&gt;needsStyleRecalc())
-        return;
-
-    auto&amp; styleResolved = document.ensureStyleResolver();
-
-    // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
-    renderView.setUsesFirstLineRules(renderView.usesFirstLineRules() || styleResolved.usesFirstLineRules());
-    renderView.setUsesFirstLetterRules(renderView.usesFirstLetterRules() || styleResolved.usesFirstLetterRules());
-
-    RenderTreePosition renderTreePosition(renderView);
-    resolveTree(*documentElement, *document.renderStyle(), renderTreePosition, change);
-
-    renderView.setUsesFirstLineRules(styleResolved.usesFirstLineRules());
-    renderView.setUsesFirstLetterRules(styleResolved.usesFirstLetterRules());
-}
-
-void detachRenderTree(Element&amp; element)
-{
-    detachRenderTree(element, NormalDetach);
-}
-
-static Vector&lt;std::function&lt;void ()&gt;&gt;&amp; postResolutionCallbackQueue()
-{
-    static NeverDestroyed&lt;Vector&lt;std::function&lt;void ()&gt;&gt;&gt; vector;
-    return vector;
-}
-
-void queuePostResolutionCallback(std::function&lt;void ()&gt; callback)
-{
-    postResolutionCallbackQueue().append(callback);
-}
-
-static void suspendMemoryCacheClientCalls(Document&amp; document)
-{
-    Page* page = document.page();
-    if (!page || !page-&gt;areMemoryCacheClientCallsEnabled())
-        return;
-
-    page-&gt;setMemoryCacheClientCallsEnabled(false);
-
-    RefPtr&lt;MainFrame&gt; protectedMainFrame = &amp;page-&gt;mainFrame();
-    postResolutionCallbackQueue().append([protectedMainFrame]{
-        if (Page* page = protectedMainFrame-&gt;page())
-            page-&gt;setMemoryCacheClientCallsEnabled(true);
-    });
-}
-
-static unsigned resolutionNestingDepth;
-
-PostResolutionCallbackDisabler::PostResolutionCallbackDisabler(Document&amp; document)
-{
-    ++resolutionNestingDepth;
-
-    if (resolutionNestingDepth == 1)
-        platformStrategies()-&gt;loaderStrategy()-&gt;suspendPendingRequests();
-
-    // FIXME: It's strange to build this into the disabler.
-    suspendMemoryCacheClientCalls(document);
-}
-
-PostResolutionCallbackDisabler::~PostResolutionCallbackDisabler()
-{
-    if (resolutionNestingDepth == 1) {
-        // Get size each time through the loop because a callback can add more callbacks to the end of the queue.
-        auto&amp; queue = postResolutionCallbackQueue();
-        for (size_t i = 0; i &lt; queue.size(); ++i)
-            queue[i]();
-        queue.clear();
-
-        platformStrategies()-&gt;loaderStrategy()-&gt;resumePendingRequests();
-    }
-
-    --resolutionNestingDepth;
-}
-
-bool postResolutionCallbacksAreSuspended()
-{
-    return resolutionNestingDepth;
-}
-
-}
-}
</del></span></pre></div>
<a id="trunkSourceWebCorestyleStyleResolveTreeh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/style/StyleResolveTree.h (194690 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleResolveTree.h        2016-01-07 08:14:39 UTC (rev 194690)
+++ trunk/Source/WebCore/style/StyleResolveTree.h        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -1,62 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StyleResolveTree_h
-#define StyleResolveTree_h
-
-#include &quot;StyleChange.h&quot;
-#include &lt;functional&gt;
-
-namespace WebCore {
-
-class Document;
-class Element;
-class RenderStyle;
-class Settings;
-class Text;
-
-namespace Style {
-
-void resolveTree(Document&amp;, Change);
-
-void detachRenderTree(Element&amp;);
-void detachTextRenderer(Text&amp;);
-
-void updateTextRendererAfterContentChange(Text&amp;, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);
-
-void queuePostResolutionCallback(std::function&lt;void ()&gt;);
-bool postResolutionCallbacksAreSuspended();
-
-class PostResolutionCallbackDisabler {
-public:
-    explicit PostResolutionCallbackDisabler(Document&amp;);
-    ~PostResolutionCallbackDisabler();
-};
-
-}
-
-}
-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolvercppfromrev194584trunkSourceWebCorestyleStyleResolveTreecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/style/StyleTreeResolver.cpp (from rev 194584, trunk/Source/WebCore/style/StyleResolveTree.cpp) (0 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp                                (rev 0)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -0,0 +1,917 @@
</span><ins>+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2001 Peter Kelly (pmk@post.com)
+ *           (C) 2001 Dirk Mueller (mueller@kde.org)
+ *           (C) 2007 David Smith (catfish.man@gmail.com)
+ * Copyright (C) 2004-2010, 2012-2014 Apple Inc. All rights reserved.
+ *           (C) 2007 Eric Seidel (eric@webkit.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;StyleTreeResolver.h&quot;
+
+#include &quot;AXObjectCache.h&quot;
+#include &quot;AnimationController.h&quot;
+#include &quot;AuthorStyleSheets.h&quot;
+#include &quot;CSSFontSelector.h&quot;
+#include &quot;ComposedTreeAncestorIterator.h&quot;
+#include &quot;ComposedTreeIterator.h&quot;
+#include &quot;ElementIterator.h&quot;
+#include &quot;ElementRareData.h&quot;
+#include &quot;FlowThreadController.h&quot;
+#include &quot;HTMLSlotElement.h&quot;
+#include &quot;InspectorInstrumentation.h&quot;
+#include &quot;LoaderStrategy.h&quot;
+#include &quot;MainFrame.h&quot;
+#include &quot;NodeRenderStyle.h&quot;
+#include &quot;NodeTraversal.h&quot;
+#include &quot;PlatformStrategies.h&quot;
+#include &quot;RenderFullScreen.h&quot;
+#include &quot;RenderNamedFlowThread.h&quot;
+#include &quot;RenderText.h&quot;
+#include &quot;RenderTreePosition.h&quot;
+#include &quot;RenderWidget.h&quot;
+#include &quot;Settings.h&quot;
+#include &quot;ShadowRoot.h&quot;
+#include &quot;StyleResolver.h&quot;
+#include &quot;Text.h&quot;
+
+#if PLATFORM(IOS)
+#include &quot;WKContentObservation.h&quot;
+#endif
+
+namespace WebCore {
+
+namespace Style {
+
+enum DetachType { NormalDetach, ReattachDetach };
+
+static void attachTextRenderer(Text&amp;, RenderTreePosition&amp;);
+static void detachRenderTree(Element&amp;, DetachType);
+static void resolveTextNode(Text&amp;, RenderTreePosition&amp;);
+
+TreeResolver::TreeResolver(Document&amp; document)
+    : m_document(document)
+    , m_styleResolver(document.ensureStyleResolver())
+{
+}
+
+TreeResolver::TreeResolver(ShadowRoot&amp; shadowRoot, TreeResolver&amp; shadowHostTreeResolver)
+    : m_document(shadowRoot.document())
+    , m_styleResolver(shadowRoot.styleResolver())
+    , m_shadowRoot(&amp;shadowRoot)
+    , m_shadowHostTreeResolver(&amp;shadowHostTreeResolver)
+{
+}
+
+static bool shouldCreateRenderer(const Element&amp; element, const RenderElement&amp; parentRenderer)
+{
+    if (!element.document().shouldCreateRenderers())
+        return false;
+    if (!parentRenderer.canHaveChildren() &amp;&amp; !(element.isPseudoElement() &amp;&amp; parentRenderer.canHaveGeneratedChildren()))
+        return false;
+    if (parentRenderer.element() &amp;&amp; !parentRenderer.element()-&gt;childShouldCreateRenderer(element))
+        return false;
+    return true;
+}
+
+Ref&lt;RenderStyle&gt; TreeResolver::styleForElement(Element&amp; element, RenderStyle&amp; inheritedStyle)
+{
+    if (element.hasCustomStyleResolveCallbacks()) {
+        if (RefPtr&lt;RenderStyle&gt; style = element.customStyleForRenderer(inheritedStyle))
+            return style.releaseNonNull();
+    }
+    return m_styleResolver.styleForElement(&amp;element, &amp;inheritedStyle);
+}
+
+#if ENABLE(CSS_REGIONS)
+static RenderNamedFlowThread* moveToFlowThreadIfNeeded(Element&amp; element, const RenderStyle&amp; style)
+{
+    if (!element.shouldMoveToFlowThread(style))
+        return 0;
+
+    FlowThreadController&amp; flowThreadController = element.document().renderView()-&gt;flowThreadController();
+    RenderNamedFlowThread&amp; parentFlowRenderer = flowThreadController.ensureRenderFlowThreadWithName(style.flowThread());
+    flowThreadController.registerNamedFlowContentElement(element, parentFlowRenderer);
+    return &amp;parentFlowRenderer;
+}
+#endif
+
+void TreeResolver::createRenderer(Element&amp; element, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, RefPtr&lt;RenderStyle&gt;&amp;&amp; resolvedStyle)
+{
+    ASSERT(!element.renderer());
+
+    RefPtr&lt;RenderStyle&gt; style = resolvedStyle;
+
+    if (!shouldCreateRenderer(element, renderTreePosition.parent()))
+        return;
+
+    if (!style)
+        style = styleForElement(element, inheritedStyle);
+
+    RenderNamedFlowThread* parentFlowRenderer = 0;
+#if ENABLE(CSS_REGIONS)
+    parentFlowRenderer = moveToFlowThreadIfNeeded(element, *style);
+#endif
+
+    if (!element.rendererIsNeeded(*style))
+        return;
+
+    renderTreePosition.computeNextSibling(element);
+
+    RenderTreePosition insertionPosition = parentFlowRenderer
+        ? RenderTreePosition(*parentFlowRenderer, parentFlowRenderer-&gt;nextRendererForElement(element))
+        : renderTreePosition;
+
+    RenderElement* newRenderer = element.createElementRenderer(style.releaseNonNull(), insertionPosition).leakPtr();
+    if (!newRenderer)
+        return;
+    if (!insertionPosition.canInsert(*newRenderer)) {
+        newRenderer-&gt;destroy();
+        return;
+    }
+
+    // Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
+    // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
+    newRenderer-&gt;setFlowThreadState(insertionPosition.parent().flowThreadState());
+
+    // Code below updateAnimations() can depend on Element::renderer() already being set.
+    element.setRenderer(newRenderer);
+
+    // FIXME: There's probably a better way to factor this.
+    // This just does what setAnimatedStyle() does, except with setStyleInternal() instead of setStyle().
+    Ref&lt;RenderStyle&gt; animatedStyle = newRenderer-&gt;style();
+    newRenderer-&gt;animation().updateAnimations(*newRenderer, animatedStyle, animatedStyle);
+    newRenderer-&gt;setStyleInternal(WTFMove(animatedStyle));
+
+    newRenderer-&gt;initializeStyle();
+
+#if ENABLE(FULLSCREEN_API)
+    if (m_document.webkitIsFullScreen() &amp;&amp; m_document.webkitCurrentFullScreenElement() == &amp;element) {
+        newRenderer = RenderFullScreen::wrapRenderer(newRenderer, &amp;insertionPosition.parent(), m_document);
+        if (!newRenderer)
+            return;
+    }
+#endif
+    // Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
+    insertionPosition.insert(*newRenderer);
+}
+
+static void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node&amp; current)
+{
+    // FIXME: This needs to traverse in composed tree order.
+
+    // This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of
+    // the current node gaining or losing the renderer. This can only affect white space text nodes.
+    for (Node* sibling = current.nextSibling(); sibling; sibling = sibling-&gt;nextSibling()) {
+        if (sibling-&gt;needsStyleRecalc())
+            return;
+        if (is&lt;Element&gt;(*sibling)) {
+            // Text renderers beyond rendered elements can't be affected.
+            if (!sibling-&gt;renderer() || RenderTreePosition::isRendererReparented(*sibling-&gt;renderer()))
+                continue;
+            return;
+        }
+        if (!is&lt;Text&gt;(*sibling))
+            continue;
+        Text&amp; textSibling = downcast&lt;Text&gt;(*sibling);
+        if (!textSibling.containsOnlyWhitespace())
+            continue;
+        textSibling.setNeedsStyleRecalc();
+    }
+}
+
+static bool textRendererIsNeeded(const Text&amp; textNode, const RenderTreePosition&amp; renderTreePosition)
+{
+    const RenderElement&amp; parentRenderer = renderTreePosition.parent();
+    if (!parentRenderer.canHaveChildren())
+        return false;
+    if (parentRenderer.element() &amp;&amp; !parentRenderer.element()-&gt;childShouldCreateRenderer(textNode))
+        return false;
+    if (textNode.isEditingText())
+        return true;
+    if (!textNode.length())
+        return false;
+    if (!textNode.containsOnlyWhitespace())
+        return true;
+    // This text node has nothing but white space. We may still need a renderer in some cases.
+    if (parentRenderer.isTable() || parentRenderer.isTableRow() || parentRenderer.isTableSection() || parentRenderer.isRenderTableCol() || parentRenderer.isFrameSet())
+        return false;
+    if (parentRenderer.style().preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
+        return true;
+
+    RenderObject* previousRenderer = renderTreePosition.previousSiblingRenderer(textNode);
+    if (previousRenderer &amp;&amp; previousRenderer-&gt;isBR()) // &lt;span&gt;&lt;br/&gt; &lt;br/&gt;&lt;/span&gt;
+        return false;
+
+    if (parentRenderer.isRenderInline()) {
+        // &lt;span&gt;&lt;div/&gt; &lt;div/&gt;&lt;/span&gt;
+        if (previousRenderer &amp;&amp; !previousRenderer-&gt;isInline())
+            return false;
+    } else {
+        if (parentRenderer.isRenderBlock() &amp;&amp; !parentRenderer.childrenInline() &amp;&amp; (!previousRenderer || !previousRenderer-&gt;isInline()))
+            return false;
+        
+        RenderObject* first = parentRenderer.firstChild();
+        while (first &amp;&amp; first-&gt;isFloatingOrOutOfFlowPositioned())
+            first = first-&gt;nextSibling();
+        RenderObject* nextRenderer = renderTreePosition.nextSiblingRenderer(textNode);
+        if (!first || nextRenderer == first) {
+            // Whitespace at the start of a block just goes away. Don't even make a render object for this text.
+            return false;
+        }
+    }
+    return true;
+}
+
+static void createTextRendererIfNeeded(Text&amp; textNode, RenderTreePosition&amp; renderTreePosition)
+{
+    ASSERT(!textNode.renderer());
+
+    if (!textRendererIsNeeded(textNode, renderTreePosition))
+        return;
+
+    auto newRenderer = textNode.createTextRenderer(renderTreePosition.parent().style());
+    ASSERT(newRenderer);
+
+    renderTreePosition.computeNextSibling(textNode);
+
+    if (!renderTreePosition.canInsert(*newRenderer))
+        return;
+
+    // Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
+    // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
+    newRenderer-&gt;setFlowThreadState(renderTreePosition.parent().flowThreadState());
+
+    textNode.setRenderer(newRenderer.get());
+    // Parent takes care of the animations, no need to call setAnimatableStyle.
+    renderTreePosition.insert(*newRenderer.leakPtr());
+}
+
+void attachTextRenderer(Text&amp; textNode, RenderTreePosition&amp; renderTreePosition)
+{
+    createTextRendererIfNeeded(textNode, renderTreePosition);
+
+    textNode.clearNeedsStyleRecalc();
+}
+
+void detachTextRenderer(Text&amp; textNode)
+{
+    if (textNode.renderer())
+        textNode.renderer()-&gt;destroyAndCleanupAnonymousWrappers();
+    textNode.setRenderer(0);
+}
+
+void updateTextRendererAfterContentChange(Text&amp; textNode, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData)
+{
+    auto* renderingParentNode = composedTreeAncestors(textNode).first();
+    if (!renderingParentNode || !renderingParentNode-&gt;renderer())
+        return;
+
+    bool hadRenderer = textNode.renderer();
+
+    RenderTreePosition renderTreePosition(*renderingParentNode-&gt;renderer());
+    resolveTextNode(textNode, renderTreePosition);
+
+    if (hadRenderer &amp;&amp; textNode.renderer())
+        textNode.renderer()-&gt;setTextWithOffset(textNode.data(), offsetOfReplacedData, lengthOfReplacedData);
+}
+
+void TreeResolver::createRenderTreeForChildren(ContainerNode&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition)
+{
+    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
+        ASSERT((!child-&gt;renderer() || child-&gt;isNamedFlowContentNode()) || current.shadowRoot());
+        if (child-&gt;renderer()) {
+            renderTreePosition.invalidateNextSibling(*child-&gt;renderer());
+            continue;
+        }
+        if (is&lt;Text&gt;(*child)) {
+            attachTextRenderer(downcast&lt;Text&gt;(*child), renderTreePosition);
+            continue;
+        }
+        if (is&lt;Element&gt;(*child))
+            createRenderTreeRecursively(downcast&lt;Element&gt;(*child), inheritedStyle, renderTreePosition, nullptr);
+    }
+}
+
+void TreeResolver::createRenderTreeForShadowRoot(ShadowRoot&amp; shadowRoot)
+{
+    ASSERT(shadowRoot.host());
+    ASSERT(shadowRoot.host()-&gt;renderer());
+
+    TreeResolver shadowTreeResolver(shadowRoot, *this);
+
+    auto&amp; renderer = *shadowRoot.host()-&gt;renderer();
+    RenderTreePosition renderTreePosition(renderer);
+    shadowTreeResolver.createRenderTreeForChildren(shadowRoot, renderer.style(), renderTreePosition);
+
+    shadowRoot.clearNeedsStyleRecalc();
+    shadowRoot.clearChildNeedsStyleRecalc();
+}
+
+static PseudoElement* beforeOrAfterPseudoElement(Element&amp; current, PseudoId pseudoId)
+{
+    ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
+    if (pseudoId == BEFORE)
+        return current.beforePseudoElement();
+    return current.afterPseudoElement();
+}
+
+static void setBeforeOrAfterPseudoElement(Element&amp; current, Ref&lt;PseudoElement&gt;&amp;&amp; pseudoElement, PseudoId pseudoId)
+{
+    ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
+    if (pseudoId == BEFORE) {
+        current.setBeforePseudoElement(WTFMove(pseudoElement));
+        return;
+    }
+    current.setAfterPseudoElement(WTFMove(pseudoElement));
+}
+
+static void clearBeforeOrAfterPseudoElement(Element&amp; current, PseudoId pseudoId)
+{
+    ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
+    if (pseudoId == BEFORE) {
+        current.clearBeforePseudoElement();
+        return;
+    }
+    current.clearAfterPseudoElement();
+}
+
+static void resetStyleForNonRenderedDescendants(Element&amp; current)
+{
+    ASSERT(!current.renderer());
+    bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
+    for (auto&amp; child : childrenOfType&lt;Element&gt;(current)) {
+        ASSERT(!child.renderer());
+        if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
+            if (child.styleIsAffectedByPreviousSibling())
+                child.setNeedsStyleRecalc();
+            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = child.affectsNextSiblingElementStyle();
+        }
+
+        if (child.needsStyleRecalc()) {
+            child.resetComputedStyle();
+            child.clearNeedsStyleRecalc();
+            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = child.affectsNextSiblingElementStyle();
+        }
+
+        if (child.childNeedsStyleRecalc()) {
+            resetStyleForNonRenderedDescendants(child);
+            child.clearChildNeedsStyleRecalc();
+        }
+    }
+}
+
+static bool needsPseudoElement(Element&amp; current, PseudoId pseudoId)
+{
+    if (!current.renderer() || !current.renderer()-&gt;canHaveGeneratedChildren())
+        return false;
+    if (current.isPseudoElement())
+        return false;
+    if (!pseudoElementRendererIsNeeded(current.renderer()-&gt;getCachedPseudoStyle(pseudoId)))
+        return false;
+    return true;
+}
+
+void TreeResolver::createRenderTreeForBeforeOrAfterPseudoElement(Element&amp; current, PseudoId pseudoId, RenderTreePosition&amp; renderTreePosition)
+{
+    if (!needsPseudoElement(current, pseudoId))
+        return;
+    Ref&lt;PseudoElement&gt; pseudoElement = PseudoElement::create(current, pseudoId);
+    InspectorInstrumentation::pseudoElementCreated(m_document.page(), pseudoElement.get());
+    setBeforeOrAfterPseudoElement(current, pseudoElement.copyRef(), pseudoId);
+    createRenderTreeRecursively(pseudoElement.get(), *current.renderStyle(), renderTreePosition, nullptr);
+}
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+void TreeResolver::createRenderTreeForSlotAssignees(HTMLSlotElement&amp; slot, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition)
+{
+    if (auto* assignedNodes = slot.assignedNodes()) {
+        ASSERT(m_shadowHostTreeResolver);
+        for (auto* child : *assignedNodes) {
+            if (is&lt;Text&gt;(*child))
+                attachTextRenderer(downcast&lt;Text&gt;(*child), renderTreePosition);
+            else if (is&lt;Element&gt;(*child))
+                m_shadowHostTreeResolver-&gt;createRenderTreeRecursively(downcast&lt;Element&gt;(*child), inheritedStyle, renderTreePosition, nullptr);
+        }
+    } else
+        createRenderTreeForChildren(slot, inheritedStyle, renderTreePosition);
+
+    slot.clearNeedsStyleRecalc();
+    slot.clearChildNeedsStyleRecalc();
+}
+#endif
+
+void TreeResolver::createRenderTreeRecursively(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, RefPtr&lt;RenderStyle&gt;&amp;&amp; resolvedStyle)
+{
+    PostResolutionCallbackDisabler callbackDisabler(m_document);
+    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+    if (is&lt;HTMLSlotElement&gt;(current)) {
+        createRenderTreeForSlotAssignees(downcast&lt;HTMLSlotElement&gt;(current), inheritedStyle, renderTreePosition);
+        return;
+    }
+#endif
+
+    if (current.hasCustomStyleResolveCallbacks())
+        current.willAttachRenderers();
+
+    createRenderer(current, inheritedStyle, renderTreePosition, WTFMove(resolvedStyle));
+
+    if (auto* renderer = current.renderer()) {
+        StyleResolverParentPusher parentPusher(&amp;current);
+
+        RenderTreePosition childRenderTreePosition(*renderer);
+        createRenderTreeForBeforeOrAfterPseudoElement(current, BEFORE, childRenderTreePosition);
+
+        auto* shadowRoot = current.shadowRoot();
+        if (shadowRoot)
+            createRenderTreeForShadowRoot(*shadowRoot);
+        else if (current.firstChild())
+            parentPusher.push();
+
+        bool skipChildren = shadowRoot;
+        if (!skipChildren)
+            createRenderTreeForChildren(current, renderer-&gt;style(), childRenderTreePosition);
+
+        if (AXObjectCache* cache = m_document.axObjectCache())
+            cache-&gt;updateCacheAfterNodeIsAttached(&amp;current);
+
+        createRenderTreeForBeforeOrAfterPseudoElement(current, AFTER, childRenderTreePosition);
+
+        current.updateFocusAppearanceAfterAttachIfNeeded();
+    } else
+        resetStyleForNonRenderedDescendants(current);
+
+    current.clearNeedsStyleRecalc();
+    current.clearChildNeedsStyleRecalc();
+
+    if (current.hasCustomStyleResolveCallbacks())
+        current.didAttachRenderers();
+}
+
+static void detachChildren(ContainerNode&amp; current, DetachType detachType)
+{
+    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
+        if (is&lt;Text&gt;(*child))
+            detachTextRenderer(downcast&lt;Text&gt;(*child));
+        else if (is&lt;Element&gt;(*child))
+            detachRenderTree(downcast&lt;Element&gt;(*child), detachType);
+    }
+    current.clearChildNeedsStyleRecalc();
+}
+
+static void detachShadowRoot(ShadowRoot&amp; shadowRoot, DetachType detachType)
+{
+    detachChildren(shadowRoot, detachType);
+}
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+static void detachSlotAssignees(HTMLSlotElement&amp; slot, DetachType detachType)
+{
+    ASSERT(!slot.renderer());
+    if (auto* assignedNodes = slot.assignedNodes()) {
+        for (auto* child : *assignedNodes) {
+            if (is&lt;Text&gt;(*child))
+                detachTextRenderer(downcast&lt;Text&gt;(*child));
+            else if (is&lt;Element&gt;(*child))
+                detachRenderTree(downcast&lt;Element&gt;(*child), detachType);
+        }
+    } else
+        detachChildren(slot, detachType);
+
+    slot.clearNeedsStyleRecalc();
+    slot.clearChildNeedsStyleRecalc();
+}
+#endif
+
+static void detachRenderTree(Element&amp; current, DetachType detachType)
+{
+    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
+
+    if (current.hasCustomStyleResolveCallbacks())
+        current.willDetachRenderers();
+
+    current.clearStyleDerivedDataBeforeDetachingRenderer();
+
+    // Do not remove the element's hovered and active status
+    // if performing a reattach.
+    if (detachType != ReattachDetach)
+        current.clearHoverAndActiveStatusBeforeDetachingRenderer();
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+    if (is&lt;HTMLSlotElement&gt;(current))
+        detachSlotAssignees(downcast&lt;HTMLSlotElement&gt;(current), detachType);
+#endif
+    else if (ShadowRoot* shadowRoot = current.shadowRoot())
+        detachShadowRoot(*shadowRoot, detachType);
+
+    detachChildren(current, detachType);
+
+    if (current.renderer())
+        current.renderer()-&gt;destroyAndCleanupAnonymousWrappers();
+    current.setRenderer(0);
+
+    if (current.hasCustomStyleResolveCallbacks())
+        current.didDetachRenderers();
+}
+
+static bool pseudoStyleCacheIsInvalid(RenderElement* renderer, RenderStyle* newStyle)
+{
+    const RenderStyle&amp; currentStyle = renderer-&gt;style();
+
+    const PseudoStyleCache* pseudoStyleCache = currentStyle.cachedPseudoStyles();
+    if (!pseudoStyleCache)
+        return false;
+
+    for (auto&amp; cache : *pseudoStyleCache) {
+        RefPtr&lt;RenderStyle&gt; newPseudoStyle;
+        PseudoId pseudoId = cache-&gt;styleType();
+        if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED)
+            newPseudoStyle = renderer-&gt;uncachedFirstLineStyle(newStyle);
+        else
+            newPseudoStyle = renderer-&gt;getUncachedPseudoStyle(PseudoStyleRequest(pseudoId), newStyle, newStyle);
+        if (!newPseudoStyle)
+            return true;
+        if (*newPseudoStyle != *cache) {
+            if (pseudoId &lt; FIRST_INTERNAL_PSEUDOID)
+                newStyle-&gt;setHasPseudoStyle(pseudoId);
+            newStyle-&gt;addCachedPseudoStyle(newPseudoStyle);
+            if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) {
+                // FIXME: We should do an actual diff to determine whether a repaint vs. layout
+                // is needed, but for now just assume a layout will be required. The diff code
+                // in RenderObject::setStyle would need to be factored out so that it could be reused.
+                renderer-&gt;setNeedsLayoutAndPrefWidthsRecalc();
+            }
+            return true;
+        }
+    }
+    return false;
+}
+
+Change TreeResolver::resolveLocally(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change inheritedChange)
+{
+    Change localChange = Detach;
+    RefPtr&lt;RenderStyle&gt; newStyle;
+    RefPtr&lt;RenderStyle&gt; currentStyle = current.renderStyle();
+
+    if (currentStyle &amp;&amp; current.styleChangeType() != ReconstructRenderTree) {
+        Ref&lt;RenderStyle&gt; style(styleForElement(current, inheritedStyle));
+        newStyle = style.ptr();
+        localChange = determineChange(*currentStyle, style);
+    }
+    if (localChange == Detach) {
+        if (current.renderer() || current.isNamedFlowContentNode())
+            detachRenderTree(current, ReattachDetach);
+        createRenderTreeRecursively(current, inheritedStyle, renderTreePosition, newStyle.release());
+        invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(current);
+
+        return Detach;
+    }
+
+    if (RenderElement* renderer = current.renderer()) {
+        if (localChange != NoChange || pseudoStyleCacheIsInvalid(renderer, newStyle.get()) || (inheritedChange == Force &amp;&amp; renderer-&gt;requiresForcedStyleRecalcPropagation()) || current.styleChangeType() == SyntheticStyleChange)
+            renderer-&gt;setAnimatableStyle(*newStyle, current.styleChangeType() == SyntheticStyleChange ? StyleDifferenceRecompositeLayer : StyleDifferenceEqual);
+        else if (current.needsStyleRecalc()) {
+            // Although no change occurred, we use the new style so that the cousin style sharing code won't get
+            // fooled into believing this style is the same.
+            renderer-&gt;setStyleInternal(*newStyle);
+        }
+    }
+
+    // If &quot;rem&quot; units are used anywhere in the document, and if the document element's font size changes, then force font updating
+    // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
+    if (m_document.authorStyleSheets().usesRemUnits() &amp;&amp; m_document.documentElement() == &amp;current &amp;&amp; localChange != NoChange &amp;&amp; currentStyle &amp;&amp; newStyle &amp;&amp; currentStyle-&gt;fontSize() != newStyle-&gt;fontSize()) {
+        // Cached RenderStyles may depend on the re units.
+        m_styleResolver.invalidateMatchedPropertiesCache();
+        return Force;
+    }
+    if (inheritedChange == Force)
+        return Force;
+    if (current.styleChangeType() &gt;= FullStyleChange)
+        return Force;
+
+    return localChange;
+}
+
+void resolveTextNode(Text&amp; text, RenderTreePosition&amp; renderTreePosition)
+{
+    text.clearNeedsStyleRecalc();
+
+    bool hasRenderer = text.renderer();
+    bool needsRenderer = textRendererIsNeeded(text, renderTreePosition);
+    if (hasRenderer) {
+        if (needsRenderer)
+            return;
+        detachTextRenderer(text);
+        invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);
+        return;
+    }
+    if (!needsRenderer)
+        return;
+    attachTextRenderer(text, renderTreePosition);
+    invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);
+}
+
+void TreeResolver::resolveChildAtShadowBoundary(Node&amp; child, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Style::Change change)
+{
+    if (auto* renderer = child.renderer())
+        renderTreePosition.invalidateNextSibling(*renderer);
+
+    if (is&lt;Text&gt;(child) &amp;&amp; child.needsStyleRecalc()) {
+        resolveTextNode(downcast&lt;Text&gt;(child), renderTreePosition);
+        return;
+    }
+    if (is&lt;Element&gt;(child))
+        resolveRecursively(downcast&lt;Element&gt;(child), inheritedStyle, renderTreePosition, change);
+}
+
+void TreeResolver::resolveShadowTree(Style::Change change, RenderStyle&amp; inheritedStyle)
+{
+    ASSERT(m_shadowRoot);
+    auto&amp; host = *m_shadowRoot-&gt;host();
+    ASSERT(host.renderer());
+    if (m_shadowRoot-&gt;styleChangeType() &gt;= FullStyleChange)
+        change = Force;
+    RenderTreePosition renderTreePosition(*host.renderer());
+    for (auto* child = m_shadowRoot-&gt;firstChild(); child; child = child-&gt;nextSibling())
+        resolveChildAtShadowBoundary(*child, inheritedStyle, renderTreePosition, change);
+
+    m_shadowRoot-&gt;clearNeedsStyleRecalc();
+    m_shadowRoot-&gt;clearChildNeedsStyleRecalc();
+}
+
+void TreeResolver::resolveBeforeOrAfterPseudoElement(Element&amp; current, Change change, PseudoId pseudoId, RenderTreePosition&amp; renderTreePosition)
+{
+    ASSERT(current.renderer());
+    if (PseudoElement* existingPseudoElement = beforeOrAfterPseudoElement(current, pseudoId)) {
+        if (existingPseudoElement-&gt;renderer())
+            renderTreePosition.invalidateNextSibling(*existingPseudoElement-&gt;renderer());
+
+        if (needsPseudoElement(current, pseudoId))
+            resolveRecursively(*existingPseudoElement, current.renderer()-&gt;style(), renderTreePosition, current.needsStyleRecalc() ? Force : change);
+        else
+            clearBeforeOrAfterPseudoElement(current, pseudoId);
+        return;
+    }
+    createRenderTreeForBeforeOrAfterPseudoElement(current, pseudoId, renderTreePosition);
+}
+
+#if PLATFORM(IOS)
+static EVisibility elementImplicitVisibility(const Element* element)
+{
+    RenderObject* renderer = element-&gt;renderer();
+    if (!renderer)
+        return VISIBLE;
+
+    RenderStyle&amp; style = renderer-&gt;style();
+
+    Length width(style.width());
+    Length height(style.height());
+    if ((width.isFixed() &amp;&amp; width.value() &lt;= 0) || (height.isFixed() &amp;&amp; height.value() &lt;= 0))
+        return HIDDEN;
+
+    Length top(style.top());
+    Length left(style.left());
+    if (left.isFixed() &amp;&amp; width.isFixed() &amp;&amp; -left.value() &gt;= width.value())
+        return HIDDEN;
+
+    if (top.isFixed() &amp;&amp; height.isFixed() &amp;&amp; -top.value() &gt;= height.value())
+        return HIDDEN;
+    return VISIBLE;
+}
+
+class CheckForVisibilityChangeOnRecalcStyle {
+public:
+    CheckForVisibilityChangeOnRecalcStyle(Element* element, RenderStyle* currentStyle)
+        : m_element(element)
+        , m_previousDisplay(currentStyle ? currentStyle-&gt;display() : NONE)
+        , m_previousVisibility(currentStyle ? currentStyle-&gt;visibility() : HIDDEN)
+        , m_previousImplicitVisibility(WKObservingContentChanges() &amp;&amp; WKContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : VISIBLE)
+    {
+    }
+    ~CheckForVisibilityChangeOnRecalcStyle()
+    {
+        if (!WKObservingContentChanges())
+            return;
+        if (m_element-&gt;isInUserAgentShadowTree())
+            return;
+        RenderStyle* style = m_element-&gt;renderStyle();
+        if (!style)
+            return;
+        if ((m_previousDisplay == NONE &amp;&amp; style-&gt;display() != NONE) || (m_previousVisibility == HIDDEN &amp;&amp; style-&gt;visibility() != HIDDEN)
+            || (m_previousImplicitVisibility == HIDDEN &amp;&amp; elementImplicitVisibility(m_element.get()) == VISIBLE))
+            WKSetObservedContentChange(WKContentVisibilityChange);
+    }
+private:
+    RefPtr&lt;Element&gt; m_element;
+    EDisplay m_previousDisplay;
+    EVisibility m_previousVisibility;
+    EVisibility m_previousImplicitVisibility;
+};
+#endif // PLATFORM(IOS)
+
+void TreeResolver::resolveChildren(Element&amp; current, RenderStyle&amp; inheritedStyle, Change change, RenderTreePosition&amp; childRenderTreePosition)
+{
+    StyleResolverParentPusher parentPusher(&amp;current);
+
+    bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
+    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
+        if (RenderObject* childRenderer = child-&gt;renderer())
+            childRenderTreePosition.invalidateNextSibling(*childRenderer);
+        if (is&lt;Text&gt;(*child) &amp;&amp; child-&gt;needsStyleRecalc()) {
+            resolveTextNode(downcast&lt;Text&gt;(*child), childRenderTreePosition);
+            continue;
+        }
+        if (!is&lt;Element&gt;(*child))
+            continue;
+
+        Element&amp; childElement = downcast&lt;Element&gt;(*child);
+        if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
+            if (childElement.styleIsAffectedByPreviousSibling())
+                childElement.setNeedsStyleRecalc();
+            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
+        } else if (childElement.needsStyleRecalc())
+            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
+        if (change &gt;= Inherit || childElement.childNeedsStyleRecalc() || childElement.needsStyleRecalc()) {
+            parentPusher.push();
+            resolveRecursively(childElement, inheritedStyle, childRenderTreePosition, change);
+        }
+    }
+}
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+void TreeResolver::resolveSlotAssignees(HTMLSlotElement&amp; slot, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change change)
+{
+    if (auto* assignedNodes = slot.assignedNodes()) {
+        ASSERT(m_shadowHostTreeResolver);
+        for (auto* child : *assignedNodes)
+            m_shadowHostTreeResolver-&gt;resolveChildAtShadowBoundary(*child, inheritedStyle, renderTreePosition, change);
+    } else
+        resolveChildren(slot, inheritedStyle, change, renderTreePosition);
+
+    slot.clearNeedsStyleRecalc();
+    slot.clearChildNeedsStyleRecalc();
+}
+#endif
+
+void TreeResolver::resolveRecursively(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change change)
+{
+    ASSERT(change != Detach);
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+    if (is&lt;HTMLSlotElement&gt;(current)) {
+        resolveSlotAssignees(downcast&lt;HTMLSlotElement&gt;(current), inheritedStyle, renderTreePosition, change);
+        return;
+    }
+#endif
+
+    if (current.hasCustomStyleResolveCallbacks()) {
+        if (!current.willRecalcStyle(change))
+            return;
+    }
+
+#if PLATFORM(IOS)
+    CheckForVisibilityChangeOnRecalcStyle checkForVisibilityChange(&amp;current, current.renderStyle());
+#endif
+
+    if (change &gt; NoChange || current.needsStyleRecalc())
+        current.resetComputedStyle();
+
+    if (change &gt;= Inherit || current.needsStyleRecalc())
+        change = resolveLocally(current, inheritedStyle, renderTreePosition, change);
+
+    auto* renderer = current.renderer();
+
+    if (change != Detach &amp;&amp; renderer) {
+        auto* shadowRoot = current.shadowRoot();
+        if (shadowRoot &amp;&amp; (change &gt;= Inherit || shadowRoot-&gt;childNeedsStyleRecalc() || shadowRoot-&gt;needsStyleRecalc())) {
+            TreeResolver shadowTreeResolver(*shadowRoot, *this);
+            shadowTreeResolver.resolveShadowTree(change, renderer-&gt;style());
+        }
+
+        RenderTreePosition childRenderTreePosition(*renderer);
+        resolveBeforeOrAfterPseudoElement(current, change, BEFORE, childRenderTreePosition);
+
+        bool skipChildren = shadowRoot;
+        if (!skipChildren)
+            resolveChildren(current, renderer-&gt;style(), change, childRenderTreePosition);
+
+        resolveBeforeOrAfterPseudoElement(current, change, AFTER, childRenderTreePosition);
+    }
+    if (change != Detach &amp;&amp; !renderer)
+        resetStyleForNonRenderedDescendants(current);
+
+    current.clearNeedsStyleRecalc();
+    current.clearChildNeedsStyleRecalc();
+    
+    if (current.hasCustomStyleResolveCallbacks())
+        current.didRecalcStyle(change);
+}
+
+void TreeResolver::resolve(Change change)
+{
+    ASSERT(!m_shadowRoot);
+
+    auto&amp; renderView = *m_document.renderView();
+
+    Element* documentElement = m_document.documentElement();
+    if (!documentElement)
+        return;
+    if (change != Force &amp;&amp; !documentElement-&gt;childNeedsStyleRecalc() &amp;&amp; !documentElement-&gt;needsStyleRecalc())
+        return;
+
+    // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
+    renderView.setUsesFirstLineRules(renderView.usesFirstLineRules() || m_styleResolver.usesFirstLineRules());
+    renderView.setUsesFirstLetterRules(renderView.usesFirstLetterRules() || m_styleResolver.usesFirstLetterRules());
+
+    RenderTreePosition renderTreePosition(renderView);
+    resolveRecursively(*documentElement, *m_document.renderStyle(), renderTreePosition, change);
+
+    renderView.setUsesFirstLineRules(m_styleResolver.usesFirstLineRules());
+    renderView.setUsesFirstLetterRules(m_styleResolver.usesFirstLetterRules());
+}
+
+void detachRenderTree(Element&amp; element)
+{
+    detachRenderTree(element, NormalDetach);
+}
+
+static Vector&lt;std::function&lt;void ()&gt;&gt;&amp; postResolutionCallbackQueue()
+{
+    static NeverDestroyed&lt;Vector&lt;std::function&lt;void ()&gt;&gt;&gt; vector;
+    return vector;
+}
+
+void queuePostResolutionCallback(std::function&lt;void ()&gt; callback)
+{
+    postResolutionCallbackQueue().append(callback);
+}
+
+static void suspendMemoryCacheClientCalls(Document&amp; document)
+{
+    Page* page = document.page();
+    if (!page || !page-&gt;areMemoryCacheClientCallsEnabled())
+        return;
+
+    page-&gt;setMemoryCacheClientCallsEnabled(false);
+
+    RefPtr&lt;MainFrame&gt; protectedMainFrame = &amp;page-&gt;mainFrame();
+    postResolutionCallbackQueue().append([protectedMainFrame]{
+        if (Page* page = protectedMainFrame-&gt;page())
+            page-&gt;setMemoryCacheClientCallsEnabled(true);
+    });
+}
+
+static unsigned resolutionNestingDepth;
+
+PostResolutionCallbackDisabler::PostResolutionCallbackDisabler(Document&amp; document)
+{
+    ++resolutionNestingDepth;
+
+    if (resolutionNestingDepth == 1)
+        platformStrategies()-&gt;loaderStrategy()-&gt;suspendPendingRequests();
+
+    // FIXME: It's strange to build this into the disabler.
+    suspendMemoryCacheClientCalls(document);
+}
+
+PostResolutionCallbackDisabler::~PostResolutionCallbackDisabler()
+{
+    if (resolutionNestingDepth == 1) {
+        // Get size each time through the loop because a callback can add more callbacks to the end of the queue.
+        auto&amp; queue = postResolutionCallbackQueue();
+        for (size_t i = 0; i &lt; queue.size(); ++i)
+            queue[i]();
+        queue.clear();
+
+        platformStrategies()-&gt;loaderStrategy()-&gt;resumePendingRequests();
+    }
+
+    --resolutionNestingDepth;
+}
+
+bool postResolutionCallbacksAreSuspended()
+{
+    return resolutionNestingDepth;
+}
+
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolverhfromrev194584trunkSourceWebCorestyleStyleResolveTreeh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/style/StyleTreeResolver.h (from rev 194584, trunk/Source/WebCore/style/StyleResolveTree.h) (0 => 194691)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.h                                (rev 0)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h        2016-01-07 08:16:49 UTC (rev 194691)
</span><span class="lines">@@ -0,0 +1,105 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StyleTreeResolver_h
+#define StyleTreeResolver_h
+
+#include &quot;RenderStyleConstants.h&quot;
+#include &quot;StyleChange.h&quot;
+#include &lt;functional&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace WebCore {
+
+class ContainerNode;
+class Document;
+class Element;
+class HTMLSlotElement;
+class Node;
+class RenderStyle;
+class RenderTreePosition;
+class Settings;
+class ShadowRoot;
+class StyleResolver;
+class Text;
+
+namespace Style {
+
+class TreeResolver {
+public:
+    TreeResolver(Document&amp;);
+
+    void resolve(Change);
+
+private:
+    TreeResolver(ShadowRoot&amp;, TreeResolver&amp; shadowHostTreeResolver);
+
+    void resolveShadowTree(Change, RenderStyle&amp; inheritedStyle);
+
+    Ref&lt;RenderStyle&gt; styleForElement(Element&amp;, RenderStyle&amp; inheritedStyle);
+
+    void resolveRecursively(Element&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, Change);
+    Change resolveLocally(Element&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, Change inheritedChange);
+    void resolveChildren(Element&amp;, RenderStyle&amp;, Change, RenderTreePosition&amp;);
+    void resolveChildAtShadowBoundary(Node&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, Change);
+    void resolveBeforeOrAfterPseudoElement(Element&amp;, Change, PseudoId, RenderTreePosition&amp;);
+
+    void createRenderTreeRecursively(Element&amp;, RenderStyle&amp;, RenderTreePosition&amp;, RefPtr&lt;RenderStyle&gt;&amp;&amp; resolvedStyle);
+    void createRenderer(Element&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, RefPtr&lt;RenderStyle&gt;&amp;&amp; resolvedStyle);
+    void createRenderTreeForBeforeOrAfterPseudoElement(Element&amp;, PseudoId, RenderTreePosition&amp;);
+    void createRenderTreeForChildren(ContainerNode&amp;, RenderStyle&amp;, RenderTreePosition&amp;);
+    void createRenderTreeForShadowRoot(ShadowRoot&amp;);
+
+#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
+    void resolveSlotAssignees(HTMLSlotElement&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;, Change);
+    void createRenderTreeForSlotAssignees(HTMLSlotElement&amp;, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp;);
+#endif
+
+    Document&amp; m_document;
+    StyleResolver&amp; m_styleResolver;
+
+    ShadowRoot* m_shadowRoot { nullptr };
+    TreeResolver* m_shadowHostTreeResolver { nullptr };
+};
+
+void detachRenderTree(Element&amp;);
+void detachTextRenderer(Text&amp;);
+
+void updateTextRendererAfterContentChange(Text&amp;, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);
+
+void queuePostResolutionCallback(std::function&lt;void ()&gt;);
+bool postResolutionCallbacksAreSuspended();
+
+class PostResolutionCallbackDisabler {
+public:
+    explicit PostResolutionCallbackDisabler(Document&amp;);
+    ~PostResolutionCallbackDisabler();
+};
+
+}
+
+}
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>