<!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>[179413] 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/179413">179413</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-01-30 14:54:34 -0800 (Fri, 30 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>When no background-size is specified on the 2nd background layer, it takes the first instead of the initial value
https://bugs.webkit.org/show_bug.cgi?id=141059

Reviewed by Antti Koivisto.

Source/WebCore:

This patch fixes fill size support for 'initial' value.

Test: fast/css/background-layers-initial-size.html

* css/CSSToStyleMap.cpp:
- Add check for initial values and set fill size to initialFillSize()
  in this case (which is 'auto'). Previously, we were handling all
  non CSSPrimitiveValues the same way and setting the fill size type
  to SizeNone, which means no size (not 'auto').
- Clean up the rest of the function (no behavior change).

* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::FillLayer):
- Initialize m_sizeLength to SizeNone instead of calling
  initialFillSizeType(). There is no behavior change here. However,
  initialFillSizeType() was not supposed to return SizeNone.
- Stop explicitly initializing m_sizeLength to LengthSize() as this
  is already what happens implicitly.

* rendering/style/FillLayer.h:
(WebCore::FillLayer::initialFillSize):
Return FillSize() instead of FillSize(SizeNone, LengthSize()).
FillSize() is equivalent to FillSize(SizeLength, LengthSize())
which is resolved to 'auto'. SizeNone means no size which isn't
what we want as an initial value.

(WebCore::FillLayer::initialFillSizeType): Deleted.
(WebCore::FillLayer::initialFillSizeLength): Deleted.
Remove Individual initialFillSizeType() / initialFillSizeLength()
functions now that all caller use initialFillSize() instead.

LayoutTests:

Add layout test to cover the case where we have 2 background layers, with an explicit
size only for the first one.

