2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef DOM_SVG_DOMSVGSTRINGLIST_H_
|
|
|
|
#define DOM_SVG_DOMSVGSTRINGLIST_H_
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-01-25 02:40:25 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2011-12-31 13:44:03 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-04-21 10:42:00 +04:00
|
|
|
class ErrorResult;
|
2011-12-31 13:44:03 +04:00
|
|
|
class SVGStringList;
|
|
|
|
|
2019-09-21 17:38:56 +03:00
|
|
|
namespace dom {
|
|
|
|
|
2011-12-31 13:44:03 +04:00
|
|
|
/**
|
|
|
|
* Class DOMSVGStringList
|
|
|
|
*
|
|
|
|
* This class is used to create the DOM tearoff objects that wrap internal
|
|
|
|
* SVGPathData objects.
|
|
|
|
*
|
|
|
|
* See the architecture comment in DOMSVGAnimatedLengthList.h first (that's
|
|
|
|
* LENGTH list), then continue reading the remainder of this comment.
|
|
|
|
*
|
|
|
|
* The architecture of this class is similar to that of DOMSVGLengthList
|
|
|
|
* except for two important aspects:
|
|
|
|
*
|
|
|
|
* First, since there is no nsIDOMSVGAnimatedStringList interface in SVG, we
|
|
|
|
* have no parent DOMSVGAnimatedStringList (unlike DOMSVGLengthList which has
|
|
|
|
* a parent DOMSVGAnimatedLengthList class). As a consequence, much of the
|
|
|
|
* logic that would otherwise be in DOMSVGAnimatedStringList (and is in
|
|
|
|
* DOMSVGAnimatedLengthList) is contained in this class.
|
|
|
|
*
|
|
|
|
* Second, since there is no nsIDOMSVGString interface in SVG, we have no
|
|
|
|
* DOMSVGString items to maintain. As far as script is concerned, objects
|
|
|
|
* of this class contain a list of strings, not a list of mutable objects
|
|
|
|
* like the other SVG list types. As a result, unlike the other SVG list
|
|
|
|
* types, this class does not create its items lazily on demand and store
|
|
|
|
* them so it can return the same objects each time. It simply returns a new
|
|
|
|
* string each time any given item is requested.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class DOMSVGStringList final : public nsISupports, public nsWrapperCache {
|
2013-12-25 02:09:22 +04:00
|
|
|
friend class AutoChangeStringListNotifier;
|
|
|
|
|
2011-12-31 13:44:03 +04:00
|
|
|
public:
|
2013-12-22 21:56:39 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGStringList)
|
2013-04-21 10:42:00 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
dom::SVGElement* GetParentObject() const { return mElement; }
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-21 10:42:00 +04:00
|
|
|
|
|
|
|
uint32_t NumberOfItems() const;
|
|
|
|
uint32_t Length() const;
|
|
|
|
void Clear();
|
|
|
|
void Initialize(const nsAString& aNewItem, nsAString& aRetval,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
void GetItem(uint32_t aIndex, nsAString& aRetval, ErrorResult& aRv);
|
|
|
|
void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aRetval);
|
|
|
|
void InsertItemBefore(const nsAString& aNewItem, uint32_t aIndex,
|
|
|
|
nsAString& aRetval, ErrorResult& aRv);
|
|
|
|
void ReplaceItem(const nsAString& aNewItem, uint32_t aIndex,
|
|
|
|
nsAString& aRetval, ErrorResult& aRv);
|
|
|
|
void RemoveItem(uint32_t aIndex, nsAString& aRetval, ErrorResult& aRv);
|
|
|
|
void AppendItem(const nsAString& aNewItem, nsAString& aRetval,
|
|
|
|
ErrorResult& aRv);
|
2011-12-31 13:44:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Factory method to create and return a DOMSVGStringList wrapper
|
|
|
|
* for a given internal SVGStringList object. The factory takes care
|
|
|
|
* of caching the object that it returns so that the same object can be
|
|
|
|
* returned for the given SVGStringList each time it is requested.
|
|
|
|
* The cached object is only removed from the cache when it is destroyed due
|
|
|
|
* to there being no more references to it. If that happens, any subsequent
|
|
|
|
* call requesting the DOM wrapper for the SVGStringList will naturally
|
|
|
|
* result in a new DOMSVGStringList being returned.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<DOMSVGStringList> GetDOMWrapper(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGStringList* aList, dom::SVGElement* aElement,
|
2011-12-31 13:44:03 +04:00
|
|
|
bool aIsConditionalProcessingAttribute, uint8_t aAttrEnum);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Only our static GetDOMWrapper() factory method may create objects of our
|
|
|
|
* type.
|
|
|
|
*/
|
2018-12-21 11:58:14 +03:00
|
|
|
DOMSVGStringList(dom::SVGElement* aElement,
|
2012-08-22 19:56:38 +04:00
|
|
|
bool aIsConditionalProcessingAttribute, uint8_t aAttrEnum)
|
2011-12-31 13:44:03 +04:00
|
|
|
: mElement(aElement),
|
|
|
|
mAttrEnum(aAttrEnum),
|
|
|
|
mIsConditionalProcessingAttribute(aIsConditionalProcessingAttribute) {}
|
|
|
|
|
|
|
|
~DOMSVGStringList();
|
|
|
|
|
2013-04-21 10:42:00 +04:00
|
|
|
SVGStringList& InternalList() const;
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2020-04-09 15:50:28 +03:00
|
|
|
void RemoveFromTearoffTable();
|
|
|
|
|
2011-12-31 13:44:03 +04:00
|
|
|
// Strong ref to our element to keep it alive.
|
2018-12-21 11:58:14 +03:00
|
|
|
RefPtr<dom::SVGElement> mElement;
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mAttrEnum;
|
2011-12-31 13:44:03 +04:00
|
|
|
|
|
|
|
bool mIsConditionalProcessingAttribute;
|
|
|
|
};
|
|
|
|
|
2019-09-21 17:38:56 +03:00
|
|
|
} // namespace dom
|
2011-12-31 13:44:03 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // DOM_SVG_DOMSVGSTRINGLIST_H_
|