<!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>[209526] 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/209526">209526</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2016-12-07 22:29:46 -0800 (Wed, 07 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION: font shorthand parsing is broken
https://bugs.webkit.org/show_bug.cgi?id=165594

Reviewed by Zalan Bujtas.

Source/WebCore:

Unskipping fast/css/font-calculated-value.html.

* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFontWeight):
The new parser did not support calc() in the font-weight property.
In order to support a positive integer, add new functions to consume
and handle positive integers without making a CSSPrimitiveValue out of
the number. These correspond to consumeNumberRaw but are limited to positive
integers.

(WebCore::CSSPropertyParser::consumeFont):
The implicit bool was incorrectly set to true when properties were
defined because releaseNonNull() cleared the variables being null
checked. Add separate booleans to avoid this.

* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::CalcParser::consumePositiveIntegerRaw):
(WebCore::CSSPropertyParserHelpers::consumePositiveIntegerRaw):
* css/parser/CSSPropertyParserHelpers.h:
Add the new helpers that consume positive integers without creating
CSSPrimitiveValues out of them.

LayoutTests:

* TestExpectations:
* fast/css/font-shorthand-html-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsfastcssfontshorthandexpectedtxt">trunk/LayoutTests/fast/css/font-shorthand-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParsercpp">trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParserHelperscpp">trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParserHelpersh">trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/LayoutTests/ChangeLog        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-12-07  Dave Hyatt  &lt;hyatt@apple.com&gt;
+
+        REGRESSION: font shorthand parsing is broken
+        https://bugs.webkit.org/show_bug.cgi?id=165594
+
+        Reviewed by Zalan Bujtas.
+
+        * TestExpectations:
+        * fast/css/font-shorthand-html-expected.txt:
+
</ins><span class="cx"> 2016-12-07  Jeremy Jones  &lt;jeremyj@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Exit pointer lock when page goes into page cache.
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/LayoutTests/TestExpectations        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -1030,8 +1030,6 @@
</span><span class="cx"> webkit.org/b/165195 fast/css-grid-layout/grid-columns-rows-get-set.html [ Pass Failure ]
</span><span class="cx"> webkit.org/b/165195 fast/css-grid-layout/non-grid-columns-rows-get-set.html [ Pass Failure ]
</span><span class="cx"> webkit.org/b/165195 fast/masking/parsing-mask.html [ Pass Failure ]
</span><del>-webkit.org/b/165195 fast/css/font-calculated-value.html [ Pass Failure ]
-webkit.org/b/165195 fast/css/font-shorthand.html [ Pass Failure ]
</del><span class="cx"> webkit.org/b/165195 fast/shadow-dom/slotted-pseudo-element-css-text.html [ Pass Failure ]
</span><span class="cx"> 
</span><span class="cx"> # The following tests match Blink/Chrome, but we're not sure yet what to do with them when the
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssfontshorthandexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/font-shorthand-expected.txt (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/font-shorthand-expected.txt        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/LayoutTests/fast/css/font-shorthand-expected.txt        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -49,16 +49,16 @@
</span><span class="cx"> 
</span><span class="cx"> Font for 'italic bold 12px/24px serif':
</span><span class="cx"> font-style: italic (original property was font)
</span><ins>+font-variant-caps: normal (original property was font and property was implicitly set.)
</ins><span class="cx"> font-weight: bold (original property was font)
</span><del>-font-variant-caps: normal (original property was font and property was implicitly set.)
</del><span class="cx"> font-size: 12px (original property was font)
</span><span class="cx"> line-height: 24px (original property was font)
</span><span class="cx"> font-family: serif (original property was font)
</span><span class="cx"> 
</span><span class="cx"> Font for 'small-caps bold 14px/28px Arial, sans-serif':
</span><ins>+font-style: normal (original property was font and property was implicitly set.)
</ins><span class="cx"> font-variant-caps: small-caps (original property was font)
</span><span class="cx"> font-weight: bold (original property was font)
</span><del>-font-style: normal (original property was font and property was implicitly set.)
</del><span class="cx"> font-size: 14px (original property was font)
</span><span class="cx"> line-height: 28px (original property was font)
</span><span class="cx"> font-family: Arial, sans-serif (original property was font)
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/Source/WebCore/ChangeLog        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-12-07  Dave Hyatt  &lt;hyatt@apple.com&gt;
+
+        REGRESSION: font shorthand parsing is broken
+        https://bugs.webkit.org/show_bug.cgi?id=165594
+
+        Reviewed by Zalan Bujtas.
+
+        Unskipping fast/css/font-calculated-value.html.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeFontWeight):
+        The new parser did not support calc() in the font-weight property.
+        In order to support a positive integer, add new functions to consume
+        and handle positive integers without making a CSSPrimitiveValue out of
+        the number. These correspond to consumeNumberRaw but are limited to positive
+        integers.
+
+        (WebCore::CSSPropertyParser::consumeFont):
+        The implicit bool was incorrectly set to true when properties were
+        defined because releaseNonNull() cleared the variables being null
+        checked. Add separate booleans to avoid this.
+
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::CalcParser::consumePositiveIntegerRaw):
+        (WebCore::CSSPropertyParserHelpers::consumePositiveIntegerRaw):
+        * css/parser/CSSPropertyParserHelpers.h:
+        Add the new helpers that consume positive integers without creating
+        CSSPrimitiveValues out of them.
+
</ins><span class="cx"> 2016-12-07  Jeremy Jones  &lt;jeremyj@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Exit pointer lock when page goes into page cache.
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -862,12 +862,11 @@
</span><span class="cx">     const CSSParserToken&amp; token = range.peek();
</span><span class="cx">     if (token.id() &gt;= CSSValueNormal &amp;&amp; token.id() &lt;= CSSValueLighter)
</span><span class="cx">         return consumeIdent(range);
</span><del>-    if (token.type() != NumberToken || token.numericValueType() != IntegerValueType)
</del><ins>+    int weight;
+    if (!consumePositiveIntegerRaw(range, weight))
</ins><span class="cx">         return nullptr;
</span><del>-    int weight = static_cast&lt;int&gt;(token.numericValue());
</del><span class="cx">     if ((weight % 100) || weight &lt; 100 || weight &gt; 900)
</span><span class="cx">         return nullptr;
</span><del>-    range.consumeIncludingWhitespace();
</del><span class="cx">     return CSSValuePool::singleton().createIdentifierValue(static_cast&lt;CSSValueID&gt;(CSSValue100 + weight / 100 - 1));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4333,6 +4332,7 @@
</span><span class="cx">     RefPtr&lt;CSSPrimitiveValue&gt; fontStyle;
</span><span class="cx">     RefPtr&lt;CSSPrimitiveValue&gt; fontVariantCaps;
</span><span class="cx">     RefPtr&lt;CSSPrimitiveValue&gt; fontWeight;
</span><ins>+    
</ins><span class="cx">     // FIXME-NEWPARSER: Implement. RefPtr&lt;CSSPrimitiveValue&gt; fontStretch;
</span><span class="cx">     while (!m_range.atEnd()) {
</span><span class="cx">         CSSValueID id = m_range.peek().id();
</span><span class="lines">@@ -4362,8 +4362,12 @@
</span><span class="cx">     if (m_range.atEnd())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? fontStyle.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !fontStyle);
-    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, fontVariantCaps ? fontVariantCaps.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !fontVariantCaps);
</del><ins>+    bool hasStyle = fontStyle;
+    bool hasVariant = fontVariantCaps;
+    bool hasWeight = fontWeight;
+    
+    addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? fontStyle.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !hasStyle);
+    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, fontVariantCaps ? fontVariantCaps.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !hasVariant);
</ins><span class="cx"> /*  
</span><span class="cx">     // FIXME-NEWPARSER: What do we do with these? They aren't part of our fontShorthand().
</span><span class="cx">     addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, true);
</span><span class="lines">@@ -4370,10 +4374,7 @@
</span><span class="cx">     addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, true);
</span><span class="cx"> */
</span><span class="cx">     
</span><del>-    addProperty(CSSPropertyFontWeight, CSSPropertyFont, fontWeight ? fontWeight.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !fontWeight);
-    /* FIXME-NEWPARSER: Implement.
-    addProperty(CSSPropertyFontStretch, CSSPropertyFont, fontStretch ? fontStretch.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !fontStretch);
-    */
</del><ins>+    addProperty(CSSPropertyFontWeight, CSSPropertyFont, fontWeight ? fontWeight.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !hasWeight);
</ins><span class="cx"> 
</span><span class="cx">     // Now a font size _must_ come.
</span><span class="cx">     RefPtr&lt;CSSValue&gt; fontSize = consumeFontSize(m_range, m_context.mode);
</span><span class="lines">@@ -4398,9 +4399,6 @@
</span><span class="cx"> 
</span><span class="cx">     addProperty(CSSPropertyFontFamily, CSSPropertyFont, parsedFamilyValue.releaseNonNull(), important);
</span><span class="cx"> 
</span><del>-    // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requires that
-    // &quot;font-stretch&quot;, &quot;font-size-adjust&quot;, and &quot;font-kerning&quot; be reset to their initial values
-    // but we don't seem to support them at the moment. They should also be added here once implemented.
</del><span class="cx">     return m_range.atEnd();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParserHelperscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -111,6 +111,17 @@
</span><span class="cx">         result = m_calcValue-&gt;doubleValue();
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><ins>+    
+    bool consumePositiveIntegerRaw(int&amp; result)
+    {
+        if (!m_calcValue || m_calcValue-&gt;category() != CalcNumber || !m_calcValue-&gt;isInt())
+            return false;
+        result = static_cast&lt;int&gt;(m_calcValue-&gt;doubleValue());
+        if (result &lt; 1)
+            return false;
+        m_sourceRange = m_range;
+        return true;
+    }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     CSSParserTokenRange&amp; m_sourceRange;
</span><span class="lines">@@ -143,6 +154,19 @@
</span><span class="cx">     return consumeInteger(range, 1);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool consumePositiveIntegerRaw(CSSParserTokenRange&amp; range, int&amp; result)
+{
+    const CSSParserToken&amp; token = range.peek();
+    if (token.type() == NumberToken) {
+        if (token.numericValueType() == NumberValueType || token.numericValue() &lt; 1)
+            return nullptr;
+        result = range.consumeIncludingWhitespace().numericValue();
+        return true;
+    }
+    CalcParser calcParser(range);
+    return calcParser.consumePositiveIntegerRaw(result);
+}
+    
</ins><span class="cx"> bool consumeNumberRaw(CSSParserTokenRange&amp; range, double&amp; result)
</span><span class="cx"> {
</span><span class="cx">     if (range.peek().type() == NumberToken) {
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParserHelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h (209525 => 209526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h        2016-12-08 06:19:57 UTC (rev 209525)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h        2016-12-08 06:29:46 UTC (rev 209526)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;CSSPrimitiveValue&gt; consumeInteger(CSSParserTokenRange&amp;, double minimumValue = -std::numeric_limits&lt;double&gt;::max());
</span><ins>+bool consumePositiveIntegerRaw(CSSParserTokenRange&amp;, int&amp; result);
</ins><span class="cx"> RefPtr&lt;CSSPrimitiveValue&gt; consumePositiveInteger(CSSParserTokenRange&amp;);
</span><span class="cx"> bool consumeNumberRaw(CSSParserTokenRange&amp;, double&amp; result);
</span><span class="cx"> RefPtr&lt;CSSPrimitiveValue&gt; consumeNumber(CSSParserTokenRange&amp;, ValueRange);
</span></span></pre>
</div>
</div>

</body>
</html>