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_
|
||||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsTHashMap.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
|
@ -41,13 +42,15 @@ class SVGAttrTearoffTable {
|
|||
using SimpleTypePtrKey = nsPtrHashKey<SimpleType>;
|
||||
using TearoffTable = nsTHashMap<SimpleTypePtrKey, TearoffType*>;
|
||||
|
||||
TearoffTable* mTable;
|
||||
StaticAutoPtr<TearoffTable> mTable;
|
||||
};
|
||||
|
||||
template <class SimpleType, class TearoffType>
|
||||
TearoffType* SVGAttrTearoffTable<SimpleType, TearoffType>::GetTearoff(
|
||||
SimpleType* aSimple) {
|
||||
if (!mTable) return nullptr;
|
||||
if (!mTable) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TearoffType* tearoff = nullptr;
|
||||
|
||||
|
|
@ -62,7 +65,7 @@ template <class SimpleType, class TearoffType>
|
|||
void SVGAttrTearoffTable<SimpleType, TearoffType>::AddTearoff(
|
||||
SimpleType* aSimple, TearoffType* aTearoff) {
|
||||
if (!mTable) {
|
||||
mTable = new TearoffTable;
|
||||
mTable = new TearoffTable();
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (mTable->Count() == 0) {
|
||||
delete mTable;
|
||||
mTable = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue