mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Backed out changeset 63208c26bfc3 (bug 1308317)
This commit is contained in:
parent
638c43c71b
commit
46b2fe93c0
@ -63,6 +63,9 @@ interface nsISupportsArray : nsICollection {
|
||||
|
||||
nsISupportsArray clone();
|
||||
|
||||
[notxpcom] boolean MoveElement(in long aFrom,
|
||||
in long aTo);
|
||||
|
||||
[notxpcom] boolean RemoveElementsAt(in unsigned long aIndex,
|
||||
in unsigned long aCount);
|
||||
|
||||
|
@ -360,6 +360,36 @@ nsSupportsArray::RemoveLastElement(const nsISupports* aElement)
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsSupportsArray::MoveElement(int32_t aFrom, int32_t aTo)
|
||||
{
|
||||
nsISupports* tempElement;
|
||||
|
||||
if (aTo == aFrom) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aTo < 0 || aFrom < 0 ||
|
||||
(uint32_t)aTo >= mCount || (uint32_t)aFrom >= mCount) {
|
||||
// can't extend the array when moving an element. Also catches mImpl = null
|
||||
return false;
|
||||
}
|
||||
tempElement = mArray[aFrom];
|
||||
|
||||
if (aTo < aFrom) {
|
||||
// Moving one element closer to the head; the elements inbetween move down
|
||||
::memmove(mArray + aTo + 1, mArray + aTo,
|
||||
(aFrom - aTo) * sizeof(mArray[0]));
|
||||
mArray[aTo] = tempElement;
|
||||
} else { // already handled aFrom == aTo
|
||||
// Moving one element closer to the tail; the elements inbetween move up
|
||||
::memmove(mArray + aFrom, mArray + aFrom + 1,
|
||||
(aTo - aFrom) * sizeof(mArray[0]));
|
||||
mArray[aTo] = tempElement;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSupportsArray::Clear(void)
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
}
|
||||
// XXX this is badly named - should be RemoveFirstElement
|
||||
MOZ_MUST_USE NS_IMETHOD RemoveElement(nsISupports* aElement) override;
|
||||
MOZ_MUST_USE NS_IMETHOD_(bool) MoveElement(int32_t aFrom, int32_t aTo) override;
|
||||
NS_IMETHOD Enumerate(nsIEnumerator** aResult) override;
|
||||
NS_IMETHOD Clear(void) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user