Backed out changeset 928ad5e93372 (bug 1308317)

This commit is contained in:
Carsten "Tomcat" Book 2016-10-14 14:58:35 +02:00
parent b6187e2b2e
commit 3470d6dfe0
3 changed files with 17 additions and 7 deletions

View File

@ -54,6 +54,9 @@ interface nsISupportsArray : nsICollection {
nsISupportsArray clone();
[notxpcom] boolean RemoveElementsAt(in unsigned long aIndex,
in unsigned long aCount);
};
%{C++

View File

@ -283,15 +283,16 @@ nsSupportsArray::ReplaceElementAt(nsISupports* aElement, uint32_t aIndex)
}
NS_IMETHODIMP_(bool)
nsSupportsArray::RemoveElementAt(uint32_t aIndex)
nsSupportsArray::RemoveElementsAt(uint32_t aIndex, uint32_t aCount)
{
if (aIndex + 1 <= mCount) {
NS_IF_RELEASE(mArray[aIndex]);
mCount -= 1;
if (aIndex + aCount <= mCount) {
for (uint32_t i = 0; i < aCount; i++) {
NS_IF_RELEASE(mArray[aIndex + i]);
}
mCount -= aCount;
int32_t slide = (mCount - aIndex);
if (0 < slide) {
::memmove(mArray + aIndex, mArray + aIndex + 1,
::memmove(mArray + aIndex, mArray + aIndex + aCount,
slide * sizeof(nsISupports*));
}
return true;

View File

@ -82,7 +82,10 @@ public:
ReplaceElementAt(nsISupports* aElement, uint32_t aIndex) override;
MOZ_MUST_USE NS_IMETHOD_(bool)
RemoveElementAt(uint32_t aIndex) override;
RemoveElementAt(uint32_t aIndex) override
{
return RemoveElementsAt(aIndex, 1);
}
MOZ_MUST_USE NS_IMETHOD DeleteElementAt(uint32_t aIndex) override
{
@ -93,6 +96,9 @@ public:
MOZ_MUST_USE NS_IMETHOD Clone(nsISupportsArray** aResult) override;
MOZ_MUST_USE NS_IMETHOD_(bool)
RemoveElementsAt(uint32_t aIndex, uint32_t aCount) override;
protected:
void DeleteArray(void);