/src/mozilla-central/dom/svg/nsSVGAttrTearoffTable.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef NS_SVGATTRTEAROFFTABLE_H_ |
8 | | #define NS_SVGATTRTEAROFFTABLE_H_ |
9 | | |
10 | | #include "nsDataHashtable.h" |
11 | | #include "nsDebug.h" |
12 | | #include "nsHashKeys.h" |
13 | | |
14 | | /** |
15 | | * Global hashmap to associate internal SVG data types (e.g. nsSVGLength2) with |
16 | | * DOM tear-off objects (e.g. DOMSVGLength). This allows us to always return |
17 | | * the same object for subsequent requests for DOM objects. |
18 | | * |
19 | | * We don't keep an owning reference to the tear-off objects so they are |
20 | | * responsible for removing themselves from this table when they die. |
21 | | */ |
22 | | template<class SimpleType, class TearoffType> |
23 | | class nsSVGAttrTearoffTable |
24 | | { |
25 | | public: |
26 | | #ifdef DEBUG |
27 | | ~nsSVGAttrTearoffTable() |
28 | | { |
29 | | MOZ_ASSERT(!mTable, "Tear-off objects remain in hashtable at shutdown."); |
30 | | } |
31 | | #endif |
32 | | |
33 | | TearoffType* GetTearoff(SimpleType* aSimple); |
34 | | |
35 | | void AddTearoff(SimpleType* aSimple, TearoffType* aTearoff); |
36 | | |
37 | | void RemoveTearoff(SimpleType* aSimple); |
38 | | |
39 | | private: |
40 | | typedef nsPtrHashKey<SimpleType> SimpleTypePtrKey; |
41 | | typedef nsDataHashtable<SimpleTypePtrKey, TearoffType* > TearoffTable; |
42 | | |
43 | | TearoffTable* mTable; |
44 | | }; |
45 | | |
46 | | template<class SimpleType, class TearoffType> |
47 | | TearoffType* |
48 | | nsSVGAttrTearoffTable<SimpleType, TearoffType>::GetTearoff(SimpleType* aSimple) |
49 | 0 | { |
50 | 0 | if (!mTable) |
51 | 0 | return nullptr; |
52 | 0 | |
53 | 0 | TearoffType *tearoff = nullptr; |
54 | 0 |
|
55 | | #ifdef DEBUG |
56 | | bool found = |
57 | | #endif |
58 | | mTable->Get(aSimple, &tearoff); |
59 | 0 | MOZ_ASSERT(!found || tearoff, |
60 | 0 | "null pointer stored in attribute tear-off map"); |
61 | 0 |
|
62 | 0 | return tearoff; |
63 | 0 | } Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedLengthList, mozilla::DOMSVGAnimatedLengthList>::GetTearoff(mozilla::SVGAnimatedLengthList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedNumberList, mozilla::DOMSVGAnimatedNumberList>::GetTearoff(mozilla::SVGAnimatedNumberList*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGLength2, mozilla::DOMSVGLength>::GetTearoff(nsSVGLength2*) Unexecuted instantiation: nsSVGAttrTearoffTable<void, mozilla::DOMSVGPathSegList>::GetTearoff(void*) Unexecuted instantiation: nsSVGAttrTearoffTable<void, mozilla::DOMSVGPointList>::GetTearoff(void*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGStringList, mozilla::DOMSVGStringList>::GetTearoff(mozilla::SVGStringList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedPreserveAspectRatio, mozilla::dom::DOMSVGPreserveAspectRatio>::GetTearoff(mozilla::SVGAnimatedPreserveAspectRatio*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedPreserveAspectRatio, mozilla::dom::DOMSVGAnimatedPreserveAspectRatio>::GetTearoff(mozilla::SVGAnimatedPreserveAspectRatio*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::nsSVGAnimatedTransformList, mozilla::dom::SVGAnimatedTransformList>::GetTearoff(mozilla::nsSVGAnimatedTransformList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::dom::SVGTransform, mozilla::dom::SVGMatrix>::GetTearoff(mozilla::dom::SVGTransform*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGAngle, mozilla::dom::SVGAngle>::GetTearoff(nsSVGAngle*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGAngle, mozilla::dom::SVGAnimatedAngle>::GetTearoff(nsSVGAngle*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGBoolean, mozilla::dom::SVGAnimatedBoolean>::GetTearoff(nsSVGBoolean*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGEnum, nsSVGEnum::DOMAnimatedEnum>::GetTearoff(nsSVGEnum*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGInteger, nsSVGInteger::DOMAnimatedInteger>::GetTearoff(nsSVGInteger*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGIntegerPair, nsSVGIntegerPair::DOMAnimatedInteger>::GetTearoff(nsSVGIntegerPair*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGLength2, mozilla::dom::SVGAnimatedLength>::GetTearoff(nsSVGLength2*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGNumber2, nsSVGNumber2::DOMAnimatedNumber>::GetTearoff(nsSVGNumber2*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGNumberPair, nsSVGNumberPair::DOMAnimatedNumber>::GetTearoff(nsSVGNumberPair*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGString, nsSVGString::DOMAnimatedString>::GetTearoff(nsSVGString*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, mozilla::dom::SVGAnimatedRect>::GetTearoff(nsSVGViewBox*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMBaseVal>::GetTearoff(nsSVGViewBox*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMAnimVal>::GetTearoff(nsSVGViewBox*) |
64 | | |
65 | | template<class SimpleType, class TearoffType> |
66 | | void |
67 | | nsSVGAttrTearoffTable<SimpleType, TearoffType>::AddTearoff(SimpleType* aSimple, |
68 | | TearoffType* aTearoff) |
69 | 0 | { |
70 | 0 | if (!mTable) { |
71 | 0 | mTable = new TearoffTable; |
72 | 0 | } |
73 | 0 |
|
74 | 0 | // We shouldn't be adding a tear-off if there already is one. If that happens, |
75 | 0 | // something is wrong. |
76 | 0 | if (mTable->Get(aSimple, nullptr)) { |
77 | 0 | MOZ_ASSERT(false, "There is already a tear-off for this object."); |
78 | 0 | return; |
79 | 0 | } |
80 | 0 |
|
81 | 0 | mTable->Put(aSimple, aTearoff); |
82 | 0 | } Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedLengthList, mozilla::DOMSVGAnimatedLengthList>::AddTearoff(mozilla::SVGAnimatedLengthList*, mozilla::DOMSVGAnimatedLengthList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedNumberList, mozilla::DOMSVGAnimatedNumberList>::AddTearoff(mozilla::SVGAnimatedNumberList*, mozilla::DOMSVGAnimatedNumberList*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGLength2, mozilla::DOMSVGLength>::AddTearoff(nsSVGLength2*, mozilla::DOMSVGLength*) Unexecuted instantiation: nsSVGAttrTearoffTable<void, mozilla::DOMSVGPathSegList>::AddTearoff(void*, mozilla::DOMSVGPathSegList*) Unexecuted instantiation: nsSVGAttrTearoffTable<void, mozilla::DOMSVGPointList>::AddTearoff(void*, mozilla::DOMSVGPointList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGStringList, mozilla::DOMSVGStringList>::AddTearoff(mozilla::SVGStringList*, mozilla::DOMSVGStringList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedPreserveAspectRatio, mozilla::dom::DOMSVGPreserveAspectRatio>::AddTearoff(mozilla::SVGAnimatedPreserveAspectRatio*, mozilla::dom::DOMSVGPreserveAspectRatio*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedPreserveAspectRatio, mozilla::dom::DOMSVGAnimatedPreserveAspectRatio>::AddTearoff(mozilla::SVGAnimatedPreserveAspectRatio*, mozilla::dom::DOMSVGAnimatedPreserveAspectRatio*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::nsSVGAnimatedTransformList, mozilla::dom::SVGAnimatedTransformList>::AddTearoff(mozilla::nsSVGAnimatedTransformList*, mozilla::dom::SVGAnimatedTransformList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::dom::SVGTransform, mozilla::dom::SVGMatrix>::AddTearoff(mozilla::dom::SVGTransform*, mozilla::dom::SVGMatrix*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGAngle, mozilla::dom::SVGAngle>::AddTearoff(nsSVGAngle*, mozilla::dom::SVGAngle*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGAngle, mozilla::dom::SVGAnimatedAngle>::AddTearoff(nsSVGAngle*, mozilla::dom::SVGAnimatedAngle*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGBoolean, mozilla::dom::SVGAnimatedBoolean>::AddTearoff(nsSVGBoolean*, mozilla::dom::SVGAnimatedBoolean*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGEnum, nsSVGEnum::DOMAnimatedEnum>::AddTearoff(nsSVGEnum*, nsSVGEnum::DOMAnimatedEnum*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGInteger, nsSVGInteger::DOMAnimatedInteger>::AddTearoff(nsSVGInteger*, nsSVGInteger::DOMAnimatedInteger*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGIntegerPair, nsSVGIntegerPair::DOMAnimatedInteger>::AddTearoff(nsSVGIntegerPair*, nsSVGIntegerPair::DOMAnimatedInteger*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGLength2, mozilla::dom::SVGAnimatedLength>::AddTearoff(nsSVGLength2*, mozilla::dom::SVGAnimatedLength*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGNumber2, nsSVGNumber2::DOMAnimatedNumber>::AddTearoff(nsSVGNumber2*, nsSVGNumber2::DOMAnimatedNumber*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGNumberPair, nsSVGNumberPair::DOMAnimatedNumber>::AddTearoff(nsSVGNumberPair*, nsSVGNumberPair::DOMAnimatedNumber*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGString, nsSVGString::DOMAnimatedString>::AddTearoff(nsSVGString*, nsSVGString::DOMAnimatedString*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, mozilla::dom::SVGAnimatedRect>::AddTearoff(nsSVGViewBox*, mozilla::dom::SVGAnimatedRect*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMBaseVal>::AddTearoff(nsSVGViewBox*, nsSVGViewBox::DOMBaseVal*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMAnimVal>::AddTearoff(nsSVGViewBox*, nsSVGViewBox::DOMAnimVal*) |
83 | | |
84 | | template<class SimpleType, class TearoffType> |
85 | | void |
86 | | nsSVGAttrTearoffTable<SimpleType, TearoffType>::RemoveTearoff( |
87 | | SimpleType* aSimple) |
88 | 0 | { |
89 | 0 | if (!mTable) { |
90 | 0 | // Perhaps something happened in between creating the SimpleType object and |
91 | 0 | // registering it |
92 | 0 | return; |
93 | 0 | } |
94 | 0 | |
95 | 0 | mTable->Remove(aSimple); |
96 | 0 | if (mTable->Count() == 0) { |
97 | 0 | delete mTable; |
98 | 0 | mTable = nullptr; |
99 | 0 | } |
100 | 0 | } Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedLengthList, mozilla::DOMSVGAnimatedLengthList>::RemoveTearoff(mozilla::SVGAnimatedLengthList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedNumberList, mozilla::DOMSVGAnimatedNumberList>::RemoveTearoff(mozilla::SVGAnimatedNumberList*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGLength2, mozilla::DOMSVGLength>::RemoveTearoff(nsSVGLength2*) Unexecuted instantiation: nsSVGAttrTearoffTable<void, mozilla::DOMSVGPathSegList>::RemoveTearoff(void*) Unexecuted instantiation: nsSVGAttrTearoffTable<void, mozilla::DOMSVGPointList>::RemoveTearoff(void*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGStringList, mozilla::DOMSVGStringList>::RemoveTearoff(mozilla::SVGStringList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedPreserveAspectRatio, mozilla::dom::DOMSVGPreserveAspectRatio>::RemoveTearoff(mozilla::SVGAnimatedPreserveAspectRatio*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::SVGAnimatedPreserveAspectRatio, mozilla::dom::DOMSVGAnimatedPreserveAspectRatio>::RemoveTearoff(mozilla::SVGAnimatedPreserveAspectRatio*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, mozilla::dom::SVGAnimatedRect>::RemoveTearoff(nsSVGViewBox*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::nsSVGAnimatedTransformList, mozilla::dom::SVGAnimatedTransformList>::RemoveTearoff(mozilla::nsSVGAnimatedTransformList*) Unexecuted instantiation: nsSVGAttrTearoffTable<mozilla::dom::SVGTransform, mozilla::dom::SVGMatrix>::RemoveTearoff(mozilla::dom::SVGTransform*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGAngle, mozilla::dom::SVGAngle>::RemoveTearoff(nsSVGAngle*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGAngle, mozilla::dom::SVGAnimatedAngle>::RemoveTearoff(nsSVGAngle*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGBoolean, mozilla::dom::SVGAnimatedBoolean>::RemoveTearoff(nsSVGBoolean*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGEnum, nsSVGEnum::DOMAnimatedEnum>::RemoveTearoff(nsSVGEnum*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGInteger, nsSVGInteger::DOMAnimatedInteger>::RemoveTearoff(nsSVGInteger*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGIntegerPair, nsSVGIntegerPair::DOMAnimatedInteger>::RemoveTearoff(nsSVGIntegerPair*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGLength2, mozilla::dom::SVGAnimatedLength>::RemoveTearoff(nsSVGLength2*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGNumber2, nsSVGNumber2::DOMAnimatedNumber>::RemoveTearoff(nsSVGNumber2*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGNumberPair, nsSVGNumberPair::DOMAnimatedNumber>::RemoveTearoff(nsSVGNumberPair*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGString, nsSVGString::DOMAnimatedString>::RemoveTearoff(nsSVGString*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMBaseVal>::RemoveTearoff(nsSVGViewBox*) Unexecuted instantiation: nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMAnimVal>::RemoveTearoff(nsSVGViewBox*) |
101 | | |
102 | | #endif // NS_SVGATTRTEAROFFTABLE_H_ |