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/. */
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
#ifndef MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__
|
|
|
|
#define MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__
|
|
|
|
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2012-12-23 08:54:21 +04:00
|
|
|
#include "nsWrapperCache.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"
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class SVGAnimatedNumberList;
|
|
|
|
class SVGNumberList;
|
|
|
|
|
2018-12-28 16:42:46 +03:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class DOMSVGNumberList;
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
/**
|
|
|
|
* Class DOMSVGAnimatedNumberList
|
|
|
|
*
|
|
|
|
* This class is used to create the DOM tearoff objects that wrap internal
|
|
|
|
* SVGAnimatedNumberList objects.
|
|
|
|
*
|
|
|
|
* See the architecture comment in DOMSVGAnimatedLengthList.h (that's
|
|
|
|
* LENGTH list). The comment for that class largly applies to this one too
|
|
|
|
* and will go a long way to helping you understand the architecture here.
|
|
|
|
*
|
|
|
|
* This class is strongly intertwined with DOMSVGNumberList and DOMSVGNumber.
|
|
|
|
* Our DOMSVGNumberList base and anim vals are friends and take care of nulling
|
|
|
|
* out our pointers to them when they die (making our pointers to them true
|
|
|
|
* weak refs).
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class DOMSVGAnimatedNumberList final : public nsISupports,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsWrapperCache {
|
2010-12-03 19:40:23 +03:00
|
|
|
friend class DOMSVGNumberList;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2012-12-23 08:54:21 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGAnimatedNumberList)
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Factory method to create and return a DOMSVGAnimatedNumberList wrapper
|
|
|
|
* for a given internal SVGAnimatedNumberList object. The factory takes care
|
|
|
|
* of caching the object that it returns so that the same object can be
|
|
|
|
* returned for the given SVGAnimatedNumberList 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 or to any of its descendant
|
|
|
|
* objects. If that happens, any subsequent call requesting the DOM wrapper
|
|
|
|
* for the SVGAnimatedNumberList will naturally result in a new
|
|
|
|
* DOMSVGAnimatedNumberList being returned.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<DOMSVGAnimatedNumberList> GetDOMWrapper(
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGAnimatedNumberList* aList, dom::SVGElement* aElement,
|
|
|
|
uint8_t aAttrEnum);
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method returns the DOMSVGAnimatedNumberList wrapper for an internal
|
|
|
|
* SVGAnimatedNumberList object if it currently has a wrapper. If it does
|
2012-07-30 18:20:58 +04:00
|
|
|
* not, then nullptr is returned.
|
2010-12-03 19:40:23 +03:00
|
|
|
*/
|
|
|
|
static DOMSVGAnimatedNumberList* GetDOMWrapperIfExists(
|
|
|
|
SVGAnimatedNumberList* aList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by internal code to notify us when we need to sync the length of
|
|
|
|
* our baseVal DOM list with its internal list. This is called just prior to
|
|
|
|
* the length of the internal baseVal list being changed so that any DOM list
|
|
|
|
* items that need to be removed from the DOM list can first get their values
|
|
|
|
* from their internal counterpart.
|
|
|
|
*
|
|
|
|
* The only time this method could fail is on OOM when trying to increase the
|
|
|
|
* length of the DOM list. If that happens then this method simply clears the
|
|
|
|
* list and returns. Callers just proceed as normal, and we simply accept
|
|
|
|
* that the DOM list will be empty (until successfully set to a new value).
|
|
|
|
*/
|
|
|
|
void InternalBaseValListWillChangeTo(const SVGNumberList& aNewValue);
|
|
|
|
void InternalAnimValListWillChangeTo(const SVGNumberList& aNewValue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if our attribute is animating (in which case our animVal is
|
|
|
|
* not simply a mirror of our baseVal).
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAnimating() const;
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2012-12-23 08:54:21 +04:00
|
|
|
// WebIDL
|
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;
|
2012-12-23 08:54:21 +04:00
|
|
|
// These aren't weak refs because mBaseVal and mAnimVal are weak
|
|
|
|
already_AddRefed<DOMSVGNumberList> BaseVal();
|
|
|
|
already_AddRefed<DOMSVGNumberList> AnimVal();
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Only our static GetDOMWrapper() factory method may create objects of our
|
|
|
|
* type.
|
|
|
|
*/
|
2018-12-21 11:58:14 +03:00
|
|
|
DOMSVGAnimatedNumberList(dom::SVGElement* aElement, uint8_t aAttrEnum)
|
2012-07-30 18:20:58 +04:00
|
|
|
: mBaseVal(nullptr),
|
|
|
|
mAnimVal(nullptr),
|
2010-12-03 19:40:23 +03:00
|
|
|
mElement(aElement),
|
|
|
|
mAttrEnum(aAttrEnum) {}
|
|
|
|
|
|
|
|
~DOMSVGAnimatedNumberList();
|
|
|
|
|
|
|
|
/// Get a reference to this DOM wrapper object's internal counterpart.
|
|
|
|
SVGAnimatedNumberList& InternalAList();
|
|
|
|
const SVGAnimatedNumberList& InternalAList() const;
|
|
|
|
|
|
|
|
// Weak refs to our DOMSVGNumberList baseVal/animVal objects. These objects
|
|
|
|
// are friends and take care of clearing these pointers when they die, making
|
|
|
|
// these true weak references.
|
|
|
|
DOMSVGNumberList* mBaseVal;
|
|
|
|
DOMSVGNumberList* mAnimVal;
|
|
|
|
|
|
|
|
// Strong ref to our element to keep it alive. We hold this not only for
|
|
|
|
// ourself, but also for our base/animVal and all of their items.
|
2018-12-21 11:58:14 +03:00
|
|
|
RefPtr<dom::SVGElement> mElement;
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mAttrEnum;
|
2010-12-03 19:40:23 +03:00
|
|
|
};
|
|
|
|
|
2018-12-28 16:42:46 +03:00
|
|
|
} // namespace dom
|
2010-12-03 19:40:23 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__
|