<!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>[208743] trunk</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>slot doesn't work as a flex container
https://bugs.webkit.org/show_bug.cgi?id=160740
&lt;rdar://problem/28605080&gt;

Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: fast/shadow-dom/css-scoping-slot-flex.html

The style adjustment for flex children needs to be based on their parent box style rather
than the composed tree parent. This can be different when display:contents is involved.

* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::documentElementUserAgentStyle):
* css/StyleMedia.cpp:
(WebCore::StyleMedia::matchMedium):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::styleForElement):

    Optionally provide parent box style so we can do adjustments based on it when computing style for rendering.

(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::pseudoStyleForElement):
(WebCore::equivalentBlockDisplay):

    Avoid boolean parameters.

(WebCore::StyleResolver::adjustRenderStyle):

    Do the display:contents adjustment first and treat 'content' like 'none' later'. We never want to override
    'contents' with adjustments.
    Use parent box style for flex/grid adjustments instead of the DOM parent style.

* css/StyleResolver.h:
* rendering/RenderNamedFlowFragment.cpp:
(WebCore::RenderNamedFlowFragment::computeStyleInRegion):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::styleForElement):

    Call with parent box style.

(WebCore::Style::TreeResolver::parentBoxStyle):

    Find the parent box style if any.

* style/StyleTreeResolver.h:
* svg/SVGElementRareData.h:
(WebCore::SVGElementRareData::overrideComputedStyle):

LayoutTests:

