<!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>[192161] 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/192161">192161</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-11-09 10:10:29 -0800 (Mon, 09 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/190883">r190883</a>): Error calculating the tile size for an SVG with no intrinsic size but with large floating intrinsic ratio
https://bugs.webkit.org/show_bug.cgi?id=150904

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2015-11-09
Reviewed by Darin Adler.
Source/WebCore:

This patch addresses two issues. The first one is a regression from <a href="http://trac.webkit.org/projects/webkit/changeset/190883">r190883</a>
which was rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/184895">r184895</a>. There was a missing if-statement in
RenderBoxModelObject::calculateImageIntrinsicDimension(). We should return
it back. But this if-statement is an optimization; if we hit it we should
return the image resolvedSize. But we should also return the same result
if we call resolveAgainstIntrinsicWidthOrHeightAndRatio().

We had a bug in resolving the intrinsic size of an image using a large
intrinsic ratio. We need to do the calculation in LayoutUnits always.
Using float calculations and then casting the output to an integer results
in significant truncation if the intrinsic ratio is large.

Test: fast/backgrounds/background-image-large-float-intrinsic-ratio.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::resolveWidthForRatio):
(WebCore::resolveHeightForRatio):
(WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio):
(WebCore::resolveAgainstIntrinsicRatio):
Resolve the image size using its intrinsic ratio in LayoutUnits.

