diff --git a/content/svg/content/test/test_SVGxxxListIndexing.xhtml b/content/svg/content/test/test_SVGxxxListIndexing.xhtml index 95f87873b422..7f0c5bf77bb3 100644 --- a/content/svg/content/test/test_SVGxxxListIndexing.xhtml +++ b/content/svg/content/test/test_SVGxxxListIndexing.xhtml @@ -27,8 +27,6 @@ function CheckList(aListObject, aExpectedListLength, aListDescription) is(aListObject.numberOfItems, aExpectedListLength, aListDescription + ".numberOfItems"); is(aListObject.numberOfItems, aExpectedListLength, aListDescription + ".length"); for (let i = 0; i < aListObject.length; i++) { - if (aListDescription.indexOf("SVGStringList") > -1) - continue; let item = aListObject.getItem(i); ok(aListObject[i] === item, aListDescription + "[" + i + "]"); } diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 43b1b04fc693..ba3160580743 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -488,6 +488,7 @@ #include "DOMSVGNumberList.h" #include "DOMSVGPathSegList.h" #include "DOMSVGPointList.h" +#include "DOMSVGStringList.h" #include "DOMSVGTransformList.h" #include "mozilla/dom/indexedDB/IDBWrapperCache.h" @@ -1293,8 +1294,8 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGRect, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(SVGStringList, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(SVGStringList, nsSVGStringListSH, + ARRAY_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGTransform, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsSVGTransformListSH, @@ -10906,3 +10907,45 @@ nsSVGListSH::GetItemAt(nsISupports *aNative, return list->GetItemWithoutAddRef(aIndex); } + + +// SVGStringList helper + +nsresult +nsSVGStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex, + nsAString& aResult) +{ + if (aIndex < 0) { + SetDOMStringToNull(aResult); + return NS_OK; + } + + DOMSVGStringList* list = static_cast( + static_cast(aNative)); +#ifdef DEBUG + { + nsCOMPtr list_qi = do_QueryInterface(aNative); + + // If this assertion fires the QI implementation for the object in + // question doesn't use the nsIDOMDOMSVGStringList pointer as the + // nsISupports pointer. That must be fixed, or we'll crash... + NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!"); + } +#endif + + nsresult rv = list->GetItem(aIndex, aResult); +#ifdef DEBUG + if (DOMStringIsNull(aResult)) { + PRUint32 length = 0; + list->GetLength(&length); + NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access"); + } +#endif + if (rv == NS_ERROR_DOM_INDEX_SIZE_ERR) { + SetDOMStringToNull(aResult); + rv = NS_OK; + } + return rv; +} + + diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index 2d5e44210d9a..850553f84c8c 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -1748,4 +1748,27 @@ typedef nsSVGListSH nsSVGPathS typedef nsSVGListSH nsSVGPointListSH; typedef nsSVGListSH nsSVGTransformListSH; +// SVGStringList helper + +class nsSVGStringListSH : public nsStringArraySH +{ +protected: + nsSVGStringListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData) + { + } + + virtual ~nsSVGStringListSH() + { + } + + virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex, + nsAString& aResult); + +public: + static nsIClassInfo *doCreate(nsDOMClassInfoData* aData) + { + return new nsSVGStringListSH(aData); + } +}; + #endif /* nsDOMClassInfo_h___ */