* fast/css/background-layers-initial-size-expected.txt: Added.
* fast/css/background-layers-initial-size.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="#trunkSourceWebCorecssCSSToStyleMapcpp">trunk/Source/WebCore/css/CSSToStyleMap.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>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssbackgroundlayersinitialsizeexpectedtxt">trunk/LayoutTests/fast/css/background-layers-initial-size-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssbackgroundlayersinitialsizehtml">trunk/LayoutTests/fast/css/background-layers-initial-size.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (179412 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-01-30 22:27:56 UTC (rev 179412)
+++ trunk/LayoutTests/ChangeLog        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-01-30  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        When no background-size is specified on the 2nd background layer, it takes the first instead of the initial value
+        https://bugs.webkit.org/show_bug.cgi?id=141059
+
+        Reviewed by Antti Koivisto.
+
+        Add layout test to cover the case where we have 2 background layers, with an explicit
+        size only for the first one.
+
+        * fast/css/background-layers-initial-size-expected.txt: Added.
+        * fast/css/background-layers-initial-size.html: Added.
+
</ins><span class="cx"> 2015-01-30  Matthew Mirman  &lt;mmirman@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Added a test for JSON.stringify on ClientRect.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssbackgroundlayersinitialsizeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/background-layers-initial-size-expected.txt (0 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/background-layers-initial-size-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css/background-layers-initial-size-expected.txt        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test that 'initial' background-size values are properly handled in background layers.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS computedBackgroundSize is &quot;25px 25px, auto&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssbackgroundlayersinitialsizehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/background-layers-initial-size.html (0 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/background-layers-initial-size.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/background-layers-initial-size.html        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+div {
+    background: linear-gradient(45deg, rgba(0,0,0,.4) 50%, transparent 0) 100% 0 / 25px 25px no-repeat,
+                linear-gradient(-135deg, transparent 18px, yellowgreen 0);
+
+    width: 12em;
+    height: 8em;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;testDiv&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+description(&quot;Test that 'initial' background-size values are properly handled in background layers.&quot;);
+
+var computedBackgroundSize = window.getComputedStyle(testDiv)[&quot;background-size&quot;];
+// The second layer should have &quot;auto&quot; as background size as it is its initial value.
+shouldBeEqualToString(&quot;computedBackgroundSize&quot;, &quot;25px 25px, auto&quot;);
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179412 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-30 22:27:56 UTC (rev 179412)
+++ trunk/Source/WebCore/ChangeLog        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2015-01-30  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        When no background-size is specified on the 2nd background layer, it takes the first instead of the initial value
+        https://bugs.webkit.org/show_bug.cgi?id=141059
+
+        Reviewed by Antti Koivisto.
+
+        This patch fixes fill size support for 'initial' value.
+
+        Test: fast/css/background-layers-initial-size.html
+
+        * css/CSSToStyleMap.cpp:
+        - Add check for initial values and set fill size to initialFillSize()
+          in this case (which is 'auto'). Previously, we were handling all
+          non CSSPrimitiveValues the same way and setting the fill size type
+          to SizeNone, which means no size (not 'auto').
+        - Clean up the rest of the function (no behavior change).
+
+        * rendering/style/FillLayer.cpp:
+        (WebCore::FillLayer::FillLayer):
+        - Initialize m_sizeLength to SizeNone instead of calling
+          initialFillSizeType(). There is no behavior change here. However,
+          initialFillSizeType() was not supposed to return SizeNone.
+        - Stop explicitly initializing m_sizeLength to LengthSize() as this
+          is already what happens implicitly.
+
+        * rendering/style/FillLayer.h:
+        (WebCore::FillLayer::initialFillSize):
+        Return FillSize() instead of FillSize(SizeNone, LengthSize()).
+        FillSize() is equivalent to FillSize(SizeLength, LengthSize())
+        which is resolved to 'auto'. SizeNone means no size which isn't
+        what we want as an initial value.
+
+        (WebCore::FillLayer::initialFillSizeType): Deleted.
+        (WebCore::FillLayer::initialFillSizeLength): Deleted.
+        Remove Individual initialFillSizeType() / initialFillSizeLength()
+        functions now that all caller use initialFillSize() instead.
+
</ins><span class="cx"> 2015-01-30  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r179403.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSToStyleMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSToStyleMap.cpp (179412 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSToStyleMap.cpp        2015-01-30 22:27:56 UTC (rev 179412)
+++ trunk/Source/WebCore/css/CSSToStyleMap.cpp        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -184,47 +184,43 @@
</span><span class="cx">     layer.setRepeatY(downcast&lt;CSSPrimitiveValue&gt;(value));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer&amp; layer, CSSValue&amp; value)
</del><ins>+static inline bool convertToLengthSize(const CSSPrimitiveValue&amp; primitiveValue, CSSToLengthConversionData conversionData, LengthSize&amp; size)
</ins><span class="cx"> {
</span><del>-    if (!is&lt;CSSPrimitiveValue&gt;(value)) {
-        layer.setSizeType(SizeNone);
-        return;
-    }
</del><ins>+    if (auto* pair = primitiveValue.getPairValue()) {
+        size.setWidth(pair-&gt;first()-&gt;convertToLength&lt;AnyConversion&gt;(conversionData));
+        size.setHeight(pair-&gt;second()-&gt;convertToLength&lt;AnyConversion&gt;(conversionData));
+    } else
+        size.setWidth(primitiveValue.convertToLength&lt;AnyConversion&gt;(conversionData));
</ins><span class="cx"> 
</span><del>-    auto&amp; primitiveValue = downcast&lt;CSSPrimitiveValue&gt;(value);
-    if (primitiveValue.getValueID() == CSSValueContain)
-        layer.setSizeType(Contain);
-    else if (primitiveValue.getValueID() == CSSValueCover)
-        layer.setSizeType(Cover);
-    else
-        layer.setSizeType(SizeLength);
</del><ins>+    return !size.width().isUndefined() &amp;&amp; !size.height().isUndefined();
+}
</ins><span class="cx"> 
</span><del>-    LengthSize b = FillLayer::initialFillSizeLength(layer.type());
-
-    if (value.isInitialValue() || primitiveValue.getValueID() == CSSValueContain || primitiveValue.getValueID() == CSSValueCover) {
-        layer.setSizeLength(b);
</del><ins>+void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer&amp; layer, CSSValue&amp; value)
+{
+    if (value.isInitialValue()) {
+        layer.setSize(FillLayer::initialFillSize(layer.type()));
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Length firstLength;
-    Length secondLength;
-
-    if (Pair* pair = primitiveValue.getPairValue()) {
-        CSSPrimitiveValue* first = static_cast&lt;CSSPrimitiveValue*&gt;(pair-&gt;first());
-        CSSPrimitiveValue* second = static_cast&lt;CSSPrimitiveValue*&gt;(pair-&gt;second());
-        firstLength = first-&gt;convertToLength&lt;AnyConversion&gt;(m_resolver-&gt;state().cssToLengthConversionData());
-        secondLength = second-&gt;convertToLength&lt;AnyConversion&gt;(m_resolver-&gt;state().cssToLengthConversionData());
-    } else {
-        firstLength = primitiveValue.convertToLength&lt;AnyConversion&gt;(m_resolver-&gt;state().cssToLengthConversionData());
-        secondLength = Length();
-    }
-
-    if (firstLength.isUndefined() || secondLength.isUndefined())
</del><ins>+    if (!is&lt;CSSPrimitiveValue&gt;(value))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    b.setWidth(firstLength);
-    b.setHeight(secondLength);
-    layer.setSizeLength(b);
</del><ins>+    auto&amp; primitiveValue = downcast&lt;CSSPrimitiveValue&gt;(value);
+    FillSize fillSize;
+    switch (primitiveValue.getValueID()) {
+    case CSSValueContain:
+        fillSize.type = Contain;
+        break;
+    case CSSValueCover:
+        fillSize.type = Cover;
+        break;
+    default:
+        ASSERT(fillSize.type == SizeLength);
+        if (!convertToLengthSize(primitiveValue, m_resolver-&gt;state().cssToLengthConversionData(), fillSize.size))
+            return;
+        break;
+    }
+    layer.setSize(fillSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer&amp; layer, CSSValue&amp; value)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.cpp (179412 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.cpp        2015-01-30 22:27:56 UTC (rev 179412)
+++ trunk/Source/WebCore/rendering/style/FillLayer.cpp        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -45,14 +45,13 @@
</span><span class="cx">     : m_image(FillLayer::initialFillImage(type))
</span><span class="cx">     , m_xPosition(FillLayer::initialFillXPosition(type))
</span><span class="cx">     , m_yPosition(FillLayer::initialFillYPosition(type))
</span><del>-    , m_sizeLength(FillLayer::initialFillSizeLength(type))
</del><span class="cx">     , m_attachment(FillLayer::initialFillAttachment(type))
</span><span class="cx">     , m_clip(FillLayer::initialFillClip(type))
</span><span class="cx">     , m_origin(FillLayer::initialFillOrigin(type))
</span><span class="cx">     , m_repeatX(FillLayer::initialFillRepeatX(type))
</span><span class="cx">     , m_repeatY(FillLayer::initialFillRepeatY(type))
</span><span class="cx">     , m_composite(FillLayer::initialFillComposite(type))
</span><del>-    , m_sizeType(FillLayer::initialFillSizeType(type))
</del><ins>+    , m_sizeType(SizeNone)
</ins><span class="cx">     , m_blendMode(FillLayer::initialFillBlendMode(type))
</span><span class="cx">     , m_maskSourceType(FillLayer::initialFillMaskSourceType(type))
</span><span class="cx">     , m_imageSet(false)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.h (179412 => 179413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.h        2015-01-30 22:27:56 UTC (rev 179412)
+++ trunk/Source/WebCore/rendering/style/FillLayer.h        2015-01-30 22:54:34 UTC (rev 179413)
</span><span class="lines">@@ -166,12 +166,10 @@
</span><span class="cx">     static EFillRepeat initialFillRepeatY(EFillLayerType) { return RepeatFill; }
</span><span class="cx">     static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; }
</span><span class="cx">     static BlendMode initialFillBlendMode(EFillLayerType) { return BlendModeNormal; }
</span><del>-    static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeNone; }
-    static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize(); }
-    static FillSize initialFillSize(EFillLayerType type) { return FillSize(initialFillSizeType(type), initialFillSizeLength(type)); }
</del><ins>+    static FillSize initialFillSize(EFillLayerType) { return FillSize(); }
</ins><span class="cx">     static Length initialFillXPosition(EFillLayerType) { return Length(0.0f, Percent); }
</span><span class="cx">     static Length initialFillYPosition(EFillLayerType) { return Length(0.0f, Percent); }
</span><del>-    static StyleImage* initialFillImage(EFillLayerType) { return 0; }
</del><ins>+    static StyleImage* initialFillImage(EFillLayerType) { return nullptr; }
</ins><span class="cx">     static EMaskSourceType initialFillMaskSourceType(EFillLayerType) { return MaskAlpha; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre>
</div>
</div>

</body>
</html>