(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
Put back an if-statement which was missing from rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/184895">r184895</a>

LayoutTests:

Make sure the image resolvedSize is calculated correctly when the intrinsic
ratio is a large non integer value.

* fast/backgrounds/background-image-large-float-intrinsic-ratio-expected.html: Added.
* fast/backgrounds/background-image-large-float-intrinsic-ratio.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="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastbackgroundsbackgroundimagelargefloatintrinsicratioexpectedhtml">trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastbackgroundsbackgroundimagelargefloatintrinsicratiohtml">trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192160 => 192161)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-09 18:06:51 UTC (rev 192160)
+++ trunk/LayoutTests/ChangeLog        2015-11-09 18:10:29 UTC (rev 192161)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-11-09  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        REGRESSION (r190883): Error calculating the tile size for an SVG with no intrinsic size but with large floating intrinsic ratio
+        https://bugs.webkit.org/show_bug.cgi?id=150904
+
+        Reviewed by Darin Adler.
+
+        Make sure the image resolvedSize is calculated correctly when the intrinsic
+        ratio is a large non integer value.
+
+        * fast/backgrounds/background-image-large-float-intrinsic-ratio-expected.html: Added.
+        * fast/backgrounds/background-image-large-float-intrinsic-ratio.html: Added.
+
</ins><span class="cx"> 2015-11-09  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking jquery/manipulation.html as a flaky timeout on Win debug
</span></span></pre></div>
<a id="trunkLayoutTestsfastbackgroundsbackgroundimagelargefloatintrinsicratioexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio-expected.html (0 => 192161)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio-expected.html        2015-11-09 18:10:29 UTC (rev 192161)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        div {
+            height: 100px;
+            width: 100px;
+            display: inline-block;
+            border: 1px solid green;
+            margin: 10px;
+            background-color: green;
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;div&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastbackgroundsbackgroundimagelargefloatintrinsicratiohtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio.html (0 => 192161)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio.html                                (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/background-image-large-float-intrinsic-ratio.html        2015-11-09 18:10:29 UTC (rev 192161)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        div {
+            background-position: -4000px 0;
+            background-size: auto 100px;
+            height: 100px;
+            width: 100px;
+            display: inline-block;
+            border: 1px solid green;
+            margin: 10px;
+        }
+        .intrinsic-size {
+            background-image: url(&quot;data:image/svg+xml;utf-8, \
+                &lt;svg version='1.1' xmlns='http://www.w3.org/2000/svg' width='8000.8px' height='100px'&gt; \
+                    &lt;rect x='4000' y='0' width='101' height='100' fill='green'/&gt; \
+                &lt;/svg&gt;&quot;);
+        }
+        .non-intrinsic-size {
+            background-image: url(&quot;data:image/svg+xml;utf-8, \
+                &lt;svg version='1.1' xmlns='http://www.w3.org/2000/svg' width='8000.8px' viewBox='0 0 8000.8 100'&gt; \
+                    &lt;rect x='4000' y='0' width='101' height='100' fill='green'/&gt; \
+                &lt;/svg&gt;&quot;);
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div class=&quot;intrinsic-size&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;non-intrinsic-size&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192160 => 192161)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-09 18:06:51 UTC (rev 192160)
+++ trunk/Source/WebCore/ChangeLog        2015-11-09 18:10:29 UTC (rev 192161)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2015-11-09  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        REGRESSION (r190883): Error calculating the tile size for an SVG with no intrinsic size but with large floating intrinsic ratio
+        https://bugs.webkit.org/show_bug.cgi?id=150904
+
+        Reviewed by Darin Adler.
+        
+        This patch addresses two issues. The first one is a regression from r190883
+        which was rolling out r184895. There was a missing if-statement in 
+        RenderBoxModelObject::calculateImageIntrinsicDimension(). We should return
+        it back. But this if-statement is an optimization; if we hit it we should
+        return the image resolvedSize. But we should also return the same result
+        if we call resolveAgainstIntrinsicWidthOrHeightAndRatio().
+        
+        We had a bug in resolving the intrinsic size of an image using a large
+        intrinsic ratio. We need to do the calculation in LayoutUnits always.
+        Using float calculations and then casting the output to an integer results
+        in significant truncation if the intrinsic ratio is large.
+
+        Test: fast/backgrounds/background-image-large-float-intrinsic-ratio.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::resolveWidthForRatio):
+        (WebCore::resolveHeightForRatio):
+        (WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio):
+        (WebCore::resolveAgainstIntrinsicRatio):
+        Resolve the image size using its intrinsic ratio in LayoutUnits.
+        
+        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
+        Put back an if-statement which was missing from rolling out r184895
+
</ins><span class="cx"> 2015-11-09  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         [Streams API] Activate assertions
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (192160 => 192161)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-11-09 18:06:51 UTC (rev 192160)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-11-09 18:10:29 UTC (rev 192161)
</span><span class="lines">@@ -845,17 +845,17 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline int resolveWidthForRatio(LayoutUnit height, const FloatSize&amp; intrinsicRatio)
</del><ins>+static inline LayoutUnit resolveWidthForRatio(LayoutUnit height, const LayoutSize&amp; intrinsicRatio)
</ins><span class="cx"> {
</span><span class="cx">     return height * intrinsicRatio.width() / intrinsicRatio.height();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline int resolveHeightForRatio(LayoutUnit width, const FloatSize&amp; intrinsicRatio)
</del><ins>+static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const LayoutSize&amp; intrinsicRatio)
</ins><span class="cx"> {
</span><span class="cx">     return width * intrinsicRatio.height() / intrinsicRatio.width();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const LayoutSize&amp; size, const FloatSize&amp; intrinsicRatio, LayoutUnit useWidth, LayoutUnit useHeight)
</del><ins>+static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const LayoutSize&amp; size, const LayoutSize&amp; intrinsicRatio, LayoutUnit useWidth, LayoutUnit useHeight)
</ins><span class="cx"> {
</span><span class="cx">     if (intrinsicRatio.isEmpty()) {
</span><span class="cx">         if (useWidth)
</span><span class="lines">@@ -868,7 +868,7 @@
</span><span class="cx">     return LayoutSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline LayoutSize resolveAgainstIntrinsicRatio(const LayoutSize&amp; size, const FloatSize&amp; intrinsicRatio)
</del><ins>+static inline LayoutSize resolveAgainstIntrinsicRatio(const LayoutSize&amp; size, const LayoutSize&amp; intrinsicRatio)
</ins><span class="cx"> {
</span><span class="cx">     // Two possible solutions: (size.width(), solutionHeight) or (solutionWidth, size.height())
</span><span class="cx">     // &quot;... must be assumed to be the largest dimensions...&quot; = easiest answer: the rect with the largest surface area.
</span><span class="lines">@@ -915,18 +915,21 @@
</span><span class="cx">         resolvedSize.scale(style().effectiveZoom());
</span><span class="cx">     resolvedSize.clampToMinimumSize(minimumSize);
</span><span class="cx"> 
</span><ins>+    if (!resolvedSize.isEmpty())
+        return resolvedSize;
+
</ins><span class="cx">     // If the image has one of either an intrinsic width or an intrinsic height:
</span><span class="cx">     // * and an intrinsic aspect ratio, then the missing dimension is calculated from the given dimension and the ratio.
</span><span class="cx">     // * and no intrinsic aspect ratio, then the missing dimension is assumed to be the size of the rectangle that
</span><span class="cx">     //   establishes the coordinate system for the 'background-position' property.
</span><span class="cx">     if (resolvedSize.width() &gt; 0 || resolvedSize.height() &gt; 0)
</span><del>-        return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedSize.width(), resolvedSize.height());
</del><ins>+        return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, LayoutSize(intrinsicRatio), resolvedSize.width(), resolvedSize.height());
</ins><span class="cx"> 
</span><span class="cx">     // If the image has no intrinsic dimensions and has an intrinsic ratio the dimensions must be assumed to be the
</span><span class="cx">     // largest dimensions at that ratio such that neither dimension exceeds the dimensions of the rectangle that
</span><span class="cx">     // establishes the coordinate system for the 'background-position' property.
</span><span class="cx">     if (!intrinsicRatio.isEmpty())
</span><del>-        return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
</del><ins>+        return resolveAgainstIntrinsicRatio(positioningAreaSize, LayoutSize(intrinsicRatio));
</ins><span class="cx"> 
</span><span class="cx">     // If the image has no intrinsic ratio either, then the dimensions must be assumed to be the rectangle that
</span><span class="cx">     // establishes the coordinate system for the 'background-position' property.
</span></span></pre>
</div>
</div>

</body>
</html>