зеркало из https://github.com/mozilla/gecko-dev.git
Bug 722071 - Implement array style indexing for SVGStringList. r=mrbkap.
This commit is contained in:
Родитель
9fed45f55d
Коммит
df19099733
|
@ -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 + "]");
|
||||
}
|
||||
|
|
|
@ -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<ListInterfaceType, ListType>::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<DOMSVGStringList*>(
|
||||
static_cast<nsIDOMSVGStringList*>(aNative));
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGStringList> 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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1748,4 +1748,27 @@ typedef nsSVGListSH<nsIDOMSVGPathSegList, mozilla::DOMSVGPathSegList> nsSVGPathS
|
|||
typedef nsSVGListSH<nsIDOMSVGPointList, mozilla::DOMSVGPointList> nsSVGPointListSH;
|
||||
typedef nsSVGListSH<nsIDOMSVGTransformList, mozilla::DOMSVGTransformList> 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___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче