mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 803439 - Add removeFrom() that takes a list and asserts the element is initially present in it. r=jlebar
--HG-- extra : rebase_source : c2aad35774a71167f97f940fb416735862b78950
This commit is contained in:
parent
f56df4f1c5
commit
24e7854e4d
@ -189,7 +189,7 @@ nsPreflightCache::GetEntry(nsIURI* aURI,
|
||||
// Entry already existed so just return it. Also update the LRU list.
|
||||
|
||||
// Move to the head of the list.
|
||||
entry->remove();
|
||||
entry->removeFrom(mList);
|
||||
mList.insertFront(entry);
|
||||
|
||||
return entry;
|
||||
@ -243,13 +243,13 @@ nsPreflightCache::RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal)
|
||||
nsCString key;
|
||||
if (GetCacheKey(aURI, aPrincipal, true, key) &&
|
||||
mTable.Get(key, &entry)) {
|
||||
entry->remove();
|
||||
entry->removeFrom(mList);
|
||||
mTable.Remove(key);
|
||||
}
|
||||
|
||||
if (GetCacheKey(aURI, aPrincipal, false, key) &&
|
||||
mTable.Get(key, &entry)) {
|
||||
entry->remove();
|
||||
entry->removeFrom(mList);
|
||||
mTable.Remove(key);
|
||||
}
|
||||
}
|
||||
@ -273,7 +273,7 @@ nsPreflightCache::RemoveExpiredEntries(const nsACString& aKey,
|
||||
if (aValue->mHeaders.IsEmpty() &&
|
||||
aValue->mMethods.IsEmpty()) {
|
||||
// Expired, remove from the list as well as the hash table.
|
||||
aValue->remove();
|
||||
aValue->removeFrom(sPreflightCache->mList);
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
|
@ -1562,7 +1562,7 @@ public:
|
||||
mContext->gl->fDeleteBuffers(1, &mGLName);
|
||||
mByteLength = 0;
|
||||
mCache = nullptr;
|
||||
LinkedListElement<WebGLBuffer>::remove(); // remove from mContext->mBuffers
|
||||
LinkedListElement<WebGLBuffer>::removeFrom(mContext->mBuffers);
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
|
||||
@ -1655,7 +1655,7 @@ public:
|
||||
mImageInfos.Clear();
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fDeleteTextures(1, &mGLName);
|
||||
LinkedListElement<WebGLTexture>::remove(); // remove from mContext->mTextures
|
||||
LinkedListElement<WebGLTexture>::removeFrom(mContext->mTextures);
|
||||
}
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
@ -2173,7 +2173,7 @@ public:
|
||||
mTranslationLog.Truncate();
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fDeleteShader(mGLName);
|
||||
LinkedListElement<WebGLShader>::remove(); // remove from mContext->mShaders
|
||||
LinkedListElement<WebGLShader>::removeFrom(mContext->mShaders);
|
||||
}
|
||||
|
||||
WebGLuint GLName() { return mGLName; }
|
||||
@ -2295,7 +2295,7 @@ public:
|
||||
DetachShaders();
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fDeleteProgram(mGLName);
|
||||
LinkedListElement<WebGLProgram>::remove(); // remove from mContext->mPrograms
|
||||
LinkedListElement<WebGLProgram>::removeFrom(mContext->mPrograms);
|
||||
}
|
||||
|
||||
void DetachShaders() {
|
||||
@ -2578,7 +2578,7 @@ public:
|
||||
void Delete() {
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fDeleteRenderbuffers(1, &mGLName);
|
||||
LinkedListElement<WebGLRenderbuffer>::remove(); // remove from mContext->mRenderbuffers
|
||||
LinkedListElement<WebGLRenderbuffer>::removeFrom(mContext->mRenderbuffers);
|
||||
}
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
@ -2823,7 +2823,7 @@ public:
|
||||
mDepthStencilAttachment.Reset();
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->gl->fDeleteFramebuffers(1, &mGLName);
|
||||
LinkedListElement<WebGLFramebuffer>::remove(); // remove from mContext->mFramebuffers
|
||||
LinkedListElement<WebGLFramebuffer>::removeFrom(mContext->mFramebuffers);
|
||||
}
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
|
@ -3276,7 +3276,7 @@ RasterImage::DecodeWorker::MarkAsASAP(RasterImage* aImg)
|
||||
// If the decode request is in a list, it must be in the normal decode
|
||||
// requests list -- if it had been in the ASAP list, then mIsASAP would
|
||||
// have been true above. Move the request to the ASAP list.
|
||||
request->remove();
|
||||
request->removeFrom(mNormalDecodeRequests);
|
||||
mASAPDecodeRequests.insertBack(request);
|
||||
|
||||
// Since request is in a list, one of the decode worker's lists is
|
||||
|
@ -40,6 +40,8 @@
|
||||
* void removeObserver(Observer* observer) {
|
||||
* // Will assert if |observer| is not part of some list.
|
||||
* observer.remove();
|
||||
* // Or, will assert if |observer| is not part of |list| specifically.
|
||||
* // observer.removeFrom(list);
|
||||
* }
|
||||
*
|
||||
* void notifyObservers(char* topic) {
|
||||
@ -173,6 +175,15 @@ class LinkedListElement
|
||||
prev = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Identical to remove(), but also asserts in debug builds that this element
|
||||
* is in list.
|
||||
*/
|
||||
void removeFrom(const LinkedList<T>& list) {
|
||||
list.assertContains(asT());
|
||||
remove();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if |this| part is of a linked list, and false otherwise.
|
||||
*/
|
||||
@ -393,6 +404,21 @@ class LinkedList
|
||||
}
|
||||
|
||||
private:
|
||||
friend class LinkedListElement<T>;
|
||||
|
||||
void assertContains(const T* t) const {
|
||||
#ifdef DEBUG
|
||||
for (const T* elem = getFirst();
|
||||
elem;
|
||||
elem = elem->getNext())
|
||||
{
|
||||
if (elem == t)
|
||||
return;
|
||||
}
|
||||
MOZ_NOT_REACHED("element wasn't found in this list!");
|
||||
#endif
|
||||
}
|
||||
|
||||
LinkedList& operator=(const LinkedList<T>& other) MOZ_DELETE;
|
||||
LinkedList(const LinkedList<T>& other) MOZ_DELETE;
|
||||
};
|
||||
|
@ -83,7 +83,7 @@ nsHtml5TreeOpExecutor::~nsHtml5TreeOpExecutor()
|
||||
{
|
||||
if (gBackgroundFlushList && isInList()) {
|
||||
mOpQueue.Clear();
|
||||
remove();
|
||||
removeFrom(*gBackgroundFlushList);
|
||||
if (gBackgroundFlushList->isEmpty()) {
|
||||
delete gBackgroundFlushList;
|
||||
gBackgroundFlushList = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user