<!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>[205102] 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/205102">205102</a></dd>
<dt>Author</dt> <dd>jfernandez@igalia.com</dd>
<dt>Date</dt> <dd>2016-08-28 07:45:43 -0700 (Sun, 28 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Should never be reached failure in WebCore::RenderFlexibleBox::alignChildren
https://bugs.webkit.org/show_bug.cgi?id=151591
&lt;rdar://problem/27711829&gt;

Reviewed by Darin Adler.

Source/WebCore:

The align-self and align-items CSS properties were originally defined in the
Flexbible Box specification. The new CSS Box Alignment specification tries
to generalize them so they can be used by other layout models, as it's  the
case of the GridLayout spec.

Since we have implemented the Grid Layout spec behind a runtime flag, we should
do the same with the new syntax of these properties.

Test: css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
(WebCore::isKeywordPropertyID):
(WebCore::CSSParser::parseValue):
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::alignChildren):

LayoutTests:

Test to verify that align-self and align-items CSS properties use the old
syntax when the Grid Layout feature is not enabled.

* css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled-expected.txt: Added.
* css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSParsercpp">trunk/Source/WebCore/css/parser/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderFlexibleBoxcpp">trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscss3flexboxnewalignmentvaluesinvalidifgridnotenabledexpectedtxt">trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestscss3flexboxnewalignmentvaluesinvalidifgridnotenabledhtml">trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205101 => 205102)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-28 09:35:33 UTC (rev 205101)
+++ trunk/LayoutTests/ChangeLog        2016-08-28 14:45:43 UTC (rev 205102)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-08-28  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
+
+        Should never be reached failure in WebCore::RenderFlexibleBox::alignChildren
+        https://bugs.webkit.org/show_bug.cgi?id=151591
+        &lt;rdar://problem/27711829&gt;
+
+        Reviewed by Darin Adler.
+
+        Test to verify that align-self and align-items CSS properties use the old
+        syntax when the Grid Layout feature is not enabled.
+
+        * css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled-expected.txt: Added.
+        * css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html: Added.
+
</ins><span class="cx"> 2016-08-28  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Improve parsing of the menclose notation attribute value
</span></span></pre></div>
<a id="trunkLayoutTestscss3flexboxnewalignmentvaluesinvalidifgridnotenabledexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled-expected.txt (0 => 205102)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled-expected.txt                                (rev 0)
+++ trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled-expected.txt        2016-08-28 14:45:43 UTC (rev 205102)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+Test to verify that the new alignment values are parsed as invalid if Grid Layout is disabled and in any case they do not cause a crash because assertions in flexbox layout code.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+
+New alignment values should be invalid when grid layout is disabled
+
+Testing Self-Alignment values.
+PASS alignSelf is 'flex-start'
+PASS alignSelf is 'flex-start'
+PASS alignSelf is 'flex-start'
+PASS alignSelf is 'flex-start'
+PASS alignSelf is 'flex-start'
+PASS alignSelf is 'flex-start'
+
+Testing Default-Alignment values.
+PASS alignItems is 'flex-end'
+PASS alignSelf is 'flex-end'
+PASS alignItems is 'flex-end'
+PASS alignSelf is 'flex-end'
+PASS alignItems is 'flex-end'
+PASS alignSelf is 'flex-end'
+PASS alignItems is 'flex-end'
+PASS alignSelf is 'flex-end'
+PASS alignItems is 'flex-end'
+PASS alignSelf is 'flex-end'
+PASS alignItems is 'flex-end'
+PASS alignSelf is 'flex-end'
+
+Even when grid layout is enabled, new values should not violate assertions in FlexibleBox layout logic.
+
+Testing Self-Alignment values.
+PASS alignSelf is 'start unsafe'
+PASS alignSelf is 'start'
+PASS alignSelf is 'end'
+PASS alignSelf is 'flex-start safe'
+PASS alignSelf is 'self-start'
+PASS alignSelf is 'self-end'
+
+Testing Default-Alignment values.
+PASS alignItems is 'start unsafe'
+PASS alignSelf is 'start unsafe'
+PASS alignItems is 'start'
+PASS alignSelf is 'start'
+PASS alignItems is 'end'
+PASS alignSelf is 'end'
+PASS alignItems is 'flex-start safe'
+PASS alignSelf is 'flex-start safe'
+PASS alignItems is 'self-start'
+PASS alignSelf is 'self-start'
+PASS alignItems is 'self-end'
+PASS alignSelf is 'self-end'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscss3flexboxnewalignmentvaluesinvalidifgridnotenabledhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html (0 => 205102)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html                                (rev 0)
+++ trunk/LayoutTests/css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html        2016-08-28 14:45:43 UTC (rev 205102)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;div id=&quot;flexContainer&quot; style=&quot;display: flex&quot;&gt;
+    &lt;div id=&quot;flexItem&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;script src=&quot;../../resources/js-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description('Test to verify that the new alignment values are parsed as invalid if Grid Layout is disabled and in any case they do not cause a crash because assertions in flexbox layout code.');
+
+function checkAlignSelfValue(value, computedValue, gridEnabled)
+{
+    item.style.webkitAlignSelf = value;
+    alignSelf = getComputedStyle(item, '').getPropertyValue('-webkit-align-self');
+    if (gridEnabled)
+        shouldBe(&quot;alignSelf&quot;, computedValue);
+    else
+        shouldBe(&quot;alignSelf&quot;, &quot;'flex-start'&quot;);
+}
+
+function checkAlignItemsValue(value, computedValue, gridEnabled)
+{
+    container.style.webkitAlignItems = value;
+    alignItems = getComputedStyle(container, '').getPropertyValue('-webkit-align-items');
+    alignSelf = getComputedStyle(item, '').getPropertyValue('-webkit-align-self');
+    if (gridEnabled) {
+        shouldBe(&quot;alignItems&quot;, computedValue);
+        shouldBe(&quot;alignSelf&quot;, computedValue);
+    } else {
+        shouldBe(&quot;alignItems&quot;, &quot;'flex-end'&quot;);
+        shouldBe(&quot;alignSelf&quot;, &quot;'flex-end'&quot;);
+    }
+}
+
+function checkAlignmentValues(gridEnabled)
+{
+    if (window.internals)
+        internals.setCSSGridLayoutEnabled(gridEnabled);
+
+    debug('&lt;br&gt;Testing Self-Alignment values.');
+    checkAlignSelfValue(&quot;start unsafe&quot;, &quot;'start unsafe'&quot;, gridEnabled)
+    checkAlignSelfValue(&quot;start&quot;, &quot;'start'&quot;, gridEnabled)
+    checkAlignSelfValue(&quot;end&quot;, &quot;'end'&quot;, gridEnabled)
+    checkAlignSelfValue(&quot;flex-start safe&quot;, &quot;'flex-start safe'&quot;, gridEnabled)
+    checkAlignSelfValue(&quot;self-start&quot;, &quot;'self-start'&quot;, gridEnabled)
+    checkAlignSelfValue(&quot;self-end&quot;, &quot;'self-end'&quot;, gridEnabled)
+
+    item.style.webkitAlignSelf = &quot;auto&quot;;
+
+    debug('&lt;br&gt;Testing Default-Alignment values.');
+    checkAlignItemsValue(&quot;start unsafe&quot;, &quot;'start unsafe'&quot;, gridEnabled)
+    checkAlignItemsValue(&quot;start&quot;, &quot;'start'&quot;, gridEnabled)
+    checkAlignItemsValue(&quot;end&quot;, &quot;'end'&quot;, gridEnabled)
+    checkAlignItemsValue(&quot;flex-start safe&quot;, &quot;'flex-start safe'&quot;, gridEnabled)
+    checkAlignItemsValue(&quot;self-start&quot;, &quot;'self-start'&quot;, gridEnabled)
+    checkAlignItemsValue(&quot;self-end&quot;, &quot;'self-end'&quot;, gridEnabled)
+
+    item.style.webkitAlignSelf = &quot;flex-start&quot;;
+}
+
+var container = document.getElementById(&quot;flexContainer&quot;);
+var item = document.getElementById(&quot;flexItem&quot;);
+
+container.style.webkitAlignItems = &quot;flex-end&quot;;
+item.style.webkitAlignSelf = &quot;flex-start&quot;;
+var alignSelf = &quot;flex-start&quot;;
+var alignItems = &quot;flex-start&quot;;
+
+debug('&lt;br&gt;New alignment values should be invalid when grid layout is disabled');
+checkAlignmentValues(false);
+
+debug('&lt;br&gt;Even when grid layout is enabled, new values should not violate assertions in FlexibleBox layout logic.');
+checkAlignmentValues(true);
+
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205101 => 205102)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-28 09:35:33 UTC (rev 205101)
+++ trunk/Source/WebCore/ChangeLog        2016-08-28 14:45:43 UTC (rev 205102)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-08-28  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
+
+        Should never be reached failure in WebCore::RenderFlexibleBox::alignChildren
+        https://bugs.webkit.org/show_bug.cgi?id=151591
+        &lt;rdar://problem/27711829&gt;
+
+        Reviewed by Darin Adler.
+
+        The align-self and align-items CSS properties were originally defined in the
+        Flexbible Box specification. The new CSS Box Alignment specification tries
+        to generalize them so they can be used by other layout models, as it's  the
+        case of the GridLayout spec.
+
+        Since we have implemented the Grid Layout spec behind a runtime flag, we should
+        do the same with the new syntax of these properties.
+
+        Test: css3/flexbox/new-alignment-values-invalid-if-grid-not-enabled.html
+
+        * css/CSSParser.cpp:
+        (WebCore::isValidKeywordPropertyAndValue):
+        (WebCore::isKeywordPropertyID):
+        (WebCore::CSSParser::parseValue):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::alignChildren):
+
</ins><span class="cx"> 2016-08-28  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Improve parsing of the menclose notation attribute value
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (205101 => 205102)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSParser.cpp        2016-08-28 09:35:33 UTC (rev 205101)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp        2016-08-28 14:45:43 UTC (rev 205102)
</span><span class="lines">@@ -819,6 +819,18 @@
</span><span class="cx">         if (valueID == CSSValueAuto || valueID == CSSValueBalance)
</span><span class="cx">             return true;
</span><span class="cx">         break;
</span><ins>+    case CSSPropertyAlignItems:
+        // FIXME: Per CSS alignment, this property should accept the same arguments as 'justify-self' so we should share its parsing code.
+        // FIXME: For now, we will do it behind the GRID_LAYOUT compile flag.
+        if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
+            return true;
+        break;
+    case CSSPropertyAlignSelf:
+        // FIXME: Per CSS alignment, this property should accept the same arguments as 'justify-self' so we should share its parsing code.
+        // FIXME: For now, we will do it behind the GRID_LAYOUT compile flag.
+        if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
+            return true;
+        break;
</ins><span class="cx">     case CSSPropertyFlexDirection:
</span><span class="cx">         if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID == CSSValueColumn || valueID == CSSValueColumnReverse)
</span><span class="cx">             return true;
</span><span class="lines">@@ -1143,6 +1155,9 @@
</span><span class="cx">     case CSSPropertyFontVariantCaps:
</span><span class="cx">     case CSSPropertyFontVariantAlternates:
</span><span class="cx">         return true;
</span><ins>+    case CSSPropertyAlignItems:
+    case CSSPropertyAlignSelf:
+        return !RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled();
</ins><span class="cx">     default:
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -2723,8 +2738,10 @@
</span><span class="cx">         parsedValue = parseContentDistributionOverflowPosition();
</span><span class="cx">         break;
</span><span class="cx">     case CSSPropertyJustifySelf:
</span><ins>+        ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
</ins><span class="cx">         return parseItemPositionOverflowPosition(propId, important);
</span><span class="cx">     case CSSPropertyJustifyItems:
</span><ins>+        ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
</ins><span class="cx">         if (parseLegacyPosition(propId, important))
</span><span class="cx">             return true;
</span><span class="cx">         m_valueList-&gt;setCurrentIndex(0);
</span><span class="lines">@@ -3143,9 +3160,11 @@
</span><span class="cx">         parsedValue = parseContentDistributionOverflowPosition();
</span><span class="cx">         break;
</span><span class="cx">     case CSSPropertyAlignSelf:
</span><ins>+        ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
</ins><span class="cx">         return parseItemPositionOverflowPosition(propId, important);
</span><span class="cx"> 
</span><span class="cx">     case CSSPropertyAlignItems:
</span><ins>+        ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
</ins><span class="cx">         return parseItemPositionOverflowPosition(propId, important);
</span><span class="cx">     case CSSPropertyBorderBottomStyle:
</span><span class="cx">     case CSSPropertyBorderCollapse:
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFlexibleBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (205101 => 205102)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp        2016-08-28 09:35:33 UTC (rev 205101)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp        2016-08-28 14:45:43 UTC (rev 205102)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;LayoutRepainter.h&quot;
</span><span class="cx"> #include &quot;RenderLayer.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><ins>+#include &quot;RuntimeEnabledFeatures.h&quot;
</ins><span class="cx"> #include &lt;limits&gt;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -1397,6 +1398,8 @@
</span><span class="cx">                 // yet for FlexibleBox.
</span><span class="cx">                 // Defaulting to Stretch for now, as it what most of FlexBox based renders
</span><span class="cx">                 // expect as default.
</span><ins>+                ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
+                FALLTHROUGH;
</ins><span class="cx">             case ItemPositionStretch: {
</span><span class="cx">                 applyStretchAlignmentToChild(*child, lineCrossAxisExtent);
</span><span class="cx">                 // Since wrap-reverse flips cross start and cross end, strech children should be aligned with the cross end.
</span><span class="lines">@@ -1431,6 +1434,8 @@
</span><span class="cx">             case ItemPositionRight:
</span><span class="cx">                 // FIXME: https://webkit.org/b/135460 - The extended grammar is not supported
</span><span class="cx">                 // yet for FlexibleBox.
</span><ins>+                ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
+                break;
</ins><span class="cx">             default:
</span><span class="cx">                 ASSERT_NOT_REACHED();
</span><span class="cx">                 break;
</span></span></pre>
</div>
</div>

</body>
</html>