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.
|
// Entry already existed so just return it. Also update the LRU list.
|
||||||
|
|
||||||
// Move to the head of the list.
|
// Move to the head of the list.
|
||||||
entry->remove();
|
entry->removeFrom(mList);
|
||||||
mList.insertFront(entry);
|
mList.insertFront(entry);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
@ -243,13 +243,13 @@ nsPreflightCache::RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal)
|
|||||||
nsCString key;
|
nsCString key;
|
||||||
if (GetCacheKey(aURI, aPrincipal, true, key) &&
|
if (GetCacheKey(aURI, aPrincipal, true, key) &&
|
||||||
mTable.Get(key, &entry)) {
|
mTable.Get(key, &entry)) {
|
||||||
entry->remove();
|
entry->removeFrom(mList);
|
||||||
mTable.Remove(key);
|
mTable.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetCacheKey(aURI, aPrincipal, false, key) &&
|
if (GetCacheKey(aURI, aPrincipal, false, key) &&
|
||||||
mTable.Get(key, &entry)) {
|
mTable.Get(key, &entry)) {
|
||||||
entry->remove();
|
entry->removeFrom(mList);
|
||||||
mTable.Remove(key);
|
mTable.Remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,7 +273,7 @@ nsPreflightCache::RemoveExpiredEntries(const nsACString& aKey,
|
|||||||
if (aValue->mHeaders.IsEmpty() &&
|
if (aValue->mHeaders.IsEmpty() &&
|
||||||
aValue->mMethods.IsEmpty()) {
|
aValue->mMethods.IsEmpty()) {
|
||||||
// Expired, remove from the list as well as the hash table.
|
// Expired, remove from the list as well as the hash table.
|
||||||
aValue->remove();
|
aValue->removeFrom(sPreflightCache->mList);
|
||||||
return PL_DHASH_REMOVE;
|
return PL_DHASH_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1562,7 +1562,7 @@ public:
|
|||||||
mContext->gl->fDeleteBuffers(1, &mGLName);
|
mContext->gl->fDeleteBuffers(1, &mGLName);
|
||||||
mByteLength = 0;
|
mByteLength = 0;
|
||||||
mCache = nullptr;
|
mCache = nullptr;
|
||||||
LinkedListElement<WebGLBuffer>::remove(); // remove from mContext->mBuffers
|
LinkedListElement<WebGLBuffer>::removeFrom(mContext->mBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
|
||||||
@ -1655,7 +1655,7 @@ public:
|
|||||||
mImageInfos.Clear();
|
mImageInfos.Clear();
|
||||||
mContext->MakeContextCurrent();
|
mContext->MakeContextCurrent();
|
||||||
mContext->gl->fDeleteTextures(1, &mGLName);
|
mContext->gl->fDeleteTextures(1, &mGLName);
|
||||||
LinkedListElement<WebGLTexture>::remove(); // remove from mContext->mTextures
|
LinkedListElement<WebGLTexture>::removeFrom(mContext->mTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||||
@ -2173,7 +2173,7 @@ public:
|
|||||||
mTranslationLog.Truncate();
|
mTranslationLog.Truncate();
|
||||||
mContext->MakeContextCurrent();
|
mContext->MakeContextCurrent();
|
||||||
mContext->gl->fDeleteShader(mGLName);
|
mContext->gl->fDeleteShader(mGLName);
|
||||||
LinkedListElement<WebGLShader>::remove(); // remove from mContext->mShaders
|
LinkedListElement<WebGLShader>::removeFrom(mContext->mShaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebGLuint GLName() { return mGLName; }
|
WebGLuint GLName() { return mGLName; }
|
||||||
@ -2295,7 +2295,7 @@ public:
|
|||||||
DetachShaders();
|
DetachShaders();
|
||||||
mContext->MakeContextCurrent();
|
mContext->MakeContextCurrent();
|
||||||
mContext->gl->fDeleteProgram(mGLName);
|
mContext->gl->fDeleteProgram(mGLName);
|
||||||
LinkedListElement<WebGLProgram>::remove(); // remove from mContext->mPrograms
|
LinkedListElement<WebGLProgram>::removeFrom(mContext->mPrograms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetachShaders() {
|
void DetachShaders() {
|
||||||
@ -2578,7 +2578,7 @@ public:
|
|||||||
void Delete() {
|
void Delete() {
|
||||||
mContext->MakeContextCurrent();
|
mContext->MakeContextCurrent();
|
||||||
mContext->gl->fDeleteRenderbuffers(1, &mGLName);
|
mContext->gl->fDeleteRenderbuffers(1, &mGLName);
|
||||||
LinkedListElement<WebGLRenderbuffer>::remove(); // remove from mContext->mRenderbuffers
|
LinkedListElement<WebGLRenderbuffer>::removeFrom(mContext->mRenderbuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||||
@ -2823,7 +2823,7 @@ public:
|
|||||||
mDepthStencilAttachment.Reset();
|
mDepthStencilAttachment.Reset();
|
||||||
mContext->MakeContextCurrent();
|
mContext->MakeContextCurrent();
|
||||||
mContext->gl->fDeleteFramebuffers(1, &mGLName);
|
mContext->gl->fDeleteFramebuffers(1, &mGLName);
|
||||||
LinkedListElement<WebGLFramebuffer>::remove(); // remove from mContext->mFramebuffers
|
LinkedListElement<WebGLFramebuffer>::removeFrom(mContext->mFramebuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
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
|
// 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
|
// requests list -- if it had been in the ASAP list, then mIsASAP would
|
||||||
// have been true above. Move the request to the ASAP list.
|
// have been true above. Move the request to the ASAP list.
|
||||||
request->remove();
|
request->removeFrom(mNormalDecodeRequests);
|
||||||
mASAPDecodeRequests.insertBack(request);
|
mASAPDecodeRequests.insertBack(request);
|
||||||
|
|
||||||
// Since request is in a list, one of the decode worker's lists is
|
// Since request is in a list, one of the decode worker's lists is
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
* void removeObserver(Observer* observer) {
|
* void removeObserver(Observer* observer) {
|
||||||
* // Will assert if |observer| is not part of some list.
|
* // Will assert if |observer| is not part of some list.
|
||||||
* observer.remove();
|
* observer.remove();
|
||||||
|
* // Or, will assert if |observer| is not part of |list| specifically.
|
||||||
|
* // observer.removeFrom(list);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void notifyObservers(char* topic) {
|
* void notifyObservers(char* topic) {
|
||||||
@ -173,6 +175,15 @@ class LinkedListElement
|
|||||||
prev = this;
|
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.
|
* Return true if |this| part is of a linked list, and false otherwise.
|
||||||
*/
|
*/
|
||||||
@ -393,6 +404,21 @@ class LinkedList
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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& operator=(const LinkedList<T>& other) MOZ_DELETE;
|
||||||
LinkedList(const LinkedList<T>& other) MOZ_DELETE;
|
LinkedList(const LinkedList<T>& other) MOZ_DELETE;
|
||||||
};
|
};
|
||||||
|
@ -83,7 +83,7 @@ nsHtml5TreeOpExecutor::~nsHtml5TreeOpExecutor()
|
|||||||
{
|
{
|
||||||
if (gBackgroundFlushList && isInList()) {
|
if (gBackgroundFlushList && isInList()) {
|
||||||
mOpQueue.Clear();
|
mOpQueue.Clear();
|
||||||
remove();
|
removeFrom(*gBackgroundFlushList);
|
||||||
if (gBackgroundFlushList->isEmpty()) {
|
if (gBackgroundFlushList->isEmpty()) {
|
||||||
delete gBackgroundFlushList;
|
delete gBackgroundFlushList;
|
||||||
gBackgroundFlushList = nullptr;
|
gBackgroundFlushList = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user