* fast/shadow-dom/css-scoping-slot-flex-expected.html: Added.
* fast/shadow-dom/css-scoping-slot-flex.html: Added.
* fast/shadow-dom/slot-crash-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomslotcrashexpectedtxt">trunk/LayoutTests/fast/shadow-dom/slot-crash-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssMediaQueryMatchercpp">trunk/Source/WebCore/css/MediaQueryMatcher.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleMediacpp">trunk/Source/WebCore/css/StyleMedia.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderNamedFlowFragmentcpp">trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolverh">trunk/Source/WebCore/style/StyleTreeResolver.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGElementRareDatah">trunk/Source/WebCore/svg/SVGElementRareData.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingslotflexexpectedhtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingslotflexhtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/LayoutTests/ChangeLog        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-11-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        slot doesn't work as a flex container
+        https://bugs.webkit.org/show_bug.cgi?id=160740
+        &lt;rdar://problem/28605080&gt;
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/shadow-dom/css-scoping-slot-flex-expected.html: Added.
+        * fast/shadow-dom/css-scoping-slot-flex.html: Added.
+        * fast/shadow-dom/slot-crash-expected.txt:
+
</ins><span class="cx"> 2016-11-15  Joanmarie Diggs  &lt;jdiggs@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         AX: Need to update implicit/default values for aria-valuemin, aria-valuenow, and aria-valuemax
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingslotflexexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex-expected.html (0 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex-expected.html        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;body&gt;
+        &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+        &lt;div style=&quot;width: 100px; height: 100px; background: green;&quot;&gt;&lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingslotflexhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex.html (0 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-slot-flex.html        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -0,0 +1,140 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;body&gt;
+&lt;style&gt;
+#container {
+    width: 100px;
+    height: 100px;
+}
+&lt;/style&gt;
+&lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+&lt;div id=&quot;container&quot;&gt;
+&lt;div id=&quot;host&quot;&gt;
+    &lt;span&gt;a&lt;/span&gt;
+    &lt;span&gt;b&lt;/span&gt;
+&lt;/div&gt;
+&lt;div id=&quot;host2&quot;&gt;
+    &lt;span&gt;a&lt;/span&gt;
+    &lt;span class=&quot;abs&quot;&gt;b&lt;/span&gt;
+&lt;/div&gt;
+&lt;div id=&quot;host3&quot;&gt;
+    &lt;span&gt;a&lt;/span&gt;
+    &lt;span&gt;b&lt;/span&gt;
+&lt;/div&gt;
+&lt;div id=&quot;host4&quot;&gt;
+    &lt;span&gt;a&lt;/span&gt;
+    &lt;span&gt;b&lt;/span&gt;
+&lt;/div&gt;
+&lt;div id=&quot;host5&quot;&gt;
+    &lt;span&gt;a&lt;/span&gt;
+    &lt;span&gt;b&lt;/span&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+&lt;script&gt;
+
+document.querySelector('#host').attachShadow({mode:'closed'}).innerHTML = `
+&lt;style&gt;
+:host {
+    width: 100%;
+    height: 20%;
+    display: flex;
+}
+::slotted(span) {
+    flex: 1;
+    color: green;
+    background: green;
+    height: 100%;
+}
+&lt;/style&gt;
+&lt;slot&gt;&lt;/slot&gt;`;
+
+document.querySelector('#host2').attachShadow({mode:'closed'}).innerHTML = `
+&lt;style&gt;
+:host {
+    width: 150%;
+    height: 20%;
+    display: flex;
+}
+::slotted(span) {
+    flex: 2;
+    color: green;
+    background: green;
+    display: inline-block;
+    z-index: 10;
+    height: 100%;
+}
+::slotted(span.abs) {
+    flex: 1;
+    background: red;
+    z-index: 5;
+    left: -75px;
+    position: relative;
+}
+&lt;/style&gt;
+&lt;slot&gt;&lt;/slot&gt;`;
+
+document.querySelector('#host3').attachShadow({mode:'closed'}).innerHTML = `
+&lt;style&gt;
+:host {
+    width: 100%;
+    height: 20%;
+}
+:host(.flex) {
+    display:flex;
+}
+::slotted(span) {
+    flex: 1;
+    color: green;
+    background: green;
+    height: 100%;
+}
+&lt;/style&gt;
+&lt;slot&gt;&lt;/slot&gt;`;
+window.getComputedStyle(document.querySelector('#host3')).width;
+document.querySelector('#host3').className = &quot;flex&quot;;
+
+const root4 = document.querySelector('#host4').attachShadow({mode:'closed'});
+root4.innerHTML = `
+&lt;style&gt;
+:host {
+    width: 100%;
+    height: 20%;
+}
+#deephost {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    background: red;
+}
+::slotted(span) {
+    flex: 1;
+    color: green;
+    background: green;
+    height: 100%;
+}
+&lt;/style&gt;
+&lt;div id=&quot;deephost&quot;&gt;
+&lt;slot&gt;&lt;/slot&gt;
+&lt;/div&gt;`;
+root4.querySelector('#deephost').attachShadow({mode:'closed'}).innerHTML = `&lt;slot&gt;&lt;/slot&gt;`;
+
+document.querySelector('#host5').attachShadow({mode:'closed'}).innerHTML = `
+&lt;style&gt;
+:host {
+    width: 100%;
+    height: 20%;
+}
+::slotted(span) {
+    flex: 1;
+    color: green;
+    background: green;
+    height: 100%;
+}
+slot {
+    display:flex;
+    width: 100%;
+    height: 100%;
+}
+&lt;/style&gt;
+&lt;slot&gt;&lt;/slot&gt;`;
+
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslotcrashexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/shadow-dom/slot-crash-expected.txt (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slot-crash-expected.txt        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/LayoutTests/fast/shadow-dom/slot-crash-expected.txt        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -1 +1 @@
</span><del>-This test passes if it doesn't crash/assert. 
</del><ins>+This test passes if it doesn't crash/assert.
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/ChangeLog        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2016-11-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        slot doesn't work as a flex container
+        https://bugs.webkit.org/show_bug.cgi?id=160740
+        &lt;rdar://problem/28605080&gt;
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: fast/shadow-dom/css-scoping-slot-flex.html
+
+        The style adjustment for flex children needs to be based on their parent box style rather
+        than the composed tree parent. This can be different when display:contents is involved.
+
+        * css/MediaQueryMatcher.cpp:
+        (WebCore::MediaQueryMatcher::documentElementUserAgentStyle):
+        * css/StyleMedia.cpp:
+        (WebCore::StyleMedia::matchMedium):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::styleForElement):
+
+            Optionally provide parent box style so we can do adjustments based on it when computing style for rendering.
+
+        (WebCore::StyleResolver::styleForKeyframe):
+        (WebCore::StyleResolver::pseudoStyleForElement):
+        (WebCore::equivalentBlockDisplay):
+
+            Avoid boolean parameters.
+
+        (WebCore::StyleResolver::adjustRenderStyle):
+
+            Do the display:contents adjustment first and treat 'content' like 'none' later'. We never want to override
+            'contents' with adjustments.
+            Use parent box style for flex/grid adjustments instead of the DOM parent style.
+
+        * css/StyleResolver.h:
+        * rendering/RenderNamedFlowFragment.cpp:
+        (WebCore::RenderNamedFlowFragment::computeStyleInRegion):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::styleForElement):
+
+            Call with parent box style.
+
+        (WebCore::Style::TreeResolver::parentBoxStyle):
+
+            Find the parent box style if any.
+
+        * style/StyleTreeResolver.h:
+        * svg/SVGElementRareData.h:
+        (WebCore::SVGElementRareData::overrideComputedStyle):
+
</ins><span class="cx"> 2016-11-15  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Misc Inspector backend cleanup
</span></span></pre></div>
<a id="trunkSourceWebCorecssMediaQueryMatchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/MediaQueryMatcher.cpp (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/MediaQueryMatcher.cpp        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/css/MediaQueryMatcher.cpp        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">     if (!documentElement)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return m_document-&gt;styleScope().resolver().styleForElement(*documentElement, m_document-&gt;renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</del><ins>+    return m_document-&gt;styleScope().resolver().styleForElement(*documentElement, m_document-&gt;renderStyle(), nullptr, MatchOnlyUserAgentRules).renderStyle;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaQueryMatcher::evaluate(const MediaQuerySet&amp; media)
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleMediacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleMedia.cpp (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleMedia.cpp        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/css/StyleMedia.cpp        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     if (!documentElement)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    auto rootStyle = document-&gt;styleScope().resolver().styleForElement(*documentElement, document-&gt;renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</del><ins>+    auto rootStyle = document-&gt;styleScope().resolver().styleForElement(*documentElement, document-&gt;renderStyle(), nullptr, MatchOnlyUserAgentRules).renderStyle;
</ins><span class="cx"> 
</span><span class="cx">     auto media = MediaQuerySet::create();
</span><span class="cx">     if (!media-&gt;parse(query))
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -264,7 +264,7 @@
</span><span class="cx">         m_mediaQueryEvaluator = MediaQueryEvaluator { &quot;all&quot; };
</span><span class="cx"> 
</span><span class="cx">     if (root) {
</span><del>-        m_rootDefaultStyle = styleForElement(*root, m_document.renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</del><ins>+        m_rootDefaultStyle = styleForElement(*root, m_document.renderStyle(), nullptr, MatchOnlyUserAgentRules).renderStyle;
</ins><span class="cx">         // Turn off assertion against font lookups during style resolver initialization. We may need root style font for media queries.
</span><span class="cx">         m_document.fontSelector().setIsComputingRootStyleFont(true);
</span><span class="cx">         m_rootDefaultStyle-&gt;fontCascade().update(&amp;m_document.fontSelector());
</span><span class="lines">@@ -386,7 +386,7 @@
</span><span class="cx">     return parentNode &amp;&amp; parentNode-&gt;isShadowRoot();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ElementStyle StyleResolver::styleForElement(const Element&amp; element, const RenderStyle* parentStyle, RuleMatchingBehavior matchingBehavior, const RenderRegion* regionForStyling, const SelectorFilter* selectorFilter)
</del><ins>+ElementStyle StyleResolver::styleForElement(const Element&amp; element, const RenderStyle* parentStyle, const RenderStyle* parentBoxStyle, RuleMatchingBehavior matchingBehavior, const RenderRegion* regionForStyling, const SelectorFilter* selectorFilter)
</ins><span class="cx"> {
</span><span class="cx">     RELEASE_ASSERT(!m_isDeleted);
</span><span class="cx"> 
</span><span class="lines">@@ -437,7 +437,7 @@
</span><span class="cx">     applyMatchedProperties(collector.matchedResult(), element);
</span><span class="cx"> 
</span><span class="cx">     // Clean up our style object's display and text decorations (among other fixups).
</span><del>-    adjustRenderStyle(*state.style(), *state.parentStyle(), &amp;element);
</del><ins>+    adjustRenderStyle(*state.style(), *state.parentStyle(), parentBoxStyle, &amp;element);
</ins><span class="cx"> 
</span><span class="cx">     if (state.style()-&gt;hasViewportUnits())
</span><span class="cx">         document().setHasStyleWithViewportUnits();
</span><span class="lines">@@ -487,7 +487,7 @@
</span><span class="cx"> 
</span><span class="cx">     cascade.applyDeferredProperties(*this, &amp;result);
</span><span class="cx"> 
</span><del>-    adjustRenderStyle(*state.style(), *state.parentStyle(), nullptr);
</del><ins>+    adjustRenderStyle(*state.style(), *state.parentStyle(), nullptr, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     // Add all the animating properties to the keyframe.
</span><span class="cx">     unsigned propertyCount = keyframe-&gt;properties().propertyCount();
</span><span class="lines">@@ -637,7 +637,7 @@
</span><span class="cx">     applyMatchedProperties(collector.matchedResult(), element);
</span><span class="cx"> 
</span><span class="cx">     // Clean up our style object's display and text decorations (among other fixups).
</span><del>-    adjustRenderStyle(*state.style(), *m_state.parentStyle(), nullptr);
</del><ins>+    adjustRenderStyle(*state.style(), *m_state.parentStyle(), nullptr, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     if (state.style()-&gt;hasViewportUnits())
</span><span class="cx">         document().setHasStyleWithViewportUnits();
</span><span class="lines">@@ -722,9 +722,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool strictParsing)
</del><ins>+static EDisplay equivalentBlockDisplay(const RenderStyle&amp; style, const Document&amp; document)
</ins><span class="cx"> {
</span><del>-    switch (display) {
</del><ins>+    switch (auto display = style.display()) {
</ins><span class="cx">     case BLOCK:
</span><span class="cx">     case TABLE:
</span><span class="cx">     case BOX:
</span><span class="lines">@@ -737,7 +737,7 @@
</span><span class="cx"> 
</span><span class="cx">     case LIST_ITEM:
</span><span class="cx">         // It is a WinIE bug that floated list items lose their bullets, so we'll emulate the quirk, but only in quirks mode.
</span><del>-        if (!strictParsing &amp;&amp; isFloating)
</del><ins>+        if (document.inQuirksMode() &amp;&amp; style.isFloating())
</ins><span class="cx">             return BLOCK;
</span><span class="cx">         return display;
</span><span class="cx">     case INLINE_TABLE:
</span><span class="lines">@@ -763,8 +763,10 @@
</span><span class="cx">     case TABLE_COLUMN:
</span><span class="cx">     case TABLE_CELL:
</span><span class="cx">     case TABLE_CAPTION:
</span><ins>+        return BLOCK;
</ins><span class="cx">     case CONTENTS:
</span><del>-        return BLOCK;
</del><ins>+        ASSERT_NOT_REACHED();
+        return CONTENTS;
</ins><span class="cx">     case NONE:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return NONE;
</span><span class="lines">@@ -800,19 +802,24 @@
</span><span class="cx">         style-&gt;setWritingMode(LeftToRightWritingMode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StyleResolver::adjustRenderStyle(RenderStyle&amp; style, const RenderStyle&amp; parentStyle, const Element* element)
</del><ins>+void StyleResolver::adjustRenderStyle(RenderStyle&amp; style, const RenderStyle&amp; parentStyle, const RenderStyle* parentBoxStyle, const Element* element)
</ins><span class="cx"> {
</span><ins>+    // If the composed tree parent has display:contents, the parent box style will be different from the parent style.
+    // We don't have it when resolving computed style for display:none subtree. Use parent style for adjustments in that case.
+    if (!parentBoxStyle)
+        parentBoxStyle = &amp;parentStyle;
+
</ins><span class="cx">     // Cache our original display.
</span><span class="cx">     style.setOriginalDisplay(style.display());
</span><span class="cx"> 
</span><del>-    if (style.display() != NONE) {
-        if (style.display() == CONTENTS) {
-            // FIXME: Enable for all elements.
-            bool elementSupportsDisplayContents = false;
-            elementSupportsDisplayContents = is&lt;HTMLSlotElement&gt;(element);
-            if (!elementSupportsDisplayContents)
-                style.setDisplay(INLINE);
-        }
</del><ins>+    if (style.display() == CONTENTS) {
+        // FIXME: Enable for all elements.
+        bool elementSupportsDisplayContents = is&lt;HTMLSlotElement&gt;(element);
+        if (!elementSupportsDisplayContents)
+            style.setDisplay(INLINE);
+    }
+
+    if (style.display() != NONE &amp;&amp; style.display() != CONTENTS) {
</ins><span class="cx">         if (element) {
</span><span class="cx">             // If we have a &lt;td&gt; that specifies a float property, in quirks mode we just drop the float
</span><span class="cx">             // property.
</span><span class="lines">@@ -866,7 +873,7 @@
</span><span class="cx"> 
</span><span class="cx">         // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display.
</span><span class="cx">         if (style.hasOutOfFlowPosition() || style.isFloating() || (element &amp;&amp; element-&gt;document().documentElement() == element))
</span><del>-            style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloating(), !document().inQuirksMode()));
</del><ins>+            style.setDisplay(equivalentBlockDisplay(style, document()));
</ins><span class="cx"> 
</span><span class="cx">         // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely
</span><span class="cx">         // clear how that should work.
</span><span class="lines">@@ -894,14 +901,16 @@
</span><span class="cx">         if (style.writingMode() != TopToBottomWritingMode &amp;&amp; (style.display() == BOX || style.display() == INLINE_BOX))
</span><span class="cx">             style.setWritingMode(TopToBottomWritingMode);
</span><span class="cx"> 
</span><del>-        if (parentStyle.isDisplayFlexibleOrGridBox()) {
</del><ins>+        // https://www.w3.org/TR/css-display/#transformations
+        // &quot;A parent with a grid or flex display value blockifies the box’s display type.&quot;
+        if (parentBoxStyle-&gt;isDisplayFlexibleOrGridBox()) {
</ins><span class="cx">             style.setFloating(NoFloat);
</span><del>-            style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloating(), !document().inQuirksMode()));
</del><ins>+            style.setDisplay(equivalentBlockDisplay(style, document()));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Make sure our z-index value is only applied if the object is positioned.
</span><del>-    if (style.position() == StaticPosition &amp;&amp; !parentStyle.isDisplayFlexibleOrGridBox())
</del><ins>+    if (style.position() == StaticPosition &amp;&amp; !parentBoxStyle-&gt;isDisplayFlexibleOrGridBox())
</ins><span class="cx">         style.setHasAutoZIndex();
</span><span class="cx"> 
</span><span class="cx">     // Auto z-index becomes 0 for the root element and transparent objects. This prevents
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/css/StyleResolver.h        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx">     StyleResolver(Document&amp;);
</span><span class="cx">     ~StyleResolver();
</span><span class="cx"> 
</span><del>-    ElementStyle styleForElement(const Element&amp;, const RenderStyle* parentStyle, RuleMatchingBehavior = MatchAllRules, const RenderRegion* regionForStyling = nullptr, const SelectorFilter* = nullptr);
</del><ins>+    ElementStyle styleForElement(const Element&amp;, const RenderStyle* parentStyle, const RenderStyle* parentBoxStyle = nullptr, RuleMatchingBehavior = MatchAllRules, const RenderRegion* regionForStyling = nullptr, const SelectorFilter* = nullptr);
</ins><span class="cx"> 
</span><span class="cx">     void keyframeStylesForAnimation(const Element&amp;, const RenderStyle*, KeyframeList&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -313,7 +313,7 @@
</span><span class="cx">     void checkForTextSizeAdjust(RenderStyle*);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void adjustRenderStyle(RenderStyle&amp; styleToAdjust, const RenderStyle&amp; parentStyle, const Element*);
</del><ins>+    void adjustRenderStyle(RenderStyle&amp;, const RenderStyle&amp; parentStyle, const RenderStyle* parentBoxStyle, const Element*);
</ins><span class="cx"> #if ENABLE(CSS_GRID_LAYOUT)
</span><span class="cx">     std::unique_ptr&lt;GridPosition&gt; adjustNamedGridItemPosition(const NamedGridAreaMap&amp;, const NamedGridLinesMap&amp;, const GridPosition&amp;, GridPositionSide) const;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderNamedFlowFragmentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -352,7 +352,7 @@
</span><span class="cx">     ASSERT(!renderer.isAnonymous());
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Region styling fails for pseudo-elements because the renderers don't have a node.
</span><del>-    auto renderObjectRegionStyle = renderer.element()-&gt;styleResolver().styleForElement(*renderer.element(), &amp;parentStyle, MatchAllRules, this).renderStyle;
</del><ins>+    auto renderObjectRegionStyle = renderer.element()-&gt;styleResolver().styleForElement(*renderer.element(), &amp;parentStyle, nullptr, MatchAllRules, this).renderStyle;
</ins><span class="cx"> 
</span><span class="cx">     return renderObjectRegionStyle;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -149,7 +149,7 @@
</span><span class="cx">     if (auto style = scope().sharingResolver.resolve(element, *m_update))
</span><span class="cx">         return style;
</span><span class="cx"> 
</span><del>-    auto elementStyle = scope().styleResolver.styleForElement(element, &amp;inheritedStyle, MatchAllRules, nullptr, &amp;scope().selectorFilter);
</del><ins>+    auto elementStyle = scope().styleResolver.styleForElement(element, &amp;inheritedStyle, parentBoxStyle(), MatchAllRules, nullptr, &amp;scope().selectorFilter);
</ins><span class="cx"> 
</span><span class="cx">     if (elementStyle.relations)
</span><span class="cx">         commitRelations(WTFMove(elementStyle.relations), *m_update);
</span><span class="lines">@@ -239,6 +239,20 @@
</span><span class="cx">     return update;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const RenderStyle* TreeResolver::parentBoxStyle() const
+{
+    // 'display: contents' doesn't generate boxes.
+    for (unsigned i = m_parentStack.size(); i; --i) {
+        auto&amp; parent = m_parentStack[i - 1];
+        if (parent.style.display() == NONE)
+            return nullptr;
+        if (parent.style.display() != CONTENTS)
+            return &amp;parent.style;
+    }
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
</ins><span class="cx"> ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr&lt;RenderStyle&gt; newStyle, RenderElement* rendererToUpdate, Document&amp; document)
</span><span class="cx"> {
</span><span class="cx">     ElementUpdate update;
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.h (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.h        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -94,6 +94,8 @@
</span><span class="cx">     void popParent();
</span><span class="cx">     void popParentsToDepth(unsigned depth);
</span><span class="cx"> 
</span><ins>+    const RenderStyle* parentBoxStyle() const;
+
</ins><span class="cx">     Document&amp; m_document;
</span><span class="cx">     std::unique_ptr&lt;RenderStyle&gt; m_documentElementStyle;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGElementRareDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGElementRareData.h (208742 => 208743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGElementRareData.h        2016-11-15 19:45:40 UTC (rev 208742)
+++ trunk/Source/WebCore/svg/SVGElementRareData.h        2016-11-15 19:53:25 UTC (rev 208743)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">             return nullptr;
</span><span class="cx">         if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) {
</span><span class="cx">             // The style computed here contains no CSS Animations/Transitions or SMIL induced rules - this is needed to compute the &quot;base value&quot; for the SMIL animation sandwhich model.
</span><del>-            m_overrideComputedStyle = element.styleResolver().styleForElement(element, parentStyle, MatchAllRulesExcludingSMIL).renderStyle;
</del><ins>+            m_overrideComputedStyle = element.styleResolver().styleForElement(element, parentStyle, nullptr, MatchAllRulesExcludingSMIL).renderStyle;
</ins><span class="cx">             m_needsOverrideComputedStyleUpdate = false;
</span><span class="cx">         }
</span><span class="cx">         ASSERT(m_overrideComputedStyle);
</span></span></pre>
</div>
</div>

</body>
</html>