<!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>[184169] releases/WebKitGTK/webkit-2.8</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/184169">184169</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-05-12 01:06:53 -0700 (Tue, 12 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/183765">r183765</a> - REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/178156">r178156</a>): CSS Parser incorrectly rejects valid calc() in padding-right property
https://bugs.webkit.org/show_bug.cgi?id=144584
&lt;rdar://problem/20796829&gt;

Reviewed by Darin Adler.

Source/WebCore:

The CSS parser was rejecting calculated values at parsing time if it
considered the value was negative and the CSS property did not allow
negative values. However, doing so at this point will not always work
because we don't necessarily know the font-size yet (for e.g. for
calc(0.5em - 2px). Also, rejecting negative calculated values is not
the right behavior as the the specification. The specification says
we should clamp:
http://dev.w3.org/csswg/css-values-3/#calc-range

This patch updates validateCalculationUnit() to stop marking the value
as invalid if it is negative. Instead, let the CSSCalcValue's permitted
range clamp the value as needed.

This bug was causing the bottom graphic on aldentrio.com to not be
rendered properly.

Test: fast/css/negative-calc-values.html
      fast/css/padding-calc-value.html

* css/CSSParser.cpp:
(WebCore::CSSParser::validateCalculationUnit):

LayoutTests:

* fast/css/negative-calc-values-expected.txt: Added.
* fast/css/negative-calc-values.html: Added.
Add a layout test that assigns negative calc() values to properties
whose values cannot be negative to verify that values are clamped as
per the specification:
http://dev.w3.org/csswg/css-values-3/#calc-range

* fast/css/padding-calc-value-expected.txt: Added.
* fast/css/padding-calc-value.html: Added.
Add a layout test to test that using calc(.5em - 2px) for padding-right
CSS property works as intended. It used to be resolved as 0px instead
of &quot;2*font-size - 2px&quot;.

