<!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>[177947] 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/177947">177947</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-01-05 20:48:25 -0800 (Mon, 05 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Using calc() in repeat() for -webkit-grid-template-rows does not work
https://bugs.webkit.org/show_bug.cgi?id=140094

Reviewed by Darin Adler.

Source/WebCore:

Using calc() in repeat() for -webkit-grid-template-rows was not working
because the CSS parser was not handling this case properly. This patch
addresses the issue.

Test: fast/css-grid-layout/grid-repeat-calc.html

* css/CSSCalculationValue.h:
(WebCore::CSSCalcValue::isPositive):
Add isPositive() method as it is needed by
CSSParser::validateCalculationUnit().

* css/CSSParser.cpp:
(WebCore::CSSParser::validateCalculationUnit):
Add support for FPositiveInteger, similarly to what was done in
validateUnit(). This would cause us to consider calc(1 + 1) as invalid
if a FPositiveInteger was requested.

(WebCore::CSSParser::parseGridTrackRepeatFunction):
Do not access fValue directly and call parsedDouble() instead as it
correctly handles calculation values.

LayoutTests:

* fast/css-grid-layout/grid-repeat-calc-expected.txt: Added.
* fast/css-grid-layout/grid-repeat-calc.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="#trunkSourceWebCorecssCSSCalculationValueh">trunk/Source/WebCore/css/CSSCalculationValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridrepeatcalcexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridrepeatcalchtml">trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (177946 => 177947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-01-06 04:46:51 UTC (rev 177946)
+++ trunk/LayoutTests/ChangeLog        2015-01-06 04:48:25 UTC (rev 177947)
</span><span class="lines">@@ -1,5 +1,15 @@
</span><span class="cx"> 2015-01-05  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Using calc() in repeat() for -webkit-grid-template-rows does not work
+        https://bugs.webkit.org/show_bug.cgi?id=140094
+
+        Reviewed by Darin Adler.
+
+        * fast/css-grid-layout/grid-repeat-calc-expected.txt: Added.
+        * fast/css-grid-layout/grid-repeat-calc.html: Added.
+
+2015-01-05  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         calc() cannot be used in steps() for -webkit-animation-timing-function
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=140091
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridrepeatcalcexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc-expected.txt (0 => 177947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc-expected.txt        2015-01-06 04:48:25 UTC (rev 177947)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Tests using calculated value in function() for '-webkit-grid-template-rows' CSS property works.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS testDiv.style['-webkit-grid-template-rows'] is &quot;&quot;
+testDiv.style['-webkit-grid-template-rows'] = 'repeat(calc(1 + 1), 18px)'
+PASS testDiv.style['-webkit-grid-template-rows'] is &quot;18px 18px&quot;
+PASS window.getComputedStyle(testDiv).getPropertyValue('-webkit-grid-template-rows') is &quot;18px 18px&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridrepeatcalchtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc.html (0 => 177947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc.html        2015-01-06 04:48:25 UTC (rev 177947)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;div id=&quot;testDiv&quot; style=&quot;width: 400px; height: 400px&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+description(&quot;Tests using calculated value in function() for '-webkit-grid-template-rows' CSS property works.&quot;);
+
+var testDiv = document.getElementById(&quot;testDiv&quot;);
+//-webkit-grid-template-rows: repeat(1, 18px);
+// -webkit-grid-template-columns: repeat(1, 15%);
+shouldBeEmptyString(&quot;testDiv.style['-webkit-grid-template-rows']&quot;);
+evalAndLog(&quot;testDiv.style['-webkit-grid-template-rows'] = 'repeat(calc(1 + 1), 18px)'&quot;);
+shouldBeEqualToString(&quot;testDiv.style['-webkit-grid-template-rows']&quot;, &quot;18px 18px&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('-webkit-grid-template-rows')&quot;, &quot;18px 18px&quot;);
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177946 => 177947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-06 04:46:51 UTC (rev 177946)
+++ trunk/Source/WebCore/ChangeLog        2015-01-06 04:48:25 UTC (rev 177947)
</span><span class="lines">@@ -1,5 +1,33 @@
</span><span class="cx"> 2015-01-05  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Using calc() in repeat() for -webkit-grid-template-rows does not work
+        https://bugs.webkit.org/show_bug.cgi?id=140094
+
+        Reviewed by Darin Adler.
+
+        Using calc() in repeat() for -webkit-grid-template-rows was not working
+        because the CSS parser was not handling this case properly. This patch
+        addresses the issue.
+
+        Test: fast/css-grid-layout/grid-repeat-calc.html
+
+        * css/CSSCalculationValue.h:
+        (WebCore::CSSCalcValue::isPositive):
+        Add isPositive() method as it is needed by
+        CSSParser::validateCalculationUnit().
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::validateCalculationUnit):
+        Add support for FPositiveInteger, similarly to what was done in
+        validateUnit(). This would cause us to consider calc(1 + 1) as invalid
+        if a FPositiveInteger was requested.
+
+        (WebCore::CSSParser::parseGridTrackRepeatFunction):
+        Do not access fValue directly and call parsedDouble() instead as it
+        correctly handles calculation values.
+
+2015-01-05  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         calc() cannot be used in steps() for -webkit-animation-timing-function
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=140091
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSCalculationValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSCalculationValue.h (177946 => 177947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSCalculationValue.h        2015-01-06 04:46:51 UTC (rev 177946)
+++ trunk/Source/WebCore/css/CSSCalculationValue.h        2015-01-06 04:48:25 UTC (rev 177947)
</span><span class="lines">@@ -93,6 +93,7 @@
</span><span class="cx">     bool isInt() const { return m_expression-&gt;isInteger(); }
</span><span class="cx">     double doubleValue() const;
</span><span class="cx">     bool isNegative() const { return m_expression-&gt;doubleValue() &lt; 0; }
</span><ins>+    bool isPositive() const { return m_expression-&gt;doubleValue() &gt; 0; }
</ins><span class="cx">     double computeLengthPx(const CSSToLengthConversionData&amp;) const;
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;CalculationValue&gt; createCalculationValue(const CSSToLengthConversionData&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (177946 => 177947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2015-01-06 04:46:51 UTC (rev 177946)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2015-01-06 04:48:25 UTC (rev 177947)
</span><span class="lines">@@ -1597,6 +1597,8 @@
</span><span class="cx">         isValid = (unitFlags &amp; FNumber);
</span><span class="cx">         if (!isValid &amp;&amp; (unitFlags &amp; FInteger) &amp;&amp; calculation-&gt;isInt())
</span><span class="cx">             isValid = true;
</span><ins>+        if (!isValid &amp;&amp; (unitFlags &amp; FPositiveInteger) &amp;&amp; calculation-&gt;isInt() &amp;&amp; calculation-&gt;isPositive())
+            isValid = true;
</ins><span class="cx">         if (isValid &amp;&amp; mustBeNonNegative &amp;&amp; calculation-&gt;isNegative())
</span><span class="cx">             isValid = false;
</span><span class="cx">         break;
</span><span class="lines">@@ -5313,11 +5315,9 @@
</span><span class="cx">     if (!validateUnit(firstValueWithCalculation, FPositiveInteger) || !isComma(arguments-&gt;valueAt(1)))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    // FIXME: This doesn't handle calculated values.
-    ASSERT(firstValueWithCalculation.value().fValue &gt; 0);
</del><span class="cx">     // If arguments-&gt;valueAt(0)-&gt;fValue &gt; SIZE_MAX then repetitions becomes 0 during the type casting, that's why we
</span><span class="cx">     // clamp it down to kGridMaxTracks before the type casting.
</span><del>-    unsigned repetitions = clampTo&lt;unsigned&gt;(firstValueWithCalculation.value().fValue, 0, kGridMaxTracks);
</del><ins>+    unsigned repetitions = clampTo&lt;unsigned&gt;(parsedDouble(firstValueWithCalculation), 0, kGridMaxTracks);
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;CSSValueList&gt; repeatedValues = CSSValueList::createSpaceSeparated();
</span><span class="cx">     arguments-&gt;next(); // Skip the repetition count.
</span></span></pre>
</div>
</div>

</body>
</html>