<!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>[196960] 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/196960">196960</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-02-22 14:26:23 -0800 (Mon, 22 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Repeated background images have the wrong position when using bottom/right-relative background-position
https://bugs.webkit.org/show_bug.cgi?id=154478

Reviewed by Dave Hyatt.
Source/WebCore:

Fix RenderBoxModelObject::calculateBackgroundImageGeometry() to use the right position when
painting repeated background images when right/bottom edges are used.

Also rename BackgroundEdgeOrigin to Edge

Test: fast/images/background-position.html

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator Edge):
(WebCore::CSSPrimitiveValue::operator BackgroundEdgeOrigin): Deleted.
* rendering/RenderBoxModelObject.cpp:
(WebCore::resolveEdgeRelativeLength):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::FillLayer):
* rendering/style/FillLayer.h:
(WebCore::FillLayer::backgroundXOrigin):
(WebCore::FillLayer::backgroundYOrigin):
(WebCore::FillLayer::setBackgroundXOrigin):
(WebCore::FillLayer::setBackgroundYOrigin):
* rendering/style/RenderStyleConstants.cpp:
(WebCore::operator&lt;&lt;):
* rendering/style/RenderStyleConstants.h:

LayoutTests:

Enhanced background-position-serialize.html to test values that use right/bottom edge specifiers.

Ref test for background-position.