* fast/css/text-shadow-calc-value-expected.txt:
* fast/css/text-shadow-calc-value.html:
Update test to match what the specification says:
http://dev.w3.org/csswg/css-values-3/#calc-range
&quot;width: calc(5px - 10px);&quot; is equivalent to &quot;width: 0px;&quot; since widths
smaller than 0px are not allowed.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsfastcsstextshadowcalcvalueexpectedtxt">releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsfastcsstextshadowcalcvaluehtml">releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value.html</a></li>
<li><a href="#releasesWebKitGTKwebkit28SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit28SourceWebCorecssCSSCalculationValueh">releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSCalculationValue.h</a></li>
<li><a href="#releasesWebKitGTKwebkit28SourceWebCorecssCSSParsercpp">releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSParser.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsfastcssnegativecalcvaluesexpectedtxt">releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsfastcssnegativecalcvalueshtml">releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values.html</a></li>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsfastcsspaddingcalcvalueexpectedtxt">releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit28LayoutTestsfastcsspaddingcalcvaluehtml">releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit28LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog (184168 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog        2015-05-12 08:03:07 UTC (rev 184168)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-05-04  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        REGRESSION (r178156): CSS Parser incorrectly rejects valid calc() in padding-right property
+        https://bugs.webkit.org/show_bug.cgi?id=144584
+        &lt;rdar://problem/20796829&gt;
+
+        Reviewed by Darin Adler.
+
+        * fast/css/negative-calc-values-expected.txt: Added.
+        * fast/css/negative-calc-values.html: Added.
+        Add a layout test that assigns negative calc() values to properties
+        whose values cannot be negative to verify that values are clamped as
+        per the specification:
+        http://dev.w3.org/csswg/css-values-3/#calc-range
+
+        * fast/css/padding-calc-value-expected.txt: Added.
+        * fast/css/padding-calc-value.html: Added.
+        Add a layout test to test that using calc(.5em - 2px) for padding-right
+        CSS property works as intended. It used to be resolved as 0px instead
+        of &quot;2*font-size - 2px&quot;.
+
+        * fast/css/text-shadow-calc-value-expected.txt:
+        * fast/css/text-shadow-calc-value.html:
+        Update test to match what the specification says:
+        http://dev.w3.org/csswg/css-values-3/#calc-range
+        &quot;width: calc(5px - 10px);&quot; is equivalent to &quot;width: 0px;&quot; since widths
+        smaller than 0px are not allowed.
+
</ins><span class="cx"> 2015-05-01  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reproducible crash removing name attribute from &lt;img&gt; node
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit28LayoutTestsfastcssnegativecalcvaluesexpectedtxt"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values-expected.txt (0 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values-expected.txt                                (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values-expected.txt        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+Tests that negative calc() values are properly clamped when needed.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS testDiv.style['width'] is &quot;&quot;
+testDiv.style['width'] = '100px'
+testDiv.style['width'] = 'calc(5px - 10px)'
+PASS testDiv.style['width'] is &quot;calc(-5px)&quot;
+PASS window.getComputedStyle(testDiv).getPropertyValue('width') is &quot;0px&quot;
+testDiv.style['width'] = '100px'
+testDiv.style['width'] = 'calc(10% - 100px)'
+PASS testDiv.style['width'] is &quot;calc(10% - 100px)&quot;
+PASS window.getComputedStyle(testDiv).getPropertyValue('width') is &quot;0px&quot;
+testDiv.style['line-height'] = '10%'
+testDiv.style['line-height'] = 'calc(10% - 20%)'
+PASS testDiv.style['line-height'] is &quot;calc(-10%)&quot;
+PASS window.getComputedStyle(testDiv).getPropertyValue('line-height') is &quot;0px&quot;
+testPre.style['tab-size'] = '8'
+testPre.style['tab-size'] = 'calc(2 - 4)'
+PASS testPre.style['tab-size'] is &quot;calc(-2)&quot;
+PASS window.getComputedStyle(testPre).getPropertyValue('tab-size') is &quot;0&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit28LayoutTestsfastcssnegativecalcvalueshtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values.html (0 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/negative-calc-values.html        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -0,0 +1,36 @@
</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;position: absolute;&quot;&gt;&lt;/div&gt;
+&lt;pre id=&quot;testPre&quot;&gt;&lt;pre&gt;
+&lt;script&gt;
+description(&quot;Tests that negative calc() values are properly clamped when needed.&quot;);
+
+var testDiv = document.getElementById(&quot;testDiv&quot;);
+var testPre = document.getElementById(&quot;testPre&quot;);
+
+shouldBeEmptyString(&quot;testDiv.style['width']&quot;);
+
+evalAndLog(&quot;testDiv.style['width'] = '100px'&quot;);
+evalAndLog(&quot;testDiv.style['width'] = 'calc(5px - 10px)'&quot;);
+shouldBeEqualToString(&quot;testDiv.style['width']&quot;, &quot;calc(-5px)&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('width')&quot;, &quot;0px&quot;);
+
+evalAndLog(&quot;testDiv.style['width'] = '100px'&quot;);
+evalAndLog(&quot;testDiv.style['width'] = 'calc(10% - 100px)'&quot;);
+shouldBeEqualToString(&quot;testDiv.style['width']&quot;, &quot;calc(10% - 100px)&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('width')&quot;, &quot;0px&quot;);
+
+evalAndLog(&quot;testDiv.style['line-height'] = '10%'&quot;);
+evalAndLog(&quot;testDiv.style['line-height'] = 'calc(10% - 20%)'&quot;);
+shouldBeEqualToString(&quot;testDiv.style['line-height']&quot;, &quot;calc(-10%)&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('line-height')&quot;, &quot;0px&quot;);
+
+evalAndLog(&quot;testPre.style['tab-size'] = '8'&quot;);
+evalAndLog(&quot;testPre.style['tab-size'] = 'calc(2 - 4)'&quot;);
+shouldBeEqualToString(&quot;testPre.style['tab-size']&quot;, &quot;calc(-2)&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testPre).getPropertyValue('tab-size')&quot;, &quot;0&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="releasesWebKitGTKwebkit28LayoutTestsfastcsspaddingcalcvalueexpectedtxt"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value-expected.txt (0 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value-expected.txt                                (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value-expected.txt        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests assigning a calculated value to 'padding' CSS property.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS window.getComputedStyle(testDiv).getPropertyValue('padding-right') is &quot;11px&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit28LayoutTestsfastcsspaddingcalcvaluehtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value.html (0 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/padding-calc-value.html        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -0,0 +1,16 @@
</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;padding: 0 calc(.5em - 2px) 0 0; font-size: 26px;&quot;&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Tests assigning a calculated value to 'padding' CSS property.&quot;);
+
+var testDiv = document.getElementById(&quot;testDiv&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('padding-right')&quot;, &quot;11px&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="releasesWebKitGTKwebkit28LayoutTestsfastcsstextshadowcalcvalueexpectedtxt"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value-expected.txt (184168 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value-expected.txt        2015-05-12 08:03:07 UTC (rev 184168)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value-expected.txt        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -11,8 +11,8 @@
</span><span class="cx"> PASS testDiv.style['text-shadow'] is &quot;rgb(255, 255, 255) calc(-3px) calc(-6px) calc(9px)&quot;
</span><span class="cx"> PASS window.getComputedStyle(testDiv).getPropertyValue('text-shadow') is &quot;rgb(255, 255, 255) -3px -6px 9px&quot;
</span><span class="cx"> testDiv.style['text-shadow'] = 'calc(1 * 3px) calc(2 * 3px) calc(-3 * 3px) rgb(255, 255, 255)'
</span><del>-PASS testDiv.style['text-shadow'] is previousStyle
-PASS window.getComputedStyle(testDiv).getPropertyValue('text-shadow') is previousComputedStyle
</del><ins>+PASS testDiv.style['text-shadow'] is &quot;rgb(255, 255, 255) calc(3px) calc(6px) calc(-9px)&quot;
+PASS window.getComputedStyle(testDiv).getPropertyValue('text-shadow') is &quot;rgb(255, 255, 255) 3px 6px 0px&quot;
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit28LayoutTestsfastcsstextshadowcalcvaluehtml"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value.html (184168 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value.html        2015-05-12 08:03:07 UTC (rev 184168)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css/text-shadow-calc-value.html        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -17,14 +17,11 @@
</span><span class="cx"> shouldBeEqualToString(&quot;testDiv.style['text-shadow']&quot;, &quot;rgb(255, 255, 255) calc(-3px) calc(-6px) calc(9px)&quot;);
</span><span class="cx"> shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('text-shadow')&quot;, &quot;rgb(255, 255, 255) -3px -6px 9px&quot;)
</span><span class="cx"> 
</span><del>-var previousStyle = testDiv.style['text-shadow'];
-var previousComputedStyle = window.getComputedStyle(testDiv).getPropertyValue('text-shadow');
-
-// Negative blur-radius is not allowed.
</del><ins>+// Negative blur-radius is not allowed so it should become 0.
</ins><span class="cx"> evalAndLog(&quot;testDiv.style['text-shadow'] = 'calc(1 * 3px) calc(2 * 3px) calc(-3 * 3px) rgb(255, 255, 255)'&quot;);
</span><span class="cx"> // text-shadow should not be updated.
</span><del>-shouldBe(&quot;testDiv.style['text-shadow']&quot;, &quot;previousStyle&quot;);
-shouldBe(&quot;window.getComputedStyle(testDiv).getPropertyValue('text-shadow')&quot;, &quot;previousComputedStyle&quot;)
</del><ins>+shouldBeEqualToString(&quot;testDiv.style['text-shadow']&quot;, &quot;rgb(255, 255, 255) calc(3px) calc(6px) calc(-9px)&quot;);
+shouldBeEqualToString(&quot;window.getComputedStyle(testDiv).getPropertyValue('text-shadow')&quot;, &quot;rgb(255, 255, 255) 3px 6px 0px&quot;)
</ins><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit28SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog (184168 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog        2015-05-12 08:03:07 UTC (rev 184168)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-05-04  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        REGRESSION (r178156): CSS Parser incorrectly rejects valid calc() in padding-right property
+        https://bugs.webkit.org/show_bug.cgi?id=144584
+        &lt;rdar://problem/20796829&gt;
+
+        Reviewed by Darin Adler.
+
+        The CSS parser was rejecting calculated values at parsing time if it
+        considered the value was negative and the CSS property did not allow
+        negative values. However, doing so at this point will not always work
+        because we don't necessarily know the font-size yet (for e.g. for
+        calc(0.5em - 2px). Also, rejecting negative calculated values is not
+        the right behavior as the the specification. The specification says
+        we should clamp:
+        http://dev.w3.org/csswg/css-values-3/#calc-range
+
+        This patch updates validateCalculationUnit() to stop marking the value
+        as invalid if it is negative. Instead, let the CSSCalcValue's permitted
+        range clamp the value as needed.
+
+        This bug was causing the bottom graphic on aldentrio.com to not be
+        rendered properly.
+
+        Test: fast/css/negative-calc-values.html
+              fast/css/padding-calc-value.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::validateCalculationUnit):
+
</ins><span class="cx"> 2015-05-04  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [ARM] Don't compare unsigned chars to EOF (-1)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit28SourceWebCorecssCSSCalculationValueh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSCalculationValue.h (184168 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSCalculationValue.h        2015-05-12 08:03:07 UTC (rev 184168)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSCalculationValue.h        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -92,7 +92,6 @@
</span><span class="cx">     CalculationCategory category() const { return m_expression-&gt;category(); }
</span><span class="cx">     bool isInt() const { return m_expression-&gt;isInteger(); }
</span><span class="cx">     double doubleValue() const;
</span><del>-    bool isNegative() const { return m_expression-&gt;doubleValue() &lt; 0; }
</del><span class="cx">     bool isPositive() const { return m_expression-&gt;doubleValue() &gt; 0; }
</span><span class="cx">     double computeLengthPx(const CSSToLengthConversionData&amp;) const;
</span><span class="cx">     unsigned short primitiveType() const { return m_expression-&gt;primitiveType(); }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit28SourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSParser.cpp (184168 => 184169)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSParser.cpp        2015-05-12 08:03:07 UTC (rev 184168)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/css/CSSParser.cpp        2015-05-12 08:06:53 UTC (rev 184169)
</span><span class="lines">@@ -1649,18 +1649,12 @@
</span><span class="cx">             isValid = true;
</span><span class="cx">         if (!isValid &amp;&amp; (unitFlags &amp; FPositiveInteger) &amp;&amp; calculation-&gt;isInt() &amp;&amp; calculation-&gt;isPositive())
</span><span class="cx">             isValid = true;
</span><del>-        if (isValid &amp;&amp; mustBeNonNegative &amp;&amp; calculation-&gt;isNegative())
-            isValid = false;
</del><span class="cx">         break;
</span><span class="cx">     case CalcLength:
</span><span class="cx">         isValid = (unitFlags &amp; FLength);
</span><del>-        if (isValid &amp;&amp; mustBeNonNegative &amp;&amp; calculation-&gt;isNegative())
-            isValid = false;
</del><span class="cx">         break;
</span><span class="cx">     case CalcPercent:
</span><span class="cx">         isValid = (unitFlags &amp; FPercent);
</span><del>-        if (isValid &amp;&amp; mustBeNonNegative &amp;&amp; calculation-&gt;isNegative())
-            isValid = false;
</del><span class="cx">         break;
</span><span class="cx">     case CalcPercentLength:
</span><span class="cx">         isValid = (unitFlags &amp; FPercent) &amp;&amp; (unitFlags &amp; FLength);
</span></span></pre>
</div>
</div>

</body>
</html>