<!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>[180129] 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/180129">180129</a></dd>
<dt>Author</dt> <dd>said@apple.com</dd>
<dt>Date</dt> <dd>2015-02-15 18:08:39 -0800 (Sun, 15 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Crash when accessing an item in SVGTransformList and then removing a previous item from this list.
https://bugs.webkit.org/show_bug.cgi?id=141550.

Reviewed by Darin Adler.

Source/WebCore:

Tests: LayoutTests/svg/dom/SVGTransformList-basics.xhtml: This test is modified to
include a new test case.

* svg/properties/SVGMatrixTearOff.h: m_value of SVGMatrixTearOff will be a null
pointer. There is no point in having SVGMatrixTearOff points to the parent and
the property of the parent at the same time.
        
(WebCore::SVGMatrixTearOff::create): SVGMatrixTearOff will hold a pointer to
the parent SVGPropertyTearOff&lt;SVGTransform&gt;. But it should overrides setValue()
and propertyReference() so it can set and get the SVGMatrix from the SVGTransform
parent.
        
(WebCore::SVGMatrixTearOff::SVGMatrixTearOff): Pass a nullptr to the base class.
SVGMatrixTearOff will act as a proxy of the parent. It does not hold any data by
itself but it knows what property to set and get from the parent.
        
* svg/properties/SVGPropertyTearOff.h:
(WebCore::SVGPropertyTearOff::create): Add a create method which can take a pointer value.
        
(WebCore::SVGPropertyTearOff::propertyReference):
(WebCore::SVGPropertyTearOff::setValue): Make these functions virtual so concrete classes
like SVGMatrixTearOff can override them.
        
(WebCore::SVGPropertyTearOff::SVGPropertyTearOff): Add a new constructor.

LayoutTests:

* svg/dom/SVGTransformList-basics-expected.txt:
* svg/dom/SVGTransformList-basics.xhtml: Add a new test case to this test. Have a
reference to an SVGMatrix of the last SVGTransform of an SVGTransformList and then
remove the items of this list from the beginning till the end.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGTransformListbasicsexpectedtxt">trunk/LayoutTests/svg/dom/SVGTransformList-basics-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGTransformListbasicsxhtml">trunk/LayoutTests/svg/dom/SVGTransformList-basics.xhtml</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoresvgpropertiesSVGMatrixTearOffh">trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h</a></li>
<li><a href="#trunkSourceWebCoresvgpropertiesSVGPropertyTearOffh">trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (180128 => 180129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-02-16 00:13:16 UTC (rev 180128)
+++ trunk/LayoutTests/ChangeLog        2015-02-16 02:08:39 UTC (rev 180129)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2015-02-15  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Crash when accessing an item in SVGTransformList and then removing a previous item from this list.
+        https://bugs.webkit.org/show_bug.cgi?id=141550.
+
+        Reviewed by Darin Adler.
+
+        * svg/dom/SVGTransformList-basics-expected.txt:
+        * svg/dom/SVGTransformList-basics.xhtml: Add a new test case to this test. Have a
+        reference to an SVGMatrix of the last SVGTransform of an SVGTransformList and then
+        remove the items of this list from the beginning till the end.
+
+2015-02-15  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
</ins><span class="cx">         Crash when accessing an item in SVGLengthList and then replacing it with a previous item in the list.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=141552.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGTransformListbasicsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGTransformList-basics-expected.txt (180128 => 180129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGTransformList-basics-expected.txt        2015-02-16 00:13:16 UTC (rev 180128)
+++ trunk/LayoutTests/svg/dom/SVGTransformList-basics-expected.txt        2015-02-16 02:08:39 UTC (rev 180129)
</span><span class="lines">@@ -51,6 +51,13 @@
</span><span class="cx"> PASS circle1.transform.baseVal.insertItemBefore(circle1, 0) threw exception TypeError: Argument 1 ('item') to SVGTransformList.insertItemBefore must be an instance of SVGTransform.
</span><span class="cx"> PASS circle1.transform.baseVal.insertItemBefore(null, 0) threw exception Error: SVG_WRONG_TYPE_ERR: DOM SVG Exception 0.
</span><span class="cx"> 
</span><ins>+Test overlapping edge cases for removeItem()
+PASS circle1.setAttribute('transform', 'scale(2 2) translate(10 10)') is undefined.
+PASS dumpTransform(circle1.transform.baseVal.getItem(1)) is &quot;type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 20.0 20.0]&quot;
+PASS dumpTransform(circle1.transform.baseVal.getItem(1)) is &quot;type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 20.0 20.0]&quot;
+PASS dumpTransform(circle1.transform.baseVal.getItem(1)) is &quot;type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 40.0 40.0]&quot;
+PASS circle1.transform.baseVal.numberOfItems is 0
+
</ins><span class="cx"> Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1
</span><span class="cx"> PASS circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)') is undefined.
</span><span class="cx"> PASS circle1.transform.baseVal.numberOfItems is 4
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGTransformListbasicsxhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGTransformList-basics.xhtml (180128 => 180129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGTransformList-basics.xhtml        2015-02-16 00:13:16 UTC (rev 180128)
+++ trunk/LayoutTests/svg/dom/SVGTransformList-basics.xhtml        2015-02-16 02:08:39 UTC (rev 180129)
</span><span class="lines">@@ -103,6 +103,21 @@
</span><span class="cx">     shouldThrow(&quot;circle1.transform.baseVal.insertItemBefore(null, 0)&quot;);
</span><span class="cx"> 
</span><span class="cx">     debug(&quot;&quot;);
</span><ins>+    debug(&quot;Test overlapping edge cases for removeItem()&quot;);
+    shouldBeUndefined(&quot;circle1.setAttribute('transform', 'scale(2 2) translate(10 10)')&quot;);
+    var matrix = circle1.transform.baseVal.getItem(1).matrix;
+    matrix.e *= 2;
+    matrix.f *= 2;
+    shouldBeEqualToString(&quot;dumpTransform(circle1.transform.baseVal.getItem(1))&quot;, &quot;type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 20.0 20.0]&quot;);
+    matrix = matrix.translate(20, 20);
+    shouldBeEqualToString(&quot;dumpTransform(circle1.transform.baseVal.getItem(1))&quot;, &quot;type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 20.0 20.0]&quot;);
+    circle1.transform.baseVal.getItem(1).setMatrix(matrix);
+    shouldBeEqualToString(&quot;dumpTransform(circle1.transform.baseVal.getItem(1))&quot;, &quot;type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 40.0 40.0]&quot;);
+    circle1.transform.baseVal.removeItem(0);
+    circle1.transform.baseVal.removeItem(0);
+    shouldBe(&quot;circle1.transform.baseVal.numberOfItems&quot;, &quot;0&quot;);
+
+    debug(&quot;&quot;);
</ins><span class="cx">     debug(&quot;Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1&quot;);
</span><span class="cx">     shouldBeUndefined(&quot;circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)')&quot;);
</span><span class="cx">     shouldBe(&quot;circle1.transform.baseVal.numberOfItems&quot;, &quot;4&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (180128 => 180129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-16 00:13:16 UTC (rev 180128)
+++ trunk/Source/WebCore/ChangeLog        2015-02-16 02:08:39 UTC (rev 180129)
</span><span class="lines">@@ -1,5 +1,37 @@
</span><span class="cx"> 2015-02-15  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Crash when accessing an item in SVGTransformList and then removing a previous item from this list.
+        https://bugs.webkit.org/show_bug.cgi?id=141550.
+
+        Reviewed by Darin Adler.
+
+        Tests: LayoutTests/svg/dom/SVGTransformList-basics.xhtml: This test is modified to
+        include a new test case.
+
+        * svg/properties/SVGMatrixTearOff.h: m_value of SVGMatrixTearOff will be a null
+        pointer. There is no point in having SVGMatrixTearOff points to the parent and
+        the property of the parent at the same time.
+        
+        (WebCore::SVGMatrixTearOff::create): SVGMatrixTearOff will hold a pointer to
+        the parent SVGPropertyTearOff&lt;SVGTransform&gt;. But it should overrides setValue()
+        and propertyReference() so it can set and get the SVGMatrix from the SVGTransform
+        parent.
+        
+        (WebCore::SVGMatrixTearOff::SVGMatrixTearOff): Pass a nullptr to the base class.
+        SVGMatrixTearOff will act as a proxy of the parent. It does not hold any data by
+        itself but it knows what property to set and get from the parent.
+        
+        * svg/properties/SVGPropertyTearOff.h:
+        (WebCore::SVGPropertyTearOff::create): Add a create method which can take a pointer value.
+        
+        (WebCore::SVGPropertyTearOff::propertyReference):
+        (WebCore::SVGPropertyTearOff::setValue): Make these functions virtual so concrete classes
+        like SVGMatrixTearOff can override them.
+        
+        (WebCore::SVGPropertyTearOff::SVGPropertyTearOff): Add a new constructor.
+
+2015-02-15  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
</ins><span class="cx">         Crash when accessing an item in SVGLengthList and then replacing it with a previous item in the list.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=141552.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoresvgpropertiesSVGMatrixTearOffh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h (180128 => 180129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h        2015-02-16 00:13:16 UTC (rev 180128)
+++ trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h        2015-02-16 02:08:39 UTC (rev 180129)
</span><span class="lines">@@ -30,13 +30,18 @@
</span><span class="cx">     // Used for non-animated POD types that are not associated with a SVGAnimatedProperty object, nor with a XML DOM attribute
</span><span class="cx">     // and that contain a parent type that's exposed to the bindings via a SVGStaticPropertyTearOff object
</span><span class="cx">     // (for example: SVGTransform::matrix).
</span><del>-    static PassRefPtr&lt;SVGMatrixTearOff&gt; create(SVGPropertyTearOff&lt;SVGTransform&gt;&amp; parent, SVGMatrix&amp; value)
</del><ins>+    static Ref&lt;SVGMatrixTearOff&gt; create(SVGPropertyTearOff&lt;SVGTransform&gt;&amp; parent, SVGMatrix&amp; value)
</ins><span class="cx">     {
</span><del>-        RefPtr&lt;SVGMatrixTearOff&gt; result = adoptRef(new SVGMatrixTearOff(&amp;parent, value));
</del><ins>+        ASSERT(&amp;parent.propertyReference().svgMatrix() == &amp;value);
+        Ref&lt;SVGMatrixTearOff&gt; result = adoptRef(*new SVGMatrixTearOff(&amp;parent));
</ins><span class="cx">         parent.addChild(result-&gt;m_weakFactory.createWeakPtr());
</span><del>-        return result.release();
</del><ins>+        return result;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    virtual SVGMatrix&amp; propertyReference() override { return m_parent-&gt;propertyReference().svgMatrix(); }
+
+    virtual void setValue(SVGMatrix&amp; value) override { m_parent-&gt;propertyReference().setMatrix(value); }
+
</ins><span class="cx">     virtual void commitChange()
</span><span class="cx">     {
</span><span class="cx">         m_parent-&gt;propertyReference().updateSVGMatrix();
</span><span class="lines">@@ -44,8 +49,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    SVGMatrixTearOff(SVGPropertyTearOff&lt;SVGTransform&gt;* parent, SVGMatrix&amp; value)
-        : SVGPropertyTearOff&lt;SVGMatrix&gt;(0, UndefinedRole, value)
</del><ins>+    SVGMatrixTearOff(SVGPropertyTearOff&lt;SVGTransform&gt;* parent)
+        : SVGPropertyTearOff&lt;SVGMatrix&gt;(nullptr)
</ins><span class="cx">         , m_parent(parent)
</span><span class="cx">         , m_weakFactory(this)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCoresvgpropertiesSVGPropertyTearOffh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h (180128 => 180129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h        2015-02-16 00:13:16 UTC (rev 180128)
+++ trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h        2015-02-16 02:08:39 UTC (rev 180129)
</span><span class="lines">@@ -39,22 +39,27 @@
</span><span class="cx"> 
</span><span class="cx">     // Used for child types (baseVal/animVal) of a SVGAnimated* property (for example: SVGAnimatedLength::baseVal()).
</span><span class="cx">     // Also used for list tear offs (for example: text.x.baseVal.getItem(0)).
</span><del>-    static PassRefPtr&lt;Self&gt; create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType&amp; value)
</del><ins>+    static Ref&lt;Self&gt; create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         ASSERT(animatedProperty);
</span><del>-        return adoptRef(new Self(animatedProperty, role, value));
</del><ins>+        return adoptRef(*new Self(animatedProperty, role, value));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Used for non-animated POD types (for example: SVGSVGElement::createSVGLength()).
</span><del>-    static PassRefPtr&lt;Self&gt; create(const PropertyType&amp; initialValue)
</del><ins>+    static Ref&lt;Self&gt; create(const PropertyType&amp; initialValue)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new Self(initialValue));
</del><ins>+        return adoptRef(*new Self(initialValue));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    PropertyType&amp; propertyReference() { return *m_value; }
</del><ins>+    static Ref&lt;Self&gt; create(const PropertyType* initialValue)
+    {
+        return adoptRef(*new Self(initialValue));
+    }
+
+    virtual PropertyType&amp; propertyReference() { return *m_value; }
</ins><span class="cx">     SVGAnimatedProperty* animatedProperty() const { return m_animatedProperty; }
</span><span class="cx"> 
</span><del>-    void setValue(PropertyType&amp; value)
</del><ins>+    virtual void setValue(PropertyType&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         if (m_valueIsCopy) {
</span><span class="cx">             detachChildren();
</span><span class="lines">@@ -134,9 +139,14 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     SVGPropertyTearOff(const PropertyType&amp; initialValue)
</span><ins>+        : SVGPropertyTearOff(&amp;initialValue)
+    {
+    }
+
+    SVGPropertyTearOff(const PropertyType* initialValue)
</ins><span class="cx">         : m_animatedProperty(0)
</span><span class="cx">         , m_role(UndefinedRole)
</span><del>-        , m_value(new PropertyType(initialValue))
</del><ins>+        , m_value(initialValue ? new PropertyType(*initialValue) : nullptr)
</ins><span class="cx">         , m_valueIsCopy(true)
</span><span class="cx">     {
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>