* fast/css/background-position-serialize-expected.txt:
* fast/css/background-position-serialize.html:
* fast/images/background-position-expected.html: Added.
* fast/images/background-position.html: Added.
* fast/images/resources/checker.png: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcssbackgroundpositionserializeexpectedtxt">trunk/LayoutTests/fast/css/background-position-serialize-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssbackgroundpositionserializehtml">trunk/LayoutTests/fast/css/background-position-serialize.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSPrimitiveValueMappingsh">trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayercpp">trunk/Source/WebCore/rendering/style/FillLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayerh">trunk/Source/WebCore/rendering/style/FillLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStyleConstantscpp">trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStyleConstantsh">trunk/Source/WebCore/rendering/style/RenderStyleConstants.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastimagesbackgroundpositionexpectedhtml">trunk/LayoutTests/fast/images/background-position-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesbackgroundpositionhtml">trunk/LayoutTests/fast/images/background-position.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/LayoutTests/ChangeLog        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-02-22  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Repeated background images have the wrong position when using bottom/right-relative background-position
+        https://bugs.webkit.org/show_bug.cgi?id=154478
+
+        Reviewed by Dave Hyatt.
+        
+        Enhanced background-position-serialize.html to test values that use right/bottom edge specifiers.
+        
+        Ref test for background-position.
+
+        * fast/css/background-position-serialize-expected.txt:
+        * fast/css/background-position-serialize.html:
+        * fast/images/background-position-expected.html: Added.
+        * fast/images/background-position.html: Added.
+        * fast/images/resources/checker.png: Added.
+
</ins><span class="cx"> 2016-02-22  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Font Loading] Split CSSFontSelector into a FontFaceSet implementation and the rest of the class
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssbackgroundpositionserializeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/background-position-serialize-expected.txt (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/background-position-serialize-expected.txt        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/LayoutTests/fast/css/background-position-serialize-expected.txt        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -56,6 +56,19 @@
</span><span class="cx"> PASS: t.style.backgroundPositionX should be 10px, 20px, 30px and is.
</span><span class="cx"> PASS: t.style.backgroundPositionY should be 15px, 25px, 35px and is.
</span><span class="cx"> PASS: t.style.cssText should be background-position: 10px 15px, 20px 25px, 30px 35px; and is.
</span><ins>+t.setAttribute('style', 'background-position: bottom 10px right 20px');
+PASS: t.style.backgroundPosition should be right 20px bottom 10px and is.
+PASS: window.getComputedStyle(t).backgroundPosition should be right 20px bottom 10px and is.
+t.setAttribute('style', 'background-position: top 10px right 20px');
+PASS: t.style.backgroundPosition should be right 20px top 10px and is.
+PASS: window.getComputedStyle(t).backgroundPosition should be right 20px top 10px and is.
+t.setAttribute('style', 'background-position: 50% left');
+PASS: t.style.backgroundPosition should be and is.
+t.setAttribute('style', 'background-position-x: right 20px');
+PASS: window.getComputedStyle(t).backgroundPositionX should be 0% and is.
+t.setAttribute('style', 'background-position: right 20px bottom 10px');
+PASS: window.getComputedStyle(t).backgroundPosition should be right 20px bottom 10px and is.
+PASS: window.getComputedStyle(t).backgroundPositionX should be 20px and is.
</ins><span class="cx"> t.setAttribute('style', 'background: url(about:blank) 80% 80%;');
</span><span class="cx"> t.style.backgroundPositionY = '50px'
</span><span class="cx"> style.cssText =
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssbackgroundpositionserializehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/background-position-serialize.html (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/background-position-serialize.html        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/LayoutTests/fast/css/background-position-serialize.html        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;body&gt;
</span><del>-&lt;div id=t&gt;&lt;/div&gt;
-&lt;div id=console&gt;&lt;/div&gt;
</del><ins>+&lt;div id=&quot;t&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;script&gt;
</span><span class="cx"> function print(message, color) 
</span><span class="cx"> {
</span><span class="lines">@@ -111,6 +111,24 @@
</span><span class="cx"> shouldBe(&quot;t.style.backgroundPositionY&quot;, &quot;15px, 25px, 35px&quot;);
</span><span class="cx"> shouldBe(&quot;t.style.cssText&quot;, &quot;background-position: 10px 15px, 20px 25px, 30px 35px;&quot;);
</span><span class="cx"> 
</span><ins>+run(&quot;t.setAttribute('style', 'background-position: bottom 10px right 20px');&quot;);
+shouldBe(&quot;t.style.backgroundPosition&quot;, &quot;right 20px bottom 10px&quot;);
+shouldBe(&quot;window.getComputedStyle(t).backgroundPosition&quot;, &quot;right 20px bottom 10px&quot;);
+
+run(&quot;t.setAttribute('style', 'background-position: top 10px right 20px');&quot;);
+shouldBe(&quot;t.style.backgroundPosition&quot;, &quot;right 20px top 10px&quot;);
+shouldBe(&quot;window.getComputedStyle(t).backgroundPosition&quot;, &quot;right 20px top 10px&quot;);
+
+run(&quot;t.setAttribute('style', 'background-position: 50% left');&quot;); // Invalid per spec.
+shouldBe(&quot;t.style.backgroundPosition&quot;, &quot;&quot;);
+
+run(&quot;t.setAttribute('style', 'background-position-x: right 20px');&quot;); // This does not parse, but perhaps it should.
+shouldBe(&quot;window.getComputedStyle(t).backgroundPositionX&quot;, &quot;0%&quot;);
+
+run(&quot;t.setAttribute('style', 'background-position: right 20px bottom 10px');&quot;);
+shouldBe(&quot;window.getComputedStyle(t).backgroundPosition&quot;, &quot;right 20px bottom 10px&quot;);
+shouldBe(&quot;window.getComputedStyle(t).backgroundPositionX&quot;, &quot;20px&quot;); // This is a bug. webkit.org/b/154551
+
</ins><span class="cx"> run(&quot;t.setAttribute('style', 'background: url(about:blank) 80% 80%;');&quot;);
</span><span class="cx"> run(&quot;t.style.backgroundPositionY = '50px'&quot;);
</span><span class="cx"> print(&quot;style.cssText =&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagesbackgroundpositionexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/background-position-expected.html (0 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/background-position-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/images/background-position-expected.html        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            width: 100px;
+            height: 100px;
+            margin: 10px;
+            border: 2px solid gray;
+            display: inline-block;
+            position: relative;
+        }
+        .box {
+            position: absolute;
+            width: 100px;
+            height: 100px;
+            background-image: url('resources/checker.png');
+            background-repeat: no-repeat;
+        }
+        
+        .repeat .box {
+            background-repeat: repeat;
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 0 0&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10px 20px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 5px 25px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 25px 5px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 45px 25px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 100% 25px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;repeat&quot;&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 0 0&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10px 20px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 5px 25px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 25px 5px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 45px 25px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 100% 25px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;repeat&quot;&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 0 0; -webkit-clip-path: inset(0 50px 50px 0);&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10px 20px; -webkit-clip-path: inset(20px 40px 30px 10px);&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 5px 25px; -webkit-clip-path: inset(25px 45px 25px 5px);&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 25px 5px; -webkit-clip-path: inset(5px 25px 45px 25px);&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 45px 25px; -webkit-clip-path: inset(25px 5px 25px 45px);&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 100% 25px; -webkit-clip-path: inset(25px 0 25px 50px);&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesbackgroundpositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/background-position.html (0 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/background-position.html                                (rev 0)
+++ trunk/LayoutTests/fast/images/background-position.html        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            width: 100px;
+            height: 100px;
+            margin: 10px;
+            border: 2px solid gray;
+            display: inline-block;
+            position: relative;
+        }
+        .box {
+            position: absolute;
+            width: 100px;
+            height: 100px;
+            background-image: url('resources/checker.png');
+            background-repeat: no-repeat;
+        }
+        
+        .repeat .box {
+            background-repeat: repeat;
+        }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 0 0&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10px 20px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10% 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: top 10% left 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: right 10% bottom 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: center right&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;repeat&quot;&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 0 0&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10px 20px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10% 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: top 10% left 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: right 10% bottom 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: center right&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+    &lt;div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 0 0&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10px 20px&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: 10% 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: top 10% left 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: right 10% bottom 50%&quot;&gt;&lt;/div&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;container&quot;&gt;
+            &lt;div class=&quot;box&quot; style=&quot;background-position: center right&quot;&gt;&lt;/div&gt;
+        &lt;/div&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 (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/ChangeLog        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-02-22  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Repeated background images have the wrong position when using bottom/right-relative background-position
+        https://bugs.webkit.org/show_bug.cgi?id=154478
+
+        Reviewed by Dave Hyatt.
+
+        Fix RenderBoxModelObject::calculateBackgroundImageGeometry() to use the right position when
+        painting repeated background images when right/bottom edges are used.
+
+        Also rename BackgroundEdgeOrigin to Edge
+
+        Test: fast/images/background-position.html
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator Edge):
+        (WebCore::CSSPrimitiveValue::operator BackgroundEdgeOrigin): Deleted.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::resolveEdgeRelativeLength):
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+        * rendering/style/FillLayer.cpp:
+        (WebCore::FillLayer::FillLayer):
+        * rendering/style/FillLayer.h:
+        (WebCore::FillLayer::backgroundXOrigin):
+        (WebCore::FillLayer::backgroundYOrigin):
+        (WebCore::FillLayer::setBackgroundXOrigin):
+        (WebCore::FillLayer::setBackgroundYOrigin):
+        * rendering/style/RenderStyleConstants.cpp:
+        (WebCore::operator&lt;&lt;):
+        * rendering/style/RenderStyleConstants.h:
+
</ins><span class="cx"> 2016-02-22  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r196935.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPrimitiveValueMappingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -902,45 +902,45 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-template&lt;&gt; inline CSSPrimitiveValue::CSSPrimitiveValue(BackgroundEdgeOrigin e)
</del><ins>+template&lt;&gt; inline CSSPrimitiveValue::CSSPrimitiveValue(Edge e)
</ins><span class="cx">     : CSSValue(PrimitiveClass)
</span><span class="cx"> {
</span><span class="cx">     m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">     switch (e) {
</span><del>-    case TopEdge:
</del><ins>+    case Edge::Top:
</ins><span class="cx">         m_value.valueID = CSSValueTop;
</span><span class="cx">         break;
</span><del>-    case RightEdge:
</del><ins>+    case Edge::Right:
</ins><span class="cx">         m_value.valueID = CSSValueRight;
</span><span class="cx">         break;
</span><del>-    case BottomEdge:
</del><ins>+    case Edge::Bottom:
</ins><span class="cx">         m_value.valueID = CSSValueBottom;
</span><span class="cx">         break;
</span><del>-    case LeftEdge:
</del><ins>+    case Edge::Left:
</ins><span class="cx">         m_value.valueID = CSSValueLeft;
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;&gt; inline CSSPrimitiveValue::operator BackgroundEdgeOrigin() const
</del><ins>+template&lt;&gt; inline CSSPrimitiveValue::operator Edge() const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isValueID());
</span><span class="cx"> 
</span><span class="cx">     switch (m_value.valueID) {
</span><span class="cx">     case CSSValueTop:
</span><del>-        return TopEdge;
</del><ins>+        return Edge::Top;
</ins><span class="cx">     case CSSValueRight:
</span><del>-        return RightEdge;
</del><ins>+        return Edge::Right;
</ins><span class="cx">     case CSSValueBottom:
</span><del>-        return BottomEdge;
</del><ins>+        return Edge::Bottom;
</ins><span class="cx">     case CSSValueLeft:
</span><del>-        return LeftEdge;
</del><ins>+        return Edge::Left;
</ins><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return TopEdge;
</del><ins>+    return Edge::Top;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxSizing e)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -1044,6 +1044,19 @@
</span><span class="cx">     return space;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static LayoutUnit resolveEdgeRelativeLength(const Length&amp; length, Edge edge, LayoutUnit availableSpace, const LayoutSize&amp; areaSize, const LayoutSize&amp; tileSize)
+{
+    LayoutUnit result = minimumValueForLength(length, availableSpace, false);
+
+    if (edge == Edge::Right)
+        return areaSize.width() - tileSize.width() - result;
+    
+    if (edge == Edge::Bottom)
+        return areaSize.height() - tileSize.height() - result;
+
+    return result;
+}
+
</ins><span class="cx"> BackgroundImageGeometry RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerModelObject* paintContainer, const FillLayer&amp; fillLayer, const LayoutPoint&amp; paintOffset,
</span><span class="cx">     const LayoutRect&amp; borderBoxRect, RenderElement* backgroundObject) const
</span><span class="cx"> {
</span><span class="lines">@@ -1147,7 +1160,7 @@
</span><span class="cx">     LayoutSize spaceSize;
</span><span class="cx">     LayoutSize phase;
</span><span class="cx">     LayoutSize noRepeat;
</span><del>-    LayoutUnit computedXPosition = minimumValueForLength(fillLayer.xPosition(), availableWidth, false);
</del><ins>+    LayoutUnit computedXPosition = resolveEdgeRelativeLength(fillLayer.xPosition(), fillLayer.backgroundXOrigin(), availableWidth, positioningAreaSize, tileSize);
</ins><span class="cx">     if (backgroundRepeatX == RoundFill &amp;&amp; positioningAreaSize.width() &gt; 0 &amp;&amp; tileSize.width() &gt; 0) {
</span><span class="cx">         int numTiles = std::max(1, roundToInt(positioningAreaSize.width() / tileSize.width()));
</span><span class="cx">         if (fillLayer.size().size.height().isAuto() &amp;&amp; backgroundRepeatY != RoundFill)
</span><span class="lines">@@ -1157,7 +1170,7 @@
</span><span class="cx">         phase.setWidth(tileSize.width() ? tileSize.width() - fmodf((computedXPosition + left), tileSize.width()) : 0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LayoutUnit computedYPosition = minimumValueForLength(fillLayer.yPosition(), availableHeight, false);
</del><ins>+    LayoutUnit computedYPosition = resolveEdgeRelativeLength(fillLayer.yPosition(), fillLayer.backgroundYOrigin(), availableHeight, positioningAreaSize, tileSize);
</ins><span class="cx">     if (backgroundRepeatY == RoundFill &amp;&amp; positioningAreaSize.height() &gt; 0 &amp;&amp; tileSize.height() &gt; 0) {
</span><span class="cx">         int numTiles = std::max(1, roundToInt(positioningAreaSize.height() / tileSize.height()));
</span><span class="cx">         if (fillLayer.size().size.width().isAuto() &amp;&amp; backgroundRepeatX != RoundFill)
</span><span class="lines">@@ -1181,8 +1194,9 @@
</span><span class="cx">         } else
</span><span class="cx">             backgroundRepeatX = NoRepeatFill;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     if (backgroundRepeatX == NoRepeatFill) {
</span><del>-        LayoutUnit xOffset = left + (fillLayer.backgroundXOrigin() == RightEdge ? availableWidth - computedXPosition : computedXPosition);
</del><ins>+        LayoutUnit xOffset = left + computedXPosition;
</ins><span class="cx">         if (xOffset &gt; 0)
</span><span class="cx">             destinationRect.move(xOffset, 0);
</span><span class="cx">         xOffset = std::min&lt;LayoutUnit&gt;(xOffset, 0);
</span><span class="lines">@@ -1206,7 +1220,7 @@
</span><span class="cx">             backgroundRepeatY = NoRepeatFill;
</span><span class="cx">     }
</span><span class="cx">     if (backgroundRepeatY == NoRepeatFill) {
</span><del>-        LayoutUnit yOffset = top + (fillLayer.backgroundYOrigin() == BottomEdge ? availableHeight - computedYPosition : computedYPosition);
</del><ins>+        LayoutUnit yOffset = top + computedYPosition;
</ins><span class="cx">         if (yOffset &gt; 0)
</span><span class="cx">             destinationRect.move(0, yOffset);
</span><span class="cx">         yOffset = std::min&lt;LayoutUnit&gt;(yOffset, 0);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.cpp (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.cpp        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/rendering/style/FillLayer.cpp        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -65,8 +65,8 @@
</span><span class="cx">     , m_xPosSet(false)
</span><span class="cx">     , m_yPosSet(false)
</span><span class="cx">     , m_backgroundOriginSet(false)
</span><del>-    , m_backgroundXOrigin(LeftEdge)
-    , m_backgroundYOrigin(TopEdge)
</del><ins>+    , m_backgroundXOrigin(static_cast&lt;unsigned&gt;(Edge::Left))
+    , m_backgroundYOrigin(static_cast&lt;unsigned&gt;(Edge::Top))
</ins><span class="cx">     , m_compositeSet(type == MaskFillLayer)
</span><span class="cx">     , m_blendModeSet(false)
</span><span class="cx">     , m_maskSourceTypeSet(false)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.h (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.h        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/rendering/style/FillLayer.h        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -70,8 +70,8 @@
</span><span class="cx">     StyleImage* image() const { return m_image.get(); }
</span><span class="cx">     const Length&amp; xPosition() const { return m_xPosition; }
</span><span class="cx">     const Length&amp; yPosition() const { return m_yPosition; }
</span><del>-    BackgroundEdgeOrigin backgroundXOrigin() const { return static_cast&lt;BackgroundEdgeOrigin&gt;(m_backgroundXOrigin); }
-    BackgroundEdgeOrigin backgroundYOrigin() const { return static_cast&lt;BackgroundEdgeOrigin&gt;(m_backgroundYOrigin); }
</del><ins>+    Edge backgroundXOrigin() const { return static_cast&lt;Edge&gt;(m_backgroundXOrigin); }
+    Edge backgroundYOrigin() const { return static_cast&lt;Edge&gt;(m_backgroundYOrigin); }
</ins><span class="cx">     EFillAttachment attachment() const { return static_cast&lt;EFillAttachment&gt;(m_attachment); }
</span><span class="cx">     EFillBox clip() const { return static_cast&lt;EFillBox&gt;(m_clip); }
</span><span class="cx">     EFillBox origin() const { return static_cast&lt;EFillBox&gt;(m_origin); }
</span><span class="lines">@@ -104,8 +104,8 @@
</span><span class="cx">     void setImage(PassRefPtr&lt;StyleImage&gt; image) { m_image = image; m_imageSet = true; }
</span><span class="cx">     void setXPosition(Length length) { m_xPosition = WTFMove(length); m_xPosSet = true; }
</span><span class="cx">     void setYPosition(Length length) { m_yPosition = WTFMove(length); m_yPosSet = true; }
</span><del>-    void setBackgroundXOrigin(BackgroundEdgeOrigin o) { m_backgroundXOrigin = o; m_backgroundOriginSet = true; }
-    void setBackgroundYOrigin(BackgroundEdgeOrigin o) { m_backgroundYOrigin = o; m_backgroundOriginSet = true; }
</del><ins>+    void setBackgroundXOrigin(Edge o) { m_backgroundXOrigin = static_cast&lt;unsigned&gt;(o); m_backgroundOriginSet = true; }
+    void setBackgroundYOrigin(Edge o) { m_backgroundYOrigin = static_cast&lt;unsigned&gt;(o); m_backgroundOriginSet = true; }
</ins><span class="cx">     void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; }
</span><span class="cx">     void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
</span><span class="cx">     void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; }
</span><span class="lines">@@ -202,8 +202,8 @@
</span><span class="cx">     unsigned m_xPosSet : 1;
</span><span class="cx">     unsigned m_yPosSet : 1;
</span><span class="cx">     unsigned m_backgroundOriginSet : 1;
</span><del>-    unsigned m_backgroundXOrigin : 2; // BackgroundEdgeOrigin
-    unsigned m_backgroundYOrigin : 2; // BackgroundEdgeOrigin
</del><ins>+    unsigned m_backgroundXOrigin : 2; // Edge
+    unsigned m_backgroundYOrigin : 2; // Edge
</ins><span class="cx">     unsigned m_compositeSet : 1;
</span><span class="cx">     unsigned m_blendModeSet : 1;
</span><span class="cx">     unsigned m_maskSourceTypeSet : 1;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStyleConstantscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -85,13 +85,13 @@
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextStream&amp; operator&lt;&lt;(TextStream&amp; ts, BackgroundEdgeOrigin edge)
</del><ins>+TextStream&amp; operator&lt;&lt;(TextStream&amp; ts, Edge edge)
</ins><span class="cx"> {
</span><span class="cx">     switch (edge) {
</span><del>-    case TopEdge: ts &lt;&lt; &quot;top&quot;; break;
-    case RightEdge: ts &lt;&lt; &quot;right&quot;; break;
-    case BottomEdge: ts &lt;&lt; &quot;bottom&quot;; break;
-    case LeftEdge: ts &lt;&lt; &quot;left&quot;; break;
</del><ins>+    case Edge::Top: ts &lt;&lt; &quot;top&quot;; break;
+    case Edge::Right: ts &lt;&lt; &quot;right&quot;; break;
+    case Edge::Bottom: ts &lt;&lt; &quot;bottom&quot;; break;
+    case Edge::Left: ts &lt;&lt; &quot;left&quot;; break;
</ins><span class="cx">     }
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStyleConstantsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (196959 => 196960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h        2016-02-22 22:24:51 UTC (rev 196959)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h        2016-02-22 22:26:23 UTC (rev 196960)
</span><span class="lines">@@ -230,8 +230,8 @@
</span><span class="cx"> // CSS3 Background Values
</span><span class="cx"> enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
</span><span class="cx"> 
</span><del>-// CSS3 Background Position
-enum BackgroundEdgeOrigin { TopEdge, RightEdge, BottomEdge, LeftEdge };
</del><ins>+// CSS3 &lt;position&gt;
+enum class Edge { Top, Right, Bottom, Left };
</ins><span class="cx"> 
</span><span class="cx"> // CSS3 Mask Source Types
</span><span class="cx"> enum EMaskSourceType { MaskAlpha, MaskLuminance };
</span><span class="lines">@@ -694,7 +694,7 @@
</span><span class="cx"> TextStream&amp; operator&lt;&lt;(TextStream&amp;, EFillBox);
</span><span class="cx"> TextStream&amp; operator&lt;&lt;(TextStream&amp;, EFillRepeat);
</span><span class="cx"> TextStream&amp; operator&lt;&lt;(TextStream&amp;, EMaskSourceType);
</span><del>-TextStream&amp; operator&lt;&lt;(TextStream&amp;, BackgroundEdgeOrigin);
</del><ins>+TextStream&amp; operator&lt;&lt;(TextStream&amp;, Edge);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>