Bug 711958 - Add a 'length' property to DOMSVGStringList. r=dholbert.
authorJonathan Watt <jwatt@jwatt.org>
Sat, 28 Jan 2012 10:43:34 +0000
changeset 86883 b939fbd0a46f9e6db2651c850641a3874996cf3c
parent 86882 b945ae00f5f582c3023fbe72f8ad253c5bc940b0
child 86884 a9a667cc58397d67ec297138ec0b421b0254ab59
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs711958
milestone12.0a1
Bug 711958 - Add a 'length' property to DOMSVGStringList. r=dholbert.
content/svg/content/src/DOMSVGStringList.cpp
content/svg/content/test/test_SVGxxxListIndexing.xhtml
dom/interfaces/svg/nsIDOMSVGStringList.idl
--- a/content/svg/content/src/DOMSVGStringList.cpp
+++ b/content/svg/content/src/DOMSVGStringList.cpp
@@ -95,16 +95,22 @@ DOMSVGStringList::~DOMSVGStringList()
 NS_IMETHODIMP
 DOMSVGStringList::GetNumberOfItems(PRUint32 *aNumberOfItems)
 {
   *aNumberOfItems = InternalList().Length();
   return NS_OK;
 }
 
 NS_IMETHODIMP
+DOMSVGStringList::GetLength(PRUint32 *aLength)
+{
+  return GetNumberOfItems(aLength);
+}
+
+NS_IMETHODIMP
 DOMSVGStringList::Clear()
 {
   if (InternalList().IsExplicitlySet()) {
     InternalList().Clear();
     mElement->DidChangeStringList(mIsConditionalProcessingAttribute,
                                   mAttrEnum);
   }
   return NS_OK;
--- a/content/svg/content/test/test_SVGxxxListIndexing.xhtml
+++ b/content/svg/content/test/test_SVGxxxListIndexing.xhtml
@@ -8,17 +8,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=631437">Mozilla Bug 631437</a>
 <svg xmlns="http://www.w3.org/2000/svg" id="svg">
   <text id="text" x="10 20 30" rotate="40 50 60">abcde</text>
   <path id="path" d="M0,0 L100,100"/>
   <polygon id="poly" points="50,50 70,70 90,50"/>
-  <g id="g" transform="translate(20 30) rotate(50 60 70) scale(2)"/>
+  <g id="g" transform="translate(20 30) rotate(50 60 70) scale(2)"
+     requiredFeatures="foo bar baz"/>
 </svg>
 <script type="text/javascript;version=1.8"><![CDATA[
 var text = document.getElementById("text"),
     path = document.getElementById("path"),
     poly = document.getElementById("poly");
     g    = document.getElementById("g");
 
 function CheckList(aListObject, aExpectedListLength, aListDescription)
@@ -64,16 +65,23 @@ var tests = [
   { element: g,
     attribute: "transform",
     listProperty: "transform.baseVal",
     type: "SVGTransformList",
     subtests: [ { values: null, length: 3 },
                 { values: "skewX(45)", length: 1 },
                 { values: "translate(1 2) rotate(3) scale(4) skewY(5) skewX(6)",
                   length: 5 } ] }
+  { element: g,
+    attribute: "requiredFeatures",
+    listProperty: "requiredFeatures",
+    type: "SVGStringList",
+    subtests: [ { values: null, length: 3 },
+                { values: "foo", length: 1 },
+                { values: "foo bar baz qux", length: 4 } ] }
 ];
 
 for each (let test in tests) {
   let list = test.element;
   for each (let property in test.listProperty.split(".")) {
     list = list[property];
   }
 
--- a/dom/interfaces/svg/nsIDOMSVGStringList.idl
+++ b/dom/interfaces/svg/nsIDOMSVGStringList.idl
@@ -36,16 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "domstubs.idl"
 
 [scriptable, uuid(481f01a5-0bbb-4abf-8623-f3c2fb5642a9)]
 interface nsIDOMSVGStringList : nsISupports
 { 
   readonly attribute unsigned long numberOfItems;
+  readonly attribute unsigned long length;
 
   void clear();
           // raises(nsIDOMDOMException);
   DOMString initialize(in DOMString newItem);
                     // raises(nsIDOMDOMException);
   DOMString getItem(in unsigned long index);
                     // raises(nsIDOMDOMException);
   DOMString insertItemBefore(in DOMString newItem, in unsigned long index);