Backed out changeset bb30697071b2 (bug 1308317)

This commit is contained in:
Carsten "Tomcat" Book 2016-10-14 14:58:42 +02:00
Родитель ac6a598542
Коммит 8f39dfed93
3 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -33,6 +33,8 @@ class nsISupportsArray;
[scriptable, uuid(241addc8-3608-4e73-8083-2fd6fa09eba2)]
interface nsISupportsArray : nsICollection {
[notxpcom] boolean Equals([const] in nsISupportsArray other);
[notxpcom] long IndexOf([const] in nsISupports aPossibleElement);
[notxpcom] long IndexOfStartingAt([const] in nsISupports aPossibleElement,
in unsigned long aStartIndex);

Просмотреть файл

@ -196,6 +196,35 @@ nsSupportsArray::DeleteArray(void)
}
}
NS_IMETHODIMP_(bool)
nsSupportsArray::Equals(const nsISupportsArray* aOther)
{
if (aOther) {
uint32_t countOther;
nsISupportsArray* other = const_cast<nsISupportsArray*>(aOther);
nsresult rv = other->Count(&countOther);
if (NS_FAILED(rv)) {
return false;
}
if (mCount == countOther) {
uint32_t index = mCount;
nsCOMPtr<nsISupports> otherElem;
while (index--) {
if (NS_FAILED(other->GetElementAt(index, getter_AddRefs(otherElem)))) {
return false;
}
if (mArray[index] != otherElem) {
return false;
}
}
return true;
}
}
return false;
}
NS_IMETHODIMP
nsSupportsArray::GetElementAt(uint32_t aIndex, nsISupports** aOutPtr)
{

Просмотреть файл

@ -60,6 +60,8 @@ public:
NS_IMETHOD Clear(void) override;
// nsISupportsArray methods:
NS_IMETHOD_(bool) Equals(const nsISupportsArray* aOther) override;
NS_IMETHOD_(int32_t) IndexOf(const nsISupports* aPossibleElement) override;
NS_IMETHOD_(int32_t) IndexOfStartingAt(const nsISupports* aPossibleElement,
uint32_t aStartIndex = 0) override;