1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla SVG Project code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Robert Longson <longsonr@gmail.com>
19 : * Portions created by the Initial Developer are Copyright (C) 2011
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef MOZILLA_DOMSVGSTRINGLIST_H__
39 : #define MOZILLA_DOMSVGSTRINGLIST_H__
40 :
41 : #include "nsAutoPtr.h"
42 : #include "nsCOMPtr.h"
43 : #include "nsCycleCollectionParticipant.h"
44 : #include "nsIDOMSVGStringList.h"
45 : #include "nsSVGElement.h"
46 :
47 : namespace mozilla {
48 :
49 : class SVGStringList;
50 :
51 : /**
52 : * Class DOMSVGStringList
53 : *
54 : * This class is used to create the DOM tearoff objects that wrap internal
55 : * SVGPathData objects.
56 : *
57 : * See the architecture comment in DOMSVGAnimatedLengthList.h first (that's
58 : * LENGTH list), then continue reading the remainder of this comment.
59 : *
60 : * The architecture of this class is similar to that of DOMSVGLengthList
61 : * except for two important aspects:
62 : *
63 : * First, since there is no nsIDOMSVGAnimatedStringList interface in SVG, we
64 : * have no parent DOMSVGAnimatedStringList (unlike DOMSVGLengthList which has
65 : * a parent DOMSVGAnimatedLengthList class). As a consequence, much of the
66 : * logic that would otherwise be in DOMSVGAnimatedStringList (and is in
67 : * DOMSVGAnimatedLengthList) is contained in this class.
68 : *
69 : * Second, since there is no nsIDOMSVGString interface in SVG, we have no
70 : * DOMSVGString items to maintain. As far as script is concerned, objects
71 : * of this class contain a list of strings, not a list of mutable objects
72 : * like the other SVG list types. As a result, unlike the other SVG list
73 : * types, this class does not create its items lazily on demand and store
74 : * them so it can return the same objects each time. It simply returns a new
75 : * string each time any given item is requested.
76 : */
77 : class DOMSVGStringList : public nsIDOMSVGStringList
78 : {
79 : public:
80 0 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
81 1464 : NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGStringList)
82 : NS_DECL_NSIDOMSVGSTRINGLIST
83 :
84 : /**
85 : * Factory method to create and return a DOMSVGStringList wrapper
86 : * for a given internal SVGStringList object. The factory takes care
87 : * of caching the object that it returns so that the same object can be
88 : * returned for the given SVGStringList each time it is requested.
89 : * The cached object is only removed from the cache when it is destroyed due
90 : * to there being no more references to it. If that happens, any subsequent
91 : * call requesting the DOM wrapper for the SVGStringList will naturally
92 : * result in a new DOMSVGStringList being returned.
93 : */
94 : static already_AddRefed<DOMSVGStringList>
95 : GetDOMWrapper(SVGStringList *aList,
96 : nsSVGElement *aElement,
97 : bool aIsConditionalProcessingAttribute,
98 : PRUint8 aAttrEnum);
99 :
100 : private:
101 : /**
102 : * Only our static GetDOMWrapper() factory method may create objects of our
103 : * type.
104 : */
105 0 : DOMSVGStringList(nsSVGElement *aElement,
106 : bool aIsConditionalProcessingAttribute, PRUint8 aAttrEnum)
107 : : mElement(aElement)
108 : , mAttrEnum(aAttrEnum)
109 0 : , mIsConditionalProcessingAttribute(aIsConditionalProcessingAttribute)
110 0 : {}
111 :
112 : ~DOMSVGStringList();
113 :
114 : SVGStringList &InternalList();
115 :
116 : // Strong ref to our element to keep it alive.
117 : nsRefPtr<nsSVGElement> mElement;
118 :
119 : PRUint8 mAttrEnum;
120 :
121 : bool mIsConditionalProcessingAttribute;
122 : };
123 :
124 : } // namespace mozilla
125 :
126 : #endif // MOZILLA_DOMSVGSTRINGLIST_H__
|