forked from mirrors/gecko-dev
Bug 1835177: Modernize SVGAttrTearoffTable to use StaticAutoPtr to manage deletion. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D179164
This commit is contained in:
parent
0a47281515
commit
d6b5a1fe9e
1 changed files with 6 additions and 4 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
#define DOM_SVG_SVGATTRTEAROFFTABLE_H_
|
#define DOM_SVG_SVGATTRTEAROFFTABLE_H_
|
||||||
|
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
|
#include "mozilla/StaticPtr.h"
|
||||||
#include "nsTHashMap.h"
|
#include "nsTHashMap.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
|
|
@ -41,13 +42,15 @@ class SVGAttrTearoffTable {
|
||||||
using SimpleTypePtrKey = nsPtrHashKey<SimpleType>;
|
using SimpleTypePtrKey = nsPtrHashKey<SimpleType>;
|
||||||
using TearoffTable = nsTHashMap<SimpleTypePtrKey, TearoffType*>;
|
using TearoffTable = nsTHashMap<SimpleTypePtrKey, TearoffType*>;
|
||||||
|
|
||||||
TearoffTable* mTable;
|
StaticAutoPtr<TearoffTable> mTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class SimpleType, class TearoffType>
|
template <class SimpleType, class TearoffType>
|
||||||
TearoffType* SVGAttrTearoffTable<SimpleType, TearoffType>::GetTearoff(
|
TearoffType* SVGAttrTearoffTable<SimpleType, TearoffType>::GetTearoff(
|
||||||
SimpleType* aSimple) {
|
SimpleType* aSimple) {
|
||||||
if (!mTable) return nullptr;
|
if (!mTable) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
TearoffType* tearoff = nullptr;
|
TearoffType* tearoff = nullptr;
|
||||||
|
|
||||||
|
|
@ -62,7 +65,7 @@ template <class SimpleType, class TearoffType>
|
||||||
void SVGAttrTearoffTable<SimpleType, TearoffType>::AddTearoff(
|
void SVGAttrTearoffTable<SimpleType, TearoffType>::AddTearoff(
|
||||||
SimpleType* aSimple, TearoffType* aTearoff) {
|
SimpleType* aSimple, TearoffType* aTearoff) {
|
||||||
if (!mTable) {
|
if (!mTable) {
|
||||||
mTable = new TearoffTable;
|
mTable = new TearoffTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We shouldn't be adding a tear-off if there already is one. If that happens,
|
// We shouldn't be adding a tear-off if there already is one. If that happens,
|
||||||
|
|
@ -86,7 +89,6 @@ void SVGAttrTearoffTable<SimpleType, TearoffType>::RemoveTearoff(
|
||||||
|
|
||||||
mTable->Remove(aSimple);
|
mTable->Remove(aSimple);
|
||||||
if (mTable->Count() == 0) {
|
if (mTable->Count() == 0) {
|
||||||
delete mTable;
|
|
||||||
mTable = nullptr;
|
mTable = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue